Added support for Ctrl-C handling if not running in a console.

Added (maintenance) configuration var to trigger external debugger on
winedbg's exceptions.
This commit is contained in:
Eric Pouech 2003-03-04 02:18:20 +00:00 committed by Alexandre Julliard
parent a2b7141a01
commit 2d309da2c0
4 changed files with 49 additions and 30 deletions

View File

@ -386,32 +386,44 @@ void DEBUG_Exit(DWORD ec)
static WINE_EXCEPTION_FILTER(wine_dbg_cmd) static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
{ {
DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg_cmd: "); if (DBG_IVAR(ExtDbgOnInternalException))
switch (GetExceptionCode()) { DEBUG_ExternalDebugger();
case DEBUG_STATUS_INTERNAL_ERROR: DEBUG_Printf(DBG_CHN_MESG, "\nwine_dbg_cmd: ");
DEBUG_Printf(DBG_CHN_MESG, "WineDbg internal error\n"); switch (GetExceptionCode()) {
break; case DEBUG_STATUS_INTERNAL_ERROR:
case DEBUG_STATUS_NO_SYMBOL: DEBUG_Printf(DBG_CHN_MESG, "WineDbg internal error\n");
DEBUG_Printf(DBG_CHN_MESG, "Undefined symbol\n"); if (DBG_IVAR(ExtDbgOnInternalException))
break; DEBUG_ExternalDebugger();
case DEBUG_STATUS_DIV_BY_ZERO: break;
DEBUG_Printf(DBG_CHN_MESG, "Division by zero\n"); case DEBUG_STATUS_NO_SYMBOL:
break; DEBUG_Printf(DBG_CHN_MESG, "Undefined symbol\n");
case DEBUG_STATUS_BAD_TYPE: break;
DEBUG_Printf(DBG_CHN_MESG, "No type or type mismatch\n"); case DEBUG_STATUS_DIV_BY_ZERO:
break; DEBUG_Printf(DBG_CHN_MESG, "Division by zero\n");
case DEBUG_STATUS_NO_FIELD: break;
DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n"); case DEBUG_STATUS_BAD_TYPE:
break; DEBUG_Printf(DBG_CHN_MESG, "No type or type mismatch\n");
case DEBUG_STATUS_ABORT: break;
break; case DEBUG_STATUS_NO_FIELD:
default: DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n");
DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode()); break;
DEBUG_ExternalDebugger(); case DEBUG_STATUS_ABORT:
break; 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) static void set_default_channels(void)

View File

@ -543,6 +543,7 @@ extern void DEBUG_DelThread(DBG_THREAD* t);
extern BOOL DEBUG_ProcessGetString(char* buffer, int size, HANDLE hp, LPSTR addr); 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 BOOL DEBUG_ProcessGetStringIndirect(char* buffer, int size, HANDLE hp, LPVOID addr);
extern void DEBUG_WaitNextException(DWORD cont, int count, int mode); extern void DEBUG_WaitNextException(DWORD cont, int count, int mode);
extern BOOL DEBUG_InterruptDebuggee(void);
extern int curr_frame; extern int curr_frame;
/* gdbproxy.c */ /* gdbproxy.c */

View File

@ -33,6 +33,7 @@ INTERNAL_VAR(StdChannelMask, 0, NULL, DT_BASIC_CONST_INT)
/* debugging debugger */ /* debugging debugger */
INTERNAL_VAR(ExtDbgOnInvalidAddress, FALSE, NULL, DT_BASIC_CONST_INT) INTERNAL_VAR(ExtDbgOnInvalidAddress, FALSE, NULL, DT_BASIC_CONST_INT)
INTERNAL_VAR(ExtDbgOnInternalException, FALSE, NULL, DT_BASIC_CONST_INT)
/* current process/thread */ /* current process/thread */
INTERNAL_VAR(ThreadId, FALSE, &DEBUG_CurrTid, DT_BASIC_CONST_INT) INTERNAL_VAR(ThreadId, FALSE, &DEBUG_CurrTid, DT_BASIC_CONST_INT)

View File

@ -988,15 +988,20 @@ void DEBUG_Run(const char* args)
} }
} }
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) static BOOL WINAPI DEBUG_CtrlCHandler(DWORD dwCtrlType)
{ {
if (dwCtrlType == CTRL_C_EVENT) if (dwCtrlType == CTRL_C_EVENT)
{ {
DEBUG_Printf(DBG_CHN_MESG, "Ctrl-C: stopping debuggee\n"); return DEBUG_InterruptDebuggee();
/* FIXME: since we likely have a single process, signal the first process
* in list
*/
return DEBUG_ProcessList && DebugBreakProcess(DEBUG_ProcessList->handle);
} }
return FALSE; return FALSE;
} }