Module: wine Branch: master Commit: aade0bf7e3f58431f20566733881716cb3075d03 URL: https://source.winehq.org/git/wine.git/?a=commit;h=aade0bf7e3f58431f20566733...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Mon Sep 30 22:08:00 2019 +0900
ntdll: Add exception handling around DbgBreakPoint.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47509 Signed-off-by: Akihiro Sagawa sagawa.aki@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernel32/tests/debugger.c | 31 +++++++++++++++++++++++-------- dlls/ntdll/process.c | 14 +++++++++++++- 2 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/dlls/kernel32/tests/debugger.c b/dlls/kernel32/tests/debugger.c index 8148c396d0..4a1b1d4076 100644 --- a/dlls/kernel32/tests/debugger.c +++ b/dlls/kernel32/tests/debugger.c @@ -399,7 +399,7 @@ static void wait_for_breakpoint_(unsigned line, struct debugger_context *ctx) ctx->ev.u.Exception.ExceptionRecord.ExceptionCode); }
-static void process_attach_events(struct debugger_context *ctx) +static void process_attach_events(struct debugger_context *ctx, BOOL pass_exception) { DEBUG_EVENT ev; BOOL ret; @@ -445,6 +445,13 @@ static void process_attach_events(struct debugger_context *ctx) ctx->ev.u.Exception.ExceptionRecord.ExceptionCode); ok(ctx->ev.u.Exception.ExceptionRecord.ExceptionAddress == pDbgBreakPoint, "ExceptionAddress != DbgBreakPoint\n");
+ if (pass_exception) + { + ret = ContinueDebugEvent(ctx->ev.dwProcessId, ctx->ev.dwThreadId, DBG_EXCEPTION_NOT_HANDLED); + ok(ret, "ContinueDebugEvent failed, last error %d.\n", GetLastError()); + ctx->ev.dwDebugEventCode = -1; + } + /* flush debug events */ do next_event(ctx, POLL_EVENT_TIMEOUT); while (ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT || ctx->ev.dwDebugEventCode == UNLOAD_DLL_DEBUG_EVENT @@ -477,7 +484,7 @@ static void doDebugger(int argc, char** argv) if (strstr(myARGV[2], "process")) { strcat(buf, "processing debug messages\n"); - process_attach_events(&ctx); + process_attach_events(&ctx, FALSE); }
debug_event=(argc >= 6 ? (HANDLE)(INT_PTR)atol(argv[5]) : NULL); @@ -1023,7 +1030,7 @@ static void doChildren(int argc, char **argv) HeapFree(GetProcessHeap(), 0, cmd); }
-static void test_debug_children(char *name, DWORD flag, BOOL debug_child) +static void test_debug_children(const char *name, DWORD flag, BOOL debug_child, BOOL pass_exception) { const char *arguments = "debugger children"; struct child_blackbox blackbox; @@ -1096,7 +1103,7 @@ static void test_debug_children(char *name, DWORD flag, BOOL debug_child) { DWORD last_thread;
- process_attach_events(&ctx); + process_attach_events(&ctx, pass_exception); ok(ctx.pid == pi.dwProcessId, "unexpected dwProcessId %x\n", ctx.pid);
ret = DebugBreakProcess(pi.hProcess); @@ -1118,6 +1125,13 @@ static void test_debug_children(char *name, DWORD flag, BOOL debug_child)
ret = SetEvent(event_attach); ok(ret, "SetEvent failed, last error %d.\n", GetLastError()); + + if (pass_exception) + { + ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_EXCEPTION_NOT_HANDLED); + ok(ret, "ContinueDebugEvent failed, last error %d.\n", GetLastError()); + ctx.ev.dwDebugEventCode = -1; + } }
do next_event(&ctx, WAIT_EVENT_TIMEOUT); @@ -1487,10 +1501,11 @@ START_TEST(debugger) test_ExitCode(); test_RemoteDebugger(); test_debug_loop(myARGC, myARGV); - test_debug_children(myARGV[0], DEBUG_PROCESS, TRUE); - test_debug_children(myARGV[0], DEBUG_ONLY_THIS_PROCESS, FALSE); - test_debug_children(myARGV[0], DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS, FALSE); - test_debug_children(myARGV[0], 0, FALSE); + test_debug_children(myARGV[0], DEBUG_PROCESS, TRUE, FALSE); + test_debug_children(myARGV[0], DEBUG_ONLY_THIS_PROCESS, FALSE, FALSE); + test_debug_children(myARGV[0], DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS, FALSE, FALSE); + test_debug_children(myARGV[0], 0, FALSE, FALSE); + test_debug_children(myARGV[0], 0, FALSE, TRUE); test_debugger(myARGV[0]); } } diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index e3c2ba5ccb..02ae4404fd 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -46,6 +46,7 @@ #include "windef.h" #include "winternl.h" #include "ntdll_misc.h" +#include "wine/exception.h" #include "wine/library.h" #include "wine/server.h" #include "wine/unicode.h" @@ -1372,7 +1373,18 @@ done: void WINAPI DbgUiRemoteBreakin( void *arg ) { TRACE( "\n" ); - if (NtCurrentTeb()->Peb->BeingDebugged) DbgBreakPoint(); + if (NtCurrentTeb()->Peb->BeingDebugged) + { + __TRY + { + DbgBreakPoint(); + } + __EXCEPT_ALL + { + /* do nothing */ + } + __ENDTRY + } RtlExitUserThread( STATUS_SUCCESS ); }