diff options
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
16 files changed, 76 insertions, 55 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 9b737e39953..6837700a8e8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -13,12 +13,12 @@ #include "SymbolFileDWARF.h" #include "SymbolFileDWARFDebugMap.h" -DIERef::DIERef(const DWARFFormValue &form_value) - : cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) { +DIERef::DIERef(const DWARFFormValue &form_value) { if (form_value.IsValid()) { DWARFDIE die = form_value.Reference(); die_offset = die.GetOffset(); if (die) { + section = die.GetCU()->GetDebugSection(); if (die.GetCU()->GetBaseObjOffset() != DW_INVALID_OFFSET) cu_offset = die.GetCU()->GetBaseObjOffset(); else diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h index 8d7729f0bb7..d692d4a5499 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h @@ -16,9 +16,12 @@ class DWARFFormValue; class SymbolFileDWARF; struct DIERef { + enum Section : uint8_t { DebugInfo, DebugTypes }; + DIERef() = default; - DIERef(dw_offset_t c, dw_offset_t d) : cu_offset(c), die_offset(d) {} + DIERef(Section s, dw_offset_t c, dw_offset_t d) + : section(s), cu_offset(c), die_offset(d) {} explicit DIERef(const DWARFFormValue &form_value); @@ -30,6 +33,7 @@ struct DIERef { return cu_offset != DW_INVALID_OFFSET || die_offset != DW_INVALID_OFFSET; } + Section section = Section::DebugInfo; dw_offset_t cu_offset = DW_INVALID_OFFSET; dw_offset_t die_offset = DW_INVALID_OFFSET; }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp index dd935a2903d..205d66ff7a3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -24,7 +24,7 @@ DIERef DWARFBaseDIE::GetDIERef() const { dw_offset_t cu_offset = m_cu->GetOffset(); if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET) cu_offset = m_cu->GetBaseObjOffset(); - return DIERef(cu_offset, m_die->GetOffset()); + return DIERef(m_cu->GetDebugSection(), cu_offset, m_die->GetOffset()); } dw_tag_t DWARFBaseDIE::Tag() const { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h index fa8184fc29b..c0c4413fd76 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -34,6 +34,10 @@ public: /// Byte size of the compile unit header uint32_t GetHeaderByteSize() const override; + DIERef::Section GetDebugSection() const override { + return DIERef::Section::DebugInfo; + } + private: DWARFCompileUnit(SymbolFileDWARF *dwarf2Data, lldb::user_id_t uid); DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp index fdb1721ed1c..5c529c1b8f5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -153,7 +153,8 @@ DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const { return DWARFDIE(cu, block_die); else return DWARFDIE(dwarf->DebugInfo()->GetUnit( - DIERef(cu->GetOffset(), block_die->GetOffset())), + DIERef(cu->GetDebugSection(), cu->GetOffset(), + block_die->GetOffset())), block_die); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 016b9eaed3b..de4a48a2c06 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -116,26 +116,28 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtIndex(user_id_t idx) { return cu; } -bool DWARFDebugInfo::OffsetLessThanUnitOffset(dw_offset_t offset, - const DWARFUnitSP &cu_sp) { - return offset < cu_sp->GetOffset(); -} - -uint32_t DWARFDebugInfo::FindUnitIndex(dw_offset_t offset) { +uint32_t DWARFDebugInfo::FindUnitIndex(DIERef::Section section, + dw_offset_t offset) { ParseUnitHeadersIfNeeded(); // llvm::lower_bound is not used as for DIE offsets it would still return // index +1 and GetOffset() returning index itself would be a special case. - auto pos = llvm::upper_bound(m_units, offset, OffsetLessThanUnitOffset); + auto pos = llvm::upper_bound( + m_units, std::make_pair(section, offset), + [](const std::pair<DIERef::Section, dw_offset_t> &lhs, + const DWARFUnitSP &rhs) { + return lhs < std::make_pair(rhs->GetDebugSection(), rhs->GetOffset()); + }); uint32_t idx = std::distance(m_units.begin(), pos); if (idx == 0) return DW_INVALID_OFFSET; return idx - 1; } -DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(dw_offset_t cu_offset, +DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section section, + dw_offset_t cu_offset, uint32_t *idx_ptr) { - uint32_t idx = FindUnitIndex(cu_offset); + uint32_t idx = FindUnitIndex(section, cu_offset); DWARFUnit *result = GetUnitAtIndex(idx); if (result && result->GetOffset() != cu_offset) { result = nullptr; @@ -148,13 +150,15 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(dw_offset_t cu_offset, DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) { if (die_ref.cu_offset == DW_INVALID_OFFSET) - return GetUnitContainingDIEOffset(die_ref.die_offset); + return GetUnitContainingDIEOffset(die_ref.section, die_ref.die_offset); else - return GetUnitAtOffset(die_ref.cu_offset); + return GetUnitAtOffset(die_ref.section, die_ref.cu_offset); } -DWARFUnit *DWARFDebugInfo::GetUnitContainingDIEOffset(dw_offset_t die_offset) { - uint32_t idx = FindUnitIndex(die_offset); +DWARFUnit * +DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section, + dw_offset_t die_offset) { + uint32_t idx = FindUnitIndex(section, die_offset); DWARFUnit *result = GetUnitAtIndex(idx); if (result && !result->ContainsDIEOffset(die_offset)) return nullptr; @@ -162,8 +166,9 @@ DWARFUnit *DWARFDebugInfo::GetUnitContainingDIEOffset(dw_offset_t die_offset) { } DWARFDIE -DWARFDebugInfo::GetDIEForDIEOffset(dw_offset_t die_offset) { - DWARFUnit *cu = GetUnitContainingDIEOffset(die_offset); +DWARFDebugInfo::GetDIEForDIEOffset(DIERef::Section section, + dw_offset_t die_offset) { + DWARFUnit *cu = GetUnitContainingDIEOffset(section, die_offset); if (cu) return cu->GetDIE(die_offset); return DWARFDIE(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index b3121c04fff..25aecf3accf 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -41,10 +41,13 @@ public: size_t GetNumUnits(); DWARFUnit *GetUnitAtIndex(lldb::user_id_t idx); - DWARFUnit *GetUnitAtOffset(dw_offset_t cu_offset, uint32_t *idx_ptr = NULL); - DWARFUnit *GetUnitContainingDIEOffset(dw_offset_t die_offset); + DWARFUnit *GetUnitAtOffset(DIERef::Section section, + dw_offset_t cu_offset, uint32_t *idx_ptr = NULL); + DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section, + dw_offset_t die_offset); DWARFUnit *GetUnit(const DIERef &die_ref); - DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset); + DWARFDIE GetDIEForDIEOffset(DIERef::Section section, + dw_offset_t die_offset); DWARFDIE GetDIE(const DIERef &die_ref); enum { @@ -57,9 +60,6 @@ public: llvm::Expected<DWARFDebugAranges &> GetCompileUnitAranges(); protected: - static bool OffsetLessThanUnitOffset(dw_offset_t offset, - const DWARFUnitSP &cu_sp); - typedef std::vector<DWARFUnitSP> UnitColl; // Member variables @@ -74,7 +74,7 @@ private: // accessors are called. void ParseUnitHeadersIfNeeded(); - uint32_t FindUnitIndex(dw_offset_t offset); + uint32_t FindUnitIndex(DIERef::Section section, dw_offset_t offset); DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo); }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index db055951a7a..cead5b2618b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -567,7 +567,7 @@ DWARFDIE DWARFFormValue::Reference() const { case DW_FORM_ref_addr: { DWARFUnit *ref_cu = m_unit->GetSymbolFileDWARF()->DebugInfo()->GetUnitContainingDIEOffset( - value); + DIERef::Section::DebugInfo, value); if (!ref_cu) { m_unit->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError( "DW_FORM_ref_addr DIE reference 0x%" PRIx64 " has no matching CU", diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index f652e914f5c..5aeadb3b061 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -167,6 +167,8 @@ public: return die_iterator_range(m_die_array.begin(), m_die_array.end()); } + virtual DIERef::Section GetDebugSection() const = 0; + protected: DWARFUnit(SymbolFileDWARF *dwarf, lldb::user_id_t uid); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 821738a915b..20235d00450 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -55,7 +55,7 @@ DIERef DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { if (!cu_offset) return DIERef(); - DWARFUnit *cu = m_debug_info.GetUnitAtOffset(*cu_offset); + DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset); if (!cu) return DIERef(); @@ -66,7 +66,7 @@ DIERef DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { uint64_t die_bias = cu->GetDwoSymbolFile() ? 0 : *cu_offset; if (llvm::Optional<uint64_t> die_offset = entry.getDIEUnitOffset()) - return DIERef(*cu_offset, die_bias + *die_offset); + return DIERef(DIERef::Section::DebugInfo, *cu_offset, die_bias + *die_offset); return DIERef(); } @@ -164,7 +164,8 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(ConstString class_name, if (!ref) continue; - DWARFUnit *cu = m_debug_info.GetUnitAtOffset(ref.cu_offset); + DWARFUnit *cu = + m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, ref.cu_offset); if (!cu || !cu->Supports_DW_AT_APPLE_objc_complete_type()) { incomplete_types.push_back(ref); continue; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp index f955fee1758..333e203c928 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -78,8 +78,7 @@ void DWARFMappedHash::ExtractClassOrStructDIEArray( return; } else { // Put the one true definition as the first entry so it matches first - die_offsets.emplace(die_offsets.begin(), die_info_array[i].cu_offset, - die_info_array[i].offset); + die_offsets.emplace(die_offsets.begin(), die_info_array[i]); } } else { die_offsets.emplace_back(die_info_array[i]); @@ -119,12 +118,12 @@ const char *DWARFMappedHash::GetAtomTypeName(uint16_t atom) { } DWARFMappedHash::DIEInfo::DIEInfo() - : cu_offset(DW_INVALID_OFFSET), offset(DW_INVALID_OFFSET), tag(0), - type_flags(0), qualified_name_hash(0) {} + : tag(0), type_flags(0), qualified_name_hash(0) {} DWARFMappedHash::DIEInfo::DIEInfo(dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h) - : cu_offset(c), offset(o), tag(t), type_flags(f), qualified_name_hash(h) {} + : die_ref(DIERef::Section::DebugInfo, c, o), tag(t), type_flags(f), + qualified_name_hash(h) {} DWARFMappedHash::Prologue::Prologue(dw_offset_t _die_base_offset) : die_base_offset(_die_base_offset), atoms(), atom_mask(0), @@ -272,7 +271,7 @@ bool DWARFMappedHash::Header::Read(const lldb_private::DWARFDataExtractor &data, switch (header_data.atoms[i].type) { case eAtomTypeDIEOffset: // DIE offset, check form for encoding - hash_data.offset = + hash_data.die_ref.die_offset = DWARFFormValue::IsDataForm(form_value.Form()) ? form_value.Unsigned() : form_value.Reference(header_data.die_base_offset); @@ -507,10 +506,10 @@ size_t DWARFMappedHash::MemoryTable::AppendAllDIEsInRange( for (uint32_t i = 0; i < count; ++i) { DIEInfo die_info; if (m_header.Read(m_data, &hash_data_offset, die_info)) { - if (die_info.offset == 0) + if (die_info.die_ref.die_offset == 0) done = true; - if (die_offset_start <= die_info.offset && - die_info.offset < die_offset_end) + if (die_offset_start <= die_info.die_ref.die_offset && + die_info.die_ref.die_offset < die_offset_end) die_info_array.push_back(die_info); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h index 7a7b7bb1843..7b2958e12f1 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -48,8 +48,7 @@ public: }; struct DIEInfo { - dw_offset_t cu_offset; - dw_offset_t offset; // The DIE offset + DIERef die_ref; dw_tag_t tag; uint32_t type_flags; // Any flags for this DIEInfo uint32_t qualified_name_hash; // A 32 bit hash of the fully qualified name @@ -57,7 +56,7 @@ public: DIEInfo(); DIEInfo(dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h); - explicit operator DIERef() const { return {cu_offset, offset}; } + explicit operator DIERef() const { return die_ref; } }; struct Atom { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 0a0ffb1906d..cefe81bb176 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -245,7 +245,7 @@ void ManualDWARFIndex::IndexUnitImpl( } } - DIERef ref(cu_offset, die.GetOffset()); + DIERef ref(unit.GetDebugSection(), cu_offset, die.GetOffset()); switch (tag) { case DW_TAG_inlined_subroutine: case DW_TAG_subprogram: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index ae7e463766a..af471079913 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -349,10 +349,10 @@ SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDIE &child_die) { } SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile) - : SymbolFile(objfile), UserID(uint64_t(DW_INVALID_OFFSET) - << 32), // Used by SymbolFileDWARFDebugMap to - // when this class parses .o files to - // contain the .o file index/ID + : SymbolFile(objfile), + UserID(0x7fffffff00000000), // Used by SymbolFileDWARFDebugMap to + // when this class parses .o files to + // contain the .o file index/ID m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_context(*objfile->GetModule()), m_data_debug_abbrev(), m_data_debug_frame(), m_data_debug_info(), m_data_debug_line(), @@ -1257,9 +1257,11 @@ SymbolFileDWARF::DecodedUID SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) { if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) { SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex( debug_map->GetOSOIndexFromUserID(uid)); - return {dwarf, {DW_INVALID_OFFSET, dw_offset_t(uid)}}; + return {dwarf, {DIERef::Section::DebugInfo, DW_INVALID_OFFSET, dw_offset_t(uid)}}; } - uint32_t dwarf_id = uid >> 32; + DIERef::Section section = + uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo; + uint32_t dwarf_id = uid >> 32 & 0x7fffffff; dw_offset_t die_offset = uid; if (die_offset == DW_INVALID_OFFSET) @@ -1272,7 +1274,7 @@ SymbolFileDWARF::DecodedUID SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) { dwarf = unit->GetDwoSymbolFile(); } } - return {dwarf, {DW_INVALID_OFFSET, die_offset}}; + return {dwarf, {section, DW_INVALID_OFFSET, die_offset}}; } DWARFDIE @@ -1765,7 +1767,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, } } else { uint32_t cu_idx = DW_INVALID_INDEX; - DWARFUnit *dwarf_cu = debug_info->GetUnitAtOffset(cu_offset, &cu_idx); + DWARFUnit *dwarf_cu = debug_info->GetUnitAtOffset(DIERef::Section::DebugInfo, + cu_offset, &cu_idx); if (dwarf_cu) { sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx); if (sc.comp_unit) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 10802e3d85b..7e2fe0247fa 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -287,10 +287,13 @@ public: DWARFDIE GetDIE(lldb::user_id_t uid); lldb::user_id_t GetUID(const DWARFBaseDIE &die) { - return GetID() | die.GetOffset(); + return GetUID(die.GetDIERef()); } - lldb::user_id_t GetUID(const DIERef &ref) { return GetID() | ref.die_offset; } + lldb::user_id_t GetUID(const DIERef &ref) { + return GetID() | ref.die_offset | + (lldb::user_id_t(ref.section == DIERef::Section::DebugTypes) << 63); + } virtual std::unique_ptr<SymbolFileDWARFDwo> GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp index 7a5a9cf5210..469d5b8fb85 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -160,5 +160,5 @@ DWARFDIE SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) { lldbassert(die_ref.cu_offset == m_base_dwarf_cu->GetOffset() || die_ref.cu_offset == DW_INVALID_OFFSET); - return DebugInfo()->GetDIEForDIEOffset(die_ref.die_offset); + return DebugInfo()->GetDIEForDIEOffset(die_ref.section, die_ref.die_offset); } |

