zturner created this revision.
zturner added a reviewer: amccarth.
zturner added a subscriber: lldb-commits.

Log file pre-patch:
1442531634.442000000 [0448/5520]: DoDetach called for process 25769804660 while 
state = 2673276.  Detaching...
1442531634.442000000 [0448/5520]: StopDebugging('false') called (inferior=2972).
1442531634.442000000 [0448/5520]: StopDebugging waiting for detach from process 
2972 to complete.
1442531639.442000000 [0448/5520]: error: StopDebugging 
WaitForSingleObject(0x0000033C, 5000) returned 258
1442531639.442000000 [0448/5520]: Process::SetPrivateState (detached)

Log file post-patch:
    1442606676.750000000 [4a20/574c]: DoDetach called for process 25769804636 
while state = 2673276.  Detaching...
    1442606676.750000000 [4a20/4c5c]: 
Process::lldb_private::Process::HandlePrivateEvent (pid = 19724) suppressing 
state running (old state running): should_broadcast == false
    1442606676.750000000 [4a20/574c]: StopDebugging('false') called 
(inferior=19724).
    1442606676.750000000 [4a20/4c5c]: 
Process::lldb_private::Process::WaitForEventsPrivate (timeout = 00000000, 
event_sp)...
    1442606676.750000000 [4a20/574c]: StopDebugging waiting for detach from 
process 19724 to complete.
    1442606676.750000000 [4a20/4a78]: Breakpoint exception is cue to detach 
from process 0x4d0c
    1442606676.750000000 [4a20/4a78]: WaitForDebugEvent loop completed, exiting.
    1442606676.750000000 [4a20/574c]: StopDebugging detach from process 19724 
completed successfully.

http://reviews.llvm.org/D12980

Files:
  source/Plugins/Process/Windows/Live/DebuggerThread.cpp

Index: source/Plugins/Process/Windows/Live/DebuggerThread.cpp
===================================================================
--- source/Plugins/Process/Windows/Live/DebuggerThread.cpp
+++ source/Plugins/Process/Windows/Live/DebuggerThread.cpp
@@ -306,18 +306,28 @@
                 {
                     if (m_is_shutting_down)
                     {
+                        if (m_pid_to_detach != 0 && 
dbe.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) {
+                            WINLOG_IFANY(WINDOWS_LOG_EVENT | 
WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_PROCESS,
+                                         "Breakpoint exception is cue to 
detach from process 0x%x",
+                                         m_pid_to_detach);
+                            ::DebugActiveProcessStop(m_pid_to_detach);
+                            m_detached = true;
+                        }
+
                         // Don't perform any blocking operations while we're 
shutting down.  That will
                         // cause TerminateProcess -> WaitForSingleObject to 
time out.
                         continue_status = DBG_EXCEPTION_NOT_HANDLED;
-                        break;
                     }
+                    else
+                    {
+                        ExceptionResult status = 
HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId);
 
-                    ExceptionResult status = 
HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId);
+                        if (status == ExceptionResult::MaskException)
+                            continue_status = DBG_CONTINUE;
+                        else if (status == ExceptionResult::SendToApplication)
+                            continue_status = DBG_EXCEPTION_NOT_HANDLED;
+                    }
 
-                    if (status == ExceptionResult::MaskException)
-                        continue_status = DBG_CONTINUE;
-                    else if (status == ExceptionResult::SendToApplication)
-                        continue_status = DBG_EXCEPTION_NOT_HANDLED;
                     break;
                 }
                 case CREATE_THREAD_DEBUG_EVENT:
@@ -384,18 +394,6 @@
                  "HandleExceptionEvent encountered %s chance exception 0x%x on 
thread 0x%x",
                  first_chance ? "first" : "second", 
info.ExceptionRecord.ExceptionCode, thread_id);
 
-    if (m_pid_to_detach != 0 && m_active_exception->GetExceptionCode() == 
EXCEPTION_BREAKPOINT) {
-        WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION | 
WINDOWS_LOG_PROCESS,
-                     "Breakpoint exception is cue to detach from process 0x%x",
-                     m_pid_to_detach);
-        if (::DebugActiveProcessStop(m_pid_to_detach)) {
-            m_detached = true;
-            return ExceptionResult::MaskException;
-        } else {
-            WINLOG_IFANY(WINDOWS_LOG_PROCESS, "Failed to detach, treating as a 
regular breakpoint");
-        }
-    }
-
     ExceptionResult result = m_debug_delegate->OnDebugException(first_chance,
                                                                 
*m_active_exception);
     m_exception_pred.SetValue(result, eBroadcastNever);


Index: source/Plugins/Process/Windows/Live/DebuggerThread.cpp
===================================================================
--- source/Plugins/Process/Windows/Live/DebuggerThread.cpp
+++ source/Plugins/Process/Windows/Live/DebuggerThread.cpp
@@ -306,18 +306,28 @@
                 {
                     if (m_is_shutting_down)
                     {
+                        if (m_pid_to_detach != 0 && dbe.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) {
+                            WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_PROCESS,
+                                         "Breakpoint exception is cue to detach from process 0x%x",
+                                         m_pid_to_detach);
+                            ::DebugActiveProcessStop(m_pid_to_detach);
+                            m_detached = true;
+                        }
+
                         // Don't perform any blocking operations while we're shutting down.  That will
                         // cause TerminateProcess -> WaitForSingleObject to time out.
                         continue_status = DBG_EXCEPTION_NOT_HANDLED;
-                        break;
                     }
+                    else
+                    {
+                        ExceptionResult status = HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId);
 
-                    ExceptionResult status = HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId);
+                        if (status == ExceptionResult::MaskException)
+                            continue_status = DBG_CONTINUE;
+                        else if (status == ExceptionResult::SendToApplication)
+                            continue_status = DBG_EXCEPTION_NOT_HANDLED;
+                    }
 
-                    if (status == ExceptionResult::MaskException)
-                        continue_status = DBG_CONTINUE;
-                    else if (status == ExceptionResult::SendToApplication)
-                        continue_status = DBG_EXCEPTION_NOT_HANDLED;
                     break;
                 }
                 case CREATE_THREAD_DEBUG_EVENT:
@@ -384,18 +394,6 @@
                  "HandleExceptionEvent encountered %s chance exception 0x%x on thread 0x%x",
                  first_chance ? "first" : "second", info.ExceptionRecord.ExceptionCode, thread_id);
 
-    if (m_pid_to_detach != 0 && m_active_exception->GetExceptionCode() == EXCEPTION_BREAKPOINT) {
-        WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_PROCESS,
-                     "Breakpoint exception is cue to detach from process 0x%x",
-                     m_pid_to_detach);
-        if (::DebugActiveProcessStop(m_pid_to_detach)) {
-            m_detached = true;
-            return ExceptionResult::MaskException;
-        } else {
-            WINLOG_IFANY(WINDOWS_LOG_PROCESS, "Failed to detach, treating as a regular breakpoint");
-        }
-    }
-
     ExceptionResult result = m_debug_delegate->OnDebugException(first_chance,
                                                                 *m_active_exception);
     m_exception_pred.SetValue(result, eBroadcastNever);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to