diff options
Diffstat (limited to 'source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp')
-rw-r--r-- | source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 237 |
1 files changed, 112 insertions, 125 deletions
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 8ec64dbaf764..a50d4e460bae 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -41,7 +41,7 @@ using namespace lldb_private; // Subclass lldb_private::Module so we can intercept the // "Module::GetObjectFile()" (so we can fixup the object file sections) and -// also for "Module::GetSymbolVendor()" (so we can fixup the symbol file id. +// also for "Module::GetSymbolFile()" (so we can fixup the symbol file id. const SymbolFileDWARFDebugMap::FileRangeMap & SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap( @@ -60,11 +60,11 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap( return file_range_map; Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_MAP)); - if (log) - log->Printf( - "%p: SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap ('%s')", - static_cast<void *>(this), - oso_module->GetSpecificationDescription().c_str()); + LLDB_LOGF( + log, + "%p: SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap ('%s')", + static_cast<void *>(this), + oso_module->GetSpecificationDescription().c_str()); std::vector<SymbolFileDWARFDebugMap::CompileUnitInfo *> cu_infos; if (exe_symfile->GetCompUnitInfosForModule(oso_module, cu_infos)) { @@ -173,12 +173,12 @@ public: ~DebugMapModule() override = default; - SymbolVendor * - GetSymbolVendor(bool can_create = true, - lldb_private::Stream *feedback_strm = nullptr) override { + SymbolFile * + GetSymbolFile(bool can_create = true, + lldb_private::Stream *feedback_strm = nullptr) override { // Scope for locker if (m_symfile_up.get() || !can_create) - return m_symfile_up.get(); + return m_symfile_up ? m_symfile_up->GetSymbolFile() : nullptr; ModuleSP exe_module_sp(m_exe_module_wp.lock()); if (exe_module_sp) { @@ -186,30 +186,28 @@ public: ObjectFile *oso_objfile = GetObjectFile(); if (oso_objfile) { std::lock_guard<std::recursive_mutex> guard(m_mutex); - SymbolVendor *symbol_vendor = - Module::GetSymbolVendor(can_create, feedback_strm); - if (symbol_vendor) { + if (SymbolFile *symfile = + Module::GetSymbolFile(can_create, feedback_strm)) { // Set a pointer to this class to set our OSO DWARF file know that // the DWARF is being used along with a debug map and that it will // have the remapped sections that we do below. SymbolFileDWARF *oso_symfile = - SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF( - symbol_vendor->GetSymbolFile()); + SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(symfile); if (!oso_symfile) return nullptr; ObjectFile *exe_objfile = exe_module_sp->GetObjectFile(); - SymbolVendor *exe_sym_vendor = exe_module_sp->GetSymbolVendor(); + SymbolFile *exe_symfile = exe_module_sp->GetSymbolFile(); - if (exe_objfile && exe_sym_vendor) { + if (exe_objfile && exe_symfile) { oso_symfile->SetDebugMapModule(exe_module_sp); // Set the ID of the symbol file DWARF to the index of the OSO // shifted left by 32 bits to provide a unique prefix for any // UserID's that get created in the symbol file. oso_symfile->SetID(((uint64_t)m_cu_idx + 1ull) << 32ull); } - return symbol_vendor; + return symfile; } } } @@ -239,13 +237,13 @@ const char *SymbolFileDWARFDebugMap::GetPluginDescriptionStatic() { return "DWARF and DWARF3 debug symbol file reader (debug map)."; } -SymbolFile *SymbolFileDWARFDebugMap::CreateInstance(ObjectFile *obj_file) { - return new SymbolFileDWARFDebugMap(obj_file); +SymbolFile *SymbolFileDWARFDebugMap::CreateInstance(ObjectFileSP objfile_sp) { + return new SymbolFileDWARFDebugMap(std::move(objfile_sp)); } -SymbolFileDWARFDebugMap::SymbolFileDWARFDebugMap(ObjectFile *ofile) - : SymbolFile(ofile), m_flags(), m_compile_unit_infos(), m_func_indexes(), - m_glob_indexes(), +SymbolFileDWARFDebugMap::SymbolFileDWARFDebugMap(ObjectFileSP objfile_sp) + : SymbolFile(std::move(objfile_sp)), m_flags(), m_compile_unit_infos(), + m_func_indexes(), m_glob_indexes(), m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {} SymbolFileDWARFDebugMap::~SymbolFileDWARFDebugMap() {} @@ -260,12 +258,12 @@ void SymbolFileDWARFDebugMap::InitOSO() { // If the object file has been stripped, there is no sense in looking further // as all of the debug symbols for the debug map will not be available - if (m_obj_file->IsStripped()) + if (m_objfile_sp->IsStripped()) return; // Also make sure the file type is some sort of executable. Core files, debug // info files (dSYM), object files (.o files), and stub libraries all can - switch (m_obj_file->GetType()) { + switch (m_objfile_sp->GetType()) { case ObjectFile::eTypeInvalid: case ObjectFile::eTypeCoreFile: case ObjectFile::eTypeDebugInfo: @@ -286,7 +284,7 @@ void SymbolFileDWARFDebugMap::InitOSO() { // these files exist and also contain valid DWARF. If we get any of that then // we return the abilities of the first N_OSO's DWARF. - Symtab *symtab = m_obj_file->GetSymtab(); + Symtab *symtab = m_objfile_sp->GetSymtab(); if (symtab) { Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_MAP)); @@ -352,7 +350,7 @@ void SymbolFileDWARFDebugMap::InitOSO() { // The sibling index can't be less that or equal to the current index // "i" if (sibling_idx == UINT32_MAX) { - m_obj_file->GetModule()->ReportError( + m_objfile_sp->GetModule()->ReportError( "N_SO in symbol with UID %u has invalid sibling in debug map, " "please file a bug and attach the binary listed in this error", so_symbol->GetID()); @@ -363,28 +361,27 @@ void SymbolFileDWARFDebugMap::InitOSO() { m_compile_unit_infos[i].first_symbol_id = so_symbol->GetID(); m_compile_unit_infos[i].last_symbol_id = last_symbol->GetID(); - if (log) - log->Printf("Initialized OSO 0x%8.8x: file=%s", i, - oso_symbol->GetName().GetCString()); + LLDB_LOGF(log, "Initialized OSO 0x%8.8x: file=%s", i, + oso_symbol->GetName().GetCString()); } } else { if (oso_symbol == nullptr) - m_obj_file->GetModule()->ReportError( + m_objfile_sp->GetModule()->ReportError( "N_OSO symbol[%u] can't be found, please file a bug and attach " "the binary listed in this error", oso_idx); else if (so_symbol == nullptr) - m_obj_file->GetModule()->ReportError( + m_objfile_sp->GetModule()->ReportError( "N_SO not found for N_OSO symbol[%u], please file a bug and " "attach the binary listed in this error", oso_idx); else if (so_symbol->GetType() != eSymbolTypeSourceFile) - m_obj_file->GetModule()->ReportError( + m_objfile_sp->GetModule()->ReportError( "N_SO has incorrect symbol type (%u) for N_OSO symbol[%u], " "please file a bug and attach the binary listed in this error", so_symbol->GetType(), oso_idx); else if (oso_symbol->GetType() != eSymbolTypeSourceFile) - m_obj_file->GetModule()->ReportError( + m_objfile_sp->GetModule()->ReportError( "N_OSO has incorrect symbol type (%u) for N_OSO symbol[%u], " "please file a bug and attach the binary listed in this error", oso_symbol->GetType(), oso_idx); @@ -421,7 +418,11 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo( // than the one from the CU. auto oso_mod_time = std::chrono::time_point_cast<std::chrono::seconds>( FileSystem::Instance().GetModificationTime(oso_file)); - if (oso_mod_time != comp_unit_info->oso_mod_time) { + // A timestamp of 0 means that the linker was in deterministic mode. In + // that case, we should skip the check against the filesystem last + // modification timestamp, since it will never match. + if (comp_unit_info->oso_mod_time != llvm::sys::TimePoint<>() && + oso_mod_time != comp_unit_info->oso_mod_time) { obj_file->GetModule()->ReportError( "debug map object file '%s' has changed (actual time is " "%s, debug map time is %s" @@ -448,7 +449,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo( // since .o files for "i386-apple-ios" will historically show up as "i386 // -apple-macosx" due to the lack of a LC_VERSION_MIN_MACOSX or // LC_VERSION_MIN_IPHONEOS load command... - oso_arch.SetTriple(m_obj_file->GetModule() + oso_arch.SetTriple(m_objfile_sp->GetModule() ->GetArchitecture() .GetTriple() .getArchName() @@ -534,12 +535,8 @@ SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file) { SymbolFileDWARF *SymbolFileDWARFDebugMap::GetSymbolFileByCompUnitInfo( CompileUnitInfo *comp_unit_info) { - Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info); - if (oso_module) { - SymbolVendor *sym_vendor = oso_module->GetSymbolVendor(); - if (sym_vendor) - return GetSymbolFileAsSymbolFileDWARF(sym_vendor->GetSymbolFile()); - } + if (Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info)) + return GetSymbolFileAsSymbolFileDWARF(oso_module->GetSymbolFile()); return nullptr; } @@ -562,7 +559,7 @@ uint32_t SymbolFileDWARFDebugMap::CalculateAbilities() { return 0; } -uint32_t SymbolFileDWARFDebugMap::GetNumCompileUnits() { +uint32_t SymbolFileDWARFDebugMap::CalculateNumCompileUnits() { InitOSO(); return m_compile_unit_infos.size(); } @@ -581,13 +578,12 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) { lldb::user_id_t cu_id = 0; m_compile_unit_infos[cu_idx].compile_unit_sp = std::make_shared<CompileUnit>( - m_obj_file->GetModule(), nullptr, so_file_spec, cu_id, + m_objfile_sp->GetModule(), nullptr, so_file_spec, cu_id, eLanguageTypeUnknown, eLazyBoolCalculate); if (m_compile_unit_infos[cu_idx].compile_unit_sp) { - // Let our symbol vendor know about this compile unit - m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex( - cu_idx, m_compile_unit_infos[cu_idx].compile_unit_sp); + SetCompileUnitAtIndex(cu_idx, + m_compile_unit_infos[cu_idx].compile_unit_sp); } } } @@ -625,6 +621,7 @@ size_t SymbolFileDWARFDebugMap::GetCompUnitInfosForModule( lldb::LanguageType SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseLanguage(comp_unit); @@ -632,6 +629,7 @@ SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) { } size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseFunctions(comp_unit); @@ -639,6 +637,7 @@ size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) { } bool SymbolFileDWARFDebugMap::ParseLineTable(CompileUnit &comp_unit) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseLineTable(comp_unit); @@ -646,14 +645,24 @@ bool SymbolFileDWARFDebugMap::ParseLineTable(CompileUnit &comp_unit) { } bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseDebugMacros(comp_unit); return false; } +void SymbolFileDWARFDebugMap::ForEachExternalModule( + CompileUnit &comp_unit, llvm::function_ref<void(ModuleSP)> f) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); + if (oso_dwarf) + oso_dwarf->ForEachExternalModule(comp_unit, f); +} + bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit, FileSpecList &support_files) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseSupportFiles(comp_unit, support_files); @@ -661,6 +670,7 @@ bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit, } bool SymbolFileDWARFDebugMap::ParseIsOptimized(CompileUnit &comp_unit) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseIsOptimized(comp_unit); @@ -669,6 +679,7 @@ bool SymbolFileDWARFDebugMap::ParseIsOptimized(CompileUnit &comp_unit) { bool SymbolFileDWARFDebugMap::ParseImportedModules( const SymbolContext &sc, std::vector<SourceModule> &imported_modules) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); if (oso_dwarf) return oso_dwarf->ParseImportedModules(sc, imported_modules); @@ -676,6 +687,7 @@ bool SymbolFileDWARFDebugMap::ParseImportedModules( } size_t SymbolFileDWARFDebugMap::ParseBlocksRecursive(Function &func) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); CompileUnit *comp_unit = func.GetCompileUnit(); if (!comp_unit) return 0; @@ -687,6 +699,7 @@ size_t SymbolFileDWARFDebugMap::ParseBlocksRecursive(Function &func) { } size_t SymbolFileDWARFDebugMap::ParseTypes(CompileUnit &comp_unit) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseTypes(comp_unit); @@ -695,6 +708,7 @@ size_t SymbolFileDWARFDebugMap::ParseTypes(CompileUnit &comp_unit) { size_t SymbolFileDWARFDebugMap::ParseVariablesForContext(const SymbolContext &sc) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); if (oso_dwarf) return oso_dwarf->ParseVariablesForContext(sc); @@ -702,6 +716,7 @@ SymbolFileDWARFDebugMap::ParseVariablesForContext(const SymbolContext &sc) { } Type *SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid); SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx); if (oso_dwarf) @@ -738,8 +753,9 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr, SymbolContextItem resolve_scope, SymbolContext &sc) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); uint32_t resolved_flags = 0; - Symtab *symtab = m_obj_file->GetSymtab(); + Symtab *symtab = m_objfile_sp->GetSymtab(); if (symtab) { const addr_t exe_file_addr = exe_so_addr.GetFileAddress(); @@ -766,7 +782,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr, Address oso_so_addr; if (oso_module->ResolveFileAddress(oso_file_addr, oso_so_addr)) { resolved_flags |= - oso_module->GetSymbolVendor()->ResolveSymbolContext( + oso_module->GetSymbolFile()->ResolveSymbolContext( oso_so_addr, resolve_scope, sc); } } @@ -780,6 +796,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr, uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( const FileSpec &file_spec, uint32_t line, bool check_inlines, SymbolContextItem resolve_scope, SymbolContextList &sc_list) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); const uint32_t initial = sc_list.GetSize(); const uint32_t cu_count = GetNumCompileUnits(); @@ -807,12 +824,11 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( return sc_list.GetSize() - initial; } -uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( +void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, const std::vector<uint32_t> &indexes, // Indexes into the symbol table that match "name" uint32_t max_matches, VariableList &variables) { - const uint32_t original_size = variables.GetSize(); const size_t match_count = indexes.size(); for (size_t i = 0; i < match_count; ++i) { uint32_t oso_idx; @@ -821,28 +837,26 @@ uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( if (comp_unit_info) { SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx); if (oso_dwarf) { - if (oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches, - variables)) - if (variables.GetSize() > max_matches) - break; + oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches, + variables); + if (variables.GetSize() > max_matches) + break; } } } - return variables.GetSize() - original_size; } -uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables( +void SymbolFileDWARFDebugMap::FindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { - - // Remember how many variables are in the list before we search. - const uint32_t original_size = variables.GetSize(); - + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); uint32_t total_matches = 0; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - const uint32_t oso_matches = oso_dwarf->FindGlobalVariables( - name, parent_decl_ctx, max_matches, variables); + const uint32_t old_size = variables.GetSize(); + oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches, + variables); + const uint32_t oso_matches = variables.GetSize() - old_size; if (oso_matches > 0) { total_matches += oso_matches; @@ -861,22 +875,18 @@ uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables( return false; }); - - // Return the number of variable that were appended to the list - return variables.GetSize() - original_size; } -uint32_t -SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression ®ex, - uint32_t max_matches, - VariableList &variables) { - // Remember how many variables are in the list before we search. - const uint32_t original_size = variables.GetSize(); - +void SymbolFileDWARFDebugMap::FindGlobalVariables( + const RegularExpression ®ex, uint32_t max_matches, + VariableList &variables) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); uint32_t total_matches = 0; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - const uint32_t oso_matches = - oso_dwarf->FindGlobalVariables(regex, max_matches, variables); + const uint32_t old_size = variables.GetSize(); + oso_dwarf->FindGlobalVariables(regex, max_matches, variables); + + const uint32_t oso_matches = variables.GetSize() - old_size; if (oso_matches > 0) { total_matches += oso_matches; @@ -895,9 +905,6 @@ SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression ®ex, return false; }); - - // Return the number of variable that were appended to the list - return variables.GetSize() - original_size; } int SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex( @@ -993,71 +1000,58 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp, } } -uint32_t SymbolFileDWARFDebugMap::FindFunctions( +void SymbolFileDWARFDebugMap::FindFunctions( ConstString name, const CompilerDeclContext *parent_decl_ctx, - FunctionNameType name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, SymbolContextList &sc_list) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::FindFunctions (name = %s)", name.GetCString()); - uint32_t initial_size = 0; - if (append) - initial_size = sc_list.GetSize(); - else - sc_list.Clear(); - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { uint32_t sc_idx = sc_list.GetSize(); - if (oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask, - include_inlines, true, sc_list)) { - RemoveFunctionsWithModuleNotEqualTo(m_obj_file->GetModule(), sc_list, + oso_dwarf->FindFunctions(name, parent_decl_ctx, name_type_mask, + include_inlines, sc_list); + if (!sc_list.IsEmpty()) { + RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list, sc_idx); } return false; }); - - return sc_list.GetSize() - initial_size; } -uint32_t SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex, - bool include_inlines, - bool append, - SymbolContextList &sc_list) { +void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex, + bool include_inlines, + SymbolContextList &sc_list) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')", regex.GetText().str().c_str()); - uint32_t initial_size = 0; - if (append) - initial_size = sc_list.GetSize(); - else - sc_list.Clear(); - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { uint32_t sc_idx = sc_list.GetSize(); - if (oso_dwarf->FindFunctions(regex, include_inlines, true, sc_list)) { - RemoveFunctionsWithModuleNotEqualTo(m_obj_file->GetModule(), sc_list, + oso_dwarf->FindFunctions(regex, include_inlines, sc_list); + if (!sc_list.IsEmpty()) { + RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list, sc_idx); } return false; }); - - return sc_list.GetSize() - initial_size; } -size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, - lldb::TypeClass type_mask, - TypeList &type_list) { +void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, + lldb::TypeClass type_mask, + TypeList &type_list) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)", type_mask); - uint32_t initial_size = type_list.GetSize(); SymbolFileDWARF *oso_dwarf = nullptr; if (sc_scope) { SymbolContext sc; @@ -1075,7 +1069,6 @@ size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, return false; }); } - return type_list.GetSize() - initial_size; } std::vector<lldb_private::CallEdge> @@ -1124,7 +1117,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( // N_SO. SymbolFileDWARF *oso_dwarf = nullptr; TypeSP type_sp; - ObjectFile *module_objfile = m_obj_file->GetModule()->GetObjectFile(); + ObjectFile *module_objfile = m_objfile_sp->GetModule()->GetObjectFile(); if (module_objfile) { Symtab *symtab = module_objfile->GetSymtab(); if (symtab) { @@ -1177,23 +1170,17 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( return TypeSP(); } -uint32_t SymbolFileDWARFDebugMap::FindTypes( +void SymbolFileDWARFDebugMap::FindTypes( ConstString name, const CompilerDeclContext *parent_decl_ctx, - bool append, uint32_t max_matches, + uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { - if (!append) - types.Clear(); - - const uint32_t initial_types_size = types.GetSize(); - + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - oso_dwarf->FindTypes(name, parent_decl_ctx, append, max_matches, + oso_dwarf->FindTypes(name, parent_decl_ctx, max_matches, searched_symbol_files, types); return types.GetSize() >= max_matches; }); - - return types.GetSize() - initial_types_size; } // @@ -1212,6 +1199,7 @@ uint32_t SymbolFileDWARFDebugMap::FindTypes( CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace( lldb_private::ConstString name, const CompilerDeclContext *parent_decl_ctx) { + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); CompilerDeclContext matching_namespace; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { @@ -1284,8 +1272,7 @@ void SymbolFileDWARFDebugMap::SetCompileUnit(SymbolFileDWARF *oso_dwarf, cu_sp.get()); } else { m_compile_unit_infos[cu_idx].compile_unit_sp = cu_sp; - m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex( - cu_idx, cu_sp); + SetCompileUnitAtIndex(cu_idx, cu_sp); } } } @@ -1388,8 +1375,8 @@ bool SymbolFileDWARFDebugMap::LinkOSOAddress(Address &addr) { if (addr_module == exe_module) return true; // Address is already in terms of the main executable module - CompileUnitInfo *cu_info = GetCompileUnitInfo(GetSymbolFileAsSymbolFileDWARF( - addr_module->GetSymbolVendor()->GetSymbolFile())); + CompileUnitInfo *cu_info = GetCompileUnitInfo( + GetSymbolFileAsSymbolFileDWARF(addr_module->GetSymbolFile())); if (cu_info) { const lldb::addr_t oso_file_addr = addr.GetFileAddress(); const FileRangeMap::Entry *oso_range_entry = |