Skip to content
Snippets Groups Projects
Commit fdd1c1c7 authored by eric pouech's avatar eric pouech Committed by Alexandre Julliard
Browse files

winedbg: Detect debuggee termination before first exception.

When a crash in a program happens, and the debugger in launched in --auto
mode, in some cases the program terminates before the debugger has gotten
proper context on debuggee.
(Could be a watchdog in programs checking if it's debugged and terminating
itself if so).

Detect debuggee termination and still provide some information on debuggee
(threads, modules, system info). The backtrace will not be available as
no exception is gotten from debuggee.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55187


Signed-off-by: default avatarEric Pouech <epouech@codeweavers.com>
parent 7ada0e22
No related branches found
No related tags found
No related merge requests found
...@@ -597,6 +597,26 @@ void dbg_active_wait_for_first_exception(void) ...@@ -597,6 +597,26 @@ void dbg_active_wait_for_first_exception(void)
wait_exception(); wait_exception();
} }
static BOOL dbg_active_wait_for_startup(DEBUG_EVENT* de)
{
dbg_interactiveP = FALSE;
while (dbg_num_processes() && WaitForDebugEvent(de, INFINITE))
{
switch (de->dwDebugEventCode)
{
case CREATE_PROCESS_DEBUG_EVENT:
case CREATE_THREAD_DEBUG_EVENT:
case LOAD_DLL_DEBUG_EVENT:
case EXCEPTION_DEBUG_EVENT:
if (dbg_handle_debug_event(de)) return TRUE;
break;
default:
return FALSE;
}
}
return FALSE;
}
static BOOL dbg_start_debuggee(LPSTR cmdLine) static BOOL dbg_start_debuggee(LPSTR cmdLine)
{ {
PROCESS_INFORMATION info; PROCESS_INFORMATION info;
...@@ -862,6 +882,8 @@ enum dbg_start dbg_active_auto(int argc, char* argv[]) ...@@ -862,6 +882,8 @@ enum dbg_start dbg_active_auto(int argc, char* argv[])
{ {
HANDLE thread = 0, event = 0, input, output = INVALID_HANDLE_VALUE; HANDLE thread = 0, event = 0, input, output = INVALID_HANDLE_VALUE;
enum dbg_start ds = start_error_parse; enum dbg_start ds = start_error_parse;
BOOL first_exception = TRUE;
DEBUG_EVENT de;
DBG_IVAR(BreakOnDllLoad) = 0; DBG_IVAR(BreakOnDllLoad) = 0;
...@@ -894,12 +916,25 @@ enum dbg_start dbg_active_auto(int argc, char* argv[]) ...@@ -894,12 +916,25 @@ enum dbg_start dbg_active_auto(int argc, char* argv[])
NULL); NULL);
if (input == INVALID_HANDLE_VALUE) return start_error_parse; if (input == INVALID_HANDLE_VALUE) return start_error_parse;
if (dbg_curr_process->active_debuggee) /* debuggee can terminate before we get the first exception.
dbg_active_wait_for_first_exception(); * so detect end of attach load sequence, and then print information.
*/
if (dbg_curr_process->active_debuggee && !(first_exception = dbg_active_wait_for_startup(&de)))
{
dbg_printf("Couldn't get first exception for process %04lx %ls%s.\n"
"No backtrace available\n",
dbg_curr_pid, dbg_curr_process->imageName, dbg_curr_process->is_wow64 ? " (WOW64)" : "");
}
dbg_interactiveP = TRUE; dbg_interactiveP = TRUE;
parser_handle(NULL, input); parser_handle(NULL, input);
if (!first_exception)
{
/* continue managing debug events, in case the exception event comes after current debug event */
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, DBG_CONTINUE);
dbg_active_wait_for_first_exception();
}
if (output != INVALID_HANDLE_VALUE) if (output != INVALID_HANDLE_VALUE)
{ {
SetEvent( event ); SetEvent( event );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment