Pedro Alves wrote:
Kevin O'Connor wrote:
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?


Of course, just changing the pc is not enough.  We have to setup a
new stack frame.  Really, you should look at newlib/libc/sys/wince/startup.c:

Let me see if I can come up with something in the following days.


OK, here is my take.  See/try attached.

- It shows that it is possible to have SEH/ARM with a few
  macros (to hide the __asm__).
- It shows that is is possible to wrap SEH in c++ exceptions.
- It shows that is can be pretty much cleaned up. :)
- It shows that there is no need to change the entry point.

Cheers,
Pedro Alves

Attachment: test_eh.tar.gz
Description: application/gzip

-------------------------------------------------------------------------
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

Reply via email to