summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp')
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp173
1 files changed, 89 insertions, 84 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 90b65fe6a8a..eec2aee7da9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -376,6 +376,15 @@ DWARFCompileUnit::SetDefaultAddressSize(uint8_t addr_size)
g_default_addr_size = addr_size;
}
+lldb::user_id_t
+DWARFCompileUnit::GetID () const
+{
+ if (m_dwarf2Data)
+ return m_dwarf2Data->MakeUserID(GetOffset());
+ else
+ return GetOffset();
+}
+
void
DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
DWARFDebugAranges* debug_aranges)
@@ -392,7 +401,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
const dw_offset_t cu_offset = GetOffset();
if (die)
{
- DWARFDebugRanges::RangeList ranges;
+ DWARFRangeList ranges;
const size_t num_ranges = die->GetAttributeAddressRanges(dwarf2Data, this, ranges, false);
if (num_ranges > 0)
{
@@ -402,7 +411,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
// this with recent GCC builds.
for (size_t i=0; i<num_ranges; ++i)
{
- const DWARFDebugRanges::RangeList::Entry &range = ranges.GetEntryRef(i);
+ const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd());
}
@@ -416,7 +425,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
// and then throwing them all away to keep memory usage down.
const bool clear_dies = ExtractDIEsIfNeeded (false) > 1;
- die = DIE();
+ die = DIEPtr();
if (die)
die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
@@ -496,7 +505,7 @@ DWARFCompileUnit::GetFunctionAranges ()
"DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
GetOffset());
}
- const DWARFDebugInfoEntry* die = DIE();
+ const DWARFDebugInfoEntry* die = DIEPtr();
if (die)
die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
const bool minimize = false;
@@ -505,74 +514,58 @@ DWARFCompileUnit::GetFunctionAranges ()
return *m_func_aranges_ap.get();
}
-bool
-DWARFCompileUnit::LookupAddress
-(
- const dw_addr_t address,
- DWARFDebugInfoEntry** function_die_handle,
- DWARFDebugInfoEntry** block_die_handle
-)
+DWARFDIE
+DWARFCompileUnit::LookupAddress (const dw_addr_t address)
{
- bool success = false;
-
- if (function_die_handle != NULL && DIE())
+ if (DIE())
{
-
const DWARFDebugAranges &func_aranges = GetFunctionAranges ();
// Re-check the aranges auto pointer contents in case it was created above
if (!func_aranges.IsEmpty())
- {
- *function_die_handle = GetDIEPtr(func_aranges.FindAddress(address));
- if (*function_die_handle != NULL)
- {
- success = true;
- if (block_die_handle != NULL)
- {
- DWARFDebugInfoEntry* child = (*function_die_handle)->GetFirstChild();
- while (child)
- {
- if (child->LookupAddress(address, m_dwarf2Data, this, NULL, block_die_handle))
- break;
- child = child->GetSibling();
- }
- }
- }
- }
+ return GetDIE(func_aranges.FindAddress(address));
}
- return success;
+ return DWARFDIE();
}
//----------------------------------------------------------------------
// Compare function DWARFDebugAranges::Range structures
//----------------------------------------------------------------------
-static bool CompareDIEOffset (const DWARFDebugInfoEntry& die1, const DWARFDebugInfoEntry& die2)
+static bool CompareDIEOffset (const DWARFDebugInfoEntry& die, const dw_offset_t die_offset)
{
- return die1.GetOffset() < die2.GetOffset();
+ return die.GetOffset() < die_offset;
}
//----------------------------------------------------------------------
-// GetDIEPtr()
+// GetDIE()
//
-// Get the DIE (Debug Information Entry) with the specified offset.
+// Get the DIE (Debug Information Entry) with the specified offset by
+// first checking if the DIE is contained within this compile unit and
+// grabbing the DIE from this compile unit. Otherwise we grab the DIE
+// from the DWARF file.
//----------------------------------------------------------------------
-DWARFDebugInfoEntry*
-DWARFCompileUnit::GetDIEPtr(dw_offset_t die_offset)
+DWARFDIE
+DWARFCompileUnit::GetDIE (dw_offset_t die_offset)
{
if (die_offset != DW_INVALID_OFFSET)
{
- ExtractDIEsIfNeeded (false);
- DWARFDebugInfoEntry compare_die;
- compare_die.SetOffset(die_offset);
- DWARFDebugInfoEntry::iterator end = m_die_array.end();
- DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset);
- if (pos != end)
+ if (ContainsDIEOffset(die_offset))
{
- if (die_offset == (*pos).GetOffset())
- return &(*pos);
+ ExtractDIEsIfNeeded (false);
+ DWARFDebugInfoEntry::iterator end = m_die_array.end();
+ DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset);
+ if (pos != end)
+ {
+ if (die_offset == (*pos).GetOffset())
+ return DWARFDIE(this, &(*pos));
+ }
+ }
+ else
+ {
+ return m_dwarf2Data->DebugInfo()->GetDIE (die_offset);
}
}
- return NULL; // Not found in any compile units
+ return DWARFDIE(); // Not found
}
//----------------------------------------------------------------------
@@ -581,30 +574,36 @@ DWARFCompileUnit::GetDIEPtr(dw_offset_t die_offset)
// Get the DIE (Debug Information Entry) that contains the specified
// .debug_info offset.
//----------------------------------------------------------------------
-const DWARFDebugInfoEntry*
-DWARFCompileUnit::GetDIEPtrContainingOffset(dw_offset_t die_offset)
+DWARFDIE
+DWARFCompileUnit::GetDIEContainingOffset(dw_offset_t die_offset)
{
if (die_offset != DW_INVALID_OFFSET)
{
- ExtractDIEsIfNeeded (false);
- DWARFDebugInfoEntry compare_die;
- compare_die.SetOffset(die_offset);
- DWARFDebugInfoEntry::iterator end = m_die_array.end();
- DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset);
- if (pos != end)
+ if (ContainsDIEOffset(die_offset))
{
- if (die_offset >= (*pos).GetOffset())
+
+ ExtractDIEsIfNeeded (false);
+ DWARFDebugInfoEntry::iterator end = m_die_array.end();
+ DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset);
+ if (pos != end)
{
- DWARFDebugInfoEntry::iterator next = pos + 1;
- if (next != end)
+ if (die_offset >= (*pos).GetOffset())
{
- if (die_offset < (*next).GetOffset())
- return &(*pos);
+ DWARFDebugInfoEntry::iterator next = pos + 1;
+ if (next != end)
+ {
+ if (die_offset < (*next).GetOffset())
+ return DWARFDIE(this, &(*pos));
+ }
}
}
}
+ else
+ {
+ return m_dwarf2Data->DebugInfo()->GetDIEContainingOffset (die_offset);
+ }
}
- return NULL; // Not found in any compile units
+ return DWARFDIE(); // Not found
}
@@ -618,7 +617,7 @@ DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& die
for (pos = m_die_array.begin(); pos != end; ++pos)
{
if (pos->Tag() == tag)
- dies.Append (&(*pos));
+ dies.Append (DWARFDIE(this, &(*pos)));
}
// Return the number of DIEs added to the collection
@@ -703,7 +702,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
continue;
}
- DWARFDebugInfoEntry::Attributes attributes;
+ DWARFAttributes attributes;
const char *name = NULL;
const char *mangled_cstr = NULL;
bool is_declaration = false;
@@ -713,7 +712,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
bool is_global_or_static_variable = false;
dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
- const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes);
+ const size_t num_attributes = die.GetAttributes(this, fixed_form_sizes, attributes);
if (num_attributes > 0)
{
for (uint32_t i=0; i<num_attributes; ++i)
@@ -723,24 +722,24 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
switch (attr)
{
case DW_AT_name:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- name = form_value.AsCString(m_dwarf2Data);
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ name = form_value.AsCString();
break;
case DW_AT_declaration:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
is_declaration = form_value.Unsigned() != 0;
break;
// case DW_AT_artificial:
-// if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+// if (attributes.ExtractFormValueAtIndex(i, form_value))
// is_artificial = form_value.Unsigned() != 0;
// break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- mangled_cstr = form_value.AsCString(m_dwarf2Data);
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
+ mangled_cstr = form_value.AsCString();
break;
case DW_AT_low_pc:
@@ -802,7 +801,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
break;
case DW_AT_specification:
- if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+ if (attributes.ExtractFormValueAtIndex(i, form_value))
specification_die_offset = form_value.Reference();
break;
}
@@ -850,18 +849,9 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
{
if (specification_die_offset != DW_INVALID_OFFSET)
{
- const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL);
- if (specification_die)
- {
- parent = specification_die->GetParent();
- if (parent)
- {
- parent_tag = parent->Tag();
-
- if (parent_tag == DW_TAG_class_type || parent_tag == DW_TAG_structure_type)
- is_method = true;
- }
- }
+ DWARFDIE specification_die = m_dwarf2Data->DebugInfo()->GetDIE (specification_die_offset);
+ if (specification_die.GetParent().IsStructOrClass())
+ is_method = true;
}
}
}
@@ -1133,3 +1123,18 @@ DWARFCompileUnit::GetIsOptimized ()
return false;
}
}
+
+DWARFFormValue::FixedFormSizes
+DWARFCompileUnit::GetFixedFormSizes ()
+{
+ return DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), IsDWARF64());
+}
+
+TypeSystem *
+DWARFCompileUnit::GetTypeSystem ()
+{
+ if (m_dwarf2Data)
+ return m_dwarf2Data->GetTypeSystemForLanguage(GetLanguageType());
+ else
+ return nullptr;
+}
OpenPOWER on IntegriCloud