Index: lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -228,6 +228,7 @@ } bool SymbolFileBreakpad::ParseLineTable(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); CompUnitData &data = m_cu_data->GetEntryRef(comp_unit.GetID()).data; if (!data.line_table_up) @@ -239,6 +240,7 @@ bool SymbolFileBreakpad::ParseSupportFiles(CompileUnit &comp_unit, FileSpecList &support_files) { + std::lock_guard guard(GetModuleMutex()); CompUnitData &data = m_cu_data->GetEntryRef(comp_unit.GetID()).data; if (!data.support_files) ParseLineTableAndSupportFiles(comp_unit, data); @@ -251,6 +253,7 @@ SymbolFileBreakpad::ResolveSymbolContext(const Address &so_addr, SymbolContextItem resolve_scope, SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); if (!(resolve_scope & (eSymbolContextCompUnit | eSymbolContextLineEntry))) return 0; @@ -275,6 +278,7 @@ uint32_t SymbolFileBreakpad::ResolveSymbolContext( const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); if (!(resolve_scope & eSymbolContextCompUnit)) return 0; Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -197,8 +197,6 @@ } TypeList &SymbolFileDWARF::GetTypeList() { - // This method can be called without going through the symbol vendor so we - // need to lock the module. std::lock_guard guard(GetModuleMutex()); if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) return debug_map_symfile->GetTypeList(); @@ -279,7 +277,7 @@ TypeClass type_mask, TypeList &type_list) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); TypeSet type_set; CompileUnit *comp_unit = nullptr; @@ -754,7 +752,7 @@ return true; } lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) return dwarf_cu->GetLanguageType(); @@ -763,7 +761,7 @@ } size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (!dwarf_cu) return 0; @@ -783,7 +781,7 @@ bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit, FileSpecList &support_files) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); if (DWARFUnit *unit = GetDWARFCompileUnit(&comp_unit)) { const dw_offset_t stmt_list = unit->GetLineTableOffset(); if (stmt_list != DW_INVALID_OFFSET) { @@ -833,7 +831,7 @@ } bool SymbolFileDWARF::ParseIsOptimized(CompileUnit &comp_unit) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) return dwarf_cu->GetIsOptimized(); @@ -843,7 +841,7 @@ bool SymbolFileDWARF::ParseImportedModules( const lldb_private::SymbolContext &sc, std::vector &imported_modules) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); assert(sc.comp_unit); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); if (!dwarf_cu) @@ -1013,7 +1011,7 @@ } bool SymbolFileDWARF::ParseDebugMacros(CompileUnit &comp_unit) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu == nullptr) @@ -1272,8 +1270,6 @@ CompilerDeclContext SymbolFileDWARF::GetDeclContextContainingUID(lldb::user_id_t type_uid) { - // This method can be called without going through the symbol vendor so we - // need to lock the module. std::lock_guard guard(GetModuleMutex()); // Anytime we have a lldb::user_id_t, we must get the DIE by calling // SymbolFileDWARF::GetDIE(). See comments inside the @@ -1284,8 +1280,6 @@ } Type *SymbolFileDWARF::ResolveTypeUID(lldb::user_id_t type_uid) { - // This method can be called without going through the symbol vendor so we - // need to lock the module. std::lock_guard guard(GetModuleMutex()); // Anytime we have a lldb::user_id_t, we must get the DIE by calling // SymbolFileDWARF::GetDIE(). See comments inside the @@ -1685,6 +1679,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, SymbolContextItem resolve_scope, SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARF::" @@ -1828,6 +1823,7 @@ bool check_inlines, SymbolContextItem resolve_scope, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); const uint32_t prev_size = sc_list.GetSize(); if (resolve_scope & eSymbolContextCompUnit) { for (uint32_t cu_idx = 0, num_cus = GetNumCompileUnits(); cu_idx < num_cus; @@ -1970,6 +1966,7 @@ uint32_t SymbolFileDWARF::FindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { + std::lock_guard guard(GetModuleMutex()); Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); if (log) @@ -2078,6 +2075,7 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression ®ex, uint32_t max_matches, VariableList &variables) { + std::lock_guard guard(GetModuleMutex()); Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); if (log) { @@ -2205,6 +2203,7 @@ ConstString name, const CompilerDeclContext *parent_decl_ctx, FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARF::FindFunctions (name = '%s')", name.AsCString()); @@ -2268,6 +2267,7 @@ uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARF::FindFunctions (regex = '%s')", regex.GetText().str().c_str()); @@ -2341,6 +2341,7 @@ bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { + std::lock_guard guard(GetModuleMutex()); // If we aren't appending the results to this list, then clear the list if (!append) types.Clear(); @@ -2440,6 +2441,7 @@ size_t SymbolFileDWARF::FindTypes(const std::vector &context, bool append, TypeMap &types) { + std::lock_guard guard(GetModuleMutex()); if (!append) types.Clear(); @@ -2486,6 +2488,7 @@ CompilerDeclContext SymbolFileDWARF::FindNamespace(ConstString name, const CompilerDeclContext *parent_decl_ctx) { + std::lock_guard guard(GetModuleMutex()); Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); if (log) { @@ -3009,7 +3012,7 @@ } size_t SymbolFileDWARF::ParseBlocksRecursive(Function &func) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); CompileUnit *comp_unit = func.GetCompileUnit(); lldbassert(comp_unit); @@ -3029,7 +3032,7 @@ } size_t SymbolFileDWARF::ParseTypes(CompileUnit &comp_unit) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); size_t types_added = 0; DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { @@ -3045,7 +3048,7 @@ } size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) { - ASSERT_MODULE_LOCK(this); + std::lock_guard guard(GetModuleMutex()); if (sc.comp_unit != nullptr) { DWARFDebugInfo *info = DebugInfo(); if (info == nullptr) Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -623,6 +623,7 @@ lldb::LanguageType SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseLanguage(comp_unit); @@ -630,6 +631,7 @@ } size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseFunctions(comp_unit); @@ -637,6 +639,7 @@ } bool SymbolFileDWARFDebugMap::ParseLineTable(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseLineTable(comp_unit); @@ -644,6 +647,7 @@ } bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseDebugMacros(comp_unit); @@ -652,6 +656,7 @@ bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit, FileSpecList &support_files) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseSupportFiles(comp_unit, support_files); @@ -659,6 +664,7 @@ } bool SymbolFileDWARFDebugMap::ParseIsOptimized(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseIsOptimized(comp_unit); @@ -667,6 +673,7 @@ bool SymbolFileDWARFDebugMap::ParseImportedModules( const SymbolContext &sc, std::vector &imported_modules) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); if (oso_dwarf) return oso_dwarf->ParseImportedModules(sc, imported_modules); @@ -674,6 +681,7 @@ } size_t SymbolFileDWARFDebugMap::ParseBlocksRecursive(Function &func) { + std::lock_guard guard(GetModuleMutex()); CompileUnit *comp_unit = func.GetCompileUnit(); if (!comp_unit) return 0; @@ -685,6 +693,7 @@ } size_t SymbolFileDWARFDebugMap::ParseTypes(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) return oso_dwarf->ParseTypes(comp_unit); @@ -693,6 +702,7 @@ size_t SymbolFileDWARFDebugMap::ParseVariablesForContext(const SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); if (oso_dwarf) return oso_dwarf->ParseVariablesForContext(sc); @@ -700,6 +710,7 @@ } Type *SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) { + std::lock_guard guard(GetModuleMutex()); const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid); SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx); if (oso_dwarf) @@ -736,6 +747,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr, SymbolContextItem resolve_scope, SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); uint32_t resolved_flags = 0; Symtab *symtab = m_obj_file->GetSymtab(); if (symtab) { @@ -778,6 +790,7 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( const FileSpec &file_spec, uint32_t line, bool check_inlines, SymbolContextItem resolve_scope, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); const uint32_t initial = sc_list.GetSize(); const uint32_t cu_count = GetNumCompileUnits(); @@ -832,6 +845,7 @@ uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { + std::lock_guard guard(GetModuleMutex()); // Remember how many variables are in the list before we search. const uint32_t original_size = variables.GetSize(); @@ -868,6 +882,7 @@ SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression ®ex, uint32_t max_matches, VariableList &variables) { + std::lock_guard guard(GetModuleMutex()); // Remember how many variables are in the list before we search. const uint32_t original_size = variables.GetSize(); @@ -995,6 +1010,7 @@ ConstString name, const CompilerDeclContext *parent_decl_ctx, FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::FindFunctions (name = %s)", @@ -1023,6 +1039,7 @@ bool include_inlines, bool append, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')", @@ -1050,6 +1067,7 @@ size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) { + std::lock_guard guard(GetModuleMutex()); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)", @@ -1180,6 +1198,7 @@ bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { + std::lock_guard guard(GetModuleMutex()); if (!append) types.Clear(); @@ -1210,6 +1229,7 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace( lldb_private::ConstString name, const CompilerDeclContext *parent_decl_ctx) { + std::lock_guard guard(GetModuleMutex()); CompilerDeclContext matching_namespace; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -899,6 +899,7 @@ } lldb::LanguageType SymbolFileNativePDB::ParseLanguage(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); PdbSymUid uid(comp_unit.GetID()); lldbassert(uid.kind() == PdbSymUidKind::Compiland); @@ -914,6 +915,7 @@ void SymbolFileNativePDB::AddSymbols(Symtab &symtab) { return; } size_t SymbolFileNativePDB::ParseFunctions(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); PdbSymUid uid{comp_unit.GetID()}; lldbassert(uid.kind() == PdbSymUidKind::Compiland); uint16_t modi = uid.asCompiland().modi; @@ -947,6 +949,7 @@ uint32_t SymbolFileNativePDB::ResolveSymbolContext( const Address &addr, SymbolContextItem resolve_scope, SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); uint32_t resolved_flags = 0; lldb::addr_t file_addr = addr.GetFileAddress(); @@ -1051,6 +1054,7 @@ // 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. + std::lock_guard guard(GetModuleMutex()); PdbSymUid cu_id(comp_unit.GetID()); lldbassert(cu_id.kind() == PdbSymUidKind::Compiland); CompilandIndexItem *cci = @@ -1129,6 +1133,7 @@ bool SymbolFileNativePDB::ParseSupportFiles(CompileUnit &comp_unit, FileSpecList &support_files) { + std::lock_guard guard(GetModuleMutex()); PdbSymUid cu_id(comp_unit.GetID()); lldbassert(cu_id.kind() == PdbSymUidKind::Compiland); CompilandIndexItem *cci = @@ -1159,6 +1164,7 @@ } size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) { + std::lock_guard guard(GetModuleMutex()); GetOrCreateBlock(PdbSymUid(func.GetID()).asCompilandSym()); // FIXME: Parse child blocks return 1; @@ -1169,6 +1175,7 @@ uint32_t SymbolFileNativePDB::FindGlobalVariables( ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { + std::lock_guard guard(GetModuleMutex()); using SymbolAndOffset = std::pair; std::vector results = m_index->globals().findRecordsByName( @@ -1197,6 +1204,7 @@ ConstString name, const CompilerDeclContext *parent_decl_ctx, FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); // For now we only support lookup by method name. if (!(name_type_mask & eFunctionNameTypeMethod)) return 0; @@ -1238,6 +1246,7 @@ ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { + std::lock_guard guard(GetModuleMutex()); if (!append) types.Clear(); if (!name) @@ -1279,6 +1288,7 @@ } size_t SymbolFileNativePDB::ParseTypes(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); // Only do the full type scan the first time. if (m_done_full_type_scan) return 0; @@ -1475,6 +1485,7 @@ } size_t SymbolFileNativePDB::ParseVariablesForContext(const SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); lldbassert(sc.function || sc.comp_unit); VariableListSP variables; @@ -1528,6 +1539,7 @@ } Type *SymbolFileNativePDB::ResolveTypeUID(lldb::user_id_t type_uid) { + std::lock_guard guard(GetModuleMutex()); auto iter = m_types.find(type_uid); // lldb should not be passing us non-sensical type uids. the only way it // could have a type uid in the first place is if we handed it out, in which Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -257,6 +257,7 @@ } lldb::LanguageType SymbolFilePDB::ParseLanguage(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland_up) return lldb::eLanguageTypeUnknown; @@ -311,6 +312,7 @@ } size_t SymbolFilePDB::ParseFunctions(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); size_t func_added = 0; auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland_up) @@ -329,6 +331,7 @@ } bool SymbolFilePDB::ParseLineTable(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); if (comp_unit.GetLineTable()) return true; return ParseCompileUnitLineTable(comp_unit, 0); @@ -347,6 +350,7 @@ // 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. + std::lock_guard guard(GetModuleMutex()); auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland_up) return false; @@ -424,6 +428,7 @@ } size_t SymbolFilePDB::ParseBlocksRecursive(Function &func) { + std::lock_guard guard(GetModuleMutex()); size_t num_added = 0; auto uid = func.GetID(); auto pdb_func_up = m_session_up->getConcreteSymbolById(uid); @@ -436,6 +441,7 @@ } size_t SymbolFilePDB::ParseTypes(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); size_t num_added = 0; auto compiland = GetPDBCompilandByUID(comp_unit.GetID()); @@ -488,6 +494,7 @@ size_t SymbolFilePDB::ParseVariablesForContext(const lldb_private::SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); if (!sc.comp_unit) return 0; @@ -536,6 +543,7 @@ } lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) { + std::lock_guard guard(GetModuleMutex()); auto find_result = m_types.find(type_uid); if (find_result != m_types.end()) return find_result->second.get(); @@ -666,6 +674,7 @@ SymbolFilePDB::ResolveSymbolContext(const lldb_private::Address &so_addr, SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); uint32_t resolved_flags = 0; if (resolve_scope & eSymbolContextCompUnit || resolve_scope & eSymbolContextVariable || @@ -726,6 +735,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext( const lldb_private::FileSpec &file_spec, uint32_t line, bool check_inlines, SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); const size_t old_size = sc_list.GetSize(); if (resolve_scope & lldb::eSymbolContextCompUnit) { // Locate all compilation units with line numbers referencing the specified @@ -1038,6 +1048,7 @@ lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) { + std::lock_guard guard(GetModuleMutex()); if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) return 0; if (name.IsEmpty()) @@ -1082,6 +1093,7 @@ SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression ®ex, uint32_t max_matches, lldb_private::VariableList &variables) { + std::lock_guard guard(GetModuleMutex()); if (!regex.IsValid()) return 0; auto results = m_global_scope_up->findAllChildren(); @@ -1239,6 +1251,7 @@ const lldb_private::CompilerDeclContext *parent_decl_ctx, FunctionNameType name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); if (!append) sc_list.Clear(); lldbassert((name_type_mask & eFunctionNameTypeAuto) == 0); @@ -1294,6 +1307,7 @@ SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression ®ex, bool include_inlines, bool append, lldb_private::SymbolContextList &sc_list) { + std::lock_guard guard(GetModuleMutex()); if (!append) sc_list.Clear(); if (!regex.IsValid()) @@ -1380,6 +1394,7 @@ uint32_t max_matches, llvm::DenseSet &searched_symbol_files, lldb_private::TypeMap &types) { + std::lock_guard guard(GetModuleMutex()); if (!append) types.Clear(); if (!name) @@ -1567,6 +1582,7 @@ size_t SymbolFilePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope, TypeClass type_mask, lldb_private::TypeList &type_list) { + std::lock_guard guard(GetModuleMutex()); TypeCollection type_collection; uint32_t old_size = type_list.GetSize(); CompileUnit *cu = @@ -1615,6 +1631,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace( lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx) { + std::lock_guard guard(GetModuleMutex()); auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); auto clang_type_system = llvm::dyn_cast_or_null(type_system); if (!clang_type_system) Index: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -136,6 +136,7 @@ } size_t SymbolFileSymtab::ParseFunctions(CompileUnit &comp_unit) { + std::lock_guard guard(GetModuleMutex()); size_t num_added = 0; // We must at least have a valid compile unit const Symtab *symtab = m_obj_file->GetSymtab(); @@ -246,6 +247,7 @@ uint32_t SymbolFileSymtab::ResolveSymbolContext(const Address &so_addr, SymbolContextItem resolve_scope, SymbolContext &sc) { + std::lock_guard guard(GetModuleMutex()); if (m_obj_file->GetSymtab() == nullptr) return 0; Index: lldb/trunk/source/Symbol/SymbolFile.cpp =================================================================== --- lldb/trunk/source/Symbol/SymbolFile.cpp +++ lldb/trunk/source/Symbol/SymbolFile.cpp @@ -179,6 +179,7 @@ } CompUnitSP SymbolFile::GetCompileUnitAtIndex(uint32_t idx) { + std::lock_guard guard(GetModuleMutex()); uint32_t num = GetNumCompileUnits(); if (idx >= num) return nullptr; Index: lldb/trunk/source/Symbol/SymbolVendor.cpp =================================================================== --- lldb/trunk/source/Symbol/SymbolVendor.cpp +++ lldb/trunk/source/Symbol/SymbolVendor.cpp @@ -76,135 +76,83 @@ } size_t SymbolVendor::GetNumCompileUnits() { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->GetNumCompileUnits(); - } + if (m_sym_file_up) + return m_sym_file_up->GetNumCompileUnits(); return 0; } 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_up) - return m_sym_file_up->ParseLanguage(comp_unit); - } + if (m_sym_file_up) + return m_sym_file_up->ParseLanguage(comp_unit); return eLanguageTypeUnknown; } 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_up) - return m_sym_file_up->ParseFunctions(comp_unit); - } + if (m_sym_file_up) + return m_sym_file_up->ParseFunctions(comp_unit); return 0; } bool SymbolVendor::ParseLineTable(CompileUnit &comp_unit) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ParseLineTable(comp_unit); - } + if (m_sym_file_up) + return m_sym_file_up->ParseLineTable(comp_unit); return false; } bool SymbolVendor::ParseDebugMacros(CompileUnit &comp_unit) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ParseDebugMacros(comp_unit); - } + if (m_sym_file_up) + return m_sym_file_up->ParseDebugMacros(comp_unit); return false; } 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_up) - return m_sym_file_up->ParseSupportFiles(comp_unit, support_files); - } + if (m_sym_file_up) + return m_sym_file_up->ParseSupportFiles(comp_unit, support_files); return false; } bool SymbolVendor::ParseIsOptimized(CompileUnit &comp_unit) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ParseIsOptimized(comp_unit); - } + if (m_sym_file_up) + return m_sym_file_up->ParseIsOptimized(comp_unit); return false; } bool SymbolVendor::ParseImportedModules( const SymbolContext &sc, std::vector &imported_modules) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ParseImportedModules(sc, imported_modules); - } + if (m_sym_file_up) + return m_sym_file_up->ParseImportedModules(sc, imported_modules); return false; } size_t SymbolVendor::ParseBlocksRecursive(Function &func) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ParseBlocksRecursive(func); - } + if (m_sym_file_up) + return m_sym_file_up->ParseBlocksRecursive(func); return 0; } 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_up) - return m_sym_file_up->ParseTypes(comp_unit); - } + if (m_sym_file_up) + return m_sym_file_up->ParseTypes(comp_unit); return 0; } size_t SymbolVendor::ParseVariablesForContext(const SymbolContext &sc) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ParseVariablesForContext(sc); - } + if (m_sym_file_up) + return m_sym_file_up->ParseVariablesForContext(sc); return 0; } Type *SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ResolveTypeUID(type_uid); - } + if (m_sym_file_up) + return m_sym_file_up->ResolveTypeUID(type_uid); return nullptr; } uint32_t SymbolVendor::ResolveSymbolContext(const Address &so_addr, SymbolContextItem resolve_scope, SymbolContext &sc) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ResolveSymbolContext(so_addr, resolve_scope, sc); - } + if (m_sym_file_up) + return m_sym_file_up->ResolveSymbolContext(so_addr, resolve_scope, sc); return 0; } @@ -212,13 +160,9 @@ uint32_t line, bool check_inlines, SymbolContextItem resolve_scope, SymbolContextList &sc_list) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->ResolveSymbolContext(file_spec, line, check_inlines, - resolve_scope, sc_list); - } + if (m_sym_file_up) + return m_sym_file_up->ResolveSymbolContext(file_spec, line, check_inlines, + resolve_scope, sc_list); return 0; } @@ -226,25 +170,17 @@ SymbolVendor::FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, VariableList &variables) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->FindGlobalVariables(name, parent_decl_ctx, - max_matches, variables); - } + if (m_sym_file_up) + return m_sym_file_up->FindGlobalVariables(name, parent_decl_ctx, + max_matches, variables); return 0; } size_t SymbolVendor::FindGlobalVariables(const RegularExpression ®ex, size_t max_matches, VariableList &variables) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->FindGlobalVariables(regex, max_matches, variables); - } + if (m_sym_file_up) + return m_sym_file_up->FindGlobalVariables(regex, max_matches, variables); return 0; } @@ -253,26 +189,18 @@ FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->FindFunctions(name, parent_decl_ctx, name_type_mask, - include_inlines, append, sc_list); - } + if (m_sym_file_up) + return m_sym_file_up->FindFunctions(name, parent_decl_ctx, name_type_mask, + include_inlines, append, sc_list); return 0; } size_t SymbolVendor::FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->FindFunctions(regex, include_inlines, append, - sc_list); - } + if (m_sym_file_up) + return m_sym_file_up->FindFunctions(regex, include_inlines, append, + sc_list); return 0; } @@ -281,14 +209,9 @@ bool append, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->FindTypes(name, parent_decl_ctx, append, - max_matches, searched_symbol_files, - types); - } + if (m_sym_file_up) + return m_sym_file_up->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); if (!append) types.Clear(); return 0; @@ -296,12 +219,8 @@ size_t SymbolVendor::FindTypes(const std::vector &context, bool append, TypeMap &types) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->FindTypes(context, append, types); - } + if (m_sym_file_up) + return m_sym_file_up->FindTypes(context, append, types); if (!append) types.Clear(); return 0; @@ -309,12 +228,8 @@ size_t SymbolVendor::GetTypes(SymbolContextScope *sc_scope, TypeClass type_mask, lldb_private::TypeList &type_list) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->GetTypes(sc_scope, type_mask, type_list); - } + if (m_sym_file_up) + return m_sym_file_up->GetTypes(sc_scope, type_mask, type_list); return 0; } @@ -322,12 +237,8 @@ SymbolVendor::FindNamespace(ConstString name, const CompilerDeclContext *parent_decl_ctx) { CompilerDeclContext namespace_decl_ctx; - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - namespace_decl_ctx = m_sym_file_up->FindNamespace(name, parent_decl_ctx); - } + if (m_sym_file_up) + namespace_decl_ctx = m_sym_file_up->FindNamespace(name, parent_decl_ctx); return namespace_decl_ctx; } @@ -364,12 +275,8 @@ } CompUnitSP SymbolVendor::GetCompileUnitAtIndex(size_t idx) { - ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - if (m_sym_file_up) - return m_sym_file_up->GetCompileUnitAtIndex(idx); - } + if (m_sym_file_up) + return m_sym_file_up->GetCompileUnitAtIndex(idx); return nullptr; }