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);