[Lldb-commits] [lldb] r179772 - 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.

Greg Clayton gclayton at apple.com
Thu Apr 18 09:57:27 PDT 2013


Author: gclayton
Date: Thu Apr 18 11:57:27 2013
New Revision: 179772

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


Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=179772&r1=179771&r2=179772&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Apr 18 11:57:27 2013
@@ -3457,7 +3457,17 @@ public:
     ReadWriteLock &
     GetRunLock ()
     {
-        return m_run_lock;
+#if defined(__APPLE__)
+        // The "m_private_run_lock" causes problems for other platforms
+        // right now, so we are leaving this in for Apple builds only
+        // until we can get the kinks worked out.
+        if (Host::GetCurrentThread() == m_private_state_thread)
+            return m_private_run_lock;
+        else
+            return m_public_run_lock;
+#else
+        return m_public_run_lock;
+#endif
     }
 
 protected:
@@ -3596,7 +3606,10 @@ protected:
     LanguageRuntimeCollection   m_language_runtimes;
     std::auto_ptr<NextEventAction> m_next_event_action_ap;
     std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
-    ReadWriteLock               m_run_lock;
+    ReadWriteLock               m_public_run_lock;
+#if defined(__APPLE__)
+    ReadWriteLock               m_private_run_lock;
+#endif
     Predicate<bool>             m_currently_handling_event;
     bool                        m_finalize_called;
     lldb::StateType             m_last_broadcast_state;   /// This helps with the Public event coalescing in ShouldBroadcastEvent.

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=179772&r1=179771&r2=179772&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Apr 18 11:57:27 2013
@@ -1019,7 +1019,10 @@ Process::Process(Target &target, Listene
     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 @@ Process::Finalize()
     // 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 @@ Process::SetPublicState (StateType new_s
         {
             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 @@ Process::SetPublicState (StateType new_s
                 {
                     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 @@ Process::Resume ()
     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 @@ Process::Launch (const ProcessLaunchInfo
                 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 @@ Process::Attach (ProcessAttachInfo &atta
                 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 @@ Process::Attach (ProcessAttachInfo &atta
         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 @@ Process::PrivateResume ()
             else
             {
                 m_mod_id.BumpResumeID();
+#if defined(__APPLE__)
+                m_private_run_lock.WriteLock();
+#endif
                 error = DoResume();
                 if (error.Success())
                 {
@@ -3203,6 +3213,12 @@ Process::PrivateResume ()
                     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 @@ Process::Detach ()
     // 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 @@ Process::Destroy ()
         // 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 @@ Process::ShouldBroadcastEvent (Event *ev
             // 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 @@ Process::RunPrivateStateThread ()
     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;





More information about the lldb-commits mailing list