[Lldb-commits] [lldb] r327473 - [SymbolFilePDB] Rewrite ParseTypes method
Aaron Smith via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 13 21:05:27 PDT 2018
Author: asmith
Date: Tue Mar 13 21:05:27 2018
New Revision: 327473
URL: http://llvm.org/viewvc/llvm-project?rev=327473&view=rev
Log:
[SymbolFilePDB] Rewrite ParseTypes method
Summary:
The types for the compiland's children are parsed when parsing types for a PDB compiland. Global types also need to be parsed but unfortunately PDBs do not have compiland information about each global type. So we parse them all on the first call to ParseTypes.
If a sc.function is provided then parse the types for that function. Otherwise parse the types for the overall sc.comp_unit.
The ParseTypes method can be very slow if a program has a long list of compile units containing needed modules. Debugging clang-cl with lldb will show the problem.
Reviewers: zturner, rnk, lldb-commits
Reviewed By: zturner
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44253
Modified:
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
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=327473&r1=327472&r2=327473&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Tue Mar 13 21:05:27 2018
@@ -438,30 +438,59 @@ SymbolFilePDB::ParseFunctionBlocks(const
size_t SymbolFilePDB::ParseTypes(const lldb_private::SymbolContext &sc) {
lldbassert(sc.module_sp.get());
+ if (!sc.comp_unit)
+ return 0;
+
size_t num_added = 0;
- auto results_up = m_session_up->getGlobalScope()->findAllChildren();
- if (!results_up)
+ auto compiland = GetPDBCompilandByUID(sc.comp_unit->GetID());
+ if (!compiland)
return 0;
- while (auto symbol_up = results_up->getNext()) {
- switch (symbol_up->getSymTag()) {
- case PDB_SymType::Enum:
- case PDB_SymType::UDT:
- case PDB_SymType::Typedef:
- break;
- default:
- continue;
+
+ auto ParseTypesByTagFn = [&num_added, this](const PDBSymbol &raw_sym) {
+ std::unique_ptr<IPDBEnumSymbols> results;
+ PDB_SymType tags_to_search[] = { PDB_SymType::Enum, PDB_SymType::Typedef,
+ PDB_SymType::UDT };
+ for (auto tag : tags_to_search) {
+ results = raw_sym.findAllChildren(tag);
+ if (!results || results->getChildCount() == 0)
+ continue;
+ while (auto symbol = results->getNext()) {
+ switch (symbol->getSymTag()) {
+ case PDB_SymType::Enum:
+ case PDB_SymType::UDT:
+ case PDB_SymType::Typedef:
+ break;
+ default:
+ continue;
+ }
+
+ // This should cause the type to get cached and stored in the `m_types`
+ // lookup.
+ if (!ResolveTypeUID(symbol->getSymIndexId()))
+ continue;
+
+ ++num_added;
+ }
}
+ };
- auto type_uid = symbol_up->getSymIndexId();
- if (m_types.find(type_uid) != m_types.end())
- continue;
-
- // This should cause the type to get cached and stored in the `m_types`
- // lookup.
- if (!ResolveTypeUID(symbol_up->getSymIndexId()))
- continue;
+ 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);
- ++num_added;
+ // 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;
}
More information about the lldb-commits
mailing list