summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile/PDB
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2019-01-11 18:03:20 +0000
committerZachary Turner <zturner@google.com>2019-01-11 18:03:20 +0000
commit863f8c18b9272021d9fa37b3f5ff83debb0002a3 (patch)
treeb3a7f25c3f8fd3f35bf1418638f53e91cc99fc02 /lldb/source/Plugins/SymbolFile/PDB
parent3a50a9fe74468ea376e59f81131a873fb1b4d7d7 (diff)
downloadbcm5719-llvm-863f8c18b9272021d9fa37b3f5ff83debb0002a3.tar.gz
bcm5719-llvm-863f8c18b9272021d9fa37b3f5ff83debb0002a3.zip
[SymbolFile] Make ParseCompileUnitXXX accept a CompileUnit&.
Previously all of these functions accepted a SymbolContext&. While a CompileUnit is one member of a SymbolContext, there are also many others, and by passing such a monolithic parameter in this way it makes the requirements and assumptions of the API unclear for both callers as well as implementors. All these methods need is a CompileUnit. By limiting the parameter type in this way, we simplify the code as well as make it self-documenting for both implementers and users. Differential Revision: https://reviews.llvm.org/D56564 llvm-svn: 350943
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/PDB')
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp85
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h25
2 files changed, 45 insertions, 65 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 916a7af422d..1878671662a 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -267,14 +267,8 @@ lldb::CompUnitSP SymbolFilePDB::ParseCompileUnitAtIndex(uint32_t index) {
return ParseCompileUnitForUID(compiland_up->getSymIndexId(), index);
}
-lldb::LanguageType
-SymbolFilePDB::ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) {
- // What fields should I expect to be filled out on the SymbolContext? Is it
- // safe to assume that `sc.comp_unit` is valid?
- if (!sc.comp_unit)
- return lldb::eLanguageTypeUnknown;
-
- auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID());
+lldb::LanguageType SymbolFilePDB::ParseLanguage(CompileUnit &comp_unit) {
+ auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID());
if (!compiland_up)
return lldb::eLanguageTypeUnknown;
auto details = compiland_up->findOneChild<PDBSymbolCompilandDetails>();
@@ -283,12 +277,10 @@ SymbolFilePDB::ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) {
return TranslateLanguage(details->getLanguage());
}
-lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(
- const PDBSymbolFunc &pdb_func, const lldb_private::SymbolContext &sc) {
- lldbassert(sc.comp_unit && sc.module_sp.get());
-
- if (FunctionSP result =
- sc.comp_unit->FindFunctionByUID(pdb_func.getSymIndexId()))
+lldb_private::Function *
+SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(const PDBSymbolFunc &pdb_func,
+ CompileUnit &comp_unit) {
+ if (FunctionSP result = comp_unit.FindFunctionByUID(pdb_func.getSymIndexId()))
return result.get();
auto file_vm_addr = pdb_func.getVirtualAddress();
@@ -297,7 +289,8 @@ lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(
auto func_length = pdb_func.getLength();
AddressRange func_range =
- AddressRange(file_vm_addr, func_length, sc.module_sp->GetSectionList());
+ AddressRange(file_vm_addr, func_length,
+ GetObjectFile()->GetModule()->GetSectionList());
if (!func_range.GetBaseAddress().IsValid())
return nullptr;
@@ -310,10 +303,10 @@ lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(
Mangled mangled = GetMangledForPDBFunc(pdb_func);
FunctionSP func_sp =
- std::make_shared<Function>(sc.comp_unit, pdb_func.getSymIndexId(),
+ std::make_shared<Function>(&comp_unit, pdb_func.getSymIndexId(),
func_type_uid, mangled, func_type, func_range);
- sc.comp_unit->AddFunction(func_sp);
+ comp_unit.AddFunction(func_sp);
TypeSystem *type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
if (!type_system)
@@ -327,52 +320,44 @@ lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(
return func_sp.get();
}
-size_t SymbolFilePDB::ParseCompileUnitFunctions(
- const lldb_private::SymbolContext &sc) {
- lldbassert(sc.comp_unit);
+size_t SymbolFilePDB::ParseFunctions(CompileUnit &comp_unit) {
size_t func_added = 0;
- auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID());
+ auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID());
if (!compiland_up)
return 0;
auto results_up = compiland_up->findAllChildren<PDBSymbolFunc>();
if (!results_up)
return 0;
while (auto pdb_func_up = results_up->getNext()) {
- auto func_sp =
- sc.comp_unit->FindFunctionByUID(pdb_func_up->getSymIndexId());
+ auto func_sp = comp_unit.FindFunctionByUID(pdb_func_up->getSymIndexId());
if (!func_sp) {
- if (ParseCompileUnitFunctionForPDBFunc(*pdb_func_up, sc))
+ if (ParseCompileUnitFunctionForPDBFunc(*pdb_func_up, comp_unit))
++func_added;
}
}
return func_added;
}
-bool SymbolFilePDB::ParseCompileUnitLineTable(
- const lldb_private::SymbolContext &sc) {
- lldbassert(sc.comp_unit);
- if (sc.comp_unit->GetLineTable())
+bool SymbolFilePDB::ParseLineTable(CompileUnit &comp_unit) {
+ if (comp_unit.GetLineTable())
return true;
- return ParseCompileUnitLineTable(sc, 0);
+ return ParseCompileUnitLineTable(comp_unit, 0);
}
-bool SymbolFilePDB::ParseCompileUnitDebugMacros(
- const lldb_private::SymbolContext &sc) {
+bool SymbolFilePDB::ParseDebugMacros(CompileUnit &comp_unit) {
// PDB doesn't contain information about macros
return false;
}
-bool SymbolFilePDB::ParseCompileUnitSupportFiles(
- const lldb_private::SymbolContext &sc,
- lldb_private::FileSpecList &support_files) {
- lldbassert(sc.comp_unit);
+bool SymbolFilePDB::ParseSupportFiles(
+ CompileUnit &comp_unit, lldb_private::FileSpecList &support_files) {
// In theory this is unnecessary work for us, because all of this information
// is easily (and quickly) accessible from DebugInfoPDB, so caching it a
// second time seems like a waste. Unfortunately, there's no good way around
// this short of a moderate refactor since SymbolVendor depends on being able
// to cache this list.
- auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID());
+ auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID());
if (!compiland_up)
return false;
auto files = m_session_up->getSourceFilesForCompiland(*compiland_up);
@@ -386,7 +371,7 @@ bool SymbolFilePDB::ParseCompileUnitSupportFiles(
// LLDB uses the DWARF-like file numeration (one based),
// the zeroth file is the compile unit itself
- support_files.Insert(0, *sc.comp_unit);
+ support_files.Insert(0, comp_unit);
return true;
}
@@ -464,7 +449,7 @@ SymbolFilePDB::ParseFunctionBlocks(const lldb_private::SymbolContext &sc) {
return num_added;
}
-size_t SymbolFilePDB::ParseTypesForCompileUnit(CompileUnit &comp_unit) {
+size_t SymbolFilePDB::ParseTypes(CompileUnit &comp_unit) {
size_t num_added = 0;
auto compiland = GetPDBCompilandByUID(comp_unit.GetID());
@@ -726,7 +711,8 @@ SymbolFilePDB::ResolveSymbolContext(const lldb_private::Address &so_addr,
auto func_uid = pdb_func->getSymIndexId();
sc.function = sc.comp_unit->FindFunctionByUID(func_uid).get();
if (sc.function == nullptr)
- sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func, sc);
+ sc.function =
+ ParseCompileUnitFunctionForPDBFunc(*pdb_func, *sc.comp_unit);
if (sc.function) {
resolved_flags |= eSymbolContextFunction;
if (resolve_scope & eSymbolContextBlock) {
@@ -796,7 +782,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext(
// table that match the requested line (or all lines if `line` == 0).
if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock |
eSymbolContextLineEntry)) {
- bool has_line_table = ParseCompileUnitLineTable(sc, line);
+ bool has_line_table = ParseCompileUnitLineTable(*sc.comp_unit, line);
if ((resolve_scope & eSymbolContextLineEntry) && !has_line_table) {
// The query asks for line entries, but we can't get them for the
@@ -839,7 +825,8 @@ uint32_t SymbolFilePDB::ResolveSymbolContext(
if (sc.function == nullptr) {
auto pdb_func = llvm::dyn_cast<PDBSymbolFunc>(symbol_up.get());
assert(pdb_func);
- sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func, sc);
+ sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func,
+ *sc.comp_unit);
}
if (sc.function && (resolve_scope & eSymbolContextBlock)) {
Block &block = sc.function->GetBlock(true);
@@ -1139,7 +1126,7 @@ bool SymbolFilePDB::ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func,
if (!sc.comp_unit)
return false;
sc.module_sp = sc.comp_unit->GetModule();
- sc.function = ParseCompileUnitFunctionForPDBFunc(pdb_func, sc);
+ sc.function = ParseCompileUnitFunctionForPDBFunc(pdb_func, *sc.comp_unit);
if (!sc.function)
return false;
@@ -1717,11 +1704,9 @@ lldb::CompUnitSP SymbolFilePDB::ParseCompileUnitForUID(uint32_t id,
return cu_sp;
}
-bool SymbolFilePDB::ParseCompileUnitLineTable(
- const lldb_private::SymbolContext &sc, uint32_t match_line) {
- lldbassert(sc.comp_unit);
-
- auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID());
+bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
+ uint32_t match_line) {
+ auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID());
if (!compiland_up)
return false;
@@ -1731,10 +1716,10 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(
// to do a mapping so that we can hand out indices.
llvm::DenseMap<uint32_t, uint32_t> index_map;
BuildSupportFileIdToSupportFileIndexMap(*compiland_up, index_map);
- auto line_table = llvm::make_unique<LineTable>(sc.comp_unit);
+ auto line_table = llvm::make_unique<LineTable>(&comp_unit);
// Find contributions to `compiland` from all source and header files.
- std::string path = sc.comp_unit->GetPath();
+ std::string path = comp_unit.GetPath();
auto files = m_session_up->getSourceFilesForCompiland(*compiland_up);
if (!files)
return false;
@@ -1818,7 +1803,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(
}
if (line_table->GetSize()) {
- sc.comp_unit->SetLineTable(line_table.release());
+ comp_unit.SetLineTable(line_table.release());
return true;
}
return false;
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
index 307e69147da..10fa3b4ea24 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -60,20 +60,18 @@ public:
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
lldb::LanguageType
- ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) override;
+ ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
- size_t
- ParseCompileUnitFunctions(const lldb_private::SymbolContext &sc) override;
+ size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
- bool
- ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc) override;
+ bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
- bool
- ParseCompileUnitDebugMacros(const lldb_private::SymbolContext &sc) override;
+ bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
- bool ParseCompileUnitSupportFiles(
- const lldb_private::SymbolContext &sc,
- lldb_private::FileSpecList &support_files) override;
+ bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit,
+ lldb_private::FileSpecList &support_files) override;
+
+ size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override;
bool ParseImportedModules(
const lldb_private::SymbolContext &sc,
@@ -82,9 +80,6 @@ public:
size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override;
size_t
- ParseTypesForCompileUnit(lldb_private::CompileUnit &comp_unit) override;
-
- size_t
ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;
lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
@@ -190,7 +185,7 @@ private:
lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id,
uint32_t index = UINT32_MAX);
- bool ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc,
+ bool ParseCompileUnitLineTable(lldb_private::CompileUnit &comp_unit,
uint32_t match_line);
void BuildSupportFileIdToSupportFileIndexMap(
@@ -222,7 +217,7 @@ private:
lldb_private::Function *
ParseCompileUnitFunctionForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func,
- const lldb_private::SymbolContext &sc);
+ lldb_private::CompileUnit &comp_unit);
void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
uint32_t &index);
OpenPOWER on IntegriCloud