diff options
Diffstat (limited to 'lldb/source')
6 files changed, 45 insertions, 14 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp index 96d193cbf82..9fd4ec616e2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp @@ -97,6 +97,6 @@ const DWARFDataExtractor &DWARFContext::getOrLoadStrOffsetsData() { } const DWARFDataExtractor &DWARFContext::getOrLoadDebugTypesData() { - return LoadOrGetSection(eSectionTypeDWARFDebugTypes, llvm::None, - m_data_debug_types); + return LoadOrGetSection(eSectionTypeDWARFDebugTypes, + eSectionTypeDWARFDebugTypesDwo, m_data_debug_types); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 06e9bed3190..917fbf916c5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -19,13 +19,14 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/Stream.h" -#include "DWARFUnit.h" +#include "DWARFCompileUnit.h" #include "DWARFDebugAbbrev.h" #include "DWARFDebugAranges.h" #include "DWARFDebugInfo.h" #include "DWARFDebugRanges.h" #include "DWARFDeclContext.h" #include "DWARFFormValue.h" +#include "DWARFUnit.h" #include "SymbolFileDWARF.h" #include "SymbolFileDWARFDwo.h" @@ -657,7 +658,7 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue( if (!dwo_symbol_file) return 0; - DWARFUnit *dwo_cu = dwo_symbol_file->GetCompileUnit(); + DWARFCompileUnit *dwo_cu = dwo_symbol_file->GetCompileUnit(); if (!dwo_cu) return 0; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 7eea51fbfd3..33e83d1fe57 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -363,7 +363,10 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) { else if (gnu_ranges_base) dwo_cu->SetRangesBase(*gnu_ranges_base); - SetDwoStrOffsetsBase(dwo_cu); + for (size_t i = 0; i < m_dwo_symbol_file->DebugInfo()->GetNumUnits(); ++i) { + DWARFUnit *unit = m_dwo_symbol_file->DebugInfo()->GetUnitAtIndex(i); + SetDwoStrOffsetsBase(unit); + } } DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 00f2dbfa037..aff8b5d8c15 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -104,9 +104,10 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &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, set); + if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) { + DWARFDebugInfo &dwo_info = *dwo_symbol_file->DebugInfo(); + for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i) + IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp index c6911449c73..c5b54b65ea2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -12,6 +12,7 @@ #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/LLDBAssert.h" +#include "llvm/Support/Casting.h" #include "DWARFCompileUnit.h" #include "DWARFDebugInfo.h" @@ -54,12 +55,34 @@ SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) { return GetBaseSymbolFile().ParseCompileUnit(m_base_dwarf_cu); } -DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() { - // Only dwo files with 1 compile unit is supported - if (GetNumCompileUnits() == 1) - return DebugInfo()->GetUnitAtIndex(0); - else +DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() { + if (!m_cu) + m_cu = ComputeCompileUnit(); + return m_cu; +} + +DWARFCompileUnit *SymbolFileDWARFDwo::ComputeCompileUnit() { + DWARFDebugInfo *debug_info = DebugInfo(); + if (!debug_info) return nullptr; + + // Right now we only support dwo files with one compile unit. If we don't have + // type units, we can just check for the unit count. + if (!debug_info->ContainsTypeUnits() && debug_info->GetNumUnits() == 1) + return llvm::cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(0)); + + // Otherwise, we have to run through all units, and find the compile unit that + // way. + DWARFCompileUnit *cu = nullptr; + for (size_t i = 0; i < debug_info->GetNumUnits(); ++i) { + if (auto *candidate = + llvm::dyn_cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(i))) { + if (cu) + return nullptr; // More that one CU found. + cu = candidate; + } + } + return cu; } DWARFUnit * diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h index 663f2d40054..9b2f3bb84c4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -19,7 +19,7 @@ public: lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu) override; - DWARFUnit *GetCompileUnit(); + DWARFCompileUnit *GetCompileUnit(); DWARFUnit * GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override; @@ -69,8 +69,11 @@ protected: SymbolFileDWARF &GetBaseSymbolFile(); + DWARFCompileUnit *ComputeCompileUnit(); + lldb::ObjectFileSP m_obj_file_sp; DWARFCompileUnit &m_base_dwarf_cu; + DWARFCompileUnit *m_cu = nullptr; }; #endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_ |