Author: labath Date: Thu Jul 25 01:22:05 2019 New Revision: 366994 URL: http://llvm.org/viewvc/llvm-project?rev=366994&view=rev Log: SymbolVendor: Remove the type list member
Summary: Similarly to the compile unit lists, the list of types can also be managed by the symbol file itself. Since the only purpose of this list seems to be to maintain an owning reference to all the types a symbol file has created (items are only ever added to the list, never retrieved), I remove the passthrough functions in SymbolVendor and Module. I also tighten the interface of the function (return a reference instead of a pointer, make it protected instead of public). Reviewers: clayborg, JDevlieghere, jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D65135 Modified: lldb/trunk/include/lldb/Core/Module.h lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/include/lldb/Symbol/SymbolVendor.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/trunk/source/Symbol/SymbolFile.cpp lldb/trunk/source/Symbol/SymbolVendor.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Thu Jul 25 01:22:05 2019 @@ -653,13 +653,6 @@ public: GetSymbolVendor(bool can_create = true, lldb_private::Stream *feedback_strm = nullptr); - /// Get accessor the type list for this module. - /// - /// \return - /// A valid type list pointer, or nullptr if there is no valid - /// symbol vendor for this module. - TypeList *GetTypeList(); - /// Get a reference to the UUID value contained in this object. /// /// If the executable image file doesn't not have a UUID value built into Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Thu Jul 25 01:22:05 2019 @@ -16,6 +16,7 @@ #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SourceModule.h" #include "lldb/Symbol/Type.h" +#include "lldb/Symbol/TypeList.h" #include "lldb/lldb-private.h" #include "llvm/ADT/DenseSet.h" @@ -191,10 +192,7 @@ public: virtual void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector<ConstString> &mangled_names); - // virtual uint32_t FindTypes (const SymbolContext& sc, const - // RegularExpression& regex, bool append, uint32_t max_matches, TypeList& - // types) = 0; - virtual TypeList *GetTypeList(); + virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) = 0; @@ -241,11 +239,13 @@ protected: void AssertModuleLock(); virtual uint32_t CalculateNumCompileUnits() = 0; virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t idx) = 0; + virtual TypeList &GetTypeList() { return m_type_list; } void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp); ObjectFile *m_obj_file; // The object file that symbols can be extracted from. llvm::Optional<std::vector<lldb::CompUnitSP>> m_compile_units; + TypeList m_type_list; uint32_t m_abilities; bool m_calculated_abilities; Modified: lldb/trunk/include/lldb/Symbol/SymbolVendor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolVendor.h?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolVendor.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolVendor.h Thu Jul 25 01:22:05 2019 @@ -14,7 +14,6 @@ #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/SourceModule.h" -#include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/lldb-private.h" #include "llvm/ADT/DenseSet.h" @@ -112,10 +111,6 @@ public: virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx); - TypeList &GetTypeList() { return m_type_list; } - - const TypeList &GetTypeList() const { return m_type_list; } - virtual size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list); @@ -139,7 +134,6 @@ public: uint32_t GetPluginVersion() override; protected: - TypeList m_type_list; // Uniqued types for all parsers owned by this module lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in // case it isn't the same as the module // object file (debug symbols in a separate Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Thu Jul 25 01:22:05 2019 @@ -117,8 +117,6 @@ public: SymbolFile *GetSymbolFile() { return m_symbol_file; } const SymbolFile *GetSymbolFile() const { return m_symbol_file; } - TypeList *GetTypeList(); - ConstString GetName(); llvm::Optional<uint64_t> GetByteSize(); Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Thu Jul 25 01:22:05 2019 @@ -16,6 +16,7 @@ #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/Type.h" +#include "lldb/Symbol/TypeList.h" using namespace lldb; using namespace lldb_private; Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Thu Jul 25 01:22:05 2019 @@ -1240,13 +1240,6 @@ void Module::Dump(Stream *s) { s->IndentLess(); } -TypeList *Module::GetTypeList() { - SymbolVendor *symbols = GetSymbolVendor(); - if (symbols) - return &symbols->GetTypeList(); - return nullptr; -} - ConstString Module::GetObjectName() const { return m_object_name; } ObjectFile *Module::GetObjectFile() { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Jul 25 01:22:05 2019 @@ -188,7 +188,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro nullptr, LLDB_INVALID_UID, Type::eEncodingInvalid, &dwo_type_sp->GetDeclaration(), type, Type::eResolveStateForward)); - dwarf->GetTypeList()->Insert(type_sp); + dwarf->GetTypeList().Insert(type_sp); dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); clang::TagDecl *tag_decl = ClangASTContext::GetAsTagDecl(type); if (tag_decl) @@ -434,7 +434,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro return nullptr; } - TypeList *type_list = dwarf->GetTypeList(); + TypeList &type_list = dwarf->GetTypeList(); if (type_is_new_ptr) *type_is_new_ptr = true; @@ -1672,7 +1672,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro // We are ready to put this type into the uniqued list up at the module // level - type_list->Insert(type_sp); + type_list.Insert(type_sp); dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Jul 25 01:22:05 2019 @@ -202,15 +202,13 @@ SymbolFile *SymbolFileDWARF::CreateInsta /*dwo_section_list*/ nullptr); } -TypeList *SymbolFileDWARF::GetTypeList() { +TypeList &SymbolFileDWARF::GetTypeList() { // This method can be called without going through the symbol vendor so we // need to lock the module. std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); - SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); - if (debug_map_symfile) + if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) return debug_map_symfile->GetTypeList(); - else - return m_obj_file->GetModule()->GetTypeList(); + return SymbolFile::GetTypeList(); } void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset, dw_offset_t max_die_offset, uint32_t type_mask, @@ -2971,9 +2969,7 @@ TypeSP SymbolFileDWARF::ParseType(const Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); TypeSP type_sp = dwarf_ast->ParseTypeFromDWARF(sc, die, log, type_is_new_ptr); if (type_sp) { - TypeList *type_list = GetTypeList(); - if (type_list) - type_list->Insert(type_sp); + GetTypeList().Insert(type_sp); if (die.Tag() == DW_TAG_subprogram) { std::string scope_qualified_name(GetDeclContextForUID(die.GetID()) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Thu Jul 25 01:22:05 2019 @@ -186,8 +186,6 @@ public: size_t FindTypes(const std::vector<lldb_private::CompilerContext> &context, bool append, lldb_private::TypeMap &types) override; - lldb_private::TypeList *GetTypeList() override; - size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override; @@ -331,6 +329,8 @@ protected: lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; + lldb_private::TypeList &GetTypeList() override; + virtual DWARFUnit * GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit); Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Thu Jul 25 01:22:05 2019 @@ -729,7 +729,7 @@ TypeSP SymbolFileNativePDB::GetOrCreateT TypeSP type = CreateAndCacheType(type_id); if (type) - m_obj_file->GetModule()->GetTypeList()->Insert(type); + GetTypeList().Insert(type); return type; } @@ -1283,7 +1283,7 @@ size_t SymbolFileNativePDB::ParseTypes(C if (m_done_full_type_scan) return 0; - size_t old_count = m_obj_file->GetModule()->GetTypeList()->GetSize(); + const size_t old_count = GetTypeList().GetSize(); LazyRandomTypeCollection &types = m_index->tpi().typeCollection(); // First process the entire TPI stream. @@ -1313,7 +1313,7 @@ size_t SymbolFileNativePDB::ParseTypes(C GetOrCreateTypedef(global); } - size_t new_count = m_obj_file->GetModule()->GetTypeList()->GetSize(); + const size_t new_count = GetTypeList().GetSize(); m_done_full_type_scan = true; Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Thu Jul 25 01:22:05 2019 @@ -557,9 +557,7 @@ lldb_private::Type *SymbolFilePDB::Resol lldb::TypeSP result = pdb->CreateLLDBTypeFromPDBType(*pdb_type); if (result) { m_types.insert(std::make_pair(type_uid, result)); - auto type_list = GetTypeList(); - if (type_list) - type_list->Insert(result); + GetTypeList().Insert(result); } return result.get(); } @@ -1516,10 +1514,6 @@ size_t SymbolFilePDB::FindTypes( return 0; } -lldb_private::TypeList *SymbolFilePDB::GetTypeList() { - return m_obj_file->GetModule()->GetTypeList(); -} - void SymbolFilePDB::GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol, uint32_t type_mask, TypeCollection &type_collection) { Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h Thu Jul 25 01:22:05 2019 @@ -138,8 +138,6 @@ public: void FindTypesByRegex(const lldb_private::RegularExpression ®ex, uint32_t max_matches, lldb_private::TypeMap &types); - lldb_private::TypeList *GetTypeList() override; - size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override; Modified: lldb/trunk/source/Symbol/SymbolFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolFile.cpp (original) +++ lldb/trunk/source/Symbol/SymbolFile.cpp Thu Jul 25 01:22:05 2019 @@ -82,12 +82,6 @@ SymbolFile *SymbolFile::FindPlugin(Objec return best_symfile_up.release(); } -TypeList *SymbolFile::GetTypeList() { - if (m_obj_file) - return m_obj_file->GetModule()->GetTypeList(); - return nullptr; -} - TypeSystem *SymbolFile::GetTypeSystemForLanguage(lldb::LanguageType language) { TypeSystem *type_system = m_obj_file->GetModule()->GetTypeSystemForLanguage(language); @@ -206,6 +200,10 @@ void SymbolFile::SetCompileUnitAtIndex(u } void SymbolFile::Dump(Stream &s) { + s.PutCString("Types:\n"); + m_type_list.Dump(&s, /*show_context*/ false); + s.PutChar('\n'); + s.PutCString("Compile units:\n"); if (m_compile_units) { for (const CompUnitSP &cu_sp : *m_compile_units) { Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolVendor.cpp (original) +++ lldb/trunk/source/Symbol/SymbolVendor.cpp Thu Jul 25 01:22:05 2019 @@ -58,7 +58,7 @@ SymbolVendor *SymbolVendor::FindPlugin(c // SymbolVendor constructor SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp) - : ModuleChild(module_sp), m_type_list(), m_sym_file_up(), m_symtab() {} + : ModuleChild(module_sp), m_sym_file_up(), m_symtab() {} // Destructor SymbolVendor::~SymbolVendor() {} @@ -336,8 +336,6 @@ void SymbolVendor::Dump(Stream *s) { if (module_sp) { std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); - bool show_context = false; - s->Printf("%p: ", static_cast<void *>(this)); s->Indent(); s->PutCString("SymbolVendor"); @@ -354,9 +352,6 @@ void SymbolVendor::Dump(Stream *s) { } } s->EOL(); - s->PutCString("Types:\n"); - m_type_list.Dump(s, show_context); - s->EOL(); if (m_sym_file_up) m_sym_file_up->Dump(*s); s->IndentMore(); Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=366994&r1=366993&r2=366994&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Thu Jul 25 01:22:05 2019 @@ -425,8 +425,6 @@ bool Type::WriteToMemory(ExecutionContex return false; } -TypeList *Type::GetTypeList() { return GetSymbolFile()->GetTypeList(); } - const Declaration &Type::GetDeclaration() const { return m_decl; } bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits