[Lldb-commits] [lldb] r123300 - in /lldb/trunk: include/lldb/API/SBThread.h include/lldb/Target/Thread.h include/lldb/lldb-defines.h source/API/SBThread.cpp source/Target/Thread.cpp

Greg Clayton gclayton at apple.com
Tue Jan 11 18:25:42 PST 2011


Author: gclayton
Date: Tue Jan 11 20:25:42 2011
New Revision: 123300

URL: http://llvm.org/viewvc/llvm-project?rev=123300&view=rev
Log:
Added the following functions to SBThread to allow threads to be suspended when a process is resumed:

bool SBThread::Suspend();
bool SBThread::Resume();
bool SBThread::IsSuspended();


Modified:
    lldb/trunk/include/lldb/API/SBThread.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/include/lldb/lldb-defines.h
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=123300&r1=123299&r2=123300&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Tue Jan 11 20:25:42 2011
@@ -90,6 +90,36 @@
     void
     RunToAddress (lldb::addr_t addr);
 
+    //--------------------------------------------------------------------------
+    // LLDB currently supports process centric debugging which means when any
+    // thread in a process stops, all other threads are stopped. The Suspend()
+    // call here tells our process to suspend a thread and not let it run when
+    // the other threads in a process are allowed to run. So when 
+    // SBProcess::Continue() is called, any threads that aren't suspended will
+    // be allowed to run. If any of the SBThread functions for stepping are 
+    // called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the
+    // thread will now be allowed to run and these funtions will simply return.
+    //
+    // Eventually we plan to add support for thread centric debugging where each
+    // thread is controlled individually and each thread would broadcast its
+    // state, but we haven't implemented this yet.
+    // 
+    // Likewise the SBThread::Resume() call will again allow the thread to run
+    // when the process is continued.
+    //
+    // The Suspend() and Resume() functions are not currently reference counted,
+    // if anyone has the need for them to be reference counted, please let us
+    // know.
+    //--------------------------------------------------------------------------
+    bool
+    Suspend();
+    
+    bool
+    Resume ();
+    
+    bool
+    IsSuspended();
+
     uint32_t
     GetNumFrames ();
 

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=123300&r1=123299&r2=123300&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Tue Jan 11 20:25:42 2011
@@ -186,10 +186,16 @@
     GetProcess() const { return m_process; }
 
     int
-    GetResumeSignal () const;
+    GetResumeSignal () const
+    {
+        return m_resume_signal;
+    }
 
     void
-    SetResumeSignal (int signal);
+    SetResumeSignal (int signal)
+    {
+        m_resume_signal = signal;
+    }
 
     lldb::StateType
     GetState() const;
@@ -201,10 +207,16 @@
     SetState (lldb::StateType state);
 
     lldb::StateType
-    GetResumeState () const;
+    GetResumeState () const
+    {
+        return m_resume_state;
+    }
 
     void
-    SetResumeState (lldb::StateType state);
+    SetResumeState (lldb::StateType state)
+    {
+        m_resume_state = state;
+    }
 
     // This function is called on all the threads before "WillResume" in case
     // a thread needs to change its state before the ThreadList polls all the

Modified: lldb/trunk/include/lldb/lldb-defines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=123300&r1=123299&r2=123300&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-defines.h (original)
+++ lldb/trunk/include/lldb/lldb-defines.h Tue Jan 11 20:25:42 2011
@@ -21,7 +21,14 @@
 #endif
 
 //----------------------------------------------------------------------
-// lldb defines
+// LLDB version
+//
+// A build script phase can modify this version number if needed.
+//----------------------------------------------------------------------
+//#define LLDB_VERSION
+
+//----------------------------------------------------------------------
+// LLDB defines
 //----------------------------------------------------------------------
 #define LLDB_GENERIC_ERROR              UINT32_MAX
 

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=123300&r1=123299&r2=123300&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Tue Jan 11 20:25:42 2011
@@ -562,6 +562,36 @@
 
 }
 
+bool
+SBThread::Suspend()
+{
+    if (m_opaque_sp)
+    {
+        m_opaque_sp->SetResumeState (eStateSuspended);
+        return true;
+    }
+    return false;
+}
+
+bool
+SBThread::Resume ()
+{
+    if (m_opaque_sp)
+    {
+        m_opaque_sp->SetResumeState (eStateRunning);
+        return true;
+    }
+    return false;
+}
+
+bool
+SBThread::IsSuspended()
+{
+    if (m_opaque_sp)
+        m_opaque_sp->GetResumeState () == eStateSuspended;
+    return false;
+}
+
 SBProcess
 SBThread::GetProcess ()
 {

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=123300&r1=123299&r2=123300&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Jan 11 20:25:42 2011
@@ -85,30 +85,6 @@
     m_destroy_called = true;
 }
 
-int
-Thread::GetResumeSignal () const
-{
-    return m_resume_signal;
-}
-
-void
-Thread::SetResumeSignal (int signal)
-{
-    m_resume_signal = signal;
-}
-
-StateType
-Thread::GetResumeState () const
-{
-    return m_resume_state;
-}
-
-void
-Thread::SetResumeState (StateType state)
-{
-    m_resume_state = state;
-}
-
 lldb::StopInfoSP
 Thread::GetStopInfo ()
 {





More information about the lldb-commits mailing list