summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/tools/debugserver/source/MacOSX/MachThread.cpp')
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThread.cpp35
1 files changed, 34 insertions, 1 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))
OpenPOWER on IntegriCloud