From 050f33cee8d42c148150bc78a32c1f5998d2a5de Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 24 Jan 2011 06:22:23 +0000 Subject: 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. llvm-svn: 124111 --- .../debugserver/source/MacOSX/MachThreadList.cpp | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp') diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp index 38c25d2f03b..961e7e53b7b 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -315,6 +315,13 @@ void 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 @@ MachThreadList::ProcessWillResume(MachProcess *process, const DNBThreadResumeAct 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()); } } } -- cgit v1.2.3