Index: source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h =================================================================== --- source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h +++ source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h @@ -42,7 +42,7 @@ void GetTypes(ConstString name, DIEArray &offsets) override; void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override; void GetNamespaces(ConstString name, DIEArray &offsets) override; - void GetFunctions(ConstString name, DWARFDebugInfo &info, + void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) override; Index: source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "Plugins/SymbolFile/DWARF/AppleDWARFIndex.h" -#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h" #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h" #include "Plugins/SymbolFile/DWARF/DWARFUnit.h" #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" @@ -133,14 +132,14 @@ m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets); } -void AppleDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info, +void AppleDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) { DIEArray offsets; m_apple_names_up->FindByName(name.GetStringRef(), offsets); for (const DIERef &die_ref : offsets) { - ProcessFunctionDIE(name.GetStringRef(), die_ref, info, parent_decl_ctx, + ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf, parent_decl_ctx, name_type_mask, dies); } } Index: source/Plugins/SymbolFile/DWARF/DIERef.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DIERef.h +++ source/Plugins/SymbolFile/DWARF/DIERef.h @@ -12,26 +12,36 @@ #include "lldb/Core/dwarf.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/FormatProviders.h" +#include #include -/// Identifies a DWARF debug info entry within a given Module. It contains three +/// Identifies a DWARF debug info entry within a given Module. It contains four /// "coordinates": -/// - section: identifies the section of the debug info entry: debug_info or -/// debug_types -/// - unit_offset: the offset of the unit containing the debug info entry. For -/// regular (unsplit) units, this field is optional, as the die_offset is -/// enough to uniquely identify the containing unit. For split units, this -/// field must contain the offset of the skeleton unit in the main object -/// file. -/// - die_offset: The offset of te debug info entry as an absolute offset from +/// - dwo_num: identifies the dwo file in the Module. If this field is not set, +/// the DIERef references the main file. +/// - section: identifies the section of the debug info entry in the given file: +/// debug_info or debug_types. +/// - unit_offset: the section offset of the unit containing the debug info +/// entry. This field is optional, as the die_offset is enough to uniquely +/// identify the containing unit. +/// - die_offset: The offset of the debug info entry as an absolute offset from /// the beginning of the section specified in the section field. class DIERef { public: enum Section : uint8_t { DebugInfo, DebugTypes }; - DIERef(Section s, llvm::Optional u, dw_offset_t d) - : m_section(s), m_unit_offset(u.getValueOr(DW_INVALID_OFFSET)), - m_die_offset(d) {} + DIERef(llvm::Optional num, Section s, llvm::Optional u, + dw_offset_t d) + : m_dwo_num(num.getValueOr(invalid_dwo_num)), m_section(s), + m_unit_offset(u.getValueOr(DW_INVALID_OFFSET)), m_die_offset(d) { + assert(!num || *num < invalid_dwo_num); + } + + llvm::Optional dwo_num() const { + if (m_dwo_num < invalid_dwo_num) + return m_dwo_num; + return llvm::None; + } Section section() const { return static_cast
(m_section); } @@ -44,10 +54,14 @@ dw_offset_t die_offset() const { return m_die_offset; } private: + static constexpr uint32_t invalid_dwo_num = 0x7fffffff; + + unsigned m_dwo_num : 31; unsigned m_section : 1; dw_offset_t m_unit_offset; dw_offset_t m_die_offset; }; +static_assert(sizeof(DIERef) == 12, ""); typedef std::vector DIEArray; Index: source/Plugins/SymbolFile/DWARF/DIERef.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -9,8 +9,12 @@ #include "DIERef.h" #include "llvm/Support/Format.h" +constexpr uint32_t DIERef::invalid_dwo_num; + void llvm::format_provider::format(const DIERef &ref, raw_ostream &OS, StringRef Style) { + if (ref.dwo_num()) + OS << format_hex_no_prefix(*ref.dwo_num(), 8) << "/"; OS << (ref.section() == DIERef::DebugInfo ? "INFO" : "TYPE"); if (ref.unit_offset()) OS << "/" << format_hex_no_prefix(*ref.unit_offset(), 8); Index: source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -21,10 +21,8 @@ if (!IsValid()) return llvm::None; - dw_offset_t cu_offset = m_cu->GetOffset(); - if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET) - cu_offset = m_cu->GetBaseObjOffset(); - return DIERef(m_cu->GetDebugSection(), cu_offset, m_die->GetOffset()); + return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(), + m_cu->GetOffset(), m_die->GetOffset()); } dw_tag_t DWARFBaseDIE::Tag() const { Index: source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -152,7 +152,8 @@ return DWARFDIE(cu, block_die); else return DWARFDIE(dwarf->DebugInfo()->GetUnit( - DIERef(cu->GetDebugSection(), cu->GetOffset(), + DIERef(cu->GetSymbolFileDWARF().GetDwoNum(), + cu->GetDebugSection(), cu->GetOffset(), block_die->GetOffset())), block_die); } Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -226,12 +226,6 @@ DWARFRangeList &ranges, int &decl_file, int &decl_line, int &decl_column, int &call_file, int &call_line, int &call_column, DWARFExpression *frame_base) const { - SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile(); - if (dwo_symbol_file) - return GetDIENamesAndRanges( - 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 dies; @@ -611,16 +605,7 @@ const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &form_value, 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 && - m_tag != DW_TAG_partial_unit) - return GetAttributeValue(dwo_symbol_file->GetCompileUnit(), attr, - form_value, end_attr_offset_ptr, - check_specification_or_abstract_origin); - - auto abbrevDecl = GetAbbreviationDeclarationPtr(cu); - - if (abbrevDecl) { + if (auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu)) { uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr); if (attr_idx != DW_INVALID_INDEX) { @@ -665,6 +650,10 @@ } } + // If we're a unit DIE, also check the attributes of the dwo unit (if any). + if (GetParent()) + return 0; + SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile(); if (!dwo_symbol_file) return 0; Index: source/Plugins/SymbolFile/DWARF/DWARFIndex.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFIndex.h +++ source/Plugins/SymbolFile/DWARF/DWARFIndex.h @@ -13,7 +13,6 @@ #include "Plugins/SymbolFile/DWARF/DWARFDIE.h" #include "Plugins/SymbolFile/DWARF/DWARFFormValue.h" -class DWARFDebugInfo; class DWARFDeclContext; class DWARFDIE; @@ -40,7 +39,7 @@ virtual void GetTypes(ConstString name, DIEArray &offsets) = 0; virtual void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) = 0; virtual void GetNamespaces(ConstString name, DIEArray &offsets) = 0; - virtual void GetFunctions(ConstString name, DWARFDebugInfo &info, + virtual void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) = 0; @@ -57,8 +56,8 @@ /// the function given by "ref" matches search criteria given by /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies" /// vector. - void ProcessFunctionDIE(llvm::StringRef name, DIERef ref, - DWARFDebugInfo &info, + void ProcessFunctionDIE(llvm::StringRef name, const DIERef &ref, + SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies); }; Index: source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -7,22 +7,21 @@ //===----------------------------------------------------------------------===// #include "Plugins/SymbolFile/DWARF/DWARFIndex.h" -#include "Plugins/SymbolFile/DWARF/DWARFDIE.h" -#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h" - #include "Plugins/Language/ObjC/ObjCLanguage.h" +#include "Plugins/SymbolFile/DWARF/DWARFDIE.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" using namespace lldb_private; using namespace lldb; DWARFIndex::~DWARFIndex() = default; -void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref, - DWARFDebugInfo &info, +void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, const DIERef &ref, + SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) { - DWARFDIE die = info.GetDIE(ref); + DWARFDIE die = dwarf.GetDIE(ref); if (!die) { ReportInvalidDIERef(ref, name); return; Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -148,7 +148,6 @@ dw_addr_t GetStrOffsetsBase() const { return m_str_offsets_base; } void SetAddrBase(dw_addr_t addr_base); void SetRangesBase(dw_addr_t ranges_base); - void SetBaseObjOffset(dw_offset_t base_obj_offset); void SetStrOffsetsBase(dw_offset_t str_offsets_base); virtual void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) = 0; @@ -166,6 +165,8 @@ DWARFDIE GetDIE(dw_offset_t die_offset); + DWARFUnit &GetNonSkeletonUnit(); + static uint8_t GetAddressByteSize(const DWARFUnit *cu); static uint8_t GetDefaultAddressSize(); @@ -203,8 +204,6 @@ SymbolFileDWARFDwo *GetDwoSymbolFile() const; - dw_offset_t GetBaseObjOffset() const; - die_iterator_range dies() { ExtractDIEsIfNeeded(); return die_iterator_range(m_die_array.begin(), m_die_array.end()); @@ -284,9 +283,6 @@ llvm::Optional m_file_spec; dw_addr_t m_addr_base = 0; // Value of DW_AT_addr_base dw_addr_t m_ranges_base = 0; // Value of DW_AT_ranges_base - // If this is a dwo compile unit this is the offset of the base compile unit - // in the main object file - dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET; /// Value of DW_AT_stmt_list. dw_offset_t m_line_table_offset = DW_INVALID_OFFSET; Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -363,7 +363,6 @@ else if (gnu_ranges_base) dwo_cu->SetRangesBase(*gnu_ranges_base); - dwo_cu->SetBaseObjOffset(GetOffset()); SetDwoStrOffsetsBase(dwo_cu); } @@ -419,10 +418,6 @@ m_ranges_base = ranges_base; } -void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) { - m_base_obj_offset = base_obj_offset; -} - void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) { m_str_offsets_base = str_offsets_base; } @@ -480,6 +475,12 @@ return DWARFDIE(); // Not found } +DWARFUnit &DWARFUnit::GetNonSkeletonUnit() { + if (SymbolFileDWARFDwo *dwo = GetDwoSymbolFile()) + return *dwo->GetCompileUnit(); + return *this; +} + uint8_t DWARFUnit::GetAddressByteSize(const DWARFUnit *cu) { if (cu) return cu->GetAddressByteSize(); @@ -719,8 +720,6 @@ return m_dwo_symbol_file.get(); } -dw_offset_t DWARFUnit::GetBaseObjOffset() const { return m_base_obj_offset; } - const DWARFDebugAranges &DWARFUnit::GetFunctionAranges() { if (m_func_aranges_up == nullptr) { m_func_aranges_up.reset(new DWARFDebugAranges()); Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h +++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h @@ -34,7 +34,7 @@ void GetTypes(ConstString name, DIEArray &offsets) override; void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override; void GetNamespaces(ConstString name, DIEArray &offsets) override; - void GetFunctions(ConstString name, DWARFDebugInfo &info, + void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) override; Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -64,10 +64,12 @@ // GetDwoSymbolFile to call this automatically because of mutual recursion // between this and DWARFDebugInfoEntry::GetAttributeValue. cu->ExtractUnitDIEIfNeeded(); - uint64_t die_bias = cu->GetDwoSymbolFile() ? 0 : *cu_offset; + cu = &cu->GetNonSkeletonUnit(); if (llvm::Optional die_offset = entry.getDIEUnitOffset()) - return DIERef(DIERef::Section::DebugInfo, *cu_offset, die_bias + *die_offset); + return DIERef(cu->GetSymbolFileDWARF().GetDwoNum(), + DIERef::Section::DebugInfo, cu->GetOffset(), + cu->GetOffset() + *die_offset); return llvm::None; } @@ -222,12 +224,12 @@ } void DebugNamesDWARFIndex::GetFunctions( - ConstString name, DWARFDebugInfo &info, + ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) { std::vector v; - m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, v); + m_fallback.GetFunctions(name, dwarf, parent_decl_ctx, name_type_mask, v); for (const DebugNames::Entry &entry : m_debug_names_up->equal_range(name.GetStringRef())) { @@ -236,7 +238,7 @@ continue; if (llvm::Optional ref = ToDIERef(entry)) - ProcessFunctionDIE(name.GetStringRef(), *ref, info, parent_decl_ctx, + ProcessFunctionDIE(name.GetStringRef(), *ref, dwarf, parent_decl_ctx, name_type_mask, v); } Index: source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h =================================================================== --- source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -61,7 +61,8 @@ DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h); explicit operator DIERef() const { - return DIERef(DIERef::Section::DebugInfo, llvm::None, die_offset); + return DIERef(llvm::None, DIERef::Section::DebugInfo, llvm::None, + die_offset); } }; Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h =================================================================== --- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h +++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h @@ -13,6 +13,8 @@ #include "Plugins/SymbolFile/DWARF/NameToDIE.h" #include "llvm/ADT/DenseSet.h" +class DWARFDebugInfo; + namespace lldb_private { class ManualDWARFIndex : public DWARFIndex { public: @@ -33,7 +35,7 @@ void GetTypes(ConstString name, DIEArray &offsets) override; void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override; void GetNamespaces(ConstString name, DIEArray &offsets) override; - void GetFunctions(ConstString name, DWARFDebugInfo &info, + void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) override; @@ -56,9 +58,9 @@ void Index(); void IndexUnit(DWARFUnit &unit, IndexSet &set); - static void - IndexUnitImpl(DWARFUnit &unit, const lldb::LanguageType cu_language, - const dw_offset_t cu_offset, IndexSet &set); + static void IndexUnitImpl(DWARFUnit &unit, + const lldb::LanguageType cu_language, + IndexSet &set); /// Non-null value means we haven't built the index yet. DWARFDebugInfo *m_debug_info; Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -102,18 +102,17 @@ const LanguageType cu_language = unit.GetLanguageType(); - IndexUnitImpl(unit, cu_language, unit.GetOffset(), set); + IndexUnitImpl(unit, cu_language, set); SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile(); if (dwo_symbol_file && dwo_symbol_file->GetCompileUnit()) { - IndexUnitImpl(*dwo_symbol_file->GetCompileUnit(), cu_language, - unit.GetOffset(), set); + IndexUnitImpl(*dwo_symbol_file->GetCompileUnit(), cu_language, set); } } -void ManualDWARFIndex::IndexUnitImpl( - DWARFUnit &unit, const LanguageType cu_language, - const dw_offset_t cu_offset, IndexSet &set) { +void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit, + const LanguageType cu_language, + IndexSet &set) { for (const DWARFDebugInfoEntry &die : unit.dies()) { const dw_tag_t tag = die.Tag(); @@ -243,7 +242,8 @@ } } - DIERef ref(unit.GetDebugSection(), cu_offset, die.GetOffset()); + DIERef ref(unit.GetSymbolFileDWARF().GetDwoNum(), unit.GetDebugSection(), + unit.GetOffset(), die.GetOffset()); switch (tag) { case DW_TAG_inlined_subroutine: case DW_TAG_subprogram: @@ -393,7 +393,7 @@ m_set.namespaces.Find(name, offsets); } -void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info, +void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) { @@ -405,7 +405,7 @@ m_set.function_methods.Find(name, offsets); m_set.function_fullnames.Find(name, offsets); for (const DIERef &die_ref: offsets) { - DWARFDIE die = info.GetDIE(die_ref); + DWARFDIE die = dwarf.GetDIE(die_ref); if (!die) continue; if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die)) @@ -416,7 +416,7 @@ DIEArray offsets; m_set.function_basenames.Find(name, offsets); for (const DIERef &die_ref: offsets) { - DWARFDIE die = info.GetDIE(die_ref); + DWARFDIE die = dwarf.GetDIE(die_ref); if (!die) continue; if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die)) @@ -429,7 +429,7 @@ DIEArray offsets; m_set.function_methods.Find(name, offsets); for (const DIERef &die_ref: offsets) { - if (DWARFDIE die = info.GetDIE(die_ref)) + if (DWARFDIE die = dwarf.GetDIE(die_ref)) dies.push_back(die); } } @@ -439,7 +439,7 @@ DIEArray offsets; m_set.function_selectors.Find(name, offsets); for (const DIERef &die_ref: offsets) { - if (DWARFDIE die = info.GetDIE(die_ref)) + if (DWARFDIE die = dwarf.GetDIE(die_ref)) dies.push_back(die); } } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -293,6 +293,8 @@ // the method returns a pointer to the base compile unit. virtual DWARFCompileUnit *GetBaseCompileUnit() { return nullptr; } + virtual llvm::Optional GetDwoNum() { return llvm::None; } + static bool DIEInDeclContext(const lldb_private::CompilerDeclContext *parent_decl_ctx, const DWARFDIE &die); Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1216,24 +1216,20 @@ debug_map->GetOSOIndexFromUserID(uid)); return DecodedUID{ *dwarf, - {DIERef::Section::DebugInfo, DW_INVALID_OFFSET, dw_offset_t(uid)}}; + {llvm::None, DIERef::Section::DebugInfo, llvm::None, dw_offset_t(uid)}}; } - 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) return llvm::None; - SymbolFileDWARF *dwarf = this; - if (DebugInfo()) { - if (DWARFUnit *unit = DebugInfo()->GetUnitAtIndex(dwarf_id)) { - if (unit->GetDwoSymbolFile()) - dwarf = unit->GetDwoSymbolFile(); - } - } - return DecodedUID{*dwarf, {section, DW_INVALID_OFFSET, die_offset}}; + DIERef::Section section = + uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo; + + llvm::Optional dwo_num = uid >> 32 & 0x7fffffff; + if (*dwo_num == 0x7fffffff) + dwo_num = llvm::None; + + return DecodedUID{*this, {dwo_num, section, llvm::None, die_offset}}; } DWARFDIE @@ -1493,6 +1489,14 @@ DWARFDIE SymbolFileDWARF::GetDIE(const DIERef &die_ref) { + if (die_ref.dwo_num()) { + return DebugInfo() + ->GetUnitAtIndex(*die_ref.dwo_num()) + ->GetDwoSymbolFile() + ->GetDIE(die_ref); + } + + DWARFDebugInfo *debug_info = DebugInfo(); if (debug_info) return debug_info->GetDIE(die_ref); @@ -2235,10 +2239,6 @@ const uint32_t original_size = sc_list.GetSize(); - DWARFDebugInfo *info = DebugInfo(); - if (info == nullptr) - return 0; - llvm::DenseSet resolved_dies; DIEArray offsets; CompilerDeclContext empty_decl_ctx; @@ -2246,7 +2246,7 @@ parent_decl_ctx = &empty_decl_ctx; std::vector dies; - m_index->GetFunctions(name, *info, *parent_decl_ctx, name_type_mask, dies); + m_index->GetFunctions(name, *this, *parent_decl_ctx, name_type_mask, dies); for (const DWARFDIE &die: dies) { if (resolved_dies.insert(die.GetDIE()).second) ResolveFunction(die, include_inlines, sc_list); @@ -3081,7 +3081,8 @@ sc.comp_unit->SetVariableList(variables); DIEArray die_offsets; - m_index->GetGlobalVariables(*dwarf_cu, die_offsets); + m_index->GetGlobalVariables(dwarf_cu->GetNonSkeletonUnit(), + die_offsets); const size_t num_matches = die_offsets.size(); if (num_matches) { for (size_t i = 0; i < num_matches; ++i) { Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -44,6 +44,8 @@ DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; } + llvm::Optional GetDwoNum() override { return GetID() >> 32; } + protected: void LoadSectionData(lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data) override; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -124,8 +124,7 @@ DWARFDIE SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) { - lldbassert(!die_ref.unit_offset() || - *die_ref.unit_offset() == m_base_dwarf_cu.GetOffset()); - return DebugInfo()->GetDIEForDIEOffset(die_ref.section(), - die_ref.die_offset()); + if (*die_ref.dwo_num() == GetDwoNum()) + return DebugInfo()->GetDIE(die_ref); + return GetBaseSymbolFile().GetDIE(die_ref); }