Re-enable m_private_run_lock changes from 179329, but only for Apple hosted builds so it doesn't break the buildbots. We will try and work the issues out in the Apple build before enabling this feature for everyone.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179772 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index a6a6b54..c65ceb1 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -1019,7 +1019,10 @@
     m_allocated_memory_cache (*this),
     m_should_detach (false),
     m_next_event_action_ap(),
-    m_run_lock (),
+    m_public_run_lock (),
+#if defined(__APPLE__)
+    m_private_run_lock (),
+#endif
     m_currently_handling_event(false),
     m_finalize_called(false),
     m_last_broadcast_state (eStateInvalid),
@@ -1138,6 +1141,10 @@
     // contain events that have ProcessSP values in them which can keep this
     // process around forever. These events need to be cleared out.
     m_private_state_listener.Clear();
+    m_public_run_lock.WriteUnlock();
+#if defined(__APPLE__)
+    m_private_run_lock.WriteUnlock();
+#endif
     m_finalize_called = true;
 }
 
@@ -1619,7 +1626,7 @@
         {
             if (log)
                 log->Printf("Process::SetPublicState (%s) -- unlocking run lock for detach", StateAsCString(new_state));
-            m_run_lock.WriteUnlock();
+            m_public_run_lock.WriteUnlock();
         }
         else
         {
@@ -1631,7 +1638,7 @@
                 {
                     if (log)
                         log->Printf("Process::SetPublicState (%s) -- unlocking run lock", StateAsCString(new_state));
-                    m_run_lock.WriteUnlock();
+                    m_public_run_lock.WriteUnlock();
                 }
             }
         }
@@ -1644,7 +1651,7 @@
     Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
     if (log)
         log->Printf("Process::Resume -- locking run lock");
-    if (!m_run_lock.WriteTryLock())
+    if (!m_public_run_lock.WriteTryLock())
     {
         Error error("Resume request failed - process still running.");
         if (log)
@@ -2766,7 +2773,7 @@
                 SetPublicState (eStateLaunching);
                 m_should_detach = false;
 
-                if (m_run_lock.WriteTryLock())
+                if (m_public_run_lock.WriteTryLock())
                 {
                     // Now launch using these arguments.
                     error = DoLaunch (exe_module, launch_info);
@@ -2950,7 +2957,7 @@
                 error = WillAttachToProcessWithName(process_name, wait_for_launch);
                 if (error.Success())
                 {
-                    if (m_run_lock.WriteTryLock())
+                    if (m_public_run_lock.WriteTryLock())
                     {
                         m_should_detach = true;
                         SetPublicState (eStateAttaching);
@@ -3027,7 +3034,7 @@
         if (error.Success())
         {
 
-            if (m_run_lock.WriteTryLock())
+            if (m_public_run_lock.WriteTryLock())
             {
                 // Now attach using these arguments.
                 m_should_detach = true;
@@ -3195,6 +3202,9 @@
             else
             {
                 m_mod_id.BumpResumeID();
+#if defined(__APPLE__)
+                m_private_run_lock.WriteLock();
+#endif
                 error = DoResume();
                 if (error.Success())
                 {
@@ -3203,6 +3213,12 @@
                     if (log)
                         log->Printf ("Process thinks the process has resumed.");
                 }
+#if defined(__APPLE__)
+                else
+                {
+                    m_private_run_lock.WriteUnlock();
+                }
+#endif
             }
         }
         else
@@ -3410,7 +3426,7 @@
     // the last events through the event system, in which case we might strand the write lock.  Unlock
     // it here so when we do to tear down the process we don't get an error destroying the lock.
     
-    m_run_lock.WriteUnlock();
+    m_public_run_lock.WriteUnlock();
     return error;
 }
 
@@ -3468,7 +3484,7 @@
         // If we have been interrupted (to kill us) in the middle of running, we may not end up propagating
         // the last events through the event system, in which case we might strand the write lock.  Unlock
         // it here so when we do to tear down the process we don't get an error destroying the lock.
-        m_run_lock.WriteUnlock();
+        m_public_run_lock.WriteUnlock();
     }
     
     m_destroy_in_process = false;
@@ -3571,6 +3587,9 @@
             // If we aren't going to stop, let the thread plans decide if we're going to report this event.
             // If no thread has an opinion, we don't report it.
             
+#if defined(__APPLE__)
+            m_private_run_lock.WriteUnlock();
+#endif
             RefreshStateAfterStop ();
             if (ProcessEventData::GetInterruptedFromEvent (event_ptr))
             {
@@ -3934,6 +3953,7 @@
     if (log)
         log->Printf ("Process::%s (arg = %p, pid = %" PRIu64 ") thread exiting...", __FUNCTION__, this, GetID());
 
+    m_public_run_lock.WriteUnlock();
     m_private_state_control_wait.SetValue (true, eBroadcastAlways);
     m_private_state_thread = LLDB_INVALID_HOST_THREAD;
     return NULL;