diff options
Diffstat (limited to 'src/pkg/runtime/darwin/386/signal.c')
| -rw-r--r-- | src/pkg/runtime/darwin/386/signal.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/pkg/runtime/darwin/386/signal.c b/src/pkg/runtime/darwin/386/signal.c index 6fe5f308f..65c217b4e 100644 --- a/src/pkg/runtime/darwin/386/signal.c +++ b/src/pkg/runtime/darwin/386/signal.c @@ -39,6 +39,39 @@ sighandler(int32 sig, Siginfo *info, void *context) Ucontext *uc; Mcontext *mc; Regs *r; + uintptr *sp; + void (*fn)(void); + G *gp; + byte *pc; + + uc = context; + mc = uc->uc_mcontext; + r = &mc->ss; + + if((gp = m->curg) != nil && (sigtab[sig].flags & SigPanic)) { + // Work around Leopard bug that doesn't set FPE_INTDIV. + // Look at instruction to see if it is a divide. + // Not necessary in Snow Leopard (si_code will be != 0). + if(sig == SIGFPE && info->si_code == 0) { + pc = (byte*)r->eip; + if(pc[0] == 0xF7) + info->si_code = FPE_INTDIV; + } + + // Make it look like a call to the signal func. + // Have to pass arguments out of band since + // augmenting the stack frame would break + // the unwinding code. + gp->sig = sig; + gp->sigcode0 = info->si_code; + gp->sigcode1 = (uintptr)info->si_addr; + + sp = (uintptr*)r->esp; + *--sp = r->eip; + r->eip = (uintptr)sigpanic; + r->esp = (uintptr)sp; + return; + } if(sigtab[sig].flags & SigQueue) { if(sigsend(sig) || (sigtab[sig].flags & SigIgnore)) @@ -56,11 +89,6 @@ sighandler(int32 sig, Siginfo *info, void *context) printf("%s\n", sigtab[sig].name); } - uc = context; - mc = uc->uc_mcontext; - r = &mc->ss; - - printf("Faulting address: %p\n", info->si_addr); printf("pc: %x\n", r->eip); printf("\n"); |
