forked from Mirrors/wine-wine
winedbg: Set auto attach event after processing the first exception.
On Windows, the process is broken into by ordering an actual debug break execution in a new thread. We need to process this event before continuing exception handling in debuggee to avoid race. Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>stable
parent
136a0ac49b
commit
1bb98982d6
|
@ -235,8 +235,8 @@ struct dbg_process
|
||||||
const WCHAR* imageName;
|
const WCHAR* imageName;
|
||||||
struct list threads;
|
struct list threads;
|
||||||
struct backend_cpu* be_cpu;
|
struct backend_cpu* be_cpu;
|
||||||
BOOL continue_on_first_exception : 1,
|
HANDLE event_on_first_exception;
|
||||||
active_debuggee : 1;
|
BOOL active_debuggee;
|
||||||
struct dbg_breakpoint bp[MAX_BREAKPOINTS];
|
struct dbg_breakpoint bp[MAX_BREAKPOINTS];
|
||||||
unsigned next_bp;
|
unsigned next_bp;
|
||||||
struct dbg_delayed_bp* delayed_bp;
|
struct dbg_delayed_bp* delayed_bp;
|
||||||
|
|
|
@ -334,9 +334,11 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
|
||||||
de->dwProcessId, de->dwThreadId,
|
de->dwProcessId, de->dwThreadId,
|
||||||
de->u.Exception.ExceptionRecord.ExceptionCode);
|
de->u.Exception.ExceptionRecord.ExceptionCode);
|
||||||
|
|
||||||
if (dbg_curr_process->continue_on_first_exception)
|
if (dbg_curr_process->event_on_first_exception)
|
||||||
{
|
{
|
||||||
dbg_curr_process->continue_on_first_exception = FALSE;
|
SetEvent(dbg_curr_process->event_on_first_exception);
|
||||||
|
CloseHandle(dbg_curr_process->event_on_first_exception);
|
||||||
|
dbg_curr_process->event_on_first_exception = NULL;
|
||||||
if (!DBG_IVAR(BreakOnAttach)) break;
|
if (!DBG_IVAR(BreakOnAttach)) break;
|
||||||
}
|
}
|
||||||
if (dbg_fetch_context())
|
if (dbg_fetch_context())
|
||||||
|
@ -788,13 +790,7 @@ enum dbg_start dbg_active_attach(int argc, char* argv[])
|
||||||
SetEvent((HANDLE)evt);
|
SetEvent((HANDLE)evt);
|
||||||
return start_error_init;
|
return start_error_init;
|
||||||
}
|
}
|
||||||
dbg_curr_process->continue_on_first_exception = TRUE;
|
dbg_curr_process->event_on_first_exception = (HANDLE)evt;
|
||||||
if (!SetEvent((HANDLE)evt))
|
|
||||||
{
|
|
||||||
WINE_ERR("Invalid event handle: %lx\n", evt);
|
|
||||||
return start_error_init;
|
|
||||||
}
|
|
||||||
CloseHandle((HANDLE)evt);
|
|
||||||
}
|
}
|
||||||
else return start_error_parse;
|
else return start_error_parse;
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
|
||||||
p->pio_data = NULL;
|
p->pio_data = NULL;
|
||||||
p->imageName = NULL;
|
p->imageName = NULL;
|
||||||
list_init(&p->threads);
|
list_init(&p->threads);
|
||||||
p->continue_on_first_exception = FALSE;
|
p->event_on_first_exception = NULL;
|
||||||
p->active_debuggee = FALSE;
|
p->active_debuggee = FALSE;
|
||||||
p->next_bp = 1; /* breakpoint 0 is reserved for step-over */
|
p->next_bp = 1; /* breakpoint 0 is reserved for step-over */
|
||||||
memset(p->bp, 0, sizeof(p->bp));
|
memset(p->bp, 0, sizeof(p->bp));
|
||||||
|
@ -372,6 +372,7 @@ void dbg_del_process(struct dbg_process* p)
|
||||||
source_free_files(p);
|
source_free_files(p);
|
||||||
list_remove(&p->entry);
|
list_remove(&p->entry);
|
||||||
if (p == dbg_curr_process) dbg_curr_process = NULL;
|
if (p == dbg_curr_process) dbg_curr_process = NULL;
|
||||||
|
if (p->event_on_first_exception) CloseHandle(p->event_on_first_exception);
|
||||||
HeapFree(GetProcessHeap(), 0, (char*)p->imageName);
|
HeapFree(GetProcessHeap(), 0, (char*)p->imageName);
|
||||||
HeapFree(GetProcessHeap(), 0, p);
|
HeapFree(GetProcessHeap(), 0, p);
|
||||||
}
|
}
|
||||||
|
@ -559,7 +560,12 @@ BOOL dbg_interrupt_debuggee(void)
|
||||||
p = LIST_ENTRY(list_head(&dbg_process_list), struct dbg_process, entry);
|
p = LIST_ENTRY(list_head(&dbg_process_list), struct dbg_process, entry);
|
||||||
if (list_next(&dbg_process_list, &p->entry)) dbg_printf("Ctrl-C: only stopping the first process\n");
|
if (list_next(&dbg_process_list, &p->entry)) dbg_printf("Ctrl-C: only stopping the first process\n");
|
||||||
else dbg_printf("Ctrl-C: stopping debuggee\n");
|
else dbg_printf("Ctrl-C: stopping debuggee\n");
|
||||||
p->continue_on_first_exception = FALSE;
|
if (p->event_on_first_exception)
|
||||||
|
{
|
||||||
|
SetEvent(p->event_on_first_exception);
|
||||||
|
CloseHandle(p->event_on_first_exception);
|
||||||
|
p->event_on_first_exception = NULL;
|
||||||
|
}
|
||||||
return DebugBreakProcess(p->handle);
|
return DebugBreakProcess(p->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue