[Lldb-commits] [lldb] r367298 - SymbolVendor: Move locking into the Symbol Files

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 30 01:20:05 PDT 2019


Author: labath
Date: Tue Jul 30 01:20:05 2019
New Revision: 367298

URL: http://llvm.org/viewvc/llvm-project?rev=367298&view=rev
Log:
SymbolVendor: Move locking into the Symbol Files

Summary:
The last bit of functionality in SymbolVendor passthrough functions is
the locking the module mutex. While it may be nice doing the locking in
a central place, we weren't really succesful in doing that right now,
because some SymbolFile function could still be called without going
through the SymbolVendor. This meant in SymbolFileDWARF (the only
battle-tested symbol file implementation) roughly a half of the
functions was taking additional locks and another half was asserting
that the lock is already held. By making the SymbolFile responsible for
locking, we can at least make the situation in SymbolFileDWARF more
consistent.

Reviewers: clayborg, JDevlieghere, jingham, jdoerfert

Subscribers: aprantl, lldb-commits

Differential Revision: https://reviews.llvm.org/D65329

Modified:
    lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
    lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
    lldb/trunk/source/Symbol/SymbolFile.cpp
    lldb/trunk/source/Symbol/SymbolVendor.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp Tue Jul 30 01:20:05 2019
@@ -228,6 +228,7 @@ size_t SymbolFileBreakpad::ParseFunction
 }
 
 bool SymbolFileBreakpad::ParseLineTable(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   CompUnitData &data = m_cu_data->GetEntryRef(comp_unit.GetID()).data;
 
   if (!data.line_table_up)
@@ -239,6 +240,7 @@ bool SymbolFileBreakpad::ParseLineTable(
 
 bool SymbolFileBreakpad::ParseSupportFiles(CompileUnit &comp_unit,
                                            FileSpecList &support_files) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   CompUnitData &data = m_cu_data->GetEntryRef(comp_unit.GetID()).data;
   if (!data.support_files)
     ParseLineTableAndSupportFiles(comp_unit, data);
@@ -251,6 +253,7 @@ uint32_t
 SymbolFileBreakpad::ResolveSymbolContext(const Address &so_addr,
                                          SymbolContextItem resolve_scope,
                                          SymbolContext &sc) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!(resolve_scope & (eSymbolContextCompUnit | eSymbolContextLineEntry)))
     return 0;
 
@@ -275,6 +278,7 @@ SymbolFileBreakpad::ResolveSymbolContext
 uint32_t SymbolFileBreakpad::ResolveSymbolContext(
     const FileSpec &file_spec, uint32_t line, bool check_inlines,
     lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!(resolve_scope & eSymbolContextCompUnit))
     return 0;
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Jul 30 01:20:05 2019
@@ -197,8 +197,6 @@ SymbolFile *SymbolFileDWARF::CreateInsta
 }
 
 TypeList &SymbolFileDWARF::GetTypeList() {
-  // This method can be called without going through the symbol vendor so we
-  // need to lock the module.
   std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile())
     return debug_map_symfile->GetTypeList();
@@ -279,7 +277,7 @@ size_t SymbolFileDWARF::GetTypes(SymbolC
                                  TypeClass type_mask, TypeList &type_list)
 
 {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   TypeSet type_set;
 
   CompileUnit *comp_unit = nullptr;
@@ -754,7 +752,7 @@ bool SymbolFileDWARF::FixupAddress(Addre
   return true;
 }
 lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
   if (dwarf_cu)
     return dwarf_cu->GetLanguageType();
@@ -763,7 +761,7 @@ lldb::LanguageType SymbolFileDWARF::Pars
 }
 
 size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
   if (!dwarf_cu)
     return 0;
@@ -783,7 +781,7 @@ size_t SymbolFileDWARF::ParseFunctions(C
 
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
                                         FileSpecList &support_files) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> 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 @@ SymbolFileDWARF::GetTypeUnitSupportFiles
 }
 
 bool SymbolFileDWARF::ParseIsOptimized(CompileUnit &comp_unit) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
   if (dwarf_cu)
     return dwarf_cu->GetIsOptimized();
@@ -843,7 +841,7 @@ bool SymbolFileDWARF::ParseIsOptimized(C
 bool SymbolFileDWARF::ParseImportedModules(
     const lldb_private::SymbolContext &sc,
     std::vector<SourceModule> &imported_modules) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   assert(sc.comp_unit);
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (!dwarf_cu)
@@ -1013,7 +1011,7 @@ SymbolFileDWARF::ParseDebugMacros(lldb::
 }
 
 bool SymbolFileDWARF::ParseDebugMacros(CompileUnit &comp_unit) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
 
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
   if (dwarf_cu == nullptr)
@@ -1272,8 +1270,6 @@ SymbolFileDWARF::GetDeclContextForUID(ll
 
 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<std::recursive_mutex> 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 @@ SymbolFileDWARF::GetDeclContextContainin
 }
 
 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<std::recursive_mutex> 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 @@ SymbolFileDWARF::GlobalVariableMap &Symb
 uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
                                                SymbolContextItem resolve_scope,
                                                SymbolContext &sc) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
   Timer scoped_timer(func_cat,
                      "SymbolFileDWARF::"
@@ -1828,6 +1823,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolC
                                                bool check_inlines,
                                                SymbolContextItem resolve_scope,
                                                SymbolContextList &sc_list) {
+  std::lock_guard<std::recursive_mutex> 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 @@ bool SymbolFileDWARF::DeclContextMatches
 uint32_t SymbolFileDWARF::FindGlobalVariables(
     ConstString name, const CompilerDeclContext *parent_decl_ctx,
     uint32_t max_matches, VariableList &variables) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
 
   if (log)
@@ -2078,6 +2075,7 @@ uint32_t SymbolFileDWARF::FindGlobalVari
 uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
                                               uint32_t max_matches,
                                               VariableList &variables) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
 
   if (log) {
@@ -2205,6 +2203,7 @@ uint32_t SymbolFileDWARF::FindFunctions(
     ConstString name, const CompilerDeclContext *parent_decl_ctx,
     FunctionNameType name_type_mask, bool include_inlines, bool append,
     SymbolContextList &sc_list) {
+  std::lock_guard<std::recursive_mutex> 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(
 uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression &regex,
                                         bool include_inlines, bool append,
                                         SymbolContextList &sc_list) {
+  std::lock_guard<std::recursive_mutex> 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 @@ uint32_t SymbolFileDWARF::FindTypes(
     bool append, uint32_t max_matches,
     llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
     TypeMap &types) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   // If we aren't appending the results to this list, then clear the list
   if (!append)
     types.Clear();
@@ -2440,6 +2441,7 @@ uint32_t SymbolFileDWARF::FindTypes(
 
 size_t SymbolFileDWARF::FindTypes(const std::vector<CompilerContext> &context,
                                   bool append, TypeMap &types) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!append)
     types.Clear();
 
@@ -2486,6 +2488,7 @@ size_t SymbolFileDWARF::FindTypes(const
 CompilerDeclContext
 SymbolFileDWARF::FindNamespace(ConstString name,
                                const CompilerDeclContext *parent_decl_ctx) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
 
   if (log) {
@@ -3009,7 +3012,7 @@ size_t SymbolFileDWARF::ParseTypes(const
 }
 
 size_t SymbolFileDWARF::ParseBlocksRecursive(Function &func) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   CompileUnit *comp_unit = func.GetCompileUnit();
   lldbassert(comp_unit);
 
@@ -3029,7 +3032,7 @@ size_t SymbolFileDWARF::ParseBlocksRecur
 }
 
 size_t SymbolFileDWARF::ParseTypes(CompileUnit &comp_unit) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   size_t types_added = 0;
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
   if (dwarf_cu) {
@@ -3045,7 +3048,7 @@ size_t SymbolFileDWARF::ParseTypes(Compi
 }
 
 size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
-  ASSERT_MODULE_LOCK(this);
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (sc.comp_unit != nullptr) {
     DWARFDebugInfo *info = DebugInfo();
     if (info == nullptr)

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Tue Jul 30 01:20:05 2019
@@ -623,6 +623,7 @@ size_t SymbolFileDWARFDebugMap::GetCompU
 
 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);
@@ -630,6 +631,7 @@ SymbolFileDWARFDebugMap::ParseLanguage(C
 }
 
 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);
@@ -637,6 +639,7 @@ size_t SymbolFileDWARFDebugMap::ParseFun
 }
 
 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);
@@ -644,6 +647,7 @@ bool SymbolFileDWARFDebugMap::ParseLineT
 }
 
 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);
@@ -652,6 +656,7 @@ bool SymbolFileDWARFDebugMap::ParseDebug
 
 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);
@@ -659,6 +664,7 @@ bool SymbolFileDWARFDebugMap::ParseSuppo
 }
 
 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);
@@ -667,6 +673,7 @@ bool SymbolFileDWARFDebugMap::ParseIsOpt
 
 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);
@@ -674,6 +681,7 @@ bool SymbolFileDWARFDebugMap::ParseImpor
 }
 
 size_t SymbolFileDWARFDebugMap::ParseBlocksRecursive(Function &func) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   CompileUnit *comp_unit = func.GetCompileUnit();
   if (!comp_unit)
     return 0;
@@ -685,6 +693,7 @@ size_t SymbolFileDWARFDebugMap::ParseBlo
 }
 
 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);
@@ -693,6 +702,7 @@ size_t SymbolFileDWARFDebugMap::ParseTyp
 
 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);
@@ -700,6 +710,7 @@ SymbolFileDWARFDebugMap::ParseVariablesF
 }
 
 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)
@@ -736,6 +747,7 @@ 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();
   if (symtab) {
@@ -778,6 +790,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolCo
 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();
 
@@ -832,6 +845,7 @@ uint32_t SymbolFileDWARFDebugMap::Privat
 uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables(
     ConstString name, const CompilerDeclContext *parent_decl_ctx,
     uint32_t max_matches, VariableList &variables) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
 
   // Remember how many variables are in the list before we search.
   const uint32_t original_size = variables.GetSize();
@@ -868,6 +882,7 @@ uint32_t
 SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression &regex,
                                              uint32_t max_matches,
                                              VariableList &variables) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   // Remember how many variables are in the list before we search.
   const uint32_t original_size = variables.GetSize();
 
@@ -995,6 +1010,7 @@ uint32_t SymbolFileDWARFDebugMap::FindFu
     ConstString name, const CompilerDeclContext *parent_decl_ctx,
     FunctionNameType name_type_mask, bool include_inlines, bool append,
     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)",
@@ -1023,6 +1039,7 @@ uint32_t SymbolFileDWARFDebugMap::FindFu
                                                 bool include_inlines,
                                                 bool append,
                                                 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')",
@@ -1050,6 +1067,7 @@ uint32_t SymbolFileDWARFDebugMap::FindFu
 size_t 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)",
@@ -1180,6 +1198,7 @@ uint32_t SymbolFileDWARFDebugMap::FindTy
     bool append, uint32_t max_matches,
     llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
     TypeMap &types) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!append)
     types.Clear();
 
@@ -1210,6 +1229,7 @@ uint32_t SymbolFileDWARFDebugMap::FindTy
 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 {

Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Tue Jul 30 01:20:05 2019
@@ -899,6 +899,7 @@ lldb::CompUnitSP SymbolFileNativePDB::Pa
 }
 
 lldb::LanguageType SymbolFileNativePDB::ParseLanguage(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   PdbSymUid uid(comp_unit.GetID());
   lldbassert(uid.kind() == PdbSymUidKind::Compiland);
 
@@ -914,6 +915,7 @@ lldb::LanguageType SymbolFileNativePDB::
 void SymbolFileNativePDB::AddSymbols(Symtab &symtab) { return; }
 
 size_t SymbolFileNativePDB::ParseFunctions(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   PdbSymUid uid{comp_unit.GetID()};
   lldbassert(uid.kind() == PdbSymUidKind::Compiland);
   uint16_t modi = uid.asCompiland().modi;
@@ -947,6 +949,7 @@ static bool NeedsResolvedCompileUnit(uin
 
 uint32_t SymbolFileNativePDB::ResolveSymbolContext(
     const Address &addr, SymbolContextItem resolve_scope, SymbolContext &sc) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   uint32_t resolved_flags = 0;
   lldb::addr_t file_addr = addr.GetFileAddress();
 
@@ -1051,6 +1054,7 @@ bool SymbolFileNativePDB::ParseLineTable
   // 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<std::recursive_mutex> guard(GetModuleMutex());
   PdbSymUid cu_id(comp_unit.GetID());
   lldbassert(cu_id.kind() == PdbSymUidKind::Compiland);
   CompilandIndexItem *cci =
@@ -1129,6 +1133,7 @@ bool SymbolFileNativePDB::ParseDebugMacr
 
 bool SymbolFileNativePDB::ParseSupportFiles(CompileUnit &comp_unit,
                                             FileSpecList &support_files) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   PdbSymUid cu_id(comp_unit.GetID());
   lldbassert(cu_id.kind() == PdbSymUidKind::Compiland);
   CompilandIndexItem *cci =
@@ -1159,6 +1164,7 @@ bool SymbolFileNativePDB::ParseImportedM
 }
 
 size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   GetOrCreateBlock(PdbSymUid(func.GetID()).asCompilandSym());
   // FIXME: Parse child blocks
   return 1;
@@ -1169,6 +1175,7 @@ void SymbolFileNativePDB::DumpClangAST(S
 uint32_t SymbolFileNativePDB::FindGlobalVariables(
     ConstString name, const CompilerDeclContext *parent_decl_ctx,
     uint32_t max_matches, VariableList &variables) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
 
   std::vector<SymbolAndOffset> results = m_index->globals().findRecordsByName(
@@ -1197,6 +1204,7 @@ uint32_t SymbolFileNativePDB::FindFuncti
     ConstString name, const CompilerDeclContext *parent_decl_ctx,
     FunctionNameType name_type_mask, bool include_inlines, bool append,
     SymbolContextList &sc_list) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   // For now we only support lookup by method name.
   if (!(name_type_mask & eFunctionNameTypeMethod))
     return 0;
@@ -1238,6 +1246,7 @@ uint32_t SymbolFileNativePDB::FindTypes(
     ConstString name, const CompilerDeclContext *parent_decl_ctx,
     bool append, uint32_t max_matches,
     llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!append)
     types.Clear();
   if (!name)
@@ -1279,6 +1288,7 @@ size_t SymbolFileNativePDB::FindTypesByN
 }
 
 size_t SymbolFileNativePDB::ParseTypes(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> 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::ParseVariabl
 }
 
 size_t SymbolFileNativePDB::ParseVariablesForContext(const SymbolContext &sc) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   lldbassert(sc.function || sc.comp_unit);
 
   VariableListSP variables;
@@ -1528,6 +1539,7 @@ SymbolFileNativePDB::GetDeclContextConta
 }
 
 Type *SymbolFileNativePDB::ResolveTypeUID(lldb::user_id_t type_uid) {
+  std::lock_guard<std::recursive_mutex> 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

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Tue Jul 30 01:20:05 2019
@@ -257,6 +257,7 @@ lldb::CompUnitSP SymbolFilePDB::ParseCom
 }
 
 lldb::LanguageType SymbolFilePDB::ParseLanguage(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID());
   if (!compiland_up)
     return lldb::eLanguageTypeUnknown;
@@ -311,6 +312,7 @@ SymbolFilePDB::ParseCompileUnitFunctionF
 }
 
 size_t SymbolFilePDB::ParseFunctions(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   size_t func_added = 0;
   auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID());
   if (!compiland_up)
@@ -329,6 +331,7 @@ size_t SymbolFilePDB::ParseFunctions(Com
 }
 
 bool SymbolFilePDB::ParseLineTable(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (comp_unit.GetLineTable())
     return true;
   return ParseCompileUnitLineTable(comp_unit, 0);
@@ -347,6 +350,7 @@ bool SymbolFilePDB::ParseSupportFiles(
   // 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<std::recursive_mutex> guard(GetModuleMutex());
   auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID());
   if (!compiland_up)
     return false;
@@ -424,6 +428,7 @@ static size_t ParseFunctionBlocksForPDBS
 }
 
 size_t SymbolFilePDB::ParseBlocksRecursive(Function &func) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   size_t num_added = 0;
   auto uid = func.GetID();
   auto pdb_func_up = m_session_up->getConcreteSymbolById<PDBSymbolFunc>(uid);
@@ -436,6 +441,7 @@ size_t SymbolFilePDB::ParseBlocksRecursi
 }
 
 size_t SymbolFilePDB::ParseTypes(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
 
   size_t num_added = 0;
   auto compiland = GetPDBCompilandByUID(comp_unit.GetID());
@@ -488,6 +494,7 @@ size_t SymbolFilePDB::ParseTypes(Compile
 
 size_t
 SymbolFilePDB::ParseVariablesForContext(const lldb_private::SymbolContext &sc) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!sc.comp_unit)
     return 0;
 
@@ -536,6 +543,7 @@ SymbolFilePDB::ParseVariablesForContext(
 }
 
 lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) {
+  std::lock_guard<std::recursive_mutex> 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 @@ uint32_t
 SymbolFilePDB::ResolveSymbolContext(const lldb_private::Address &so_addr,
                                     SymbolContextItem resolve_scope,
                                     lldb_private::SymbolContext &sc) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   uint32_t resolved_flags = 0;
   if (resolve_scope & eSymbolContextCompUnit ||
       resolve_scope & eSymbolContextVariable ||
@@ -726,6 +735,7 @@ SymbolFilePDB::ResolveSymbolContext(cons
 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<std::recursive_mutex> 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 @@ uint32_t SymbolFilePDB::FindGlobalVariab
     lldb_private::ConstString name,
     const lldb_private::CompilerDeclContext *parent_decl_ctx,
     uint32_t max_matches, lldb_private::VariableList &variables) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
     return 0;
   if (name.IsEmpty())
@@ -1082,6 +1093,7 @@ uint32_t
 SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression &regex,
                                    uint32_t max_matches,
                                    lldb_private::VariableList &variables) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!regex.IsValid())
     return 0;
   auto results = m_global_scope_up->findAllChildren<PDBSymbolData>();
@@ -1239,6 +1251,7 @@ uint32_t SymbolFilePDB::FindFunctions(
     const lldb_private::CompilerDeclContext *parent_decl_ctx,
     FunctionNameType name_type_mask, bool include_inlines, bool append,
     lldb_private::SymbolContextList &sc_list) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!append)
     sc_list.Clear();
   lldbassert((name_type_mask & eFunctionNameTypeAuto) == 0);
@@ -1294,6 +1307,7 @@ uint32_t
 SymbolFilePDB::FindFunctions(const lldb_private::RegularExpression &regex,
                              bool include_inlines, bool append,
                              lldb_private::SymbolContextList &sc_list) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!append)
     sc_list.Clear();
   if (!regex.IsValid())
@@ -1380,6 +1394,7 @@ uint32_t SymbolFilePDB::FindTypes(
     uint32_t max_matches,
     llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
     lldb_private::TypeMap &types) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (!append)
     types.Clear();
   if (!name)
@@ -1567,6 +1582,7 @@ void SymbolFilePDB::GetTypesForPDBSymbol
 size_t SymbolFilePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
                                TypeClass type_mask,
                                lldb_private::TypeList &type_list) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   TypeCollection type_collection;
   uint32_t old_size = type_list.GetSize();
   CompileUnit *cu =
@@ -1615,6 +1631,7 @@ PDBASTParser *SymbolFilePDB::GetPDBAstPa
 lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
     lldb_private::ConstString name,
     const lldb_private::CompilerDeclContext *parent_decl_ctx) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
   auto clang_type_system = llvm::dyn_cast_or_null<ClangASTContext>(type_system);
   if (!clang_type_system)

Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Tue Jul 30 01:20:05 2019
@@ -136,6 +136,7 @@ lldb::LanguageType SymbolFileSymtab::Par
 }
 
 size_t SymbolFileSymtab::ParseFunctions(CompileUnit &comp_unit) {
+  std::lock_guard<std::recursive_mutex> 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 @@ bool SymbolFileSymtab::CompleteType(lldb
 uint32_t SymbolFileSymtab::ResolveSymbolContext(const Address &so_addr,
                                                 SymbolContextItem resolve_scope,
                                                 SymbolContext &sc) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (m_obj_file->GetSymtab() == nullptr)
     return 0;
 

Modified: lldb/trunk/source/Symbol/SymbolFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolFile.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolFile.cpp Tue Jul 30 01:20:05 2019
@@ -179,6 +179,7 @@ uint32_t SymbolFile::GetNumCompileUnits(
 }
 
 CompUnitSP SymbolFile::GetCompileUnitAtIndex(uint32_t idx) {
+  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   uint32_t num = GetNumCompileUnits();
   if (idx >= num)
     return nullptr;

Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=367298&r1=367297&r2=367298&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolVendor.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolVendor.cpp Tue Jul 30 01:20:05 2019
@@ -76,135 +76,83 @@ void SymbolVendor::AddSymbolFileRepresen
 }
 
 size_t SymbolVendor::GetNumCompileUnits() {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<SourceModule> &imported_modules) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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 SymbolVendor::ResolveSymbolCont
                                             uint32_t line, bool check_inlines,
                                             SymbolContextItem resolve_scope,
                                             SymbolContextList &sc_list) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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 @@ size_t
 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<std::recursive_mutex> 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 &regex,
                                          size_t max_matches,
                                          VariableList &variables) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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 @@ size_t SymbolVendor::FindFunctions(Const
                                    FunctionNameType name_type_mask,
                                    bool include_inlines, bool append,
                                    SymbolContextList &sc_list) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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 &regex,
                                    bool include_inlines, bool append,
                                    SymbolContextList &sc_list) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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 @@ size_t SymbolVendor::FindTypes(
     bool append, size_t max_matches,
     llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
     TypeMap &types) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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(
 
 size_t SymbolVendor::FindTypes(const std::vector<CompilerContext> &context,
                                bool append, TypeMap &types) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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::FindTypes(const std
 
 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<std::recursive_mutex> 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 @@ CompilerDeclContext
 SymbolVendor::FindNamespace(ConstString name,
                             const CompilerDeclContext *parent_decl_ctx) {
   CompilerDeclContext namespace_decl_ctx;
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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 @@ void SymbolVendor::Dump(Stream *s) {
 }
 
 CompUnitSP SymbolVendor::GetCompileUnitAtIndex(size_t idx) {
-  ModuleSP module_sp(GetModule());
-  if (module_sp) {
-    std::lock_guard<std::recursive_mutex> 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;
 }
 




More information about the lldb-commits mailing list