summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/darwin')
-rw-r--r--src/pkg/runtime/darwin/386/signal.c10
-rw-r--r--src/pkg/runtime/darwin/386/sys.s29
-rw-r--r--src/pkg/runtime/darwin/amd64/signal.c10
-rw-r--r--src/pkg/runtime/darwin/amd64/sys.s19
-rw-r--r--src/pkg/runtime/darwin/thread.c3
5 files changed, 36 insertions, 35 deletions
diff --git a/src/pkg/runtime/darwin/386/signal.c b/src/pkg/runtime/darwin/386/signal.c
index 33f47d44f..aeef5de3f 100644
--- a/src/pkg/runtime/darwin/386/signal.c
+++ b/src/pkg/runtime/darwin/386/signal.c
@@ -34,20 +34,19 @@ runtime·signame(int32 sig)
}
void
-runtime·sighandler(int32 sig, Siginfo *info, void *context)
+runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
{
Ucontext *uc;
Mcontext *mc;
Regs *r;
uintptr *sp;
- G *gp;
byte *pc;
uc = context;
mc = uc->uc_mcontext;
r = &mc->ss;
- if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) {
+ if(gp != nil && (runtime·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).
@@ -103,12 +102,11 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context)
runtime·printf("\n");
if(runtime·gotraceback()){
- runtime·traceback((void*)r->eip, (void*)r->esp, 0, m->curg);
- runtime·tracebackothers(m->curg);
+ runtime·traceback((void*)r->eip, (void*)r->esp, 0, gp);
+ runtime·tracebackothers(gp);
runtime·dumpregs(r);
}
- runtime·breakpoint();
runtime·exit(2);
}
diff --git a/src/pkg/runtime/darwin/386/sys.s b/src/pkg/runtime/darwin/386/sys.s
index 7961e369c..9d2caca0a 100644
--- a/src/pkg/runtime/darwin/386/sys.s
+++ b/src/pkg/runtime/darwin/386/sys.s
@@ -80,33 +80,34 @@ TEXT runtime·sigtramp(SB),7,$40
get_tls(CX)
// save g
- MOVL g(CX), BP
- MOVL BP, 20(SP)
+ MOVL g(CX), DI
+ MOVL DI, 20(SP)
// g = m->gsignal
MOVL m(CX), BP
MOVL m_gsignal(BP), BP
MOVL BP, g(CX)
- MOVL handler+0(FP), DI
- // 4(FP) is sigstyle
- MOVL signo+8(FP), AX
- MOVL siginfo+12(FP), BX
- MOVL context+16(FP), CX
-
- MOVL AX, 0(SP)
+ // copy arguments to sighandler
+ MOVL sig+8(FP), BX
+ MOVL BX, 0(SP)
+ MOVL info+12(FP), BX
MOVL BX, 4(SP)
- MOVL CX, 8(SP)
- CALL DI
+ MOVL context+16(FP), BX
+ MOVL BX, 8(SP)
+ MOVL DI, 12(SP)
+
+ MOVL handler+0(FP), BX
+ CALL BX
// restore g
get_tls(CX)
- MOVL 20(SP), BP
- MOVL BP, g(CX)
+ MOVL 20(SP), DI
+ MOVL DI, g(CX)
+ // call sigreturn
MOVL context+16(FP), CX
MOVL style+4(FP), BX
-
MOVL $0, 0(SP) // "caller PC" - ignored
MOVL CX, 4(SP)
MOVL BX, 8(SP)
diff --git a/src/pkg/runtime/darwin/amd64/signal.c b/src/pkg/runtime/darwin/amd64/signal.c
index 948b6c9c2..402ab33ca 100644
--- a/src/pkg/runtime/darwin/amd64/signal.c
+++ b/src/pkg/runtime/darwin/amd64/signal.c
@@ -42,12 +42,11 @@ runtime·signame(int32 sig)
}
void
-runtime·sighandler(int32 sig, Siginfo *info, void *context)
+runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
{
Ucontext *uc;
Mcontext *mc;
Regs *r;
- G *gp;
uintptr *sp;
byte *pc;
@@ -55,7 +54,7 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context)
mc = uc->uc_mcontext;
r = &mc->ss;
- if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) {
+ if(gp != nil && (runtime·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).
@@ -113,12 +112,11 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context)
runtime·printf("\n");
if(runtime·gotraceback()){
- runtime·traceback((void*)r->rip, (void*)r->rsp, 0, g);
- runtime·tracebackothers(g);
+ runtime·traceback((void*)r->rip, (void*)r->rsp, 0, gp);
+ runtime·tracebackothers(gp);
runtime·dumpregs(r);
}
- runtime·breakpoint();
runtime·exit(2);
}
diff --git a/src/pkg/runtime/darwin/amd64/sys.s b/src/pkg/runtime/darwin/amd64/sys.s
index bc970156a..4f9e0d77a 100644
--- a/src/pkg/runtime/darwin/amd64/sys.s
+++ b/src/pkg/runtime/darwin/amd64/sys.s
@@ -66,8 +66,8 @@ TEXT runtime·sigtramp(SB),7,$64
get_tls(BX)
// save g
- MOVQ g(BX), BP
- MOVQ BP, 40(SP)
+ MOVQ g(BX), R10
+ MOVQ R10, 48(SP)
// g = m->gsignal
MOVQ m(BX), BP
@@ -77,18 +77,21 @@ TEXT runtime·sigtramp(SB),7,$64
MOVL DX, 0(SP)
MOVQ CX, 8(SP)
MOVQ R8, 16(SP)
- MOVQ R8, 24(SP) // save ucontext
- MOVQ SI, 32(SP) // save infostyle
+ MOVQ R10, 24(SP)
+
+ MOVQ R8, 32(SP) // save ucontext
+ MOVQ SI, 40(SP) // save infostyle
CALL DI
// restore g
get_tls(BX)
- MOVQ 40(SP), BP
- MOVQ BP, g(BX)
+ MOVQ 48(SP), R10
+ MOVQ R10, g(BX)
+ // call sigreturn
MOVL $(0x2000000+184), AX // sigreturn(ucontext, infostyle)
- MOVQ 24(SP), DI // saved ucontext
- MOVQ 32(SP), SI // saved infostyle
+ MOVQ 32(SP), DI // saved ucontext
+ MOVQ 40(SP), SI // saved infostyle
SYSCALL
INT $3 // not reached
diff --git a/src/pkg/runtime/darwin/thread.c b/src/pkg/runtime/darwin/thread.c
index 57e813109..235d69abf 100644
--- a/src/pkg/runtime/darwin/thread.c
+++ b/src/pkg/runtime/darwin/thread.c
@@ -5,6 +5,7 @@
#include "runtime.h"
#include "defs.h"
#include "os.h"
+#include "stack.h"
extern SigTab runtime·sigtab[];
@@ -176,7 +177,7 @@ runtime·minit(void)
{
// Initialize signal handling.
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
- runtime·signalstack(m->gsignal->stackguard, 32*1024);
+ runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
}
// Mach IPC, to get at semaphores