diff options
author | Zachary Turner <zturner@google.com> | 2019-01-10 20:57:50 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2019-01-10 20:57:50 +0000 |
commit | d3c3d46754191a5720b8464bdb535e7230aa177f (patch) | |
tree | cfcae166ad5a291a80c27a5ee46e6b1f9c2aae5b /lldb | |
parent | 0a0f5e70563bd0de1e2018de1011c3b50ec57288 (diff) |
Change SymbolFile::ParseTypes to ParseTypesForCompileUnit.
The function SymbolFile::ParseTypes previously accepted a SymbolContext.
This makes it extremely difficult to implement faithfully, because you
have to account for all possible combinations of members being set in
the SymbolContext. On the other hand, no clients of this function
actually care about implementing this function to this strict of a
standard. AFAICT, there is actually only 1 client in the entire
codebase, and it is the function ParseAllDebugSymbols, which is itself
only called for testing purposes when dumping information. At this
call-site, the only field it sets is the CompileUnit, meaning that an
implementer of a SymbolFile need not worry about any examining or
handling any other fields which might be set.
By restricting this API to accept exactly a CompileUnit& and nothing
more, we can simplify the life of new SymbolFile plugin implementers by
making it clear exactly what the necessary and sufficient set of
functionality they need to implement is, while at the same time removing
some dead code that tried to handle other types of SymbolContext fields
that were never going to be set anyway.
Differential Revision: https://reviews.llvm.org/D56462
Diffstat (limited to 'lldb')
14 files changed, 42 insertions, 52 deletions
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 30a2e7c4dd6..d84d248ddd7 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -140,7 +140,7 @@ public: ParseImportedModules(const SymbolContext &sc, std::vector<ConstString> &imported_modules) = 0; virtual size_t ParseFunctionBlocks(const SymbolContext &sc) = 0; - virtual size_t ParseTypes(const SymbolContext &sc) = 0; + virtual size_t ParseTypesForCompileUnit(CompileUnit &comp_unit) = 0; virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0; virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0; diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h index 77733de0823..0155a0806f4 100644 --- a/lldb/include/lldb/Symbol/SymbolVendor.h +++ b/lldb/include/lldb/Symbol/SymbolVendor.h @@ -64,7 +64,7 @@ public: virtual size_t ParseFunctionBlocks(const SymbolContext &sc); - virtual size_t ParseTypes(const SymbolContext &sc); + virtual size_t ParseTypesForCompileUnit(CompileUnit &comp_unit); virtual size_t ParseVariablesForContext(const SymbolContext &sc); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 3b498abf462..b9edea33b41 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -380,8 +380,7 @@ void Module::ParseAllDebugSymbols() { }); // Parse all types for this compile unit - sc.function = nullptr; - symbols->ParseTypes(sc); + symbols->ParseTypesForCompileUnit(*sc.comp_unit); } } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 9978369776d..acea7c74840 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3149,24 +3149,16 @@ size_t SymbolFileDWARF::ParseFunctionBlocks(const SymbolContext &sc) { return functions_added; } -size_t SymbolFileDWARF::ParseTypes(const SymbolContext &sc) { +size_t SymbolFileDWARF::ParseTypesForCompileUnit(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - // At least a compile unit must be valid - assert(sc.comp_unit); size_t types_added = 0; - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { - if (sc.function) { - dw_offset_t function_die_offset = sc.function->GetID(); - DWARFDIE func_die = dwarf_cu->GetDIE(function_die_offset); - if (func_die && func_die.HasChildren()) { - types_added = ParseTypes(sc, func_die.GetFirstChild(), true, true); - } - } else { - DWARFDIE dwarf_cu_die = dwarf_cu->DIE(); - if (dwarf_cu_die && dwarf_cu_die.HasChildren()) { - types_added = ParseTypes(sc, dwarf_cu_die.GetFirstChild(), true, true); - } + DWARFDIE dwarf_cu_die = dwarf_cu->DIE(); + if (dwarf_cu_die && dwarf_cu_die.HasChildren()) { + SymbolContext sc; + sc.comp_unit = &comp_unit; + types_added = ParseTypes(sc, dwarf_cu_die.GetFirstChild(), true, true); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 1e30e17f3cf..e9f98d55317 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -131,7 +131,8 @@ public: size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t + ParseTypesForCompileUnit(lldb_private::CompileUnit &comp_unit) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index d931ccb9d10..2ee4fc8c3ae 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -678,10 +678,13 @@ size_t SymbolFileDWARFDebugMap::ParseFunctionBlocks(const SymbolContext &sc) { return 0; } -size_t SymbolFileDWARFDebugMap::ParseTypes(const SymbolContext &sc) { +size_t +SymbolFileDWARFDebugMap::ParseTypesForCompileUnit(CompileUnit &comp_unit) { + SymbolContext sc; + sc.comp_unit = &comp_unit; SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); if (oso_dwarf) - return oso_dwarf->ParseTypes(sc); + return oso_dwarf->ParseTypesForCompileUnit(comp_unit); return 0; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index e67133c9f95..e641037a814 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -72,7 +72,8 @@ public: const lldb_private::SymbolContext &sc, std::vector<lldb_private::ConstString> &imported_modules) override; size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t + ParseTypesForCompileUnit(lldb_private::CompileUnit &comp_unit) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 2ac0b985a6a..b9fdc1408c7 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1274,7 +1274,7 @@ size_t SymbolFileNativePDB::FindTypesByName(llvm::StringRef name, return match_count; } -size_t SymbolFileNativePDB::ParseTypes(const SymbolContext &sc) { +size_t SymbolFileNativePDB::ParseTypesForCompileUnit(CompileUnit &comp_unit) { // Only do the full type scan the first time. if (m_done_full_type_scan) return 0; diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h index 2b112516407..ca28023e45f 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -104,7 +104,8 @@ public: uint32_t max_matches, VariableList &variables) override; - size_t ParseTypes(const SymbolContext &sc) override; + size_t + ParseTypesForCompileUnit(lldb_private::CompileUnit &comp_unit) override; size_t ParseVariablesForContext(const SymbolContext &sc) override; void AddSymbols(Symtab &symtab) override; diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 824b7a033ef..916a7af422d 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -464,13 +464,10 @@ SymbolFilePDB::ParseFunctionBlocks(const lldb_private::SymbolContext &sc) { return num_added; } -size_t SymbolFilePDB::ParseTypes(const lldb_private::SymbolContext &sc) { - lldbassert(sc.module_sp.get()); - if (!sc.comp_unit) - return 0; +size_t SymbolFilePDB::ParseTypesForCompileUnit(CompileUnit &comp_unit) { size_t num_added = 0; - auto compiland = GetPDBCompilandByUID(sc.comp_unit->GetID()); + auto compiland = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland) return 0; @@ -505,23 +502,15 @@ size_t SymbolFilePDB::ParseTypes(const lldb_private::SymbolContext &sc) { } }; - if (sc.function) { - auto pdb_func = m_session_up->getConcreteSymbolById<PDBSymbolFunc>( - sc.function->GetID()); - if (!pdb_func) - return 0; - ParseTypesByTagFn(*pdb_func); - } else { - ParseTypesByTagFn(*compiland); - - // Also parse global types particularly coming from this compiland. - // Unfortunately, PDB has no compiland information for each global type. We - // have to parse them all. But ensure we only do this once. - static bool parse_all_global_types = false; - if (!parse_all_global_types) { - ParseTypesByTagFn(*m_global_scope_up); - parse_all_global_types = true; - } + ParseTypesByTagFn(*compiland); + + // Also parse global types particularly coming from this compiland. + // Unfortunately, PDB has no compiland information for each global type. We + // have to parse them all. But ensure we only do this once. + static bool parse_all_global_types = false; + if (!parse_all_global_types) { + ParseTypesByTagFn(*m_global_scope_up); + parse_all_global_types = true; } return num_added; } diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h index 33c1007de48..307e69147da 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -81,7 +81,8 @@ public: size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t + ParseTypesForCompileUnit(lldb_private::CompileUnit &comp_unit) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 8375abf384b..f405d8470a8 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -229,7 +229,9 @@ size_t SymbolFileSymtab::ParseFunctionBlocks(const SymbolContext &sc) { return 0; } -size_t SymbolFileSymtab::ParseTypes(const SymbolContext &sc) { return 0; } +size_t SymbolFileSymtab::ParseTypesForCompileUnit(CompileUnit &comp_unit) { + return 0; +} size_t SymbolFileSymtab::ParseVariablesForContext(const SymbolContext &sc) { return 0; diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index 16936978317..4cfab1da5e9 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -70,7 +70,8 @@ public: size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t + ParseTypesForCompileUnit(lldb_private::CompileUnit &comp_unit) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index c0d1763d32d..80af0c9bccf 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -200,12 +200,12 @@ size_t SymbolVendor::ParseFunctionBlocks(const SymbolContext &sc) { return 0; } -size_t SymbolVendor::ParseTypes(const SymbolContext &sc) { +size_t SymbolVendor::ParseTypesForCompileUnit(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseTypes(sc); + return m_sym_file_ap->ParseTypesForCompileUnit(comp_unit); } return 0; } |