diff options
Diffstat (limited to 'lldb/tools/debugserver/source/MacOSX')
-rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachThread.cpp | 35 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachThread.h | 4 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp | 5 |
3 files changed, 42 insertions, 2 deletions
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); } @@ -189,6 +192,36 @@ MachThread::InferiorThreadID() const } 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) { if (ThreadIDIsValid(thread)) diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h index 2bf5ff2c3bb..f7f2ce8b1ab 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h @@ -89,6 +89,10 @@ public: nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); void NotifyBreakpointChanged (const DNBBreakpoint *bp); + + bool IsUserReady(); + struct thread_basic_info * + GetBasicInfo (); const char * GetBasicInfoAsString () const; const char * GetName (); protected: diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp index 4f096b812de..db2a00a304a 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -237,7 +237,10 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update) { // We don't have this thread, lets add it. MachThreadSP threadSP(new MachThread(process, thread_list[idx])); - currThreads.push_back(threadSP); + // Make sure the thread is ready to be displayed and shown to users + // before we add this thread to our list... + if (threadSP->IsUserReady()) + currThreads.push_back(threadSP); } } |