Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -15,7 +15,7 @@ class DWARFCompileUnit : public DWARFUnit { public: static llvm::Expected - 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 @@ uint32_t GetHeaderByteSize() const override; private: - DWARFCompileUnit(SymbolFileDWARF *dwarf2Data); + DWARFCompileUnit(SymbolFileDWARF *dwarf2Data, lldb::user_id_t uid); DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit); }; Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ 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 -DWARFCompileUnit::extract(SymbolFileDWARF *dwarf2Data, - const DWARFDataExtractor &debug_info, - lldb::offset_t *offset_ptr) { + +llvm::Expected 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 cu_sp(new DWARFCompileUnit(dwarf2Data)); + std::shared_ptr cu_sp( + new DWARFCompileUnit(dwarf2Data, uid)); cu_sp->m_offset = *offset_ptr; Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -41,7 +41,8 @@ size_t GetNumCompileUnits(); DWARFUnit *GetCompileUnitAtIndex(uint32_t idx); - DWARFUnit *GetCompileUnit(dw_offset_t cu_offset, uint32_t *idx_ptr = NULL); + 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); Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -87,8 +87,8 @@ const auto &debug_info_data = m_dwarf2Data->get_debug_info_data(); while (debug_info_data.ValidOffset(offset)) { - llvm::Expected cu_sp = - DWARFCompileUnit::extract(m_dwarf2Data, debug_info_data, &offset); + llvm::Expected cu_sp = DWARFCompileUnit::extract( + m_dwarf2Data, m_compile_units.size(), debug_info_data, &offset); if (!cu_sp) { // FIXME: Propagate this error up. @@ -123,8 +123,8 @@ 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 @@ 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 * Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -31,7 +31,7 @@ eProcucerOther }; -class DWARFUnit { +class DWARFUnit : public lldb_private::UserID { using die_iterator_range = llvm::iterator_range; @@ -74,7 +74,6 @@ 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 @@ } protected: - DWARFUnit(SymbolFileDWARF *dwarf); + DWARFUnit(SymbolFileDWARF *dwarf, lldb::user_id_t uid); SymbolFileDWARF *m_dwarf = nullptr; std::unique_ptr m_dwo_symbol_file; Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -29,8 +29,8 @@ 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 @@ 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(); } Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -55,7 +55,7 @@ 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 @@ 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; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -692,8 +692,7 @@ // 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()); + 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 +780,7 @@ // 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 +1763,7 @@ } 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 +3120,7 @@ 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;