[Lldb-commits] [lldb] r163541 - in /lldb/trunk/source: Commands/CommandObjectProcess.cpp Commands/CommandObjectThread.cpp Target/Process.cpp

Jim Ingham jingham at apple.com
Mon Sep 10 13:50:15 PDT 2012


Author: jingham
Date: Mon Sep 10 15:50:15 2012
New Revision: 163541

URL: http://llvm.org/viewvc/llvm-project?rev=163541&view=rev
Log:
Fixed a few places where we were doing:

uint32_t size = ThreadList.GetSize();
for (i=0; i < size; ++i)

without grabbing the thread list mutex.

Modified:
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Commands/CommandObjectThread.cpp
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=163541&r1=163540&r2=163541&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Sep 10 15:50:15 2012
@@ -792,14 +792,17 @@
                 }
             }
             
-            const uint32_t num_threads = process->GetThreadList().GetSize();
+            {  // Scope for thread list mutex:
+                Mutex::Locker locker (process->GetThreadList().GetMutex());
+                const uint32_t num_threads = process->GetThreadList().GetSize();
 
-            // Set the actions that the threads should each take when resuming
-            for (uint32_t idx=0; idx<num_threads; ++idx)
-            {
-                process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning);
+                // Set the actions that the threads should each take when resuming
+                for (uint32_t idx=0; idx<num_threads; ++idx)
+                {
+                    process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning);
+                }
             }
-
+            
             Error error(process->Resume());
             if (error.Success())
             {

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=163541&r1=163540&r2=163541&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Mon Sep 10 15:50:15 2012
@@ -185,6 +185,7 @@
         else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0)
         {
             Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+            Mutex::Locker locker (process->GetThreadList().GetMutex());
             uint32_t num_threads = process->GetThreadList().GetSize();
             for (uint32_t i = 0; i < num_threads; i++)
             {
@@ -208,6 +209,7 @@
         {
             uint32_t num_args = command.GetArgumentCount();
             Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+            Mutex::Locker locker (process->GetThreadList().GetMutex());
             std::vector<ThreadSP> thread_sps;
 
             for (uint32_t i = 0; i < num_args; i++)

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=163541&r1=163540&r2=163541&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Sep 10 15:50:15 2012
@@ -4860,6 +4860,7 @@
 {
     size_t num_thread_infos_dumped = 0;
     
+    Mutex::Locker locker (GetThreadList().GetMutex());
     const size_t num_threads = GetThreadList().GetSize();
     for (uint32_t i = 0; i < num_threads; i++)
     {





More information about the lldb-commits mailing list