diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index d84d248ddd75..424e5f498eac 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -125,22 +125,19 @@ public: virtual uint32_t GetNumCompileUnits() = 0; virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) = 0; - virtual lldb::LanguageType - ParseCompileUnitLanguage(const SymbolContext &sc) = 0; - virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitLineTable(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files) = 0; - virtual bool - ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) { - return false; - } + virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0; + virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0; + virtual bool ParseLineTable(CompileUnit &comp_unit) = 0; + virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0; + virtual bool ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) = 0; + virtual size_t ParseTypes(CompileUnit &comp_unit) = 0; + virtual bool ParseIsOptimized(CompileUnit &comp_unit) { return false; } + virtual bool ParseImportedModules(const SymbolContext &sc, std::vector &imported_modules) = 0; virtual size_t ParseFunctionBlocks(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 0155a0806f46..1dcd028dcc38 100644 --- a/lldb/include/lldb/Symbol/SymbolVendor.h +++ b/lldb/include/lldb/Symbol/SymbolVendor.h @@ -46,26 +46,26 @@ public: virtual void Dump(Stream *s); - virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc); + virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit); - virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc); + virtual size_t ParseFunctions(CompileUnit &comp_unit); - virtual bool ParseCompileUnitLineTable(const SymbolContext &sc); + virtual bool ParseLineTable(CompileUnit &comp_unit); - virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc); + virtual bool ParseDebugMacros(CompileUnit &comp_unit); - virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files); + virtual bool ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files); - virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc); + virtual bool ParseIsOptimized(CompileUnit &comp_unit); + + virtual size_t ParseTypes(CompileUnit &comp_unit); virtual bool ParseImportedModules(const SymbolContext &sc, std::vector &imported_modules); virtual size_t ParseFunctionBlocks(const SymbolContext &sc); - virtual size_t ParseTypesForCompileUnit(CompileUnit &comp_unit); - virtual size_t ParseVariablesForContext(const SymbolContext &sc); virtual Type *ResolveTypeUID(lldb::user_id_t type_uid); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index b9edea33b41f..6595d1340796 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -365,23 +365,23 @@ void Module::ParseAllDebugSymbols() { 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) { - sc.function = nullptr; + if (!sc.comp_unit) + continue; + + symbols->ParseVariablesForContext(sc); + + symbols->ParseFunctions(*sc.comp_unit); + + sc.comp_unit->ForeachFunction([&sc, &symbols](const FunctionSP &f) { + sc.function = f.get(); + symbols->ParseFunctionBlocks(sc); + // Parse the variables for this function and all its blocks symbols->ParseVariablesForContext(sc); + return false; + }); - symbols->ParseCompileUnitFunctions(sc); - - sc.comp_unit->ForeachFunction([&sc, &symbols](const FunctionSP &f) { - sc.function = f.get(); - symbols->ParseFunctionBlocks(sc); - // Parse the variables for this function and all its blocks - symbols->ParseVariablesForContext(sc); - return false; - }); - - // Parse all types for this compile unit - symbols->ParseTypesForCompileUnit(*sc.comp_unit); - } + // Parse all types for this compile unit + symbols->ParseTypes(*sc.comp_unit); } } diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp index ebacbd292da1..5d26c715bec6 100644 --- a/lldb/source/Core/SearchFilter.cpp +++ b/lldb/source/Core/SearchFilter.cpp @@ -328,9 +328,7 @@ SearchFilter::DoCUIteration(const ModuleSP &module_sp, SymbolVendor *sym_vendor = module_sp->GetSymbolVendor(); if (!sym_vendor) continue; - SymbolContext sym_ctx; - cu_sp->CalculateSymbolContext(&sym_ctx); - if (!sym_vendor->ParseCompileUnitFunctions(sym_ctx)) + if (!sym_vendor->ParseFunctions(*cu_sp)) continue; // If we got any functions, use ForeachFunction to do the iteration. cu_sp->ForeachFunction([&](const FunctionSP &func_sp) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h index b439d7fe590f..24d5f26745dc 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h @@ -18,6 +18,7 @@ class DWARFDIE; namespace lldb_private { +class CompileUnit; class ExecutionContext; } class SymbolFileDWARF; @@ -32,7 +33,7 @@ public: bool *type_is_new_ptr) = 0; virtual lldb_private::Function * - ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, + ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die) = 0; virtual bool diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index d8e517e718a8..ede4518636e4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -415,8 +415,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID || - encoding_data_type == Type::eEncodingIsTypedefUID) && - sc.comp_unit != NULL) { + encoding_data_type == Type::eEncodingIsTypedefUID)) { if (tag == DW_TAG_pointer_type) { DWARFDIE target_die = die.GetReferencedDIE(DW_AT_type); @@ -552,9 +551,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: - decl.SetFile( - sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( - form_value.Unsigned())); + decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( + form_value.Unsigned())); break; case DW_AT_decl_line: @@ -1295,10 +1293,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (die.HasChildren()) { bool skip_artificial = true; - ParseChildParameters(sc, containing_decl_ctx, die, skip_artificial, - is_static, is_variadic, has_template_params, - function_param_types, function_param_decls, - type_quals); + ParseChildParameters(*sc.comp_unit, containing_decl_ctx, die, + skip_artificial, is_static, is_variadic, + has_template_params, function_param_types, + function_param_decls, type_quals); } bool ignore_containing_context = false; @@ -2558,7 +2556,7 @@ protected: }; #endif -Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, +Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit, const DWARFDIE &die) { DWARFRangeList func_ranges; const char *name = NULL; @@ -2619,9 +2617,9 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE(die, nullptr); - ParseChildParameters(sc, containing_decl_ctx, die, true, is_static, - is_variadic, has_template_params, param_types, - param_decls, type_quals); + ParseChildParameters(comp_unit, containing_decl_ctx, die, true, + is_static, is_variadic, has_template_params, + param_types, param_decls, type_quals); sstr << "("; for (size_t i = 0; i < param_types.size(); i++) { if (i > 0) @@ -2642,7 +2640,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, std::unique_ptr decl_ap; if (decl_file != 0 || decl_line != 0 || decl_column != 0) decl_ap.reset(new Declaration( - sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), + comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column)); SymbolFileDWARF *dwarf = die.GetDWARF(); @@ -2653,7 +2651,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, if (dwarf->FixupAddress(func_range.GetBaseAddress())) { const user_id_t func_user_id = die.GetID(); - func_sp.reset(new Function(sc.comp_unit, + func_sp.reset(new Function(&comp_unit, func_user_id, // UserID is the DIE offset func_user_id, func_name, func_type, func_range)); // first address range @@ -2661,7 +2659,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, if (func_sp.get() != NULL) { if (frame_base.IsValid()) func_sp->GetFrameBaseExpression() = frame_base; - sc.comp_unit->AddFunction(func_sp); + comp_unit.AddFunction(func_sp); return func_sp.get(); } } @@ -3310,7 +3308,7 @@ bool DWARFASTParserClang::ParseChildMembers( } size_t DWARFASTParserClang::ParseChildParameters( - const SymbolContext &sc, clang::DeclContext *containing_decl_ctx, + CompileUnit &comp_unit, clang::DeclContext *containing_decl_ctx, const DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, bool &has_template_params, std::vector &function_param_types, @@ -3342,7 +3340,7 @@ size_t DWARFASTParserClang::ParseChildParameters( if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: - decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( + decl.SetFile(comp_unit.GetSupportFiles().GetFileSpecAtIndex( form_value.Unsigned())); break; case DW_AT_decl_line: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index f16938a78656..63e058d7bf21 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -22,6 +22,9 @@ #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" +namespace lldb_private { +class CompileUnit; +} class DWARFDebugInfoEntry; class DWARFDIECollection; class SymbolFileDWARF; @@ -38,7 +41,7 @@ public: bool *type_is_new_ptr) override; lldb_private::Function * - ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, + ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die) override; bool @@ -89,7 +92,7 @@ protected: lldb_private::ClangASTImporter::LayoutInfo &layout_info); size_t - ParseChildParameters(const lldb_private::SymbolContext &sc, + ParseChildParameters(lldb_private::CompileUnit &comp_unit, clang::DeclContext *containing_decl_ctx, const DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index acea7c74840c..c8295e325554 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -885,8 +885,8 @@ CompUnitSP SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) { return cu_sp; } -Function *SymbolFileDWARF::ParseCompileUnitFunction(const SymbolContext &sc, - const DWARFDIE &die) { +Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit, + const DWARFDIE &die) { ASSERT_MODULE_LOCK(this); if (die.IsValid()) { TypeSystem *type_system = @@ -895,7 +895,7 @@ Function *SymbolFileDWARF::ParseCompileUnitFunction(const SymbolContext &sc, if (type_system) { DWARFASTParser *dwarf_ast = type_system->GetDWARFParser(); if (dwarf_ast) - return dwarf_ast->ParseFunctionFromDWARF(sc, die); + return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die); } } return nullptr; @@ -909,22 +909,19 @@ bool SymbolFileDWARF::FixupAddress(Address &addr) { // This is a normal DWARF file, no address fixups need to happen return true; } -lldb::LanguageType -SymbolFileDWARF::ParseCompileUnitLanguage(const SymbolContext &sc) { +lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) return dwarf_cu->GetLanguageType(); else return eLanguageTypeUnknown; } -size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { +size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); size_t functions_added = 0; - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { DWARFDIECollection function_dies; const size_t num_functions = @@ -932,8 +929,8 @@ size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { size_t func_idx; for (func_idx = 0; func_idx < num_functions; ++func_idx) { DWARFDIE die = function_dies.GetDIEAtIndex(func_idx); - if (sc.comp_unit->FindFunctionByUID(die.GetID()).get() == NULL) { - if (ParseCompileUnitFunction(sc, die)) + if (comp_unit.FindFunctionByUID(die.GetID()).get() == NULL) { + if (ParseFunction(comp_unit, die)) ++functions_added; } } @@ -942,11 +939,10 @@ size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { return functions_added; } -bool SymbolFileDWARF::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { +bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly(); @@ -958,9 +954,9 @@ bool SymbolFileDWARF::ParseCompileUnitSupportFiles( if (stmt_list != DW_INVALID_OFFSET) { // All file indexes in DWARF are one based and a file of index zero is // supposed to be the compile unit itself. - support_files.Append(*sc.comp_unit); + support_files.Append(comp_unit); return DWARFDebugLine::ParseSupportFiles( - sc.comp_unit->GetModule(), get_debug_line_data(), cu_comp_dir, + comp_unit.GetModule(), get_debug_line_data(), cu_comp_dir, stmt_list, support_files, dwarf_cu); } } @@ -968,10 +964,9 @@ bool SymbolFileDWARF::ParseCompileUnitSupportFiles( return false; } -bool SymbolFileDWARF::ParseCompileUnitIsOptimized( - const lldb_private::SymbolContext &sc) { +bool SymbolFileDWARF::ParseIsOptimized(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) return dwarf_cu->GetIsOptimized(); return false; @@ -1057,13 +1052,12 @@ static void ParseDWARFLineTableCallback(dw_offset_t offset, } } -bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { +bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - if (sc.comp_unit->GetLineTable() != NULL) + if (comp_unit.GetLineTable() != NULL) return true; - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly(); if (dwarf_cu_die) { @@ -1071,7 +1065,7 @@ bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list, DW_INVALID_OFFSET); if (cu_line_offset != DW_INVALID_OFFSET) { - std::unique_ptr line_table_ap(new LineTable(sc.comp_unit)); + std::unique_ptr line_table_ap(new LineTable(&comp_unit)); if (line_table_ap.get()) { ParseDWARFLineTableCallbackInfo info; info.line_table = line_table_ap.get(); @@ -1106,10 +1100,10 @@ bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { // are not linked. We need to link the line table and convert the // addresses that are relative to the .o file into addresses for // the main executable. - sc.comp_unit->SetLineTable( + comp_unit.SetLineTable( debug_map_symfile->LinkOSOLineTable(this, line_table_ap.get())); } else { - sc.comp_unit->SetLineTable(line_table_ap.release()); + comp_unit.SetLineTable(line_table_ap.release()); return true; } } @@ -1141,11 +1135,10 @@ SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset) { return debug_macros_sp; } -bool SymbolFileDWARF::ParseCompileUnitDebugMacros(const SymbolContext &sc) { +bool SymbolFileDWARF::ParseDebugMacros(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu == nullptr) return false; @@ -1161,7 +1154,7 @@ bool SymbolFileDWARF::ParseCompileUnitDebugMacros(const SymbolContext &sc) { if (sect_offset == DW_INVALID_OFFSET) return false; - sc.comp_unit->SetDebugMacros(ParseDebugMacros(§_offset)); + comp_unit.SetDebugMacros(ParseDebugMacros(§_offset)); return true; } @@ -1583,7 +1576,7 @@ bool SymbolFileDWARF::GetFunction(const DWARFDIE &die, SymbolContext &sc) { sc.function = sc.comp_unit->FindFunctionByUID(die.GetID()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, die); + sc.function = ParseFunction(*sc.comp_unit, die); if (sc.function) { sc.module_sp = sc.function->CalculateSymbolContextModule(); @@ -1846,7 +1839,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, sc.function = sc.comp_unit->FindFunctionByUID(function_die.GetID()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, function_die); + sc.function = ParseFunction(*sc.comp_unit, function_die); if (sc.function && (resolve_scope & eSymbolContextBlock)) block_die = function_die.LookupDeepestBlock(file_vm_addr); @@ -1987,7 +1980,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec, .get(); if (sc.function == NULL) sc.function = - ParseCompileUnitFunction(sc, function_die); + ParseFunction(*sc.comp_unit, function_die); if (sc.function && (resolve_scope & eSymbolContextBlock)) @@ -3149,7 +3142,7 @@ size_t SymbolFileDWARF::ParseFunctionBlocks(const SymbolContext &sc) { return functions_added; } -size_t SymbolFileDWARF::ParseTypesForCompileUnit(CompileUnit &comp_unit) { +size_t SymbolFileDWARF::ParseTypes(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); size_t types_added = 0; DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index e9f98d55317c..411f791cc979 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -107,23 +107,20 @@ 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; - bool - ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) override; + bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override; + + size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override; bool ParseImportedModules( const lldb_private::SymbolContext &sc, @@ -131,9 +128,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; @@ -362,9 +356,8 @@ protected: bool GetFunction(const DWARFDIE &die, lldb_private::SymbolContext &sc); - lldb_private::Function * - ParseCompileUnitFunction(const lldb_private::SymbolContext &sc, - const DWARFDIE &die); + lldb_private::Function *ParseFunction(lldb_private::CompileUnit &comp_unit, + const DWARFDIE &die); size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc, lldb_private::Block *parent_block, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 2ee4fc8c3ae7..c2b84694bd25 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -488,7 +488,12 @@ ObjectFile *SymbolFileDWARFDebugMap::GetObjectFileByOSOIndex(uint32_t oso_idx) { SymbolFileDWARF * SymbolFileDWARFDebugMap::GetSymbolFile(const SymbolContext &sc) { - CompileUnitInfo *comp_unit_info = GetCompUnitInfo(sc); + return GetSymbolFile(*sc.comp_unit); +} + +SymbolFileDWARF * +SymbolFileDWARFDebugMap::GetSymbolFile(const CompileUnit &comp_unit) { + CompileUnitInfo *comp_unit_info = GetCompUnitInfo(comp_unit); if (comp_unit_info) return GetSymbolFileByCompUnitInfo(comp_unit_info); return NULL; @@ -596,9 +601,14 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) { SymbolFileDWARFDebugMap::CompileUnitInfo * SymbolFileDWARFDebugMap::GetCompUnitInfo(const SymbolContext &sc) { + return GetCompUnitInfo(*sc.comp_unit); +} + +SymbolFileDWARFDebugMap::CompileUnitInfo * +SymbolFileDWARFDebugMap::GetCompUnitInfo(const CompileUnit &comp_unit) { const uint32_t cu_count = GetNumCompileUnits(); for (uint32_t i = 0; i < cu_count; ++i) { - if (sc.comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) + if (comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) return &m_compile_unit_infos[i]; } return NULL; @@ -616,50 +626,46 @@ size_t SymbolFileDWARFDebugMap::GetCompUnitInfosForModule( } lldb::LanguageType -SymbolFileDWARFDebugMap::ParseCompileUnitLanguage(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitLanguage(sc); + return oso_dwarf->ParseLanguage(comp_unit); return eLanguageTypeUnknown; } -size_t -SymbolFileDWARFDebugMap::ParseCompileUnitFunctions(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitFunctions(sc); + return oso_dwarf->ParseFunctions(comp_unit); return 0; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitLineTable( - const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseLineTable(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitLineTable(sc); + return oso_dwarf->ParseLineTable(comp_unit); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitDebugMacros( - const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitDebugMacros(sc); + return oso_dwarf->ParseDebugMacros(comp_unit); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitSupportFiles(sc, support_files); + return oso_dwarf->ParseSupportFiles(comp_unit, support_files); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitIsOptimized( - const lldb_private::SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseIsOptimized(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitIsOptimized(sc); + return oso_dwarf->ParseIsOptimized(comp_unit); return false; } @@ -678,13 +684,10 @@ size_t SymbolFileDWARFDebugMap::ParseFunctionBlocks(const SymbolContext &sc) { return 0; } -size_t -SymbolFileDWARFDebugMap::ParseTypesForCompileUnit(CompileUnit &comp_unit) { - SymbolContext sc; - sc.comp_unit = &comp_unit; - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseTypes(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseTypesForCompileUnit(comp_unit); + return oso_dwarf->ParseTypes(comp_unit); return 0; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index e641037a814d..f8bef7e369b3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -56,25 +56,26 @@ public: lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; lldb::LanguageType - ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) override; - size_t - ParseCompileUnitFunctions(const lldb_private::SymbolContext &sc) override; - bool - ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc) override; - bool - ParseCompileUnitDebugMacros(const lldb_private::SymbolContext &sc) override; - bool ParseCompileUnitSupportFiles( - const lldb_private::SymbolContext &sc, - lldb_private::FileSpecList &support_files) override; - bool - ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) override; + ParseLanguage(lldb_private::CompileUnit &comp_unit) override; + + size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override; + + bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override; + + bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override; + + bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, + lldb_private::FileSpecList &support_files) override; + + bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override; + + size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override; + bool ParseImportedModules( const lldb_private::SymbolContext &sc, std::vector &imported_modules) override; 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; @@ -199,6 +200,7 @@ protected: bool GetFileSpecForSO(uint32_t oso_idx, lldb_private::FileSpec &file_spec); CompileUnitInfo *GetCompUnitInfo(const lldb_private::SymbolContext &sc); + CompileUnitInfo *GetCompUnitInfo(const lldb_private::CompileUnit &comp_unit); size_t GetCompUnitInfosForModule(const lldb_private::Module *oso_module, std::vector &cu_infos); @@ -216,6 +218,7 @@ protected: uint32_t GetCompUnitInfoIndex(const CompileUnitInfo *comp_unit_info); SymbolFileDWARF *GetSymbolFile(const lldb_private::SymbolContext &sc); + SymbolFileDWARF *GetSymbolFile(const lldb_private::CompileUnit &comp_unit); SymbolFileDWARF *GetSymbolFileByCompUnitInfo(CompileUnitInfo *comp_unit_info); diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index b9fdc1408c7d..7c770b65e4cc 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -882,13 +882,8 @@ lldb::CompUnitSP SymbolFileNativePDB::ParseCompileUnitAtIndex(uint32_t index) { return GetOrCreateCompileUnit(item); } -lldb::LanguageType -SymbolFileNativePDB::ParseCompileUnitLanguage(const 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; - PdbSymUid uid(sc.comp_unit->GetID()); +lldb::LanguageType SymbolFileNativePDB::ParseLanguage(CompileUnit &comp_unit) { + PdbSymUid uid(comp_unit.GetID()); lldbassert(uid.kind() == PdbSymUidKind::Compiland); CompilandIndexItem *item = @@ -902,15 +897,13 @@ SymbolFileNativePDB::ParseCompileUnitLanguage(const SymbolContext &sc) { void SymbolFileNativePDB::AddSymbols(Symtab &symtab) { return; } -size_t SymbolFileNativePDB::ParseCompileUnitFunctions(const SymbolContext &sc) { - lldbassert(sc.comp_unit); - - PdbSymUid uid{sc.comp_unit->GetID()}; +size_t SymbolFileNativePDB::ParseFunctions(CompileUnit &comp_unit) { + PdbSymUid uid{comp_unit.GetID()}; lldbassert(uid.kind() == PdbSymUidKind::Compiland); uint16_t modi = uid.asCompiland().modi; CompilandIndexItem &cii = m_index->compilands().GetOrCreateCompiland(modi); - size_t count = sc.comp_unit->GetNumFunctions(); + size_t count = comp_unit.GetNumFunctions(); const CVSymbolArray &syms = cii.m_debug_stream.getSymbolArray(); for (auto iter = syms.begin(); iter != syms.end(); ++iter) { if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) @@ -918,10 +911,10 @@ size_t SymbolFileNativePDB::ParseCompileUnitFunctions(const SymbolContext &sc) { PdbCompilandSymId sym_id{modi, iter.offset()}; - FunctionSP func = GetOrCreateFunction(sym_id, *sc.comp_unit); + FunctionSP func = GetOrCreateFunction(sym_id, comp_unit); } - size_t new_count = sc.comp_unit->GetNumFunctions(); + size_t new_count = comp_unit.GetNumFunctions(); lldbassert(new_count >= count); return new_count - count; } @@ -1037,18 +1030,17 @@ static void TerminateLineSequence(LineTable &table, table.InsertSequence(seq.release()); } -bool SymbolFileNativePDB::ParseCompileUnitLineTable(const SymbolContext &sc) { +bool SymbolFileNativePDB::ParseLineTable(CompileUnit &comp_unit) { // Unfortunately LLDB is set up to parse the entire compile unit line table // all at once, even if all it really needs is line info for a specific // function. In the future it would be nice if it could set the sc.m_function // member, and we could only get the line info for the function in question. - lldbassert(sc.comp_unit); - PdbSymUid cu_id(sc.comp_unit->GetID()); + PdbSymUid cu_id(comp_unit.GetID()); lldbassert(cu_id.kind() == PdbSymUidKind::Compiland); CompilandIndexItem *cci = m_index->compilands().GetCompiland(cu_id.asCompiland().modi); lldbassert(cci); - auto line_table = llvm::make_unique(sc.comp_unit); + auto line_table = llvm::make_unique(&comp_unit); // This is basically a copy of the .debug$S subsections from all original COFF // object files merged together with address relocations applied. We are @@ -1110,20 +1102,18 @@ bool SymbolFileNativePDB::ParseCompileUnitLineTable(const SymbolContext &sc) { if (line_table->GetSize() == 0) return false; - sc.comp_unit->SetLineTable(line_table.release()); + comp_unit.SetLineTable(line_table.release()); return true; } -bool SymbolFileNativePDB::ParseCompileUnitDebugMacros(const SymbolContext &sc) { +bool SymbolFileNativePDB::ParseDebugMacros(CompileUnit &comp_unit) { // PDB doesn't contain information about macros return false; } -bool SymbolFileNativePDB::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { - lldbassert(sc.comp_unit); - - PdbSymUid cu_id(sc.comp_unit->GetID()); +bool SymbolFileNativePDB::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { + PdbSymUid cu_id(comp_unit.GetID()); lldbassert(cu_id.kind() == PdbSymUidKind::Compiland); CompilandIndexItem *cci = m_index->compilands().GetCompiland(cu_id.asCompiland().modi); @@ -1274,7 +1264,7 @@ size_t SymbolFileNativePDB::FindTypesByName(llvm::StringRef name, return match_count; } -size_t SymbolFileNativePDB::ParseTypesForCompileUnit(CompileUnit &comp_unit) { +size_t SymbolFileNativePDB::ParseTypes(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 ca28023e45f7..d12313aa3804 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -82,16 +82,18 @@ public: lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; - lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc) override; + lldb::LanguageType + ParseLanguage(lldb_private::CompileUnit &comp_unit) override; - size_t ParseCompileUnitFunctions(const SymbolContext &sc) override; + size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override; - bool ParseCompileUnitLineTable(const SymbolContext &sc) override; + bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override; - bool ParseCompileUnitDebugMacros(const SymbolContext &sc) override; + bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override; - bool ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files) override; + bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, + FileSpecList &support_files) override; + size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override; bool ParseImportedModules(const SymbolContext &sc, @@ -104,8 +106,6 @@ public: uint32_t max_matches, VariableList &variables) 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 916a7af422d3..1878671662ae 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(); @@ -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(sc.comp_unit, pdb_func.getSymIndexId(), + std::make_shared(&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(); 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(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 index_map; BuildSupportFileIdToSupportFileIndexMap(*compiland_up, index_map); - auto line_table = llvm::make_unique(sc.comp_unit); + auto line_table = llvm::make_unique(&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 307e69147da9..10fa3b4ea24e 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, @@ -81,9 +79,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; @@ -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); diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index f405d8470a8c..81d4bc1fd442 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -131,15 +131,13 @@ CompUnitSP SymbolFileSymtab::ParseCompileUnitAtIndex(uint32_t idx) { return cu_sp; } -lldb::LanguageType -SymbolFileSymtab::ParseCompileUnitLanguage(const SymbolContext &sc) { +lldb::LanguageType SymbolFileSymtab::ParseLanguage(CompileUnit &comp_unit) { return eLanguageTypeUnknown; } -size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { +size_t SymbolFileSymtab::ParseFunctions(CompileUnit &comp_unit) { size_t num_added = 0; // We must at least have a valid compile unit - assert(sc.comp_unit != NULL); const Symtab *symtab = m_obj_file->GetSymtab(); const Symbol *curr_symbol = NULL; const Symbol *next_symbol = NULL; @@ -185,7 +183,7 @@ size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { } FunctionSP func_sp( - new Function(sc.comp_unit, + new Function(&comp_unit, symbol_idx, // UserID is the DIE offset LLDB_INVALID_UID, // We don't have any type info // for this function @@ -194,7 +192,7 @@ size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { func_range)); // first address range if (func_sp.get() != NULL) { - sc.comp_unit->AddFunction(func_sp); + comp_unit.AddFunction(func_sp); ++num_added; } } @@ -207,16 +205,16 @@ size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { return num_added; } -bool SymbolFileSymtab::ParseCompileUnitLineTable(const SymbolContext &sc) { +size_t SymbolFileSymtab::ParseTypes(CompileUnit &comp_unit) { return 0; } + +bool SymbolFileSymtab::ParseLineTable(CompileUnit &comp_unit) { return false; } + +bool SymbolFileSymtab::ParseDebugMacros(CompileUnit &comp_unit) { return false; } -bool SymbolFileSymtab::ParseCompileUnitDebugMacros(const SymbolContext &sc) { - return false; -} - -bool SymbolFileSymtab::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { +bool SymbolFileSymtab::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { return false; } @@ -229,10 +227,6 @@ size_t SymbolFileSymtab::ParseFunctionBlocks(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 4cfab1da5e9f..3535e20bf938 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -49,20 +49,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, @@ -70,9 +68,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; diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index 63317ae99e86..74512c891440 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -182,9 +182,7 @@ lldb::LanguageType CompileUnit::GetLanguage() { m_flags.Set(flagsParsedLanguage); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - m_language = symbol_vendor->ParseCompileUnitLanguage(sc); + m_language = symbol_vendor->ParseLanguage(*this); } } } @@ -196,11 +194,8 @@ LineTable *CompileUnit::GetLineTable() { if (m_flags.IsClear(flagsParsedLineTable)) { m_flags.Set(flagsParsedLineTable); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); - if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - symbol_vendor->ParseCompileUnitLineTable(sc); - } + if (symbol_vendor) + symbol_vendor->ParseLineTable(*this); } } return m_line_table_ap.get(); @@ -220,9 +215,7 @@ DebugMacros *CompileUnit::GetDebugMacros() { m_flags.Set(flagsParsedDebugMacros); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - symbol_vendor->ParseCompileUnitDebugMacros(sc); + symbol_vendor->ParseDebugMacros(*this); } } } @@ -387,9 +380,7 @@ bool CompileUnit::GetIsOptimized() { if (m_is_optimized == eLazyBoolCalculate) { m_is_optimized = eLazyBoolNo; if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (symbol_vendor->ParseCompileUnitIsOptimized(sc)) + if (symbol_vendor->ParseIsOptimized(*this)) m_is_optimized = eLazyBoolYes; } } @@ -419,9 +410,7 @@ FileSpecList &CompileUnit::GetSupportFiles() { m_flags.Set(flagsParsedSupportFiles); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - symbol_vendor->ParseCompileUnitSupportFiles(sc, m_support_files); + symbol_vendor->ParseSupportFiles(*this, m_support_files); } } } diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index 47f264f9841a..803011f69db4 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -118,63 +118,62 @@ size_t SymbolVendor::GetNumCompileUnits() { return m_compile_units.size(); } -lldb::LanguageType -SymbolVendor::ParseCompileUnitLanguage(const SymbolContext &sc) { +lldb::LanguageType SymbolVendor::ParseLanguage(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitLanguage(sc); + return m_sym_file_ap->ParseLanguage(comp_unit); } return eLanguageTypeUnknown; } -size_t SymbolVendor::ParseCompileUnitFunctions(const SymbolContext &sc) { +size_t SymbolVendor::ParseFunctions(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitFunctions(sc); + return m_sym_file_ap->ParseFunctions(comp_unit); } return 0; } -bool SymbolVendor::ParseCompileUnitLineTable(const SymbolContext &sc) { +bool SymbolVendor::ParseLineTable(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitLineTable(sc); + return m_sym_file_ap->ParseLineTable(comp_unit); } return false; } -bool SymbolVendor::ParseCompileUnitDebugMacros(const SymbolContext &sc) { +bool SymbolVendor::ParseDebugMacros(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitDebugMacros(sc); + return m_sym_file_ap->ParseDebugMacros(comp_unit); } return false; } -bool SymbolVendor::ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files) { +bool SymbolVendor::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files); + return m_sym_file_ap->ParseSupportFiles(comp_unit, support_files); } return false; } -bool SymbolVendor::ParseCompileUnitIsOptimized(const SymbolContext &sc) { +bool SymbolVendor::ParseIsOptimized(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitIsOptimized(sc); + return m_sym_file_ap->ParseIsOptimized(comp_unit); } return false; } @@ -200,12 +199,12 @@ size_t SymbolVendor::ParseFunctionBlocks(const SymbolContext &sc) { return 0; } -size_t SymbolVendor::ParseTypesForCompileUnit(CompileUnit &comp_unit) { +size_t SymbolVendor::ParseTypes(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseTypesForCompileUnit(comp_unit); + return m_sym_file_ap->ParseTypes(comp_unit); } return 0; }