TSIA A+ -- Eric Pouech
Name: wd_ctrlc ChangeLog: added support for Ctrl-C handling if not running in a console added (maintenance) configuration var to trigger external debugger on winedbg's exceptions License: X11 GenDate: 2003/03/02 18:19:55 UTC ModifiedFiles: programs/winedbg/dbg.y programs/winedbg/debugger.h programs/winedbg/intvar.h programs/winedbg/winedbg.c AddedFiles: =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/dbg.y,v retrieving revision 1.7 diff -u -u -r1.7 dbg.y --- programs/winedbg/dbg.y 17 Feb 2003 01:47:20 -0000 1.7 +++ programs/winedbg/dbg.y 2 Mar 2003 18:17:57 -0000 @@ -386,32 +391,44 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd) { - DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg_cmd: "); - switch (GetExceptionCode()) { - case DEBUG_STATUS_INTERNAL_ERROR: - DEBUG_Printf(DBG_CHN_MESG, "WineDbg internal error\n"); - break; - case DEBUG_STATUS_NO_SYMBOL: - DEBUG_Printf(DBG_CHN_MESG, "Undefined symbol\n"); - break; - case DEBUG_STATUS_DIV_BY_ZERO: - DEBUG_Printf(DBG_CHN_MESG, "Division by zero\n"); - break; - case DEBUG_STATUS_BAD_TYPE: - DEBUG_Printf(DBG_CHN_MESG, "No type or type mismatch\n"); - break; - case DEBUG_STATUS_NO_FIELD: - DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n"); - break; - case DEBUG_STATUS_ABORT: - break; - default: - DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode()); - DEBUG_ExternalDebugger(); - break; - } + if (DBG_IVAR(ExtDbgOnInternalException)) + DEBUG_ExternalDebugger(); + DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg_cmd: "); + switch (GetExceptionCode()) { + case DEBUG_STATUS_INTERNAL_ERROR: + DEBUG_Printf(DBG_CHN_MESG, "WineDbg internal error\n"); + if (DBG_IVAR(ExtDbgOnInternalException)) + DEBUG_ExternalDebugger(); + break; + case DEBUG_STATUS_NO_SYMBOL: + DEBUG_Printf(DBG_CHN_MESG, "Undefined symbol\n"); + break; + case DEBUG_STATUS_DIV_BY_ZERO: + DEBUG_Printf(DBG_CHN_MESG, "Division by zero\n"); + break; + case DEBUG_STATUS_BAD_TYPE: + DEBUG_Printf(DBG_CHN_MESG, "No type or type mismatch\n"); + break; + case DEBUG_STATUS_NO_FIELD: + DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n"); + break; + case DEBUG_STATUS_ABORT: + break; + case CONTROL_C_EXIT: + /* this is generally sent by a ctrl-c when we run winedbg outside of wineconsole */ + DEBUG_Printf(DBG_CHN_MESG, "Ctrl-C\n"); + /* stop the debuggee, and continue debugger execution, we will be reintered by the + * debug events generated by stopping + */ + DEBUG_InterruptDebuggee(); + return EXCEPTION_CONTINUE_EXECUTION; + default: + DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode()); + DEBUG_ExternalDebugger(); + break; + } - return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_EXECUTE_HANDLER; } static void set_default_channels(void) Index: programs/winedbg/debugger.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/debugger.h,v retrieving revision 1.7 diff -u -u -r1.7 debugger.h --- programs/winedbg/debugger.h 19 Feb 2003 03:41:48 -0000 1.7 +++ programs/winedbg/debugger.h 2 Mar 2003 18:16:31 -0000 @@ -543,6 +543,7 @@ extern BOOL DEBUG_ProcessGetString(char* buffer, int size, HANDLE hp, LPSTR addr); extern BOOL DEBUG_ProcessGetStringIndirect(char* buffer, int size, HANDLE hp, LPVOID addr); extern void DEBUG_WaitNextException(DWORD cont, int count, int mode); +extern BOOL DEBUG_InterruptDebuggee(void); extern int curr_frame; /* gdbproxy.c */ Index: programs/winedbg/intvar.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/intvar.h,v retrieving revision 1.2 diff -u -u -r1.2 intvar.h --- programs/winedbg/intvar.h 27 Feb 2003 01:42:39 -0000 1.2 +++ programs/winedbg/intvar.h 1 Mar 2003 07:38:04 -0000 @@ -33,6 +33,7 @@ /* debugging debugger */ INTERNAL_VAR(ExtDbgOnInvalidAddress, FALSE, NULL, DT_BASIC_CONST_INT) +INTERNAL_VAR(ExtDbgOnInternalException, FALSE, NULL, DT_BASIC_CONST_INT) /* current process/thread */ INTERNAL_VAR(ThreadId, FALSE, &DEBUG_CurrTid, DT_BASIC_CONST_INT) Index: programs/winedbg/winedbg.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/winedbg.c,v retrieving revision 1.7 diff -u -u -r1.7 winedbg.c --- programs/winedbg/winedbg.c 27 Feb 2003 01:42:39 -0000 1.7 +++ programs/winedbg/winedbg.c 2 Mar 2003 18:16:42 -0000 @@ -988,15 +988,20 @@ } } +BOOL DEBUG_InterruptDebuggee(void) +{ + DEBUG_Printf(DBG_CHN_MESG, "Ctrl-C: stopping debuggee\n"); + /* FIXME: since we likely have a single process, signal the first process + * in list + */ + return DEBUG_ProcessList && DebugBreakProcess(DEBUG_ProcessList->handle); +} + static BOOL WINAPI DEBUG_CtrlCHandler(DWORD dwCtrlType) { if (dwCtrlType == CTRL_C_EVENT) { - DEBUG_Printf(DBG_CHN_MESG, "Ctrl-C: stopping debuggee\n"); - /* FIXME: since we likely have a single process, signal the first process - * in list - */ - return DEBUG_ProcessList && DebugBreakProcess(DEBUG_ProcessList->handle); + return DEBUG_InterruptDebuggee(); } return FALSE; }