diff options
8 files changed, 31 insertions, 41 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index 646cd71eb35..2c224a5594c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -15,17 +15,19 @@ using namespace lldb; using namespace lldb_private; -DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data) - : DWARFUnit(dwarf2Data) {} +DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data, + lldb::user_id_t uid) + : DWARFUnit(dwarf2Data, uid) {} -llvm::Expected<DWARFUnitSP> -DWARFCompileUnit::extract(SymbolFileDWARF *dwarf2Data, - const DWARFDataExtractor &debug_info, - lldb::offset_t *offset_ptr) { + +llvm::Expected<DWARFUnitSP> DWARFCompileUnit::extract( + SymbolFileDWARF *dwarf2Data, user_id_t uid, + const DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr) { assert(debug_info.ValidOffset(*offset_ptr)); // std::make_shared would require the ctor to be public. - std::shared_ptr<DWARFCompileUnit> cu_sp(new DWARFCompileUnit(dwarf2Data)); + std::shared_ptr<DWARFCompileUnit> cu_sp( + new DWARFCompileUnit(dwarf2Data, uid)); cu_sp->m_offset = *offset_ptr; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h index b191ecb5fbb..fa8184fc29b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -15,7 +15,7 @@ class DWARFCompileUnit : public DWARFUnit { public: static llvm::Expected<DWARFUnitSP> - extract(SymbolFileDWARF *dwarf2Data, + extract(SymbolFileDWARF *dwarf2Data, lldb::user_id_t uid, const lldb_private::DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr); void Dump(lldb_private::Stream *s) const override; @@ -35,7 +35,7 @@ public: uint32_t GetHeaderByteSize() const override; private: - DWARFCompileUnit(SymbolFileDWARF *dwarf2Data); + DWARFCompileUnit(SymbolFileDWARF *dwarf2Data, lldb::user_id_t uid); DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit); }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index a85e621a7a2..d191b33d1b6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -87,8 +87,8 @@ void DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() { const auto &debug_info_data = m_dwarf2Data->get_debug_info_data(); while (debug_info_data.ValidOffset(offset)) { - llvm::Expected<DWARFUnitSP> cu_sp = - DWARFCompileUnit::extract(m_dwarf2Data, debug_info_data, &offset); + llvm::Expected<DWARFUnitSP> cu_sp = DWARFCompileUnit::extract( + m_dwarf2Data, m_compile_units.size(), debug_info_data, &offset); if (!cu_sp) { // FIXME: Propagate this error up. @@ -111,7 +111,7 @@ size_t DWARFDebugInfo::GetNumCompileUnits() { return m_compile_units.size(); } -DWARFUnit *DWARFDebugInfo::GetCompileUnitAtIndex(uint32_t idx) { +DWARFUnit *DWARFDebugInfo::GetCompileUnitAtIndex(user_id_t idx) { DWARFUnit *cu = NULL; if (idx < GetNumCompileUnits()) cu = m_compile_units[idx].get(); @@ -123,8 +123,8 @@ bool DWARFDebugInfo::OffsetLessThanCompileUnitOffset( return offset < cu_sp->GetOffset(); } -DWARFUnit *DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, - uint32_t *idx_ptr) { +DWARFUnit *DWARFDebugInfo::GetCompileUnitAtOffset(dw_offset_t cu_offset, + uint32_t *idx_ptr) { DWARFUnitSP cu_sp; uint32_t cu_idx = DW_INVALID_INDEX; if (cu_offset != DW_INVALID_OFFSET) { @@ -160,7 +160,7 @@ DWARFUnit *DWARFDebugInfo::GetCompileUnit(const DIERef &die_ref) { if (die_ref.cu_offset == DW_INVALID_OFFSET) return GetCompileUnitContainingDIEOffset(die_ref.die_offset); else - return GetCompileUnit(die_ref.cu_offset); + return GetCompileUnitAtOffset(die_ref.cu_offset); } DWARFUnit * diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index 4c8e0700743..dee657228e8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -40,8 +40,9 @@ public: void SetDwarfData(SymbolFileDWARF *dwarf2Data); size_t GetNumCompileUnits(); - DWARFUnit *GetCompileUnitAtIndex(uint32_t idx); - DWARFUnit *GetCompileUnit(dw_offset_t cu_offset, uint32_t *idx_ptr = NULL); + DWARFUnit *GetCompileUnitAtIndex(lldb::user_id_t idx); + DWARFUnit *GetCompileUnitAtOffset(dw_offset_t cu_offset, + uint32_t *idx_ptr = NULL); DWARFUnit *GetCompileUnitContainingDIEOffset(dw_offset_t die_offset); DWARFUnit *GetCompileUnit(const DIERef &die_ref); DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 58744a7a17c..58a190aa5fb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -29,8 +29,8 @@ using namespace std; extern int g_verbose; -DWARFUnit::DWARFUnit(SymbolFileDWARF *dwarf) - : m_dwarf(dwarf), m_cancel_scopes(false) {} +DWARFUnit::DWARFUnit(SymbolFileDWARF *dwarf, user_id_t uid) + : UserID(uid), m_dwarf(dwarf), m_cancel_scopes(false) {} DWARFUnit::~DWARFUnit() {} @@ -366,15 +366,6 @@ size_t DWARFUnit::AppendDIEsWithTag(const dw_tag_t tag, return dies.size() - old_size; } -lldb::user_id_t DWARFUnit::GetID() const { - dw_offset_t local_id = - m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset; - if (m_dwarf) - return DIERef(local_id, local_id).GetUID(m_dwarf); - else - return local_id; -} - dw_offset_t DWARFUnit::GetNextCompileUnitOffset() const { return m_offset + GetLengthByteSize() + GetLength(); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index e3418d812a6..edefcaf4898 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -31,7 +31,7 @@ enum DWARFProducer { eProcucerOther }; -class DWARFUnit { +class DWARFUnit : public lldb_private::UserID { using die_iterator_range = llvm::iterator_range<DWARFDebugInfoEntry::collection::iterator>; @@ -74,7 +74,6 @@ public: virtual uint32_t GetHeaderByteSize() const = 0; // Offset of the initial length field. dw_offset_t GetOffset() const { return m_offset; } - lldb::user_id_t GetID() const; /// Get the size in bytes of the length field in the header. /// /// In DWARF32 this is just 4 bytes @@ -169,7 +168,7 @@ public: } protected: - DWARFUnit(SymbolFileDWARF *dwarf); + DWARFUnit(SymbolFileDWARF *dwarf, lldb::user_id_t uid); SymbolFileDWARF *m_dwarf = nullptr; std::unique_ptr<SymbolFileDWARFDwo> m_dwo_symbol_file; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 4b5c07f8689..20adc99e485 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.GetCompileUnit(*cu_offset); + DWARFUnit *cu = m_debug_info.GetCompileUnitAtOffset(*cu_offset); if (!cu) return DIERef(); @@ -164,7 +164,7 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(ConstString class_name, if (!ref) continue; - DWARFUnit *cu = m_debug_info.GetCompileUnit(ref.cu_offset); + DWARFUnit *cu = m_debug_info.GetCompileUnitAtOffset(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/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index a1891caf0a0..578d7516ea5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -689,11 +689,8 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) { DWARFDebugInfo *info = DebugInfo(); if (info) { - // Just a normal DWARF file whose user ID for the compile unit is the DWARF - // offset itself - - DWARFUnit *dwarf_cu = - info->GetCompileUnit((dw_offset_t)comp_unit->GetID()); + // The compile unit ID is the index of the DWARF unit. + DWARFUnit *dwarf_cu = info->GetCompileUnitAtIndex(comp_unit->GetID()); if (dwarf_cu && dwarf_cu->GetUserData() == NULL) dwarf_cu->SetUserData(comp_unit); return dwarf_cu; @@ -781,7 +778,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFUnit *dwarf_cu, // Figure out the compile unit index if we weren't given one if (cu_idx == UINT32_MAX) - DebugInfo()->GetCompileUnit(dwarf_cu->GetOffset(), &cu_idx); + cu_idx = dwarf_cu->GetID(); m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex( cu_idx, cu_sp); @@ -1764,7 +1761,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, } else { uint32_t cu_idx = DW_INVALID_INDEX; DWARFUnit *dwarf_cu = - debug_info->GetCompileUnit(cu_offset, &cu_idx); + debug_info->GetCompileUnitAtOffset(cu_offset, &cu_idx); if (dwarf_cu) { sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx); if (sc.comp_unit) { @@ -3121,7 +3118,7 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) { return num_variables; } } else if (sc.comp_unit) { - DWARFUnit *dwarf_cu = info->GetCompileUnit(sc.comp_unit->GetID()); + DWARFUnit *dwarf_cu = info->GetCompileUnitAtIndex(sc.comp_unit->GetID()); if (dwarf_cu == NULL) return 0; |