second pass over removal of Mutex and Condition

llvm-svn: 270024
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index b7ed2a2..f8dd6ef 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1092,9 +1092,9 @@
             return false;
         }
 
-        Mutex::Locker locker;
-        target->GetBreakpointList().GetListMutex(locker);
-        
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList().GetListMutex(lock);
+
         BreakpointIDList valid_bp_ids;
 
         CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids);
@@ -1222,8 +1222,8 @@
             return false;
         }
 
-        Mutex::Locker locker;
-        target->GetBreakpointList().GetListMutex(locker);
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList().GetListMutex(lock);
 
         const BreakpointList &breakpoints = target->GetBreakpointList();
 
@@ -1339,8 +1339,8 @@
             return false;
         }
 
-        Mutex::Locker locker;
-        target->GetBreakpointList().GetListMutex(locker);
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList().GetListMutex(lock);
 
         const BreakpointList &breakpoints = target->GetBreakpointList();
         size_t num_breakpoints = breakpoints.GetSize();
@@ -1523,8 +1523,8 @@
         }
 
         const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
-        Mutex::Locker locker;
-        target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList(m_options.m_internal).GetListMutex(lock);
 
         size_t num_breakpoints = breakpoints.GetSize();
 
@@ -1713,8 +1713,8 @@
         if (m_options.m_line_num != 0)
             break_type = eClearTypeFileAndLine;
 
-        Mutex::Locker locker;
-        target->GetBreakpointList().GetListMutex(locker);
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList().GetListMutex(lock);
 
         BreakpointList &breakpoints = target->GetBreakpointList();
         size_t num_breakpoints = breakpoints.GetSize();
@@ -1901,9 +1901,9 @@
             return false;
         }
 
-        Mutex::Locker locker;
-        target->GetBreakpointList().GetListMutex(locker);
-        
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList().GetListMutex(lock);
+
         const BreakpointList &breakpoints = target->GetBreakpointList();
 
         size_t num_breakpoints = breakpoints.GetSize();
@@ -2118,9 +2118,9 @@
             return false;
         }
 
-        Mutex::Locker locker;
-        target->GetBreakpointList().GetListMutex(locker);
-        
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList().GetListMutex(lock);
+
         const BreakpointList &breakpoints = target->GetBreakpointList();
 
         size_t num_breakpoints = breakpoints.GetSize();
@@ -2211,9 +2211,9 @@
             return false;
         }
 
-        Mutex::Locker locker;
-        target->GetBreakpointList().GetListMutex(locker);
-        
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetBreakpointList().GetListMutex(lock);
+
         const BreakpointList &breakpoints = target->GetBreakpointList();
 
         size_t num_breakpoints = breakpoints.GetSize();
@@ -2292,9 +2292,9 @@
         if (m_name_options.m_name.OptionWasSet())
         {
             const char *name = m_name_options.m_name.GetCurrentValue();
-            Mutex::Locker locker;
-            target->GetBreakpointList().GetListMutex(locker);
-            
+            std::unique_lock<std::recursive_mutex> lock;
+            target->GetBreakpointList().GetListMutex(lock);
+
             BreakpointList &breakpoints = target->GetBreakpointList();
             for (BreakpointSP bp_sp : breakpoints.Breakpoints())
             {
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 857440b..2d1b0da 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -733,7 +733,7 @@
             }
             
             {  // Scope for thread list mutex:
-                Mutex::Locker locker (process->GetThreadList().GetMutex());
+                std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
                 const uint32_t num_threads = process->GetThreadList().GetSize();
 
                 // Set the actions that the threads should each take when resuming
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 1e7f1e5..45d372c 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1548,7 +1548,7 @@
 DumpModuleObjfileHeaders(Stream &strm, ModuleList &module_list)
 {
     size_t num_dumped = 0;
-    Mutex::Locker modules_locker(module_list.GetMutex());
+    std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
     const size_t num_modules = module_list.GetSize();
     if (num_modules > 0)
     {
@@ -2302,7 +2302,7 @@
             if (command.GetArgumentCount() == 0)
             {
                 // Dump all sections for all modules images
-                Mutex::Locker modules_locker(target->GetImages().GetMutex());
+                std::lock_guard<std::recursive_mutex> guard(target->GetImages().GetMutex());
                 const size_t num_modules = target->GetImages().GetSize();
                 if (num_modules > 0)
                 {
@@ -2532,7 +2532,7 @@
             {
                 // Dump all sections for all modules images
                 const ModuleList &target_modules = target->GetImages();
-                Mutex::Locker modules_locker (target_modules.GetMutex());
+                std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
                 const size_t num_modules = target_modules.GetSize();
                 if (num_modules > 0)
                 {
@@ -2633,7 +2633,7 @@
                 FileSpec file_spec(arg_cstr, false);
 
                 const ModuleList &target_modules = target->GetImages();
-                Mutex::Locker modules_locker(target_modules.GetMutex());
+                std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
                 const size_t num_modules = target_modules.GetSize();
                 if (num_modules > 0)
                 {
@@ -3296,7 +3296,6 @@
             // Otherwise it will lock the AllocationModuleCollectionMutex when accessing
             // the global module list directly.
             std::unique_lock<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex(), std::defer_lock);
-            Mutex::Locker locker;
 
             const ModuleList *module_list_ptr = nullptr;
             const size_t argc = command.GetArgumentCount();
@@ -3333,10 +3332,11 @@
                 module_list_ptr = &module_list;
             }
 
+            std::unique_lock<std::recursive_mutex> lock;
             if (module_list_ptr != nullptr)
             {
-                assert(use_global_module_list == false && "locking violation");
-                locker.Lock(module_list_ptr->GetMutex());
+                lock = std::unique_lock<std::recursive_mutex>(module_list_ptr->GetMutex());
+
                 num_modules = module_list_ptr->GetSize();
             }
 
@@ -4239,7 +4239,7 @@
                 // Dump all sections for all other modules
 
                 const ModuleList &target_modules = target->GetImages();
-                Mutex::Locker modules_locker(target_modules.GetMutex());
+                std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
                 const size_t num_modules = target_modules.GetSize();
                 if (num_modules > 0)
                 {
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index d82d99d..864300c 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -87,7 +87,7 @@
             const size_t num_args = command.GetArgumentCount();
             Process *process = m_exe_ctx.GetProcessPtr();
 
-            Mutex::Locker locker (process->GetThreadList().GetMutex());
+            std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
 
             for (size_t i = 0; i < num_args; i++)
             {
@@ -859,7 +859,7 @@
                 // These two lines appear at the beginning of both blocks in
                 // this if..else, but that is because we need to release the
                 // lock before calling process->Resume below.
-                Mutex::Locker locker (process->GetThreadList().GetMutex());
+                std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
                 const uint32_t num_threads = process->GetThreadList().GetSize();
                 std::vector<Thread *> resume_threads;
                 for (uint32_t i = 0; i < argc; ++i)
@@ -932,7 +932,7 @@
                 // These two lines appear at the beginning of both blocks in
                 // this if..else, but that is because we need to release the
                 // lock before calling process->Resume below.
-                Mutex::Locker locker (process->GetThreadList().GetMutex());
+                std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
                 const uint32_t num_threads = process->GetThreadList().GetSize();
                 Thread *current_thread = GetDefaultThread();
                 if (current_thread == nullptr)
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index d3071d5..ddda3ad 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -265,8 +265,9 @@
         }
 
         const WatchpointList &watchpoints = target->GetWatchpointList();
-        Mutex::Locker locker;
-        target->GetWatchpointList().GetListMutex(locker);
+
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetWatchpointList().GetListMutex(lock);
 
         size_t num_watchpoints = watchpoints.GetSize();
 
@@ -369,8 +370,8 @@
         if (!CheckTargetForWatchpointOperations(target, result))
             return false;
 
-        Mutex::Locker locker;
-        target->GetWatchpointList().GetListMutex(locker);
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetWatchpointList().GetListMutex(lock);
 
         const WatchpointList &watchpoints = target->GetWatchpointList();
 
@@ -444,8 +445,8 @@
         if (!CheckTargetForWatchpointOperations(target, result))
             return false;
 
-        Mutex::Locker locker;
-        target->GetWatchpointList().GetListMutex(locker);
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetWatchpointList().GetListMutex(lock);
 
         const WatchpointList &watchpoints = target->GetWatchpointList();
         size_t num_watchpoints = watchpoints.GetSize();
@@ -525,9 +526,9 @@
         if (!CheckTargetForWatchpointOperations(target, result))
             return false;
 
-        Mutex::Locker locker;
-        target->GetWatchpointList().GetListMutex(locker);
-        
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetWatchpointList().GetListMutex(lock);
+
         const WatchpointList &watchpoints = target->GetWatchpointList();
 
         size_t num_watchpoints = watchpoints.GetSize();
@@ -666,9 +667,9 @@
         if (!CheckTargetForWatchpointOperations(target, result))
             return false;
 
-        Mutex::Locker locker;
-        target->GetWatchpointList().GetListMutex(locker);
-        
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetWatchpointList().GetListMutex(lock);
+
         const WatchpointList &watchpoints = target->GetWatchpointList();
 
         size_t num_watchpoints = watchpoints.GetSize();
@@ -819,9 +820,9 @@
         if (!CheckTargetForWatchpointOperations(target, result))
             return false;
 
-        Mutex::Locker locker;
-        target->GetWatchpointList().GetListMutex(locker);
-        
+        std::unique_lock<std::recursive_mutex> lock;
+        target->GetWatchpointList().GetListMutex(lock);
+
         const WatchpointList &watchpoints = target->GetWatchpointList();
 
         size_t num_watchpoints = watchpoints.GetSize();