I've simplified the _eh_handler_ in src/newlib/newlib/libc/sys/wince/startup.c a bit, see attachment.
This kicks out all the complicated handling in that function, and replaces it with a simple message box. The downside is that the original (complicated) stuff is gone. I have no idea whether this actually worked. Is replacing this a good idea ? My test programs now show a dialog titled "WinCE Exception" and containing text such as ILLEGAL_INSTRUCTION Code C000001D Flags 0 (that's the test program that performs a floating point instruction for floating point hardware which isn't on my system), or ACCESS_VIOLATION Code C0000005 Flags 0 when trying to access a NULL pointer. Strangely, dividing by 0 doesn't cause such an exception. I haven't tried this in mingw32ce yet, only in cegcc. Opinions ? Danny -- Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
Index: startup.c =================================================================== --- startup.c (revision 915) +++ startup.c (working copy) @@ -13,6 +13,11 @@ #include "sys/io.h" #include "sys/fixpath.h" +static struct exception_txt { + int v; + wchar_t *s; +} exception_txt[]; + void _start_process(wchar_t *exe, wchar_t *cmd) { @@ -95,12 +100,33 @@ // called from startup-stub.c +#if 1 EXCEPTION_DISPOSITION _eh_handler_(struct _EXCEPTION_RECORD *ExceptionRecord, void *EstablisherFrame, struct _CONTEXT *ContextRecord, struct _DISPATCHER_CONTEXT *DispatcherContext) { + wchar_t msg[256]; + int i; + + for (i=0; exception_txt[i].s; i++) + if (exception_txt[i].v == ExceptionRecord->ExceptionCode) { + wsprintf(msg, L"%s\r\nCode %X\r\nFlags %X", + exception_txt[i].s, + ExceptionRecord->ExceptionCode, + ExceptionRecord->ExceptionFlags); + } + MessageBoxW(0, msg, L"WinCE Exception", 0); + exit(1); +} +#else +EXCEPTION_DISPOSITION +_eh_handler_(struct _EXCEPTION_RECORD *ExceptionRecord, + void *EstablisherFrame, + struct _CONTEXT *ContextRecord, + struct _DISPATCHER_CONTEXT *DispatcherContext) +{ // ### What is this needed for? static int NestedException=0; if(NestedException) @@ -230,6 +256,7 @@ printf("Signal handler returned!\n"); exit(1); } +#endif void _parse_tokens(char * string, char * tokens[]); @@ -577,3 +604,50 @@ } __argc = index; } + +/* + * Table with exception strings, stolen from sys/oldsys/wcekernel.h + */ + +/* Definitions and structs for Kernel Exceptions and handling */ +static struct exception_txt exception_txt[] = { +// { STATUS_SUCCESS, L"SUCCESS" }, +// { STATUS_UNSUCCESSFUL, L"UNSUCCESSFUL" }, + { STATUS_WAIT_0, L"WAIT_0" }, + { STATUS_ABANDONED_WAIT_0, L"ABANDONED_WAIT_0" }, + { STATUS_USER_APC, L"USER_APC" }, + { STATUS_TIMEOUT, L"TIMEOUT" }, + { STATUS_PENDING, L"PENDING" }, + { STATUS_SEGMENT_NOTIFICATION, L"SEGMENT_NOTIFICATION" }, + { STATUS_GUARD_PAGE_VIOLATION, L"GUARD_PAGE_VIOLATION" }, + { STATUS_DATATYPE_MISALIGNMENT, L"DATATYPE_MISALIGNMENT" }, + { STATUS_BREAKPOINT, L"BREAKPOINT" }, + { STATUS_SINGLE_STEP, L"SINGLE_STEP" }, + { STATUS_ACCESS_VIOLATION, L"ACCESS_VIOLATION" }, + { STATUS_IN_PAGE_ERROR, L"IN_PAGE_ERROR" }, + { STATUS_INVALID_HANDLE, L"INVALID_HANDLE" }, +// { STATUS_INVALID_PARAMETER, L"INVALID_PARAMETER" }, + { STATUS_NO_MEMORY, L"NO_MEMORY" }, +// { STATUS_INVALID_SYSTEM_SERVICE, L"INVALID_SYSTEM_SERVICE" }, + { STATUS_ILLEGAL_INSTRUCTION, L"ILLEGAL_INSTRUCTION" }, + { STATUS_NONCONTINUABLE_EXCEPTION, L"NONCONTINUABLE_EXCEPTION" }, + { STATUS_INVALID_DISPOSITION, L"INVALID_DISPOSITION" }, + { STATUS_ARRAY_BOUNDS_EXCEEDED, L"ARRAY_BOUNDS_EXCEEDED" }, + { STATUS_FLOAT_DENORMAL_OPERAND, L"FLOAT_DENORMAL_OPERAND" }, + { STATUS_FLOAT_DIVIDE_BY_ZERO, L"FLOAT_DIVIDE_BY_ZERO" }, + { STATUS_FLOAT_INEXACT_RESULT, L"FLOAT_INEXACT_RESULT" }, + { STATUS_FLOAT_INVALID_OPERATION, L"FLOAT_INVALID_OPERATION" }, + { STATUS_FLOAT_OVERFLOW, L"FLOAT_OVERFLOW" }, + { STATUS_FLOAT_STACK_CHECK, L"FLOAT_STACK_CHECK" }, + { STATUS_FLOAT_UNDERFLOW, L"FLOAT_UNDERFLOW" }, + { STATUS_INTEGER_DIVIDE_BY_ZERO, L"INTEGER_DIVIDE_BY_ZERO" }, + { STATUS_INTEGER_OVERFLOW, L"INTEGER_OVERFLOW" }, + { STATUS_PRIVILEGED_INSTRUCTION, L"PRIVILEGED_INSTRUCTION" }, + { STATUS_STACK_OVERFLOW, L"STACK_OVERFLOW" }, +// { STATUS_USER_BREAK, L"USER_BREAK" }, + { STATUS_CONTROL_C_EXIT, L"CONTROL_C_EXIT" }, +// { STATUS_FLOAT_MULTIPLE_FAULTS, L"FLOAT_MULTIPLE_FAULTS" }, +// { STATUS_FLOAT_MULTIPLE_TRAPS, L"FLOAT_MULTIPLE_TRAPS" }, +// { STATUS_ILLEGAL_VLM_REFERENCE, L"ILLEGAL_VLM_REFERENCE" }, + { 0, 0 } +};
signature.asc
Description: This is a digitally signed message part
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
_______________________________________________ Cegcc-devel mailing list Cegcc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cegcc-devel