diff options
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
12 files changed, 63 insertions, 77 deletions
diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index 5e275e34c3b..42a5e85cb30 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -187,7 +187,7 @@ uint32_t SymbolFileBreakpad::CalculateAbilities() { return CompileUnits | Functions | LineTables; } -uint32_t SymbolFileBreakpad::GetNumCompileUnits() { +uint32_t SymbolFileBreakpad::CalculateNumCompileUnits() { ParseCUData(); return m_cu_data->GetSize(); } @@ -218,7 +218,7 @@ CompUnitSP SymbolFileBreakpad::ParseCompileUnitAtIndex(uint32_t index) { eLanguageTypeUnknown, /*is_optimized*/ eLazyBoolNo); - GetSymbolVendor().SetCompileUnitAtIndex(index, cu_sp); + SetCompileUnitAtIndex(index, cu_sp); return cu_sp; } @@ -260,7 +260,7 @@ SymbolFileBreakpad::ResolveSymbolContext(const Address &so_addr, if (idx == UINT32_MAX) return 0; - sc.comp_unit = GetSymbolVendor().GetCompileUnitAtIndex(idx).get(); + sc.comp_unit = GetCompileUnitAtIndex(idx).get(); SymbolContextItem result = eSymbolContextCompUnit; if (resolve_scope & eSymbolContextLineEntry) { if (sc.comp_unit->GetLineTable()->FindLineEntryByAddress(so_addr, @@ -280,7 +280,7 @@ uint32_t SymbolFileBreakpad::ResolveSymbolContext( uint32_t old_size = sc_list.GetSize(); for (size_t i = 0, size = GetNumCompileUnits(); i < size; ++i) { - CompileUnit &cu = *GetSymbolVendor().GetCompileUnitAtIndex(i); + CompileUnit &cu = *GetCompileUnitAtIndex(i); cu.ResolveSymbolContext(file_spec, line, check_inlines, /*exact*/ false, resolve_scope, sc_list); } @@ -522,10 +522,6 @@ SymbolFileBreakpad::GetUnwindPlan(const Address &address, return plan_sp; } -SymbolVendor &SymbolFileBreakpad::GetSymbolVendor() { - return *m_obj_file->GetModule()->GetSymbolVendor(); -} - addr_t SymbolFileBreakpad::GetBaseFileAddress() { return m_obj_file->GetModule() ->GetObjectFile() diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h index 8a0b7645fd0..68036360686 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h @@ -46,10 +46,6 @@ public: // Compile Unit function calls - uint32_t GetNumCompileUnits() override; - - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) override { return lldb::eLanguageTypeUnknown; } @@ -196,7 +192,9 @@ private: }; - SymbolVendor &GetSymbolVendor(); + uint32_t CalculateNumCompileUnits() override; + lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; + lldb::addr_t GetBaseFileAddress(); void ParseFileRecords(); void ParseCUData(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index fb5a94fa903..3b6d8da2312 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -677,8 +677,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) { dwarf_cu.SetUserData(cu_sp.get()); - m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex( - dwarf_cu.GetID(), cu_sp); + SetCompileUnitAtIndex(dwarf_cu.GetID(), cu_sp); } } } @@ -715,7 +714,7 @@ llvm::Optional<uint32_t> SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) { return m_lldb_cu_to_dwarf_unit[cu_idx]; } -uint32_t SymbolFileDWARF::GetNumCompileUnits() { +uint32_t SymbolFileDWARF::CalculateNumCompileUnits() { DWARFDebugInfo *info = DebugInfo(); if (!info) return 0; @@ -3713,7 +3712,10 @@ ConstString SymbolFileDWARF::GetPluginName() { return GetPluginNameStatic(); } uint32_t SymbolFileDWARF::GetPluginVersion() { return 1; } -void SymbolFileDWARF::Dump(lldb_private::Stream &s) { m_index->Dump(s); } +void SymbolFileDWARF::Dump(lldb_private::Stream &s) { + SymbolFile::Dump(s); + m_index->Dump(s); +} void SymbolFileDWARF::DumpClangAST(Stream &s) { TypeSystem *ts = GetTypeSystemForLanguage(eLanguageTypeC_plus_plus); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 018af47305f..6daa060b9a0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -95,10 +95,6 @@ public: // Compile Unit function calls - uint32_t GetNumCompileUnits() override; - - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override; @@ -331,6 +327,10 @@ protected: bool DeclContextMatchesThisSymbolFile( const lldb_private::CompilerDeclContext *decl_ctx); + uint32_t CalculateNumCompileUnits() override; + + lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; + virtual DWARFUnit * GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 8ec64dbaf76..e44ff5f2d79 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -562,7 +562,7 @@ uint32_t SymbolFileDWARFDebugMap::CalculateAbilities() { return 0; } -uint32_t SymbolFileDWARFDebugMap::GetNumCompileUnits() { +uint32_t SymbolFileDWARFDebugMap::CalculateNumCompileUnits() { InitOSO(); return m_compile_unit_infos.size(); } @@ -585,9 +585,8 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) { eLanguageTypeUnknown, eLazyBoolCalculate); if (m_compile_unit_infos[cu_idx].compile_unit_sp) { - // Let our symbol vendor know about this compile unit - m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex( - cu_idx, m_compile_unit_infos[cu_idx].compile_unit_sp); + SetCompileUnitAtIndex(cu_idx, + m_compile_unit_infos[cu_idx].compile_unit_sp); } } } @@ -1284,8 +1283,7 @@ void SymbolFileDWARFDebugMap::SetCompileUnit(SymbolFileDWARF *oso_dwarf, cu_sp.get()); } else { m_compile_unit_infos[cu_idx].compile_unit_sp = cu_sp; - m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex( - cu_idx, cu_sp); + SetCompileUnitAtIndex(cu_idx, cu_sp); } } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index afc6142e823..2cdebaf3a46 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -44,9 +44,6 @@ public: void InitializeObject() override; // Compile Unit function calls - uint32_t GetNumCompileUnits() override; - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override; @@ -174,6 +171,9 @@ protected: // Protected Member Functions void InitOSO(); + uint32_t CalculateNumCompileUnits() override; + lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; + static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid) { return (uint32_t)((uid >> 32ull) - 1ull); } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index c9fb1dc8614..9585b35152f 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -329,7 +329,7 @@ void SymbolFileNativePDB::InitializeObject() { m_ast = llvm::make_unique<PdbAstBuilder>(*m_obj_file, *m_index); } -uint32_t SymbolFileNativePDB::GetNumCompileUnits() { +uint32_t SymbolFileNativePDB::CalculateNumCompileUnits() { const DbiModuleList &modules = m_index->dbi().modules(); uint32_t count = modules.getModuleCount(); if (count == 0) @@ -433,8 +433,7 @@ SymbolFileNativePDB::CreateCompileUnit(const CompilandIndexItem &cci) { std::make_shared<CompileUnit>(m_obj_file->GetModule(), nullptr, fs, toOpaqueUid(cci.m_id), lang, optimized); - m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex( - cci.m_id.modi, cu_sp); + SetCompileUnitAtIndex(cci.m_id.modi, cu_sp); return cu_sp; } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h index 20daff219a0..88bd5de5435 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -68,13 +68,9 @@ public: // Compile Unit function calls - uint32_t GetNumCompileUnits() override; - void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override; - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override; @@ -157,6 +153,9 @@ public: void DumpClangAST(Stream &s) override; private: + uint32_t CalculateNumCompileUnits() override; + + lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; size_t FindTypesByName(llvm::StringRef name, uint32_t max_matches, TypeMap &types); diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 17dfcdaceb9..c6c25fd719c 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -123,8 +123,7 @@ SymbolFilePDB::CreateInstance(lldb_private::ObjectFile *obj_file) { } SymbolFilePDB::SymbolFilePDB(lldb_private::ObjectFile *object_file) - : SymbolFile(object_file), m_session_up(), m_global_scope_up(), - m_cached_compile_unit_count(0) {} + : SymbolFile(object_file), m_session_up(), m_global_scope_up() {} SymbolFilePDB::~SymbolFilePDB() {} @@ -191,33 +190,30 @@ void SymbolFilePDB::InitializeObject() { lldbassert(m_global_scope_up.get()); } -uint32_t SymbolFilePDB::GetNumCompileUnits() { - if (m_cached_compile_unit_count == 0) { - auto compilands = m_global_scope_up->findAllChildren<PDBSymbolCompiland>(); - if (!compilands) - return 0; +uint32_t SymbolFilePDB::CalculateNumCompileUnits() { + auto compilands = m_global_scope_up->findAllChildren<PDBSymbolCompiland>(); + if (!compilands) + return 0; - // The linker could link *.dll (compiland language = LINK), or import - // *.dll. For example, a compiland with name `Import:KERNEL32.dll` could be - // found as a child of the global scope (PDB executable). Usually, such - // compilands contain `thunk` symbols in which we are not interested for - // now. However we still count them in the compiland list. If we perform - // any compiland related activity, like finding symbols through - // llvm::pdb::IPDBSession methods, such compilands will all be searched - // automatically no matter whether we include them or not. - m_cached_compile_unit_count = compilands->getChildCount(); - - // The linker can inject an additional "dummy" compilation unit into the - // PDB. Ignore this special compile unit for our purposes, if it is there. - // It is always the last one. - auto last_compiland_up = - compilands->getChildAtIndex(m_cached_compile_unit_count - 1); - lldbassert(last_compiland_up.get()); - std::string name = last_compiland_up->getName(); - if (name == "* Linker *") - --m_cached_compile_unit_count; - } - return m_cached_compile_unit_count; + // The linker could link *.dll (compiland language = LINK), or import + // *.dll. For example, a compiland with name `Import:KERNEL32.dll` could be + // found as a child of the global scope (PDB executable). Usually, such + // compilands contain `thunk` symbols in which we are not interested for + // now. However we still count them in the compiland list. If we perform + // any compiland related activity, like finding symbols through + // llvm::pdb::IPDBSession methods, such compilands will all be searched + // automatically no matter whether we include them or not. + uint32_t compile_unit_count = compilands->getChildCount(); + + // The linker can inject an additional "dummy" compilation unit into the + // PDB. Ignore this special compile unit for our purposes, if it is there. + // It is always the last one. + auto last_compiland_up = compilands->getChildAtIndex(compile_unit_count - 1); + lldbassert(last_compiland_up.get()); + std::string name = last_compiland_up->getName(); + if (name == "* Linker *") + --compile_unit_count; + return compile_unit_count; } void SymbolFilePDB::GetCompileUnitIndex( @@ -1698,8 +1694,7 @@ lldb::CompUnitSP SymbolFilePDB::ParseCompileUnitForUID(uint32_t id, if (index == UINT32_MAX) GetCompileUnitIndex(*compiland_up, index); lldbassert(index != UINT32_MAX); - m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(index, - cu_sp); + SetCompileUnitAtIndex(index, cu_sp); return cu_sp; } diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h index ba3099aaec4..13bff40958f 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -48,10 +48,6 @@ public: // Compile Unit function calls - uint32_t GetNumCompileUnits() override; - - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override; @@ -173,6 +169,10 @@ private: }; using SecContribsMap = std::map<uint32_t, std::vector<SecContribInfo>>; + uint32_t CalculateNumCompileUnits() override; + + lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; + lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id, uint32_t index = UINT32_MAX); @@ -245,7 +245,6 @@ private: std::vector<lldb::TypeSP> m_builtin_types; std::unique_ptr<llvm::pdb::IPDBSession> m_session_up; std::unique_ptr<llvm::pdb::PDBSymbolExe> m_global_scope_up; - uint32_t m_cached_compile_unit_count; lldb_private::UniqueCStringMap<uint32_t> m_func_full_names; lldb_private::UniqueCStringMap<uint32_t> m_func_base_names; diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index a1b21e51b0f..ae0499d5ee6 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -104,7 +104,7 @@ uint32_t SymbolFileSymtab::CalculateAbilities() { return abilities; } -uint32_t SymbolFileSymtab::GetNumCompileUnits() { +uint32_t SymbolFileSymtab::CalculateNumCompileUnits() { // If we don't have any source file symbols we will just have one compile // unit for the entire object file if (m_source_indexes.empty()) diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index bc9a531419a..98a8e004d71 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -37,10 +37,6 @@ public: uint32_t CalculateAbilities() override; // Compile Unit function calls - uint32_t GetNumCompileUnits() override; - - lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override; @@ -85,6 +81,10 @@ public: uint32_t GetPluginVersion() override; protected: + uint32_t CalculateNumCompileUnits() override; + + lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; + typedef std::map<lldb_private::ConstString, lldb::TypeSP> TypeMap; lldb_private::Symtab::IndexCollection m_source_indexes; |