summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-09-14 02:20:48 +0000
committerGreg Clayton <gclayton@apple.com>2010-09-14 02:20:48 +0000
commit016a95eb040364e47bc25ddbdfcdaf306ad7ce2b (patch)
treef8a87af145e212ec86e5207e59b8a045b30b6af3 /lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
parente1328dc0e958f8190492fc9c870ced6e1441bf01 (diff)
downloadbcm5719-llvm-016a95eb040364e47bc25ddbdfcdaf306ad7ce2b.tar.gz
bcm5719-llvm-016a95eb040364e47bc25ddbdfcdaf306ad7ce2b.zip
Looking at some of the test suite failures in DWARF in .o files with the
debug map showed that the location lists in the .o files needed some refactoring in order to work. The case that was failing was where a function that was in the "__TEXT.__textcoal_nt" in the .o file, and in the "__TEXT.__text" section in the main executable. This made symbol lookup fail due to the way we were finding a real address in the debug map which was by finding the section that the function was in in the .o file and trying to find this in the main executable. Now the section list supports finding a linked address in a section or any child sections. After fixing this, we ran into issue that were due to DWARF and how it represents locations lists. DWARF makes a list of address ranges and expressions that go along with those address ranges. The location addresses are expressed in terms of a compile unit address + offset. This works fine as long as nothing moves around. When stuff moves around and offsets change between the remapped compile unit base address and the new function address, then we can run into trouble. To deal with this, we now store supply a location list slide amount to any location list expressions that will allow us to make the location list addresses into zero based offsets from the object that owns the location list (always a function in our case). With these fixes we can now re-link random address ranges inside the debugger for use with our DWARF + debug map, incremental linking, and more. Another issue that arose when doing the DWARF in the .o files was that GCC 4.2 emits a ".debug_aranges" that only mentions functions that are externally visible. This makes .debug_aranges useless to us and we now generate a real address range lookup table in the DWARF parser at the same time as we index the name tables (that are needed because .debug_pubnames is just as useless). llvm-gcc doesn't generate a .debug_aranges section, though this could be fixed, we aren't going to rely upon it. Renamed a bunch of "UINT_MAX" to "UINT32_MAX". llvm-svn: 113829
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp')
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp55
1 files changed, 53 insertions, 2 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 8a21e1ec555..d75b5fc4cf4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -355,7 +355,7 @@ DWARFCompileUnit::SetDIERelations()
// the running average ends up being in the stdout log.
static size_t g_total_cu_debug_info_size = 0;
static size_t g_total_num_dies = 0;
- static size_t g_min_bytes_per_die = UINT_MAX;
+ static size_t g_min_bytes_per_die = UINT32_MAX;
static size_t g_max_bytes_per_die = 0;
const size_t num_dies = m_die_array.size();
const size_t cu_debug_info_size = GetDebugInfoSize();
@@ -555,7 +555,9 @@ DWARFCompileUnit::Index
lldb_private::UniqueCStringMap<dw_offset_t>& method_name_to_function_die,
lldb_private::UniqueCStringMap<dw_offset_t>& selector_name_to_function_die,
lldb_private::UniqueCStringMap<dw_offset_t>& name_to_type_die,
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_global_die
+ lldb_private::UniqueCStringMap<dw_offset_t>& name_to_global_die,
+ const DWARFDebugRanges *debug_ranges,
+ DWARFDebugAranges *aranges
)
{
const DataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data();
@@ -599,6 +601,10 @@ DWARFCompileUnit::Index
bool has_address = false;
bool has_location = false;
bool is_global_or_static_variable = false;
+ dw_addr_t lo_pc = DW_INVALID_ADDRESS;
+ dw_addr_t hi_pc = DW_INVALID_ADDRESS;
+ DWARFDebugRanges::RangeList ranges;
+
dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, attributes);
if (num_attributes > 0)
@@ -634,7 +640,36 @@ DWARFCompileUnit::Index
break;
case DW_AT_low_pc:
+ has_address = true;
+ if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+ {
+ lo_pc = form_value.Unsigned();
+ }
+ break;
+
+ case DW_AT_high_pc:
+ has_address = true;
+ if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+ {
+ hi_pc = form_value.Unsigned();
+ }
+ break;
+
case DW_AT_ranges:
+ if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+ {
+ if (debug_ranges)
+ {
+ debug_ranges->FindRanges(form_value.Unsigned(), ranges);
+ // All DW_AT_ranges are relative to the base address of the
+ // compile unit. We add the compile unit base address to make
+ // sure all the addresses are properly fixed up.
+ ranges.AddOffset(GetBaseAddress());
+ }
+ }
+ has_address = true;
+ break;
+
case DW_AT_entry_pc:
has_address = true;
break;
@@ -693,6 +728,22 @@ DWARFCompileUnit::Index
break;
}
}
+
+ if (tag == DW_TAG_subprogram)
+ {
+ if (lo_pc != DW_INVALID_ADDRESS && hi_pc != DW_INVALID_ADDRESS)
+ {
+ aranges->AppendRange (m_offset, lo_pc, hi_pc);
+ }
+ else
+ {
+ for (size_t i=0, num_ranges = ranges.Size(); i<num_ranges; ++i)
+ {
+ const DWARFDebugRanges::Range *range = ranges.RangeAtIndex (i);
+ aranges->AppendRange (m_offset, range->begin_offset, range->end_offset);
+ }
+ }
+ }
}
switch (tag)
OpenPOWER on IntegriCloud