Danny Backx wrote:
> On Sun, 2007-07-01 at 09:41 -0400, Kevin O'Connor wrote:
>> On Fri, Jun 22, 2007 at 09:37:21PM +0200, Danny Backx wrote:
>>> The null.C example however - when used with my exception handling code -
>>> shows a dialog from my new exception handler, but never makes its way to
>>> the C++ exception handler.
>> Have you figured out a way to raise a c++ exception from the wince
>> handler?
> 
> Actually I was just getting there minutes ago.
> 
>>> Running the null.C program on Linux creates a coredump too, no exception
>>> handler is called.
>> Invalid memory accesses don't cause exceptions under Linux.
>>
>> Also, it appears gcc may optimize out c++ exception handlers if it
>> doesn't think the code can create an exception.  It thinks it is
>> running under a linux like environment and the optimizer wont even try
>> to handle memory raised exceptions.
>>

This may need gcc tweaking.

> 
> Let me know what you think.
> 


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

Cheers,
Pedro Alves


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