summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-11-12 00:49:23 +0000
committerGreg Clayton <gclayton@apple.com>2010-11-12 00:49:23 +0000
commit1b946bf6368353e9b56cbb3f29a1192706ff7ae2 (patch)
treeafa0526ab6deaa3598eacca0c629333a6016c4b0 /lldb/tools/debugserver/source/MacOSX/MachThread.cpp
parent6d95ed176002a071cb9148ef82132fa81e4424c2 (diff)
downloadbcm5719-llvm-1b946bf6368353e9b56cbb3f29a1192706ff7ae2.tar.gz
bcm5719-llvm-1b946bf6368353e9b56cbb3f29a1192706ff7ae2.zip
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
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