zturner created this revision.
zturner added reviewers: clayborg, labath, jingham.
This function was being used in 2 separate use cases. The first is parsing
variables in a function, and the second is parsing global variables. To
clarify the intent, I've split this into two functions,
ParseLocalVariablesRecursive and ParseGlobalVariables.
In doing so, I found what may actually be a bug. This bug was very subtle in
the old implementation, and an example of exactly why I think it's important to
clean up these interfaces. There was a disconnect in what the caller expected
to happen and what the implementation actually did.
Specifically, before when calling `Block::GetBlockVariableList` it was
implemented this way:
SymbolContext sc;
CalculateSymbolContext(&sc);
assert(sc.module_sp);
sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
This is logical, because it expects that `ParseVariablesForContext` will see
that the block is set, then only parse variables for the given block. However,
the implementation of this function did not actually handle the case where
`sc.m_block` was set. Instead, this would fall to the `sc.m_function` code
path, and parse all variables for the entire function, recursively, even though
only 1 block was requested.
I expect this will be a performance problem if you have large function with
many blocks and you put a breakpoint in one of the leaf-blocks and try to print
a variable. It would have to parse potentially thousands of other blocks'
variables even though only 1 is needed.
After this patch, there is no functional change, but the bug is more obvious,
because `Block::GetVariableList` is implemented like this:
VariableListSP Block::GetBlockVariableList(bool can_create) {
if (!m_parsed_block_variables) {
if (m_variable_list_sp.get() == nullptr && can_create) {
m_parsed_block_variables = true;
Function *func = CalculateSymbolContextFunction();
ModuleSP module = CalculateSymbolContextModule();
module->GetSymbolVendor()->ParseLocalVariablesRecursive(*func);
}
}
return m_variable_list_sp;
}
This way, a person so motivated can go through and add another overload such as
`ParseVariablesForBlock` (or change `ParseVariablesForFunction` to
`ParseVariablesForBlock(Block& block, bool recursive)` so that we can pass
false there.`
https://reviews.llvm.org/D56737
Files:
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Symbol/SymbolVendor.h
lldb/source/Core/Module.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
lldb/source/Symbol/Block.cpp
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/SymbolVendor.cpp
Index: lldb/source/Symbol/SymbolVendor.cpp
===================================================================
--- lldb/source/Symbol/SymbolVendor.cpp
+++ lldb/source/Symbol/SymbolVendor.cpp
@@ -209,12 +209,22 @@
return 0;
}
-size_t SymbolVendor::ParseVariablesForContext(const SymbolContext &sc) {
+size_t SymbolVendor::ParseGlobalVariables(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->ParseVariablesForContext(sc);
+ return m_sym_file_ap->ParseGlobalVariables(comp_unit);
+ }
+ return 0;
+}
+
+size_t SymbolVendor::ParseLocalVariablesRecursive(Function &func) {
+ 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->ParseLocalVariablesRecursive(func);
}
return 0;
}
Index: lldb/source/Symbol/CompileUnit.cpp
===================================================================
--- lldb/source/Symbol/CompileUnit.cpp
+++ lldb/source/Symbol/CompileUnit.cpp
@@ -233,10 +233,8 @@
VariableListSP CompileUnit::GetVariableList(bool can_create) {
if (m_variables.get() == nullptr && can_create) {
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- assert(sc.module_sp);
- sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
+ ModuleSP module = CalculateSymbolContextModule();
+ GetModule()->GetSymbolVendor()->ParseGlobalVariables(*this);
}
return m_variables;
Index: lldb/source/Symbol/Block.cpp
===================================================================
--- lldb/source/Symbol/Block.cpp
+++ lldb/source/Symbol/Block.cpp
@@ -372,10 +372,9 @@
if (!m_parsed_block_variables) {
if (m_variable_list_sp.get() == nullptr && can_create) {
m_parsed_block_variables = true;
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- assert(sc.module_sp);
- sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
+ Function *func = CalculateSymbolContextFunction();
+ ModuleSP module = CalculateSymbolContextModule();
+ module->GetSymbolVendor()->ParseLocalVariablesRecursive(*func);
}
}
return m_variable_list_sp;
Index: lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
===================================================================
--- lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -68,8 +68,8 @@
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
- size_t
- ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;
+ size_t ParseGlobalVariables(lldb_private::CompileUnit &comp_unit) override;
+ size_t ParseLocalVariablesRecursive(lldb_private::Function &func) override;
lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
Index: lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -225,7 +225,11 @@
size_t SymbolFileSymtab::ParseBlocksRecursive(Function &func) { return 0; }
-size_t SymbolFileSymtab::ParseVariablesForContext(const SymbolContext &sc) {
+size_t SymbolFileSymtab::ParseGlobalVariables(CompileUnit &comp_unit) {
+ return 0;
+}
+
+size_t SymbolFileSymtab::ParseLocalVariablesRecursive(Function &func) {
return 0;
}
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -79,8 +79,9 @@
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
+ size_t ParseGlobalVariables(lldb_private::CompileUnit &comp_unit) override;
size_t
- ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;
+ ParseLocalVariablesRecursive(lldb_private::Function &function) override;
lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
@@ -202,6 +203,7 @@
size_t ParseVariables(const lldb_private::SymbolContext &sc,
const llvm::pdb::PDBSymbol &pdb_data,
+ bool recursive = true,
lldb_private::VariableList *variable_list = nullptr);
lldb::CompUnitSP
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -497,52 +497,52 @@
}
size_t
-SymbolFilePDB::ParseVariablesForContext(const lldb_private::SymbolContext &sc) {
- if (!sc.comp_unit)
- return 0;
-
+SymbolFilePDB::ParseGlobalVariables(lldb_private::CompileUnit &comp_unit) {
size_t num_added = 0;
- if (sc.function) {
- auto pdb_func = m_session_up->getConcreteSymbolById<PDBSymbolFunc>(
- sc.function->GetID());
- if (!pdb_func)
- return 0;
- num_added += ParseVariables(sc, *pdb_func);
- sc.function->GetBlock(false).SetDidParseVariables(true, true);
- } else if (sc.comp_unit) {
- auto compiland = GetPDBCompilandByUID(sc.comp_unit->GetID());
- if (!compiland)
- return 0;
+ auto compiland = GetPDBCompilandByUID(comp_unit.GetID());
+ if (!compiland)
+ return 0;
- if (sc.comp_unit->GetVariableList(false))
- return 0;
+ if (comp_unit.GetVariableList(false))
+ return 0;
+
+ PDBSymbol *scopes[] = {m_global_scope_up.get(), compiland.get()};
+ for (PDBSymbol *symbol : scopes) {
auto results = m_global_scope_up->findAllChildren<PDBSymbolData>();
- if (results && results->getChildCount()) {
- while (auto result = results->getNext()) {
- auto cu_id = GetCompilandId(*result);
- // FIXME: We are not able to determine variable's compile unit.
- if (cu_id == 0)
- continue;
+ if (!results || results->getChildCount() == 0)
+ continue;
+ while (auto result = results->getNext()) {
+ auto cu_id = GetCompilandId(*result);
+ // FIXME: We are not able to determine variable's compile unit.
+ if (cu_id == 0)
+ continue;
- if (cu_id == sc.comp_unit->GetID())
- num_added += ParseVariables(sc, *result);
- }
+ if (cu_id != comp_unit.GetID())
+ continue;
+
+ SymbolContext sc;
+ sc.comp_unit = &comp_unit;
+ num_added += ParseVariables(sc, *result, false);
}
+ }
- // FIXME: A `file static` or `global constant` variable appears both in
- // compiland's children and global scope's children with unexpectedly
- // different symbol's Id making it ambiguous.
+ return num_added;
+}
- // FIXME: 'local constant', for example, const char var[] = "abc", declared
- // in a function scope, can't be found in PDB.
+size_t
+SymbolFilePDB::ParseLocalVariablesRecursive(lldb_private::Function &function) {
+ auto pdb_func =
+ m_session_up->getConcreteSymbolById<PDBSymbolFunc>(function.GetID());
+ if (!pdb_func)
+ return 0;
- // Parse variables in this compiland.
- num_added += ParseVariables(sc, *compiland);
- }
+ function.GetBlock(false).SetDidParseVariables(true, true);
- return num_added;
+ SymbolContext sc;
+ sc.function = &function;
+ return ParseVariables(sc, *pdb_func, true);
}
lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) {
@@ -966,6 +966,7 @@
size_t
SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc,
const llvm::pdb::PDBSymbol &pdb_symbol,
+ bool recursive,
lldb_private::VariableList *variable_list) {
size_t num_added = 0;
@@ -1025,9 +1026,11 @@
}
}
- if (auto results = pdb_symbol.findAllChildren()) {
- while (auto result = results->getNext())
- num_added += ParseVariables(sc, *result, variable_list);
+ if (recursive) {
+ if (auto results = pdb_symbol.findAllChildren()) {
+ while (auto result = results->getNext())
+ num_added += ParseVariables(sc, *result, true, variable_list);
+ }
}
return num_added;
@@ -1070,7 +1073,7 @@
result->getSymIndexId()) != *parent_decl_ctx)
continue;
- ParseVariables(sc, *pdb_data, &variables);
+ ParseVariables(sc, *pdb_data, false, &variables);
matches = variables.GetSize() - old_size;
}
@@ -1107,7 +1110,7 @@
if (sc.comp_unit == nullptr)
continue;
- ParseVariables(sc, *pdb_data, &variables);
+ ParseVariables(sc, *pdb_data, false, &variables);
matches = variables.GetSize() - old_size;
}
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -106,7 +106,8 @@
uint32_t max_matches,
VariableList &variables) override;
- size_t ParseVariablesForContext(const SymbolContext &sc) override;
+ size_t ParseGlobalVariables(lldb_private::CompileUnit &comp_unit) override;
+ size_t ParseLocalVariablesRecursive(lldb_private::Function &func) override;
void AddSymbols(Symtab &symtab) override;
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1456,34 +1456,17 @@
return count;
}
-size_t SymbolFileNativePDB::ParseVariablesForContext(const SymbolContext &sc) {
- lldbassert(sc.function || sc.comp_unit);
-
+size_t SymbolFileNativePDB::ParseGlobalVariables(
+ lldb_private::CompileUnit &comp_unit) {
VariableListSP variables;
- if (sc.block) {
- PdbSymUid block_id(sc.block->GetID());
-
- size_t count = ParseVariablesForBlock(block_id.asCompilandSym());
- return count;
- }
-
- if (sc.function) {
- PdbSymUid block_id(sc.function->GetID());
-
- size_t count = ParseVariablesForBlock(block_id.asCompilandSym());
- return count;
- }
+ return ParseVariablesForCompileUnit(comp_unit, *variables);
+}
- if (sc.comp_unit) {
- variables = sc.comp_unit->GetVariableList(false);
- if (!variables) {
- variables = std::make_shared<VariableList>();
- sc.comp_unit->SetVariableList(variables);
- }
- return ParseVariablesForCompileUnit(*sc.comp_unit, *variables);
- }
+size_t SymbolFileNativePDB::ParseLocalVariablesRecursive(
+ lldb_private::Function &func) {
+ PdbSymUid block_id(func.GetID());
- llvm_unreachable("Unreachable!");
+ return ParseVariablesForBlock(block_id.asCompilandSym());
}
CompilerDecl SymbolFileNativePDB::GetDeclForUID(lldb::user_id_t uid) {
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -75,8 +75,8 @@
const lldb_private::SymbolContext &sc,
std::vector<lldb_private::ConstString> &imported_modules) override;
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
- size_t
- ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;
+ size_t ParseGlobalVariables(lldb_private::CompileUnit &comp_unit) override;
+ size_t ParseLocalVariablesRecursive(lldb_private::Function &func) override;
lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -695,11 +695,22 @@
return 0;
}
-size_t
-SymbolFileDWARFDebugMap::ParseVariablesForContext(const SymbolContext &sc) {
- SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc);
+size_t SymbolFileDWARFDebugMap::ParseGlobalVariables(CompileUnit &comp_unit) {
+ SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
+ if (oso_dwarf)
+ return oso_dwarf->ParseGlobalVariables(comp_unit);
+ return 0;
+}
+
+size_t SymbolFileDWARFDebugMap::ParseLocalVariablesRecursive(Function &func) {
+ CompileUnit *comp_unit = func.GetCompileUnit();
+ if (!comp_unit)
+ return 0;
+
+ SymbolFileDWARF *oso_dwarf = GetSymbolFile(*comp_unit);
+
if (oso_dwarf)
- return oso_dwarf->ParseVariablesForContext(sc);
+ return oso_dwarf->ParseLocalVariablesRecursive(func);
return 0;
}
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -128,8 +128,9 @@
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
+ size_t ParseGlobalVariables(lldb_private::CompileUnit &comp_unit) override;
size_t
- ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;
+ ParseLocalVariablesRecursive(lldb_private::Function &comp_unit) override;
lldb_private::Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3159,62 +3159,67 @@
return types_added;
}
-size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
+size_t SymbolFileDWARF::ParseGlobalVariables(CompileUnit &comp_unit) {
ASSERT_MODULE_LOCK(this);
- if (sc.comp_unit != NULL) {
- DWARFDebugInfo *info = DebugInfo();
- if (info == NULL)
- return 0;
+ DWARFDebugInfo *info = DebugInfo();
+ if (!info)
+ return 0;
- if (sc.function) {
- DWARFDIE function_die = info->GetDIE(DIERef(sc.function->GetID(), this));
+ DWARFUnit *dwarf_cu = info->GetCompileUnit(comp_unit.GetID());
- const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsAddress(
- DW_AT_low_pc, LLDB_INVALID_ADDRESS);
- if (func_lo_pc != LLDB_INVALID_ADDRESS) {
- const size_t num_variables = ParseVariables(
- sc, function_die.GetFirstChild(), func_lo_pc, true, true);
+ if (dwarf_cu == NULL)
+ return 0;
- // Let all blocks know they have parse all their variables
- sc.function->GetBlock(false).SetDidParseVariables(true, true);
- return num_variables;
- }
- } else if (sc.comp_unit) {
- DWARFUnit *dwarf_cu = info->GetCompileUnit(sc.comp_unit->GetID());
-
- if (dwarf_cu == NULL)
- return 0;
-
- uint32_t vars_added = 0;
- VariableListSP variables(sc.comp_unit->GetVariableList(false));
-
- if (variables.get() == NULL) {
- variables.reset(new VariableList());
- sc.comp_unit->SetVariableList(variables);
-
- DIEArray die_offsets;
- m_index->GetGlobalVariables(*dwarf_cu, die_offsets);
- const size_t num_matches = die_offsets.size();
- if (num_matches) {
- for (size_t i = 0; i < num_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
- if (die) {
- VariableSP var_sp(
- ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
- if (var_sp) {
- variables->AddVariableIfUnique(var_sp);
- ++vars_added;
- }
- } else
- m_index->ReportInvalidDIEOffset(die_ref.die_offset, "");
+ uint32_t vars_added = 0;
+ VariableListSP variables(comp_unit.GetVariableList(false));
+
+ if (variables.get() == NULL) {
+ variables.reset(new VariableList());
+ comp_unit.SetVariableList(variables);
+
+ DIEArray die_offsets;
+ m_index->GetGlobalVariables(*dwarf_cu, die_offsets);
+ const size_t num_matches = die_offsets.size();
+ if (num_matches) {
+ for (size_t i = 0; i < num_matches; ++i) {
+ const DIERef &die_ref = die_offsets[i];
+ DWARFDIE die = GetDIE(die_ref);
+ if (die) {
+ SymbolContext sc;
+ comp_unit.CalculateSymbolContext(&sc);
+ VariableSP var_sp(ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
+ if (var_sp) {
+ variables->AddVariableIfUnique(var_sp);
+ ++vars_added;
}
- }
+ } else
+ m_index->ReportInvalidDIEOffset(die_ref.die_offset, "");
}
- return vars_added;
}
}
- return 0;
+ return vars_added;
+}
+
+size_t SymbolFileDWARF::ParseLocalVariablesRecursive(Function &func) {
+ ASSERT_MODULE_LOCK(this);
+ DWARFDebugInfo *info = DebugInfo();
+ if (!info)
+ return 0;
+
+ DWARFDIE function_die = info->GetDIE(DIERef(func.GetID(), this));
+
+ const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsAddress(
+ DW_AT_low_pc, LLDB_INVALID_ADDRESS);
+ if (func_lo_pc != LLDB_INVALID_ADDRESS) {
+ SymbolContext sc;
+ func.CalculateSymbolContext(&sc);
+ const size_t num_variables = ParseVariables(
+ sc, function_die.GetFirstChild(), func_lo_pc, true, true);
+
+ // Let all blocks know they have parse all their variables
+ sc.function->GetBlock(false).SetDidParseVariables(true, true);
+ return num_variables;
+ }
}
VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
===================================================================
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
@@ -84,9 +84,9 @@
return 0;
}
- size_t ParseVariablesForContext(const SymbolContext &sc) override {
- return 0;
- }
+ size_t ParseGlobalVariables(CompileUnit &comp_unit) override { return 0; }
+ size_t ParseLocalVariablesRecursive(Function &function) override { return 0; }
+
Type *ResolveTypeUID(lldb::user_id_t type_uid) override { return nullptr; }
llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
lldb::user_id_t type_uid,
Index: lldb/source/Core/Module.cpp
===================================================================
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -359,30 +359,27 @@
if (num_comp_units == 0)
return;
- SymbolContext sc;
- sc.module_sp = shared_from_this();
SymbolVendor *symbols = GetSymbolVendor();
for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++) {
- sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
- if (!sc.comp_unit)
+ CompUnitSP comp_unit = symbols->GetCompileUnitAtIndex(cu_idx);
+ if (!comp_unit)
continue;
- symbols->ParseVariablesForContext(sc);
+ symbols->ParseGlobalVariables(*comp_unit);
- symbols->ParseFunctions(*sc.comp_unit);
+ symbols->ParseFunctions(*comp_unit);
- sc.comp_unit->ForeachFunction([&sc, &symbols](const FunctionSP &f) {
+ comp_unit->ForeachFunction([&symbols](const FunctionSP &f) {
symbols->ParseBlocksRecursive(*f);
// Parse the variables for this function and all its blocks
- sc.function = f.get();
- symbols->ParseVariablesForContext(sc);
+ symbols->ParseLocalVariablesRecursive(*f);
return false;
});
// Parse all types for this compile unit
- symbols->ParseTypes(*sc.comp_unit);
+ symbols->ParseTypes(*comp_unit);
}
}
Index: lldb/include/lldb/Symbol/SymbolVendor.h
===================================================================
--- lldb/include/lldb/Symbol/SymbolVendor.h
+++ lldb/include/lldb/Symbol/SymbolVendor.h
@@ -66,7 +66,8 @@
virtual size_t ParseBlocksRecursive(Function &func);
- virtual size_t ParseVariablesForContext(const SymbolContext &sc);
+ virtual size_t ParseGlobalVariables(CompileUnit &comp_unit);
+ virtual size_t ParseLocalVariablesRecursive(Function &func);
virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
Index: lldb/include/lldb/Symbol/SymbolFile.h
===================================================================
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -138,7 +138,8 @@
ParseImportedModules(const SymbolContext &sc,
std::vector<ConstString> &imported_modules) = 0;
virtual size_t ParseBlocksRecursive(Function &func) = 0;
- virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0;
+ virtual size_t ParseGlobalVariables(CompileUnit &comp_unit) = 0;
+ virtual size_t ParseLocalVariablesRecursive(Function &func) = 0;
virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0;
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits