[Lldb-commits] [lldb] r118866 - in /lldb/trunk/tools/debugserver/source/MacOSX: MachThread.cpp MachThread.h MachThreadList.cpp

Greg Clayton gclayton at apple.com
Thu Nov 11 16:49:23 PST 2010


Author: gclayton
Date: Thu Nov 11 18:49:23 2010
New Revision: 118866

URL: http://llvm.org/viewvc/llvm-project?rev=118866&view=rev
Log:
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.


Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h
    lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=118866&r1=118865&r2=118866&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Thu Nov 11 18:49:23 2010
@@ -39,7 +39,10 @@
     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 @@
 }
 
 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))

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h?rev=118866&r1=118865&r2=118866&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h Thu Nov 11 18:49:23 2010
@@ -89,6 +89,10 @@
     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:

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=118866&r1=118865&r2=118866&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Thu Nov 11 18:49:23 2010
@@ -237,7 +237,10 @@
                 {
                     // 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);
                 }
             }
 





More information about the lldb-commits mailing list