[Lldb-commits] [lldb] r235811 - Fix CMIUtilThreadActiveObjBase::ThreadIsActive when a thread has died (MI)

Ilia K ki.stfu at gmail.com
Sat Apr 25 14:20:00 PDT 2015


Author: ki.stfu
Date: Sat Apr 25 16:20:00 2015
New Revision: 235811

URL: http://llvm.org/viewvc/llvm-project?rev=235811&view=rev
Log:
Fix CMIUtilThreadActiveObjBase::ThreadIsActive when a thread has died (MI)


Modified:
    lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.cpp
    lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.h

Modified: lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.cpp?rev=235811&r1=235810&r2=235811&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.cpp Sat Apr 25 16:20:00 2015
@@ -205,6 +205,8 @@ CMIUtilThreadActiveObjBase::ThreadManage
     // Execute the finish routine just before we die
     // to give the object a chance to clean up
     ThreadFinish();
+
+    m_thread.Finish();
 }
 
 //---------------------------------------------------------------------------------------
@@ -214,6 +216,7 @@ CMIUtilThreadActiveObjBase::ThreadManage
 //
 CMIUtilThread::CMIUtilThread(void)
     : m_pThread(nullptr)
+    , m_bIsActive(false)
 {
 }
 
@@ -266,12 +269,24 @@ CMIUtilThread::Join(void)
 bool
 CMIUtilThread::IsActive(void)
 {
-    // Lock while we access the thread pointer
+    // Lock while we access the thread status
     CMIUtilThreadLock _lock(m_mutex);
-    if (m_pThread == nullptr)
-        return false;
-    else
-        return true;
+    return m_bIsActive;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Finish this thread
+// Type:    Method.
+// Args:    None.
+// Return:  None.
+// Throws:  None.
+//--
+void
+CMIUtilThread::Finish(void)
+{
+    // Lock while we access the thread status
+    CMIUtilThreadLock _lock(m_mutex);
+    m_bIsActive = false;
 }
 
 //++ ------------------------------------------------------------------------------------
@@ -286,8 +301,12 @@ CMIUtilThread::IsActive(void)
 bool
 CMIUtilThread::Start(FnThreadProc vpFn, void *vpArg)
 {
-    // Create the std thread, which starts immediately
+    // Lock while we access the thread pointer and status
+    CMIUtilThreadLock _lock(m_mutex);
+
+    // Create the std thread, which starts immediately and update its status
     m_pThread = new std::thread(vpFn, vpArg);
+    m_bIsActive = true;
 
     // We expect to always be able to create one
     assert(m_pThread != nullptr);

Modified: lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.h?rev=235811&r1=235810&r2=235811&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.h (original)
+++ lldb/trunk/tools/lldb-mi/MIUtilThreadBaseStd.h Sat Apr 25 16:20:00 2015
@@ -75,6 +75,8 @@ class CMIUtilThread
     Join(void); // Wait for this thread to stop
     bool
     IsActive(void); // Returns true if this thread is running
+    void
+    Finish(void); // Finish this thread
 
     // Overrideable:
   public:
@@ -84,6 +86,7 @@ class CMIUtilThread
   private:
     CMIUtilThreadMutex m_mutex;
     std::thread *m_pThread;
+    bool m_bIsActive;
 };
 
 //++ ============================================================================





More information about the lldb-commits mailing list