Raise an exception if any Wine or Winelib code does an assert.

This commit is contained in:
Lionel Ulmer 2002-10-28 23:56:58 +00:00 committed by Alexandre Julliard
parent 629f02b329
commit bdb44555a3
6 changed files with 73 additions and 4 deletions

View File

@ -1040,6 +1040,26 @@ static HANDLER_DEF(int_handler)
}
}
/**********************************************************************
* abrt_handler
*
* Handler for SIGABRT.
*/
static HANDLER_DEF(abrt_handler)
{
EXCEPTION_RECORD rec;
CONTEXT context;
save_context( &context, HANDLER_CONTEXT );
rec.ExceptionCode = EXCEPTION_WINE_ASSERTION;
rec.ExceptionFlags = EH_NONCONTINUABLE;
rec.ExceptionRecord = NULL;
rec.ExceptionAddress = (LPVOID)context.Eip;
rec.NumberParameters = 0;
EXC_RtlRaiseException( &rec, &context ); /* Should never return.. */
restore_context( &context, HANDLER_CONTEXT );
}
/***********************************************************************
* set_handler
@ -1124,6 +1144,7 @@ BOOL SIGNAL_Init(void)
if (set_handler( SIGFPE, have_sigaltstack, (void (*)())fpe_handler ) == -1) goto error;
if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGILL, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error;
#ifdef SIGBUS
if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
#endif

View File

@ -381,6 +381,26 @@ static HANDLER_DEF(int_handler)
}
}
/**********************************************************************
* abrt_handler
*
* Handler for SIGABRT.
*/
static HANDLER_DEF(abrt_handler)
{
EXCEPTION_RECORD rec;
CONTEXT context;
save_context( &context, HANDLER_CONTEXT );
rec.ExceptionCode = EXCEPTION_WINE_ASSERTION;
rec.ExceptionFlags = EH_NONCONTINUABLE;
rec.ExceptionRecord = NULL;
rec.ExceptionAddress = (LPVOID)context.Eip;
rec.NumberParameters = 0;
EXC_RtlRaiseException( &rec, &context ); /* Should never return.. */
restore_context( &context, HANDLER_CONTEXT );
}
/***********************************************************************
* set_handler
@ -440,6 +460,7 @@ BOOL SIGNAL_Init(void)
if (set_handler( SIGFPE, have_sigaltstack, (void (*)())fpe_handler ) == -1) goto error;
if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGILL, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error;
#ifdef SIGBUS
if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
#endif

View File

@ -343,6 +343,25 @@ static void int_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
}
}
/**********************************************************************
* abrt_handler
*
* Handler for SIGABRT.
*/
static HANDLER_DEF(abrt_handler)
{
EXCEPTION_RECORD rec;
CONTEXT context;
save_context( &context, HANDLER_CONTEXT );
rec.ExceptionCode = EXCEPTION_WINE_ASSERTION;
rec.ExceptionFlags = EH_NONCONTINUABLE;
rec.ExceptionRecord = NULL;
rec.ExceptionAddress = (LPVOID)context.Eip;
rec.NumberParameters = 0;
EXC_RtlRaiseException( &rec, &context ); /* Should never return.. */
restore_context( &context, HANDLER_CONTEXT );
}
/***********************************************************************
* set_handler
@ -398,7 +417,8 @@ BOOL SIGNAL_Init(void)
if (set_handler( SIGILL, (void (*)())ill_handler ) == -1) goto error;
if (set_handler( SIGBUS, (void (*)())bus_handler ) == -1) goto error;
if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
return TRUE;
if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error;
return TRUE;
error:
perror("sigaction");

View File

@ -183,11 +183,12 @@ static inline EXCEPTION_FRAME * WINE_UNUSED __wine_pop_frame( EXCEPTION_FRAME *f
/* Wine-specific exceptions codes */
#define EXCEPTION_WINE_STUB 0x80000100 /* stub entry point called */
#define EXCEPTION_WINE_ASSERTION 0x80000101 /* assertion failed */
/* unhandled return status from vm86 mode */
#define EXCEPTION_VM86_INTx 0x80000101
#define EXCEPTION_VM86_STI 0x80000102
#define EXCEPTION_VM86_PICRETURN 0x80000103
#define EXCEPTION_VM86_INTx 0x80000110
#define EXCEPTION_VM86_STI 0x80000111
#define EXCEPTION_VM86_PICRETURN 0x80000112
extern void __wine_enter_vm86( CONTEXT *context );

View File

@ -556,6 +556,9 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL
DEBUG_Printf(DBG_CHN_MESG, "unimplemented function %s.%s called", dll, name );
}
break;
case EXCEPTION_WINE_ASSERTION:
DEBUG_Printf(DBG_CHN_MESG, "assertion failed");
break;
case EXCEPTION_VM86_INTx:
DEBUG_Printf(DBG_CHN_MESG, "interrupt %02lx in vm86 mode",
rec->ExceptionInformation[0]);

View File

@ -135,6 +135,9 @@ static int format_exception_msg( const EXCEPTION_POINTERS *ptr, char *buffer, in
len = snprintf( buffer, size, "Unimplemented function %s.%s called",
(char *)rec->ExceptionInformation[0], (char *)rec->ExceptionInformation[1] );
break;
case EXCEPTION_WINE_ASSERTION:
len = snprintf( buffer, size, "Assertion failed" );
break;
case EXCEPTION_VM86_INTx:
len = snprintf( buffer, size, "Unhandled interrupt %02lx in vm86 mode",
rec->ExceptionInformation[0]);