[darwin] unwind context question
Andreas Tobler
toa@pop.agri.ch
Mon Jul 7 20:57:00 GMT 2003
Geoffrey Keating wrote:
> Won't Darwin do this for you? All you should need to do is catch SIGSEGV.
Well, not from my experience. I tried, but not success. Maybe I run a
kernel which is to old? But I don't think so.
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("%d",*((int*)0));
return 0;
}
[titanium:~/gcc-work/exception] andreast% ./print
Bus error
I write to a protected mem area.
[titanium:~/gcc-work/exception] andreast% gdb print
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x00001db0 in main ()
(gdb)
So, these kind of errors end up in KERN_PROTECTION_FAILURE. And a
SIGSEGV does not help. At least I didn't manage it to catch the failure.
It would be much easier to handle a SEGV than incorporate a mach msg
handler.
>> Below the disass.
>> I would expect context->ra at 0x9000fae0 and not at 0x9000fa9c.
>
>
> Maybe. It's hard to tell without seeing how the return address got
> set. You'll note that the code there does eventually wind up in sigreturn.
>
What do you need to see?
Thanks,
Andreas
More information about the Gcc
mailing list