On Sun, Jul 01, 2007 at 08:12:33PM +0100, Pedro Alves wrote: > Danny Backx wrote: > > void Handle(struct _EXCEPTION_RECORD *ExceptionRecord, > > void *EstablisherFrame, > > struct _CONTEXT *ContextRecord, > > struct _DISPATCHER_CONTEXT *DispatcherContext) > > { > > throw WindowsException(ExceptionRecord, EstablisherFrame, > > ContextRecord, DispatcherContext); > > } > > I'm not sure that is safe. You are throwing away from a callback started > from the kernel. I think the safest is to tweak the current threads > context with GetThreaContext/SetThreadContext to point the pc at a different > address like your registered handler, and return > EXCEPTION_CONTINUE_EXECUTION. Then, in that handler, you're got the stack > setup as if the exception called directly into your handler, and it should be > safe to throw a c++ exception. Take another look at cegcc's startup.c for > inspiration - It already does something similar.
Is it safe to enter an exception handler using the calling program's stack? That is, if you set the pc to a handler and call EXCEPTION_CONTINUE_EXECUTION that handler will alter the stack and registers of the function that raised the exception. Are we guarenteed that this is okay? Another option would be to manually create the exception and then "throw it" by setting pc to the address of longjmp and return EXCEPTION_CONTINUE_EXECUTION. But this would be pretty complicated and it would require copying some gcc code into cegcc. -Kevin ------------------------------------------------------------------------- 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