[Lldb-commits] [lldb] r155560 - in /lldb/trunk/tools/debugserver/source/MacOSX: MachProcess.cpp MachProcess.h

Jim Ingham jingham at apple.com
Wed Apr 25 10:45:27 PDT 2012


Author: jingham
Date: Wed Apr 25 12:45:26 2012
New Revision: 155560

URL: http://llvm.org/viewvc/llvm-project?rev=155560&view=rev
Log:
Suspend program threads before sending the SIGSTOP & resuming, so other threads won't get into trouble while we are waiting for the SIGSTOP.

rdar://problem/11174834

Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=155560&r1=155559&r2=155560&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Wed Apr 25 12:45:26 2012
@@ -335,7 +335,7 @@
 MachProcess::Kill (const struct timespec *timeout_abstime)
 {
     DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Kill ()");
-    nub_state_t state = DoSIGSTOP(true);
+    nub_state_t state = DoSIGSTOP(true, false, NULL);
     DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Kill() DoSIGSTOP() state = %s", DNBStateAsString(state));
     errno = 0;
     ::ptrace (PT_KILL, m_pid, 0, 0);
@@ -373,7 +373,7 @@
 }
 
 nub_state_t
-MachProcess::DoSIGSTOP (bool clear_bps_and_wps, uint32_t *thread_idx_ptr)
+MachProcess::DoSIGSTOP (bool clear_bps_and_wps, bool allow_running, uint32_t *thread_idx_ptr)
 {
     nub_state_t state = GetState();
     DNBLogThreadedIf(LOG_PROCESS, "MachProcess::DoSIGSTOP() state = %s", DNBStateAsString (state));
@@ -398,7 +398,11 @@
         // No threads were stopped with a SIGSTOP, we need to run and halt the
         // process with a signal
         DNBLogThreadedIf(LOG_PROCESS, "MachProcess::DoSIGSTOP() state = %s -- resuming process", DNBStateAsString (state));
-        m_thread_actions = DNBThreadResumeActions (eStateRunning, 0);
+        if (allow_running)
+            m_thread_actions = DNBThreadResumeActions (eStateRunning, 0);
+        else
+            m_thread_actions = DNBThreadResumeActions (eStateSuspended, 0);
+            
         PrivateResume ();
 
         // Reset the event that says we were indeed running
@@ -432,7 +436,7 @@
     DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Detach()");
 
     uint32_t thread_idx = UINT32_MAX;
-    nub_state_t state = DoSIGSTOP(true, &thread_idx);
+    nub_state_t state = DoSIGSTOP(true, true, &thread_idx);
     DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Detach() DoSIGSTOP() returned %s", DNBStateAsString(state));
 
     {

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=155560&r1=155559&r2=155560&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Wed Apr 25 12:45:26 2012
@@ -248,7 +248,7 @@
     nub_size_t              RemoveTrapsFromBuffer (nub_addr_t addr, nub_size_t size, uint8_t *buf) const;
 
     uint32_t                Flags () const { return m_flags; }
-    nub_state_t             DoSIGSTOP (bool clear_bps_and_wps, uint32_t *thread_idx_ptr = NULL);
+    nub_state_t             DoSIGSTOP (bool clear_bps_and_wps, bool allow_running, uint32_t *thread_idx_ptr);
 
     pid_t                       m_pid;                      // Process ID of child process
     cpu_type_t                  m_cpu_type;                 // The CPU type of this process





More information about the lldb-commits mailing list