diff options
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
11 files changed, 207 insertions, 78 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) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h index d269537ce69..0e097dd5c86 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -26,7 +26,7 @@ public: DWARFDebugInfoEntry** function_die, DWARFDebugInfoEntry** block_die); - size_t AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT_MAX) const; + size_t AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT32_MAX) const; void Clear(); bool Verify(lldb_private::Stream *s) const; void Dump(lldb_private::Stream *s) const; @@ -147,7 +147,9 @@ public: 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); protected: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp index c51a2dde34d..9c5f05ec5be 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp @@ -45,7 +45,7 @@ DWARFAbbreviationDeclarationSet::Extract(const DataExtractor& data, uint32_t* of else { if (prev_abbr_code + 1 != abbrevDeclaration.Code()) - m_idx_offset = UINT_MAX; // Out of order indexes, we can't do O(1) lookups... + m_idx_offset = UINT32_MAX; // Out of order indexes, we can't do O(1) lookups... } prev_abbr_code = abbrevDeclaration.Code(); } @@ -69,7 +69,7 @@ DWARFAbbreviationDeclarationSet::Dump(Stream *s) const const DWARFAbbreviationDeclaration* DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const { - if (m_idx_offset == UINT_MAX) + if (m_idx_offset == UINT32_MAX) { DWARFAbbreviationDeclarationCollConstIter pos; DWARFAbbreviationDeclarationCollConstIter end = m_decls.end(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index 39c5a7fd189..1c8ef58c3c5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -35,7 +35,6 @@ DWARFDebugAranges::DWARFDebugAranges() : //---------------------------------------------------------------------- static bool RangeLessThan (const DWARFDebugAranges::Range& range1, const DWARFDebugAranges::Range& range2) { -// printf("RangeLessThan -- 0x%8.8x < 0x%8.8x ? %d\n", range1.lo_pc, range1.lo_pc, range1.lo_pc < range2.lo_pc); return range1.lo_pc < range2.lo_pc; } @@ -274,6 +273,54 @@ DWARFDebugAranges::InsertRange(const DWARFDebugAranges::Range& range) } +void +DWARFDebugAranges::AppendRange (dw_offset_t offset, dw_addr_t low_pc, dw_addr_t high_pc) +{ + if (!m_aranges.empty()) + { + if (m_aranges.back().offset == offset && m_aranges.back().hi_pc == low_pc) + { + m_aranges.back().hi_pc = high_pc; + return; + } + } + m_aranges.push_back (DWARFDebugAranges::Range(low_pc, high_pc, offset)); +} + +void +DWARFDebugAranges::Sort() +{ + // Sort our address range entries + std::stable_sort (m_aranges.begin(), m_aranges.end(), RangeLessThan); + + // Merge any entries that have the same offset and same start/end address + RangeColl::iterator pos = m_aranges.begin(); + RangeColl::iterator end = m_aranges.end(); + while (pos != end) + { + RangeColl::iterator next_pos = pos + 1; + if (next_pos != end && + pos->offset == next_pos->offset && + pos->hi_pc == next_pos->lo_pc) + { + // We have found an entry whose end address it he same as the + // next entry's start address and the offsets are the same so + // we can merge these two entries. + pos->hi_pc = next_pos->hi_pc; + // Erase the next entry that wasn't needed + pos = m_aranges.erase (next_pos); + // Now recompute the end of the collection + end = m_aranges.end(); + } + else + { + // Two entries have either different offsets or there are gaps + // in the address range, move along, nothing to see here. + pos = next_pos; + } + } +} + //---------------------------------------------------------------------- // FindAddress //---------------------------------------------------------------------- diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h index f3db949bf26..0861376fc66 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h @@ -59,8 +59,13 @@ public: bool GetMaxRange(dw_addr_t& lo_pc, dw_addr_t& hi_pc) const; bool Extract(const lldb_private::DataExtractor &debug_aranges_data); bool Generate(SymbolFileDWARF* dwarf2Data); - void InsertRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc); - void InsertRange(const DWARFDebugAranges::Range& range); + void InsertRange (dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc); + void InsertRange (const DWARFDebugAranges::Range& range); + + // Use append range multiple times and then call sort + void AppendRange (dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc); + void Sort(); + const Range* RangeAtIndex(uint32_t idx) const { if (idx < m_aranges.size()) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index fcb0ccf1189..abe26ef0b38 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -868,7 +868,7 @@ typedef struct DumpInfo strm(init_strm), die_offset(off), recurse_depth(depth), - found_depth(UINT_MAX), + found_depth(UINT32_MAX), found_die(false), ancestors() { @@ -959,7 +959,7 @@ static dw_offset_t DumpCallback // We have already found our DIE and are printing it's children. Obey // our recurse depth and return an invalid offset if we get done // dumping all the the children - if (dumpInfo->recurse_depth == UINT_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) + if (dumpInfo->recurse_depth == UINT32_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) die->Dump(dwarf2Data, cu, s, 0); } else if (dumpInfo->die_offset > die->GetOffset()) @@ -1076,7 +1076,7 @@ DWARFDebugInfo::Dump else { s->Printf(" for DIE entry at .debug_info[0x%8.8x]", die_offset); - if (recurse_depth != UINT_MAX) + if (recurse_depth != UINT32_MAX) s->Printf(" recursing %u levels deep.", recurse_depth); s->EOL(); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 19eef06d3d1..50a7e9ba5ed 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -56,7 +56,7 @@ DWARFDebugInfoEntry::Attributes::FindAttributeIndex(dw_attr_t attr) const if (pos->attr == attr) return std::distance(beg, pos); } - return UINT_MAX; + return UINT32_MAX; } void @@ -69,14 +69,14 @@ DWARFDebugInfoEntry::Attributes::Append(const DWARFCompileUnit *cu, dw_offset_t bool DWARFDebugInfoEntry::Attributes::ContainsAttribute(dw_attr_t attr) const { - return FindAttributeIndex(attr) != UINT_MAX; + return FindAttributeIndex(attr) != UINT32_MAX; } bool DWARFDebugInfoEntry::Attributes::RemoveAttribute(dw_attr_t attr) { uint32_t attr_index = FindAttributeIndex(attr); - if (attr_index != UINT_MAX) + if (attr_index != UINT32_MAX) { m_infos.erase(m_infos.begin() + attr_index); return true; @@ -584,9 +584,9 @@ DWARFDebugInfoEntry::Compare if (a_attr_count != b_attr_count) { uint32_t is_decl_index = a_attrs.FindAttributeIndex(DW_AT_declaration); - uint32_t a_name_index = UINT_MAX; - uint32_t b_name_index = UINT_MAX; - if (is_decl_index != UINT_MAX) + 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) { @@ -597,13 +597,13 @@ DWARFDebugInfoEntry::Compare else { is_decl_index = b_attrs.FindAttributeIndex(DW_AT_declaration); - if (is_decl_index != UINT_MAX && a_attr_count == 2) + 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 != UINT_MAX && b_name_index != UINT_MAX) + 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)) @@ -794,6 +794,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges dw_addr_t lo_pc = DW_INVALID_ADDRESS; dw_addr_t hi_pc = DW_INVALID_ADDRESS; std::vector<dw_offset_t> die_offsets; + bool set_frame_base_loclist_addr = false; if (m_abbrevDecl) { const DataExtractor& debug_info_data = dwarf2Data->get_debug_info_data(); @@ -892,18 +893,26 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges { uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); uint32_t block_length = form_value.Unsigned(); - frame_base->SetOpcodeData(debug_info_data, block_offset, block_length, NULL); + frame_base->SetOpcodeData(debug_info_data, block_offset, block_length); } else { - const DataExtractor& debug_loc_data = dwarf2Data->get_debug_loc_data(); + const DataExtractor &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); if (loc_list_length > 0) { - Address base_address(cu->GetBaseAddress(), dwarf2Data->GetObjectFile()->GetSectionList()); - frame_base->SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length, &base_address); + frame_base->SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length); + if (lo_pc != DW_INVALID_ADDRESS) + { + assert (lo_pc >= cu->GetBaseAddress()); + frame_base->SetLocationListSlide(lo_pc - cu->GetBaseAddress()); + } + else + { + set_frame_base_loclist_addr = true; + } } } } @@ -928,6 +937,12 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges ranges.AddRange(lo_pc, lo_pc); } } + + if (set_frame_base_loclist_addr) + { + assert (ranges.LowestAddress(0) >= cu->GetBaseAddress()); + frame_base->SetLocationListSlide(ranges.LowestAddress(0) - cu->GetBaseAddress()); + } if (ranges.Size() == 0 || (name == NULL) || (mangled == NULL)) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp index 2b3f39b24f3..ed658032b63 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp @@ -1008,7 +1008,7 @@ static bool FindMatchingAddress (const DWARFDebugLine::Row& row1, const DWARFDeb uint32_t DWARFDebugLine::LineTable::LookupAddress(dw_addr_t address, dw_addr_t cu_high_pc) const { - uint32_t index = UINT_MAX; + uint32_t index = UINT32_MAX; if (!rows.empty()) { // Use the lower_bound algorithm to perform a binary search since we know @@ -1036,7 +1036,7 @@ DWARFDebugLine::LineTable::LookupAddress(dw_addr_t address, dw_addr_t cu_high_pc if (index > 0) --index; else - index = UINT_MAX; + index = UINT32_MAX; } } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index c8fef6504f2..0dbd479c5ab 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -418,19 +418,29 @@ SymbolFileDWARF::DebugAbbrev() const DWARFDebugAranges* SymbolFileDWARF::DebugAranges() { - if (m_aranges.get() == NULL) - { - Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); - m_aranges.reset(new DWARFDebugAranges()); - if (m_aranges.get()) - { - const DataExtractor &debug_aranges_data = get_debug_aranges_data(); - if (debug_aranges_data.GetByteSize() > 0) - m_aranges->Extract(debug_aranges_data); - else - m_aranges->Generate(this); - } - } + // It turns out that llvm-gcc doesn't generate .debug_aranges in .o files + // and we are already parsing all of the DWARF because the .debug_pubnames + // is useless (it only mentions symbols that are externally visible), so + // don't use the .debug_aranges section, we should be using a debug aranges + // we got from SymbolFileDWARF::Index(). + + if (!m_indexed) + Index(); + + +// if (m_aranges.get() == NULL) +// { +// Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); +// m_aranges.reset(new DWARFDebugAranges()); +// if (m_aranges.get()) +// { +// const DataExtractor &debug_aranges_data = get_debug_aranges_data(); +// if (debug_aranges_data.GetByteSize() > 0) +// m_aranges->Extract(debug_aranges_data); +// else +// m_aranges->Generate(this); +// } +// } return m_aranges.get(); } @@ -1492,7 +1502,7 @@ SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_i if (dc_cu.get()) { // Figure out the compile unit index if we weren't given one - if (cu_idx == UINT_MAX) + if (cu_idx == UINT32_MAX) DebugInfo()->GetCompileUnit(cu->GetOffset(), &cu_idx); m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(dc_cu, cu_idx); @@ -1507,7 +1517,7 @@ SymbolFileDWARF::GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* f sc.Clear(); // Check if the symbol vendor already knows about this compile unit? sc.module_sp = m_obj_file->GetModule()->GetSP(); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); sc.function = sc.comp_unit->FindFunctionByUID (func_die->GetOffset()).get(); if (sc.function == NULL) @@ -1669,7 +1679,7 @@ SymbolFileDWARF::ResolveSymbolContext(const FileSpec& file_spec, uint32_t line, uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_idx, line, false, &sc.line_entry); found_line = sc.line_entry.line; - while (line_idx != UINT_MAX) + while (line_idx != UINT32_MAX) { sc.function = NULL; sc.block = NULL; @@ -1742,6 +1752,8 @@ SymbolFileDWARF::Index () DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { + m_aranges.reset(new DWARFDebugAranges()); + uint32_t cu_idx = 0; const uint32_t num_compile_units = GetNumCompileUnits(); for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) @@ -1755,7 +1767,9 @@ SymbolFileDWARF::Index () m_method_name_to_function_die, m_selector_name_to_function_die, m_name_to_global_die, - m_name_to_type_die); + m_name_to_type_die, + DebugRanges(), + m_aranges.get()); // Keep memory down by clearing DIEs if this generate function // caused them to be parsed @@ -1769,6 +1783,7 @@ SymbolFileDWARF::Index () m_selector_name_to_function_die.Sort(); m_name_to_global_die.Sort(); m_name_to_type_die.Sort(); + m_aranges->Sort(); } } @@ -1804,10 +1819,10 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint sc.module_sp = m_obj_file->GetModule()->GetSP(); assert (sc.module_sp); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); assert(sc.comp_unit != NULL); - ParseVariables(sc, cu_sp.get(), die, false, false, &variables); + ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) break; @@ -1854,10 +1869,10 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append assert (sc.module_sp); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); assert(sc.comp_unit != NULL); - ParseVariables(sc, cu_sp.get(), die, false, false, &variables); + ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) break; @@ -3308,7 +3323,11 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc) if (sc.function) { const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(sc.function->GetID()); - return ParseVariables(sc, dwarf_cu, function_die->GetFirstChild(), true, true); + + dw_addr_t func_lo_pc = function_die->GetAttributeValueAsUnsigned (this, dwarf_cu, DW_AT_low_pc, DW_INVALID_ADDRESS); + assert (func_lo_pc != DW_INVALID_ADDRESS); + + return ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true); } else if (sc.comp_unit) { @@ -3328,7 +3347,7 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc) const size_t num_globals = dwarf_cu->GetNumGlobals(); for (size_t idx=0; idx<num_globals; ++idx) { - VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetGlobalDIEAtIndex (idx))); + VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetGlobalDIEAtIndex (idx), LLDB_INVALID_ADDRESS)); if (var_sp) { variables->AddVariable(var_sp); @@ -3348,7 +3367,8 @@ SymbolFileDWARF::ParseVariableDIE ( const SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die + const DWARFDebugInfoEntry *die, + const lldb::addr_t func_low_pc ) { @@ -3393,7 +3413,7 @@ SymbolFileDWARF::ParseVariableDIE uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); uint32_t block_length = form_value.Unsigned(); - location.SetOpcodeData(get_debug_info_data(), block_offset, block_length, NULL); + location.SetOpcodeData(get_debug_info_data(), block_offset, block_length); } else { @@ -3403,8 +3423,9 @@ SymbolFileDWARF::ParseVariableDIE size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset); if (loc_list_length > 0) { - Address base_address(dwarf_cu->GetBaseAddress(), m_obj_file->GetSectionList()); - location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length, &base_address); + location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length); + assert (func_low_pc != LLDB_INVALID_ADDRESS); + location.SetLocationListSlide (func_low_pc - dwarf_cu->GetBaseAddress()); } } } @@ -3489,6 +3510,7 @@ SymbolFileDWARF::ParseVariables ( const SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, + const lldb::addr_t func_low_pc, const DWARFDebugInfoEntry *orig_die, bool parse_siblings, bool parse_children, @@ -3565,7 +3587,7 @@ SymbolFileDWARF::ParseVariables (tag == DW_TAG_constant) || (tag == DW_TAG_formal_parameter && sc.function)) { - VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die)); + VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); if (var_sp) { variables->AddVariable(var_sp); @@ -3578,7 +3600,7 @@ SymbolFileDWARF::ParseVariables if (!skip_children && parse_children && die->HasChildren()) { - vars_added += ParseVariables(sc, dwarf_cu, die->GetFirstChild(), true, true); + vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true); //vars_added += ParseVariables(sc, dwarf_cu, die->GetFirstChild(), parse_siblings, parse_children); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index fc4325a5447..2d86359f010 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -218,7 +218,7 @@ protected: bool ParseCompileUnit(DWARFCompileUnit* cu, lldb::CompUnitSP& compile_unit_sp); DWARFCompileUnit* GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid); DWARFCompileUnit* GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu); - lldb_private::CompileUnit* GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx = UINT_MAX); + lldb_private::CompileUnit* GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx = UINT32_MAX); bool GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc); lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die); size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc, @@ -234,11 +234,13 @@ protected: lldb::VariableSP ParseVariableDIE( const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die); + const DWARFDebugInfoEntry *die, + const lldb::addr_t func_low_pc); size_t ParseVariables( const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, + const lldb::addr_t func_low_pc, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 0140dd2dc70..b99a30ce476 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -617,30 +617,15 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint3 { SectionList *oso_section_list = oso_objfile->GetSectionList(); + SectionSP oso_symbol_section_sp (oso_section_list->FindSectionContainingLinkedFileAddress (exe_file_addr, UINT32_MAX)); - SectionSP oso_section_sp(oso_section_list->FindSectionByName(exe_so_addr.GetSection()->GetName())); - if (oso_section_sp) + if (oso_symbol_section_sp) { - SectionSP oso_symbol_section_sp (oso_section_sp->GetChildren().FindSectionContainingLinkedFileAddress (exe_file_addr)); - - if (oso_symbol_section_sp) - { - const addr_t linked_file_addr = oso_symbol_section_sp->GetLinkedFileAddress(); - Address oso_so_addr (oso_symbol_section_sp.get(), exe_file_addr - linked_file_addr); - if (oso_so_addr.IsSectionOffset()) - resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); - } + const addr_t linked_file_addr = oso_symbol_section_sp->GetLinkedFileAddress(); + Address oso_so_addr (oso_symbol_section_sp.get(), exe_file_addr - linked_file_addr); + if (oso_so_addr.IsSectionOffset()) + resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); } - // Map the load address from in the executable back to a - // section/offset address in the .o file so we can do - // lookups in the .o DWARF. -// Address oso_so_addr (exe_load_addr, false, comp_unit_info->debug_map_sections_sp.get()); -// -// // Make sure we were able to resolve this back to a .o -// // section offset address, and if so, resolve the context -// // for everything that was asked for. -// if (oso_so_addr.IsSectionOffset()) -// resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); } } } |