[Lldb-commits] [lldb] r124111 - /lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp

Greg Clayton gclayton at apple.com
Sun Jan 23 22:22:23 PST 2011


Author: gclayton
Date: Mon Jan 24 00:22:23 2011
New Revision: 124111

URL: http://llvm.org/viewvc/llvm-project?rev=124111&view=rev
Log:
Discover new threads right before we continue a process since libdispatch has
been known to make threads for us while our process/task is suspended.


Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=124111&r1=124110&r2=124111&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Mon Jan 24 00:22:23 2011
@@ -315,6 +315,13 @@
 MachThreadList::ProcessWillResume(MachProcess *process, const DNBThreadResumeActions &thread_actions)
 {
     PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+
+    // Update our thread list, because sometimes libdispatch or the kernel
+    // will spawn threads while a task is suspended.
+    MachThreadList::collection new_threads;
+
+    UpdateThreadList(process, true, &new_threads);
+
     const uint32_t num_threads = m_threads.size();
     for (uint32_t idx = 0; idx < num_threads; ++idx)
     {
@@ -326,21 +333,15 @@
         thread->ThreadWillResume (thread_action);
     }
     
-    if (DNBLogCheckLogBit(LOG_THREAD))
+    if (new_threads.size())
     {
-        MachThreadList::collection new_threads;
-        UpdateThreadList(process, true, &new_threads);
-        if (new_threads.size())
+        for (uint32_t idx = 0, num_new_threads = new_threads.size(); idx < num_new_threads; ++idx)
         {
-            
-            for (uint32_t idx = 0, num_new_threads = new_threads.size(); idx < num_new_threads; ++idx)
-            {
-                DNBLogThreadedIf (LOG_THREAD, "MachThreadList::ProcessWillResume (pid = %4.4x) stop-id=%u, newly discovered thread: 0x%4.4x, thread-is-user-ready=%i)", 
-                                  process->ProcessID(), 
-                                  process->StopCount(), 
-                                  new_threads[idx]->ThreadID(),
-                                  new_threads[idx]->IsUserReady());
-            }
+            DNBLogThreadedIf (LOG_THREAD, "MachThreadList::ProcessWillResume (pid = %4.4x) stop-id=%u, resuming newly discovered thread: 0x%4.4x, thread-is-user-ready=%i)", 
+                              process->ProcessID(), 
+                              process->StopCount(), 
+                              new_threads[idx]->ThreadID(),
+                              new_threads[idx]->IsUserReady());
         }
     }
 }





More information about the lldb-commits mailing list