[Lldb-commits] [lldb] r230945 - Make it possible to stop the operation thread in NativeProcessLinux

Tamas Berghammer tberghammer at google.com
Mon Mar 2 03:04:04 PST 2015


Author: tberghammer
Date: Mon Mar  2 05:04:03 2015
New Revision: 230945

URL: http://llvm.org/viewvc/llvm-project?rev=230945&view=rev
Log:
Make it possible to stop the operation thread in NativeProcessLinux

Previously the operation thread is stopped with a cancel event but
pthread_cancel is not supported on android. This CL creates a custom
operation which asks the operation thread to exit without any pthread
call.

Differential revision: http://reviews.llvm.org/D7937

Modified:
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=230945&r1=230944&r2=230945&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Mon Mar  2 05:04:03 2015
@@ -3370,6 +3370,15 @@ NativeProcessLinux::ServeOperation(Opera
             assert(false && "Unexpected errno from sem_wait");
         }
 
+        // nullptr as operation means the operation thread should exit. Cancel() can't be used
+        // because it is not supported on android.
+        if (!monitor->m_operation)
+        {
+            // notify calling thread that operation is complete
+            sem_post(&monitor->m_operation_done);
+            break;
+        }
+
         reinterpret_cast<Operation*>(monitor->m_operation)->Execute(monitor);
 
         // notify calling thread that operation is complete
@@ -3555,8 +3564,8 @@ NativeProcessLinux::StopMonitoringChildP
 void
 NativeProcessLinux::StopMonitor()
 {
-    StopMonitoringChildProcess();
     StopOpThread();
+    StopMonitoringChildProcess();
     StopCoordinatorThread ();
     sem_destroy(&m_operation_pending);
     sem_destroy(&m_operation_done);
@@ -3574,7 +3583,7 @@ NativeProcessLinux::StopOpThread()
     if (!m_operation_thread.IsJoinable())
         return;
 
-    m_operation_thread.Cancel();
+    DoOperation(nullptr); // nullptr as operation ask the operation thread to exit
     m_operation_thread.Join(nullptr);
 }
 





More information about the lldb-commits mailing list