From 1b946bf6368353e9b56cbb3f29a1192706ff7ae2 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 12 Nov 2010 00:49:23 +0000 Subject: Fixed an issue with the MachThread class where we might not get the initial thread basic info state and not realize that a thread was already suspended or if a thread was starting up and not ready to be displayed to the user (in an uninterruptable state). If it is not user ready yet, we don't add it to our list of threads that can be played with. llvm-svn: 118866 --- .../tools/debugserver/source/MacOSX/MachThread.cpp | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'lldb/tools/debugserver/source/MacOSX/MachThread.cpp') diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp index 9d018f66ea6..c44c7db4081 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp @@ -39,7 +39,10 @@ MachThread::MachThread (MachProcess *process, thread_t thread) : if (num_reg_sets > 0) m_regSets.assign(regSetInfo, regSetInfo + num_reg_sets); - ::memset (&m_basicInfo, 0, sizeof (m_basicInfo)); + // Get the thread state so we know if a thread is in a state where we can't + // muck with it and also so we get the suspend count correct in case it was + // already suspended + GetBasicInfo(); DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::MachThread ( process = %p, tid = 0x%4.4x, seq_id = %u )", &m_process, m_tid, m_seq_id); } @@ -188,6 +191,36 @@ MachThread::InferiorThreadID() const return inferior_tid; } +bool +MachThread::IsUserReady() +{ + if (m_basicInfo.run_state == 0) + GetBasicInfo (); + + switch (m_basicInfo.run_state) + { + default: + case TH_STATE_UNINTERRUPTIBLE: + break; + + case TH_STATE_RUNNING: + case TH_STATE_STOPPED: + case TH_STATE_WAITING: + case TH_STATE_HALTED: + return true; + } + return false; +} + +struct thread_basic_info * +MachThread::GetBasicInfo () +{ + if (MachThread::GetBasicInfo(m_tid, &m_basicInfo)) + return &m_basicInfo; + return NULL; +} + + bool MachThread::GetBasicInfo(thread_t thread, struct thread_basic_info *basicInfoPtr) { -- cgit v1.2.3