Rémi Bernon : winedbg: Clean handle_exception return values.

Alexandre Julliard julliard at winehq.org
Mon Apr 6 15:53:19 CDT 2020


Module: wine
Branch: master
Commit: 2fcf051fae760f4d9b4745ec20296e3f3bf8526a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2fcf051fae760f4d9b4745ec20296e3f3bf8526a

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Sat Apr  4 11:30:15 2020 +0200

winedbg: Clean handle_exception return values.

It was returning a mix of TRUE/FALSE and in some cases DBG_CONTINUE.

Let's return TRUE if the exception has been handled and should be
ignored, or FALSE if not and if we should notify gdb.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/winedbg/gdbproxy.c | 39 ++++++++++++++-------------------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 81fc648985..5b7fdaa83e 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -312,8 +312,7 @@ static void dbg_thread_set_single_step(struct dbg_thread *thread, BOOL enable)
 
 static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* exc)
 {
-    EXCEPTION_RECORD*   rec = &exc->ExceptionRecord;
-    BOOL                ret = FALSE;
+    EXCEPTION_RECORD* rec = &exc->ExceptionRecord;
 
     switch (rec->ExceptionCode)
     {
@@ -322,18 +321,15 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
     case EXCEPTION_STACK_OVERFLOW:
     case EXCEPTION_GUARD_PAGE:
         gdbctx->last_sig = SIGSEGV;
-        ret = TRUE;
-        break;
+        return FALSE;
     case EXCEPTION_DATATYPE_MISALIGNMENT:
         gdbctx->last_sig = SIGBUS;
-        ret = TRUE;
-        break;
+        return FALSE;
     case EXCEPTION_SINGLE_STEP:
         /* fall through */
     case EXCEPTION_BREAKPOINT:
         gdbctx->last_sig = SIGTRAP;
-        ret = TRUE;
-        break;
+        return FALSE;
     case EXCEPTION_FLT_DENORMAL_OPERAND:
     case EXCEPTION_FLT_DIVIDE_BY_ZERO:
     case EXCEPTION_FLT_INEXACT_RESULT:
@@ -342,26 +338,21 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
     case EXCEPTION_FLT_STACK_CHECK:
     case EXCEPTION_FLT_UNDERFLOW:
         gdbctx->last_sig = SIGFPE;
-        ret = TRUE;
-        break;
+        return FALSE;
     case EXCEPTION_INT_DIVIDE_BY_ZERO:
     case EXCEPTION_INT_OVERFLOW:
         gdbctx->last_sig = SIGFPE;
-        ret = TRUE;
-        break;
+        return FALSE;
     case EXCEPTION_ILLEGAL_INSTRUCTION:
         gdbctx->last_sig = SIGILL;
-        ret = TRUE;
-        break;
+        return FALSE;
     case CONTROL_C_EXIT:
         gdbctx->last_sig = SIGINT;
-        ret = TRUE;
-        break;
+        return FALSE;
     case STATUS_POSSIBLE_DEADLOCK:
-        gdbctx->last_sig = SIGALRM;
-        ret = TRUE;
         /* FIXME: we could also add here a O packet with additional information */
-        break;
+        gdbctx->last_sig = SIGALRM;
+        return FALSE;
     case EXCEPTION_NAME_THREAD:
     {
         const THREADNAME_INFO *threadname = (const THREADNAME_INFO *)rec->ExceptionInformation;
@@ -384,17 +375,15 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
         }
         else
             ERR("Cannot set name of thread %04x\n", threadname->dwThreadID);
-        return DBG_CONTINUE;
+        return TRUE;
     }
     case EXCEPTION_INVALID_HANDLE:
-        return DBG_CONTINUE;
+        return TRUE;
     default:
         fprintf(stderr, "Unhandled exception code 0x%08x\n", rec->ExceptionCode);
         gdbctx->last_sig = SIGABRT;
-        ret = TRUE;
-        break;
+        return FALSE;
     }
-    return ret;
 }
 
 static void handle_debug_event(struct gdb_context* gdbctx)
@@ -469,7 +458,7 @@ static void handle_debug_event(struct gdb_context* gdbctx)
         TRACE("%08x:%08x: exception code=0x%08x\n", de->dwProcessId,
             de->dwThreadId, de->u.Exception.ExceptionRecord.ExceptionCode);
 
-        gdbctx->in_trap = handle_exception(gdbctx, &de->u.Exception);
+        gdbctx->in_trap = !handle_exception(gdbctx, &de->u.Exception);
         break;
 
     case CREATE_THREAD_DEBUG_EVENT:




More information about the wine-cvs mailing list