aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp')
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp953
1 files changed, 314 insertions, 639 deletions
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 0ad1f1a3a95a..b9d825489aef 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -19,107 +19,26 @@
#include "lldb/Symbol/ObjectFile.h"
#include "DWARFCompileUnit.h"
-#include "SymbolFileDWARF.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "DWARFDeclContext.h"
#include "DWARFDIECollection.h"
#include "DWARFFormValue.h"
-#include "DWARFLocationDescription.h"
-#include "DWARFLocationList.h"
#include "DWARFDebugRanges.h"
+#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDwo.h"
using namespace lldb_private;
using namespace std;
extern int g_verbose;
-
-
-DWARFDebugInfoEntry::Attributes::Attributes() :
- m_infos()
-{
-}
-
-DWARFDebugInfoEntry::Attributes::~Attributes()
-{
-}
-
-
-uint32_t
-DWARFDebugInfoEntry::Attributes::FindAttributeIndex(dw_attr_t attr) const
-{
- collection::const_iterator end = m_infos.end();
- collection::const_iterator beg = m_infos.begin();
- collection::const_iterator pos;
- for (pos = beg; pos != end; ++pos)
- {
- if (pos->attr == attr)
- return std::distance(beg, pos);
- }
- return UINT32_MAX;
-}
-
-void
-DWARFDebugInfoEntry::Attributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form)
-{
- Info info = { cu, attr_die_offset, attr, form };
- m_infos.push_back(info);
-}
-
-bool
-DWARFDebugInfoEntry::Attributes::ContainsAttribute(dw_attr_t attr) const
-{
- return FindAttributeIndex(attr) != UINT32_MAX;
-}
-
-bool
-DWARFDebugInfoEntry::Attributes::RemoveAttribute(dw_attr_t attr)
-{
- uint32_t attr_index = FindAttributeIndex(attr);
- if (attr_index != UINT32_MAX)
- {
- m_infos.erase(m_infos.begin() + attr_index);
- return true;
- }
- return false;
-}
-
-bool
-DWARFDebugInfoEntry::Attributes::ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const
-{
- form_value.SetCompileUnit(CompileUnitAtIndex(i));
- form_value.SetForm(FormAtIndex(i));
- lldb::offset_t offset = DIEOffsetAtIndex(i);
- return form_value.ExtractValue(dwarf2Data->get_debug_info_data(), &offset);
-}
-
-uint64_t
-DWARFDebugInfoEntry::Attributes::FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const
-{
- const uint32_t attr_idx = FindAttributeIndex (attr);
- if (attr_idx != UINT32_MAX)
- return FormValueAsUnsignedAtIndex (dwarf2Data, attr_idx, fail_value);
- return fail_value;
-}
-
-uint64_t
-DWARFDebugInfoEntry::Attributes::FormValueAsUnsignedAtIndex(SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const
-{
- DWARFFormValue form_value;
- if (ExtractFormValueAtIndex(dwarf2Data, i, form_value))
- return form_value.Reference();
- return fail_value;
-}
-
-
-
bool
DWARFDebugInfoEntry::FastExtract
(
const DWARFDataExtractor& debug_info_data,
const DWARFCompileUnit* cu,
- const uint8_t *fixed_form_sizes,
+ const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
lldb::offset_t *offset_ptr
)
{
@@ -158,7 +77,7 @@ DWARFDebugInfoEntry::FastExtract
{
form = abbrevDecl->GetFormByIndexUnchecked(i);
- const uint8_t fixed_skip_size = fixed_form_sizes [form];
+ const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
if (fixed_skip_size)
offset += fixed_skip_size;
else
@@ -226,9 +145,11 @@ DWARFDebugInfoEntry::FastExtract
break;
// signed or unsigned LEB 128 values
- case DW_FORM_sdata :
- case DW_FORM_udata :
- case DW_FORM_ref_udata :
+ case DW_FORM_sdata :
+ case DW_FORM_udata :
+ case DW_FORM_ref_udata :
+ case DW_FORM_GNU_addr_index:
+ case DW_FORM_GNU_str_index :
debug_info_data.Skip_LEB128 (&offset);
break;
@@ -306,7 +227,7 @@ DWARFDebugInfoEntry::Extract
bool isCompileUnitTag = m_tag == DW_TAG_compile_unit;
if (cu && isCompileUnitTag)
- ((DWARFCompileUnit*)cu)->SetBaseAddress(0);
+ const_cast<DWARFCompileUnit *>(cu)->SetBaseAddress(0);
// Skip all data in the .debug_info for the attributes
const uint32_t numAttributes = abbrevDecl->NumAttributes();
@@ -323,7 +244,7 @@ DWARFDebugInfoEntry::Extract
if (form_value.ExtractValue(debug_info_data, &offset))
{
if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc)
- ((DWARFCompileUnit*)cu)->SetBaseAddress(form_value.Unsigned());
+ const_cast<DWARFCompileUnit*>(cu)->SetBaseAddress(form_value.Address());
}
}
else
@@ -389,9 +310,11 @@ DWARFDebugInfoEntry::Extract
break;
// signed or unsigned LEB 128 values
- case DW_FORM_sdata :
- case DW_FORM_udata :
- case DW_FORM_ref_udata :
+ case DW_FORM_sdata :
+ case DW_FORM_udata :
+ case DW_FORM_ref_udata :
+ case DW_FORM_GNU_addr_index:
+ case DW_FORM_GNU_str_index :
debug_info_data.Skip_LEB128(&offset);
break;
@@ -456,276 +379,6 @@ DWARFDebugInfoEntry::DumpAncestry
}
//----------------------------------------------------------------------
-// Compare two DIE by comparing all their attributes values, and
-// following all DW_FORM_ref attributes and comparing their contents as
-// well (except for DW_AT_sibling attributes.
-//
-// DWARFDebugInfoEntry::CompareState compare_state;
-// int result = DWARFDebugInfoEntry::Compare(this, 0x00017ccb, 0x0001eb2b, compare_state, false, true);
-//----------------------------------------------------------------------
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-// SymbolFileDWARF* dwarf2Data,
-// dw_offset_t a_die_offset,
-// dw_offset_t b_die_offset,
-// CompareState &compare_state,
-// bool compare_siblings,
-// bool compare_children
-//)
-//{
-// if (a_die_offset == b_die_offset)
-// return 0;
-//
-// DWARFCompileUnitSP a_cu_sp;
-// DWARFCompileUnitSP b_cu_sp;
-// const DWARFDebugInfoEntry* a_die = dwarf2Data->DebugInfo()->GetDIEPtr(a_die_offset, &a_cu_sp);
-// const DWARFDebugInfoEntry* b_die = dwarf2Data->DebugInfo()->GetDIEPtr(b_die_offset, &b_cu_sp);
-//
-// return Compare(dwarf2Data, a_cu_sp.get(), a_die, b_cu_sp.get(), b_die, compare_state, compare_siblings, compare_children);
-//}
-//
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-// SymbolFileDWARF* dwarf2Data,
-// DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die,
-// DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die,
-// CompareState &compare_state,
-// bool compare_siblings,
-// bool compare_children
-//)
-//{
-// if (a_die == b_die)
-// return 0;
-//
-// if (!compare_state.AddTypePair(a_die->GetOffset(), b_die->GetOffset()))
-// {
-// // We are already comparing both of these types, so let
-// // compares complete for the real result
-// return 0;
-// }
-//
-// //printf("DWARFDebugInfoEntry::Compare(0x%8.8x, 0x%8.8x)\n", a_die->GetOffset(), b_die->GetOffset());
-//
-// // Do we have two valid DIEs?
-// if (a_die && b_die)
-// {
-// // Both DIE are valid
-// int result = 0;
-//
-// const dw_tag_t a_tag = a_die->Tag();
-// const dw_tag_t b_tag = b_die->Tag();
-// if (a_tag == 0 && b_tag == 0)
-// return 0;
-//
-// //printf(" comparing tags: %s and %s\n", DW_TAG_value_to_name(a_tag), DW_TAG_value_to_name(b_tag));
-//
-// if (a_tag < b_tag)
-// return -1;
-// else if (a_tag > b_tag)
-// return 1;
-//
-// DWARFDebugInfoEntry::Attributes a_attrs;
-// DWARFDebugInfoEntry::Attributes b_attrs;
-// size_t a_attr_count = a_die->GetAttributes(dwarf2Data, a_cu, a_attrs);
-// size_t b_attr_count = b_die->GetAttributes(dwarf2Data, b_cu, b_attrs);
-// if (a_attr_count != b_attr_count)
-// {
-// a_attrs.RemoveAttribute(DW_AT_sibling);
-// b_attrs.RemoveAttribute(DW_AT_sibling);
-// }
-//
-// a_attr_count = a_attrs.Size();
-// b_attr_count = b_attrs.Size();
-//
-// DWARFFormValue a_form_value;
-// DWARFFormValue b_form_value;
-//
-// if (a_attr_count != b_attr_count)
-// {
-// uint32_t is_decl_index = a_attrs.FindAttributeIndex(DW_AT_declaration);
-// uint32_t a_name_index = UINT32_MAX;
-// uint32_t b_name_index = UINT32_MAX;
-// if (is_decl_index != UINT32_MAX)
-// {
-// if (a_attr_count == 2)
-// {
-// a_name_index = a_attrs.FindAttributeIndex(DW_AT_name);
-// b_name_index = b_attrs.FindAttributeIndex(DW_AT_name);
-// }
-// }
-// else
-// {
-// is_decl_index = b_attrs.FindAttributeIndex(DW_AT_declaration);
-// if (is_decl_index != UINT32_MAX && a_attr_count == 2)
-// {
-// a_name_index = a_attrs.FindAttributeIndex(DW_AT_name);
-// b_name_index = b_attrs.FindAttributeIndex(DW_AT_name);
-// }
-// }
-// if (a_name_index != UINT32_MAX && b_name_index != UINT32_MAX)
-// {
-// if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, a_name_index, a_form_value) &&
-// b_attrs.ExtractFormValueAtIndex(dwarf2Data, b_name_index, b_form_value))
-// {
-// result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, &dwarf2Data->get_debug_str_data());
-// if (result == 0)
-// {
-// a_attr_count = b_attr_count = 0;
-// compare_children = false;
-// }
-// }
-// }
-// }
-//
-// if (a_attr_count < b_attr_count)
-// return -1;
-// if (a_attr_count > b_attr_count)
-// return 1;
-//
-//
-// // The number of attributes are the same...
-// if (a_attr_count > 0)
-// {
-// const DWARFDataExtractor* debug_str_data_ptr = &dwarf2Data->get_debug_str_data();
-//
-// uint32_t i;
-// for (i=0; i<a_attr_count; ++i)
-// {
-// const dw_attr_t a_attr = a_attrs.AttributeAtIndex(i);
-// const dw_attr_t b_attr = b_attrs.AttributeAtIndex(i);
-// //printf(" comparing attributes\n\t\t0x%8.8x: %s %s\t\t0x%8.8x: %s %s\n",
-// // a_attrs.DIEOffsetAtIndex(i), DW_FORM_value_to_name(a_attrs.FormAtIndex(i)), DW_AT_value_to_name(a_attr),
-// // b_attrs.DIEOffsetAtIndex(i), DW_FORM_value_to_name(b_attrs.FormAtIndex(i)), DW_AT_value_to_name(b_attr));
-//
-// if (a_attr < b_attr)
-// return -1;
-// else if (a_attr > b_attr)
-// return 1;
-//
-// switch (a_attr)
-// {
-// // Since we call a form of GetAttributes which inlines the
-// // attributes from DW_AT_abstract_origin and DW_AT_specification
-// // we don't care if their values mismatch...
-// case DW_AT_abstract_origin:
-// case DW_AT_specification:
-// case DW_AT_sibling:
-// case DW_AT_containing_type:
-// //printf(" action = IGNORE\n");
-// result = 0;
-// break; // ignore
-//
-// default:
-// if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, i, a_form_value) &&
-// b_attrs.ExtractFormValueAtIndex(dwarf2Data, i, b_form_value))
-// result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, debug_str_data_ptr);
-// break;
-// }
-//
-// //printf("\t result = %i\n", result);
-//
-// if (result != 0)
-// {
-// // Attributes weren't equal, lets see if we care?
-// switch (a_attr)
-// {
-// case DW_AT_decl_file:
-// // TODO: add the ability to compare files in two different compile units
-// if (a_cu == b_cu)
-// {
-// //printf(" action = RETURN RESULT\n");
-// return result; // Only return the compare results when the compile units are the same and the decl_file attributes can be compared
-// }
-// else
-// {
-// result = 0;
-// //printf(" action = IGNORE\n");
-// }
-// break;
-//
-// default:
-// switch (a_attrs.FormAtIndex(i))
-// {
-// case DW_FORM_ref1:
-// case DW_FORM_ref2:
-// case DW_FORM_ref4:
-// case DW_FORM_ref8:
-// case DW_FORM_ref_udata:
-// case DW_FORM_ref_addr:
-// //printf(" action = COMPARE DIEs 0x%8.8x 0x%8.8x\n", (dw_offset_t)a_form_value.Reference(a_cu), (dw_offset_t)b_form_value.Reference(b_cu));
-// // These attribute values refer to other DIEs, so lets compare those instead of their DIE offsets...
-// result = Compare(dwarf2Data, a_form_value.Reference(a_cu), b_form_value.Reference(b_cu), compare_state, false, true);
-// if (result != 0)
-// return result;
-// break;
-//
-// default:
-// // We do care that they were different, return this result...
-// //printf(" action = RETURN RESULT\n");
-// return result;
-// }
-// }
-// }
-// }
-// }
-// //printf(" SUCCESS\n\t\t0x%8.8x: %s\n\t\t0x%8.8x: %s\n", a_die->GetOffset(), DW_TAG_value_to_name(a_tag), b_die->GetOffset(), DW_TAG_value_to_name(b_tag));
-//
-// if (compare_children)
-// {
-// bool a_has_children = a_die->HasChildren();
-// bool b_has_children = b_die->HasChildren();
-// if (a_has_children == b_has_children)
-// {
-// // Both either have kids or don't
-// if (a_has_children)
-// result = Compare( dwarf2Data,
-// a_cu, a_die->GetFirstChild(),
-// b_cu, b_die->GetFirstChild(),
-// compare_state, true, compare_children);
-// else
-// result = 0;
-// }
-// else if (!a_has_children)
-// result = -1; // A doesn't have kids, but B does
-// else
-// result = 1; // A has kids, but B doesn't
-// }
-//
-// if (compare_siblings)
-// {
-// result = Compare( dwarf2Data,
-// a_cu, a_die->GetSibling(),
-// b_cu, b_die->GetSibling(),
-// compare_state, true, compare_children);
-// }
-//
-// return result;
-// }
-//
-// if (a_die == NULL)
-// return -1; // a_die is NULL, yet b_die is non-NULL
-// else
-// return 1; // a_die is non-NULL, yet b_die is NULL
-//
-//}
-//
-//
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-// SymbolFileDWARF* dwarf2Data,
-// const DWARFCompileUnit* cu_a,
-// const DWARFDebugInfoEntry* die_a,
-// const DWARFCompileUnit* cu_a,
-// const DWARFDebugInfoEntry* die_b,
-// CompareState &compare_state
-//)
-//{
-//}
-
-//----------------------------------------------------------------------
// GetDIENamesAndRanges
//
// Gets the valid address ranges for a given DIE by looking for a
@@ -739,7 +392,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
const DWARFCompileUnit* cu,
const char * &name,
const char * &mangled,
- DWARFDebugRanges::RangeList& ranges,
+ DWARFRangeList& ranges,
int& decl_file,
int& decl_line,
int& decl_column,
@@ -749,12 +402,27 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
DWARFExpression *frame_base
) const
{
- if (dwarf2Data == NULL)
+ if (dwarf2Data == nullptr)
return false;
+ SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile();
+ if (dwo_symbol_file)
+ return GetDIENamesAndRanges(dwo_symbol_file,
+ dwo_symbol_file->GetCompileUnit(),
+ name,
+ mangled,
+ ranges,
+ decl_file,
+ decl_line,
+ decl_column,
+ call_file,
+ call_line,
+ call_column,
+ frame_base);
+
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- std::vector<dw_offset_t> die_offsets;
+ std::vector<DIERef> die_refs;
bool set_frame_base_loclist_addr = false;
lldb::offset_t offset;
@@ -784,7 +452,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
switch (attr)
{
case DW_AT_low_pc:
- lo_pc = form_value.Unsigned();
+ lo_pc = form_value.Address();
if (do_offset)
hi_pc += lo_pc;
@@ -792,13 +460,18 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
break;
case DW_AT_entry_pc:
- lo_pc = form_value.Unsigned();
+ lo_pc = form_value.Address();
break;
case DW_AT_high_pc:
- hi_pc = form_value.Unsigned();
- if (form_value.Form() != DW_FORM_addr)
+ if (form_value.Form() == DW_FORM_addr ||
+ form_value.Form() == DW_FORM_GNU_addr_index)
{
+ hi_pc = form_value.Address();
+ }
+ else
+ {
+ hi_pc = form_value.Unsigned();
if (lo_pc == LLDB_INVALID_ADDRESS)
do_offset = hi_pc != LLDB_INVALID_ADDRESS;
else
@@ -819,21 +492,21 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
case DW_AT_name:
if (name == NULL)
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ name = form_value.AsCString();
break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
if (mangled == NULL)
- mangled = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ mangled = form_value.AsCString();
break;
case DW_AT_abstract_origin:
- die_offsets.push_back(form_value.Reference());
+ die_refs.emplace_back(form_value);
break;
case DW_AT_specification:
- die_offsets.push_back(form_value.Reference());
+ die_refs.emplace_back(form_value);
break;
case DW_AT_decl_file:
@@ -880,7 +553,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
const DWARFDataExtractor &debug_loc_data = dwarf2Data->get_debug_loc_data();
const dw_offset_t debug_loc_offset = form_value.Unsigned();
- size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset);
+ size_t loc_list_length = DWARFExpression::LocationListSize(cu, debug_loc_data, debug_loc_offset);
if (loc_list_length > 0)
{
frame_base->SetOpcodeData(module, debug_loc_data, debug_loc_offset, loc_list_length);
@@ -910,9 +583,9 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
if (lo_pc != LLDB_INVALID_ADDRESS)
{
if (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc)
- ranges.Append(DWARFDebugRanges::Range (lo_pc, hi_pc - lo_pc));
+ ranges.Append(DWARFRangeList::Entry (lo_pc, hi_pc - lo_pc));
else
- ranges.Append(DWARFDebugRanges::Range (lo_pc, 0));
+ ranges.Append(DWARFRangeList::Entry (lo_pc, 0));
}
}
@@ -925,18 +598,13 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
if (ranges.IsEmpty() || name == NULL || mangled == NULL)
{
- std::vector<dw_offset_t>::const_iterator pos;
- std::vector<dw_offset_t>::const_iterator end = die_offsets.end();
- for (pos = die_offsets.begin(); pos != end; ++pos)
+ for (const DIERef& die_ref : die_refs)
{
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = NULL;
- dw_offset_t die_offset = *pos;
- if (die_offset != DW_INVALID_OFFSET)
+ if (die_ref.die_offset != DW_INVALID_OFFSET)
{
- die = dwarf2Data->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr);
+ DWARFDIE die = dwarf2Data->DebugInfo()->GetDIE(die_ref);
if (die)
- die->GetDIENamesAndRanges(dwarf2Data, cu_sp_ptr.get(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column);
+ die.GetDIE()->GetDIENamesAndRanges(die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column);
}
}
}
@@ -1023,10 +691,10 @@ DWARFDebugInfoEntry::DumpLocation
Stream &s
) const
{
- const DWARFDebugInfoEntry *cu_die = cu->GetCompileUnitDIEOnly();
+ const DWARFDIE cu_die = cu->GetCompileUnitDIEOnly();
const char *cu_name = NULL;
- if (cu_die != NULL)
- cu_name = cu_die->GetName (dwarf2Data, cu);
+ if (cu_die)
+ cu_name = cu_die.GetName ();
const char *obj_file_name = NULL;
ObjectFile *obj_file = dwarf2Data->GetObjectFile();
if (obj_file)
@@ -1062,7 +730,6 @@ DWARFDebugInfoEntry::DumpAttribute
bool verbose = s.GetVerbose();
bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
- const DWARFDataExtractor* debug_str_data = dwarf2Data ? &dwarf2Data->get_debug_str_data() : NULL;
if (verbose)
s.Offset (*offset_ptr);
else
@@ -1094,7 +761,7 @@ DWARFDebugInfoEntry::DumpAttribute
// Always dump form value if verbose is enabled
if (verbose)
{
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
}
@@ -1127,12 +794,16 @@ DWARFDebugInfoEntry::DumpAttribute
if (blockData)
{
if (!verbose)
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
// Location description is inlined in data in the form value
DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned());
if ( verbose ) s.PutCString(" ( ");
- print_dwarf_expression (s, locationData, DWARFCompileUnit::GetAddressByteSize(cu), 4, false);
+ DWARFExpression::PrintDWARFExpression(s,
+ locationData,
+ DWARFCompileUnit::GetAddressByteSize(cu),
+ 4,
+ false);
if ( verbose ) s.PutCString(" )");
}
else
@@ -1144,13 +815,16 @@ DWARFDebugInfoEntry::DumpAttribute
if (dwarf2Data)
{
if ( !verbose )
- form_value.Dump(s, debug_str_data);
- DWARFLocationList::Dump(s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset);
+ form_value.Dump(s);
+ DWARFExpression::PrintDWARFLocationList(s,
+ cu,
+ dwarf2Data->get_debug_loc_data(),
+ debug_loc_offset);
}
else
{
if ( !verbose )
- form_value.Dump(s, NULL);
+ form_value.Dump(s);
}
}
}
@@ -1160,7 +834,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_specification:
{
uint64_t abstract_die_offset = form_value.Reference();
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
// *ostrm_ptr << HEX32 << abstract_die_offset << " ( ";
if ( verbose ) s.PutCString(" ( ");
GetName(dwarf2Data, cu, abstract_die_offset, s);
@@ -1172,7 +846,7 @@ DWARFDebugInfoEntry::DumpAttribute
{
uint64_t type_die_offset = form_value.Reference();
if (!verbose)
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
s.PutCString(" ( ");
AppendTypeName(dwarf2Data, cu, type_die_offset, s);
s.PutCString(" )");
@@ -1182,7 +856,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_ranges:
{
if ( !verbose )
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
lldb::offset_t ranges_offset = form_value.Unsigned();
dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
if (dwarf2Data)
@@ -1192,7 +866,7 @@ DWARFDebugInfoEntry::DumpAttribute
default:
if ( !verbose )
- form_value.Dump(s, debug_str_data);
+ form_value.Dump(s);
break;
}
@@ -1206,24 +880,37 @@ DWARFDebugInfoEntry::DumpAttribute
// take precedence (this can happen for declaration attributes).
//----------------------------------------------------------------------
size_t
-DWARFDebugInfoEntry::GetAttributes
-(
- SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- const uint8_t *fixed_form_sizes,
- DWARFDebugInfoEntry::Attributes& attributes,
- uint32_t curr_depth
-) const
+DWARFDebugInfoEntry::GetAttributes (const DWARFCompileUnit* cu,
+ DWARFFormValue::FixedFormSizes fixed_form_sizes,
+ DWARFAttributes& attributes,
+ uint32_t curr_depth) const
{
- lldb::offset_t offset;
- const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
+ SymbolFileDWARF* dwarf2Data = nullptr;
+ const DWARFAbbreviationDeclaration* abbrevDecl = nullptr;
+ lldb::offset_t offset = 0;
+ if (cu)
+ {
+ if (m_tag != DW_TAG_compile_unit)
+ {
+ SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile();
+ if (dwo_symbol_file)
+ return GetAttributes(dwo_symbol_file->GetCompileUnit(),
+ fixed_form_sizes,
+ attributes,
+ curr_depth);
+ }
+
+ dwarf2Data = cu->GetSymbolFileDWARF();
+ abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
+ }
if (abbrevDecl)
{
const DWARFDataExtractor& debug_info_data = dwarf2Data->get_debug_info_data();
- if (fixed_form_sizes == NULL)
- fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(cu->GetAddressByteSize(), cu->IsDWARF64());
+ if (fixed_form_sizes.Empty())
+ fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(
+ cu->GetAddressByteSize(), cu->IsDWARF64());
const uint32_t num_attributes = abbrevDecl->NumAttributes();
uint32_t i;
@@ -1258,26 +945,15 @@ DWARFDebugInfoEntry::GetAttributes
DWARFFormValue form_value (cu, form);
if (form_value.ExtractValue(debug_info_data, &offset))
{
- const DWARFDebugInfoEntry* die = NULL;
dw_offset_t die_offset = form_value.Reference();
- if (cu->ContainsDIEOffset(die_offset))
- {
- die = const_cast<DWARFCompileUnit*>(cu)->GetDIEPtr(die_offset);
- if (die)
- die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes, curr_depth + 1);
- }
- else
- {
- DWARFCompileUnitSP cu_sp_ptr;
- die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr);
- if (die)
- die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), fixed_form_sizes, attributes, curr_depth + 1);
- }
+ DWARFDIE spec_die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(die_offset);
+ if (spec_die)
+ spec_die.GetAttributes(attributes, curr_depth + 1);
}
}
else
{
- const uint8_t fixed_skip_size = fixed_form_sizes [form];
+ const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
if (fixed_skip_size)
offset += fixed_skip_size;
else
@@ -1308,9 +984,19 @@ DWARFDebugInfoEntry::GetAttributeValue
const DWARFCompileUnit* cu,
const dw_attr_t attr,
DWARFFormValue& form_value,
- dw_offset_t* end_attr_offset_ptr
+ dw_offset_t* end_attr_offset_ptr,
+ bool check_specification_or_abstract_origin
) const
{
+ SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile();
+ if (dwo_symbol_file && m_tag != DW_TAG_compile_unit)
+ return GetAttributeValue(dwo_symbol_file,
+ dwo_symbol_file->GetCompileUnit(),
+ attr,
+ form_value,
+ end_attr_offset_ptr,
+ check_specification_or_abstract_origin);
+
lldb::offset_t offset;
const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
@@ -1338,7 +1024,58 @@ DWARFDebugInfoEntry::GetAttributeValue
}
}
- return 0;
+ if (check_specification_or_abstract_origin)
+ {
+ if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
+ {
+ DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference());
+ if (die)
+ {
+ dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(die.GetDWARF(),
+ die.GetCU(),
+ attr,
+ form_value,
+ end_attr_offset_ptr,
+ false);
+ if (die_offset)
+ return die_offset;
+ }
+ }
+
+ if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value))
+ {
+ DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference());
+ if (die)
+ {
+ dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(die.GetDWARF(),
+ die.GetCU(),
+ attr,
+ form_value,
+ end_attr_offset_ptr,
+ false);
+ if (die_offset)
+ return die_offset;
+ }
+ }
+ }
+
+ if (!dwo_symbol_file)
+ return 0;
+
+ DWARFCompileUnit* dwo_cu = dwo_symbol_file->GetCompileUnit();
+ if (!dwo_cu)
+ return 0;
+
+ DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly();
+ if (!dwo_cu_die.IsValid())
+ return 0;
+
+ return dwo_cu_die.GetDIE()->GetAttributeValue(dwo_symbol_file,
+ dwo_cu,
+ attr,
+ form_value,
+ end_attr_offset_ptr,
+ check_specification_or_abstract_origin);
}
//----------------------------------------------------------------------
@@ -1355,11 +1092,12 @@ DWARFDebugInfoEntry::GetAttributeValueAsString
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- const char* fail_value) const
+ const char* fail_value,
+ bool check_specification_or_abstract_origin) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
- return form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
+ return form_value.AsCString();
return fail_value;
}
@@ -1374,11 +1112,12 @@ DWARFDebugInfoEntry::GetAttributeValueAsUnsigned
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
return form_value.Unsigned();
return fail_value;
}
@@ -1394,11 +1133,12 @@ DWARFDebugInfoEntry::GetAttributeValueAsSigned
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- int64_t fail_value
+ int64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
return form_value.Signed();
return fail_value;
}
@@ -1415,15 +1155,32 @@ DWARFDebugInfoEntry::GetAttributeValueAsReference
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
const dw_attr_t attr,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
return form_value.Reference();
return fail_value;
}
+uint64_t
+DWARFDebugInfoEntry::GetAttributeValueAsAddress
+(
+ SymbolFileDWARF* dwarf2Data,
+ const DWARFCompileUnit* cu,
+ const dw_attr_t attr,
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
+) const
+{
+ DWARFFormValue form_value;
+ if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
+ return form_value.Address();
+ return fail_value;
+}
+
//----------------------------------------------------------------------
// GetAttributeHighPC
//
@@ -1438,17 +1195,19 @@ DWARFDebugInfoEntry::GetAttributeHighPC
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
dw_addr_t lo_pc,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
DWARFFormValue form_value;
-
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value))
+ if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value, nullptr, check_specification_or_abstract_origin))
{
- dw_addr_t hi_pc = form_value.Unsigned();
- if (form_value.Form() != DW_FORM_addr)
- hi_pc += lo_pc; // DWARF4 can specify the hi_pc as an <offset-from-lowpc>
- return hi_pc;
+ dw_form_t form = form_value.Form();
+ if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index)
+ return form_value.Address();
+
+ // DWARF4 can specify the hi_pc as an <offset-from-lowpc>
+ return lo_pc + form_value.Unsigned();
}
return fail_value;
}
@@ -1468,13 +1227,14 @@ DWARFDebugInfoEntry::GetAttributeAddressRange
const DWARFCompileUnit* cu,
dw_addr_t& lo_pc,
dw_addr_t& hi_pc,
- uint64_t fail_value
+ uint64_t fail_value,
+ bool check_specification_or_abstract_origin
) const
{
- lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, fail_value);
+ lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc, fail_value, check_specification_or_abstract_origin);
if (lo_pc != fail_value)
{
- hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, fail_value);
+ hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, fail_value, check_specification_or_abstract_origin);
if (hi_pc != fail_value)
return true;
}
@@ -1484,89 +1244,40 @@ DWARFDebugInfoEntry::GetAttributeAddressRange
}
size_t
-DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- DWARFDebugRanges::RangeList &ranges,
- bool check_hi_lo_pc) const
+DWARFDebugInfoEntry::GetAttributeAddressRanges (SymbolFileDWARF* dwarf2Data,
+ const DWARFCompileUnit* cu,
+ DWARFRangeList &ranges,
+ bool check_hi_lo_pc,
+ bool check_specification_or_abstract_origin) const
{
ranges.Clear();
- dw_offset_t ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
- if (ranges_offset != DW_INVALID_OFFSET)
+ dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data,
+ cu,
+ DW_AT_ranges,
+ DW_INVALID_OFFSET,
+ check_specification_or_abstract_origin);
+ if (debug_ranges_offset != DW_INVALID_OFFSET)
{
- dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
- if (debug_ranges_offset != DW_INVALID_OFFSET)
- {
- DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
-
- debug_ranges->FindRanges(debug_ranges_offset, ranges);
- ranges.Slide (cu->GetBaseAddress());
- }
+ DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
+
+ debug_ranges->FindRanges(debug_ranges_offset, ranges);
+ ranges.Slide (cu->GetBaseAddress());
}
else if (check_hi_lo_pc)
{
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS))
+ if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS, check_specification_or_abstract_origin))
{
if (lo_pc < hi_pc)
- ranges.Append(DWARFDebugRanges::RangeList::Entry(lo_pc, hi_pc - lo_pc));
+ ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc));
}
}
return ranges.GetSize();
}
//----------------------------------------------------------------------
-// GetAttributeValueAsLocation
-//
-// Get the value of an attribute as reference and fix up and compile
-// unit relative offsets as needed.
-//----------------------------------------------------------------------
-dw_offset_t
-DWARFDebugInfoEntry::GetAttributeValueAsLocation
-(
- SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- const dw_attr_t attr,
- DWARFDataExtractor& location_data,
- uint32_t &block_size
-) const
-{
- block_size = 0;
- DWARFFormValue form_value;
-
- // Empty out data in case we don't find anything
- location_data.Clear();
- dw_offset_t end_addr_offset = DW_INVALID_OFFSET;
- const dw_offset_t attr_offset = GetAttributeValue(dwarf2Data, cu, attr, form_value, &end_addr_offset);
- if (attr_offset)
- {
- const uint8_t* blockData = form_value.BlockData();
- if (blockData)
- {
- // We have an inlined location list in the .debug_info section
- const DWARFDataExtractor& debug_info = dwarf2Data->get_debug_info_data();
- dw_offset_t block_offset = blockData - debug_info.GetDataStart();
- block_size = (end_addr_offset - attr_offset) - form_value.Unsigned();
- location_data.SetData(debug_info, block_offset, block_size);
- }
- else
- {
- // We have a location list offset as the value that is
- // the offset into the .debug_loc section that describes
- // the value over it's lifetime
- lldb::offset_t debug_loc_offset = form_value.Unsigned();
- if (dwarf2Data)
- {
- assert(dwarf2Data->get_debug_loc_data().GetAddressByteSize() == cu->GetAddressByteSize());
- return DWARFLocationList::Extract(dwarf2Data->get_debug_loc_data(), &debug_loc_offset, location_data);
- }
- }
- }
- return attr_offset;
-}
-
-//----------------------------------------------------------------------
// GetName
//
// Get value of the DW_AT_name attribute and return it if one exists,
@@ -1579,27 +1290,9 @@ DWARFDebugInfoEntry::GetName
const DWARFCompileUnit* cu
) const
{
- DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- return form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
- {
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
- if (die)
- return die->GetName(dwarf2Data, cu_sp_ptr.get());
- }
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value))
- {
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
- if (die)
- return die->GetName(dwarf2Data, cu_sp_ptr.get());
- }
- return nullptr;
+ return GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
}
-
//----------------------------------------------------------------------
// GetMangledName
//
@@ -1614,20 +1307,20 @@ DWARFDebugInfoEntry::GetMangledName
bool substitute_name_allowed
) const
{
- const char* name = NULL;
- DWARFFormValue form_value;
+ const char* name = nullptr;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true);
+ if (name)
+ return name;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true);
+ if (name)
+ return name;
- if (substitute_name_allowed && name == NULL)
- {
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- }
+ if (!substitute_name_allowed)
+ return nullptr;
+
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
return name;
}
@@ -1645,27 +1338,19 @@ DWARFDebugInfoEntry::GetPubname
const DWARFCompileUnit* cu
) const
{
- const char* name = NULL;
+ const char* name = nullptr;
if (!dwarf2Data)
return name;
-
- DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
- {
- // The specification DIE may be in another compile unit so we need
- // to get a die and its compile unit.
- DWARFCompileUnitSP cu_sp_ptr;
- const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
- if (die)
- return die->GetPubname(dwarf2Data, cu_sp_ptr.get());
- }
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true);
+ if (name)
+ return name;
+
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true);
+ if (name)
+ return name;
+
+ name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
return name;
}
@@ -1705,15 +1390,11 @@ DWARFDebugInfoEntry::GetName
}
else
{
- DWARFFormValue form_value;
- if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
+ const char* name = die.GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
+ if (name)
{
- const char* name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
- if (name)
- {
- s.PutCString(name);
- return true;
- }
+ s.PutCString(name);
+ return true;
}
}
}
@@ -1755,8 +1436,6 @@ DWARFDebugInfoEntry::AppendTypeName
else
{
const char* name = die.GetPubname(dwarf2Data, cu);
- // if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
- // name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
if (name)
s.PutCString(name);
else
@@ -1909,16 +1588,12 @@ DWARFDebugInfoEntry::BuildFunctionAddressRangeTable
}
void
-DWARFDebugInfoEntry::GetDeclContextDIEs (SymbolFileDWARF* dwarf2Data,
- DWARFCompileUnit* cu,
+DWARFDebugInfoEntry::GetDeclContextDIEs (DWARFCompileUnit* cu,
DWARFDIECollection &decl_context_dies) const
{
- const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
- if (parent_decl_ctx_die && parent_decl_ctx_die != this)
- {
- decl_context_dies.Append(parent_decl_ctx_die);
- parent_decl_ctx_die->GetDeclContextDIEs (dwarf2Data, cu, decl_context_dies);
- }
+
+ DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
+ die.GetDeclContextDIEs(decl_context_dies);
}
void
@@ -1930,11 +1605,11 @@ DWARFDebugInfoEntry::GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
if (tag != DW_TAG_compile_unit)
{
dwarf_decl_ctx.AppendDeclContext(tag, GetName(dwarf2Data, cu));
- const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
- if (parent_decl_ctx_die && parent_decl_ctx_die != this)
+ DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
+ if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this)
{
- if (parent_decl_ctx_die->Tag() != DW_TAG_compile_unit)
- parent_decl_ctx_die->GetDWARFDeclContext (dwarf2Data, cu, dwarf_decl_ctx);
+ if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit)
+ parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext (parent_decl_ctx_die.GetDWARF(), parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
}
}
}
@@ -1951,30 +1626,30 @@ DWARFDebugInfoEntry::MatchesDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
return this_dwarf_decl_ctx == dwarf_decl_ctx;
}
-const DWARFDebugInfoEntry *
+DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu) const
{
- DWARFDebugInfoEntry::Attributes attributes;
- GetAttributes(dwarf2Data, cu, NULL, attributes);
+ DWARFAttributes attributes;
+ GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
return GetParentDeclContextDIE (dwarf2Data, cu, attributes);
}
-const DWARFDebugInfoEntry *
+DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry::Attributes& attributes) const
+ const DWARFAttributes& attributes) const
{
- const DWARFDebugInfoEntry * die = this;
-
- while (die != NULL)
+ DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
+
+ while (die)
{
// If this is the original DIE that we are searching for a declaration
// for, then don't look in the cache as we don't want our own decl
// context to be our decl context...
- if (die != this)
+ if (die.GetDIE() != this)
{
- switch (die->Tag())
+ switch (die.Tag())
{
case DW_TAG_compile_unit:
case DW_TAG_namespace:
@@ -1990,33 +1665,33 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
dw_offset_t die_offset;
- die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_specification, DW_INVALID_OFFSET);
+ die_offset = attributes.FormValueAsUnsigned(DW_AT_specification, DW_INVALID_OFFSET);
if (die_offset != DW_INVALID_OFFSET)
{
- const DWARFDebugInfoEntry *spec_die = cu->GetDIEPtr (die_offset);
+ DWARFDIE spec_die = cu->GetDIE (die_offset);
if (spec_die)
- {
- const DWARFDebugInfoEntry *spec_die_decl_ctx_die = spec_die->GetParentDeclContextDIE (dwarf2Data, cu);
- if (spec_die_decl_ctx_die)
- return spec_die_decl_ctx_die;
- }
+ {
+ DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE();
+ if (decl_ctx_die)
+ return decl_ctx_die;
+ }
}
- die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_abstract_origin, DW_INVALID_OFFSET);
+ die_offset = attributes.FormValueAsUnsigned(DW_AT_abstract_origin, DW_INVALID_OFFSET);
if (die_offset != DW_INVALID_OFFSET)
{
- const DWARFDebugInfoEntry *abs_die = cu->GetDIEPtr (die_offset);
+ DWARFDIE abs_die = cu->GetDIE (die_offset);
if (abs_die)
{
- const DWARFDebugInfoEntry *abs_die_decl_ctx_die = abs_die->GetParentDeclContextDIE (dwarf2Data, cu);
- if (abs_die_decl_ctx_die)
- return abs_die_decl_ctx_die;
+ DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE();
+ if (decl_ctx_die)
+ return decl_ctx_die;
}
}
- die = die->GetParent();
+ die = die.GetParent();
}
- return NULL;
+ return DWARFDIE();
}
@@ -2025,15 +1700,15 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
std::string &storage) const
{
- DWARFDebugInfoEntry::Attributes attributes;
- GetAttributes(dwarf2Data, cu, NULL, attributes);
+ DWARFAttributes attributes;
+ GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
return GetQualifiedName (dwarf2Data, cu, attributes, storage);
}
const char*
DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
- const DWARFDebugInfoEntry::Attributes& attributes,
+ const DWARFAttributes& attributes,
std::string &storage) const
{
@@ -2041,47 +1716,47 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
if (name)
{
- const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
+ DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
storage.clear();
// TODO: change this to get the correct decl context parent....
while (parent_decl_ctx_die)
{
- const dw_tag_t parent_tag = parent_decl_ctx_die->Tag();
+ const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
switch (parent_tag)
{
case DW_TAG_namespace:
- {
- const char *namespace_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
- if (namespace_name)
- {
- storage.insert (0, "::");
- storage.insert (0, namespace_name);
- }
- else
- {
- storage.insert (0, "(anonymous namespace)::");
- }
- parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
- }
+ {
+ const char *namespace_name = parent_decl_ctx_die.GetName ();
+ if (namespace_name)
+ {
+ storage.insert (0, "::");
+ storage.insert (0, namespace_name);
+ }
+ else
+ {
+ storage.insert (0, "(anonymous namespace)::");
+ }
+ parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
+ }
break;
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
- {
- const char *class_union_struct_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
-
- if (class_union_struct_name)
- {
- storage.insert (0, "::");
- storage.insert (0, class_union_struct_name);
- }
- parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
- }
+ {
+ const char *class_union_struct_name = parent_decl_ctx_die.GetName ();
+
+ if (class_union_struct_name)
+ {
+ storage.insert (0, "::");
+ storage.insert (0, class_union_struct_name);
+ }
+ parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
+ }
break;
default:
- parent_decl_ctx_die = NULL;
+ parent_decl_ctx_die.Clear();
break;
}
}
@@ -2179,7 +1854,7 @@ DWARFDebugInfoEntry::LookupAddress
if (match_addr_range)
{
- dw_addr_t lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
+ dw_addr_t lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
if (lo_pc != LLDB_INVALID_ADDRESS)
{
dw_addr_t hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, LLDB_INVALID_ADDRESS);
@@ -2229,7 +1904,7 @@ DWARFDebugInfoEntry::LookupAddress
dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
if (debug_ranges_offset != DW_INVALID_OFFSET)
{
- DWARFDebugRanges::RangeList ranges;
+ DWARFRangeList ranges;
DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
debug_ranges->FindRanges(debug_ranges_offset, ranges);
// All DW_AT_ranges are relative to the base address of the