diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-04-20 15:44:41 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-04-20 15:44:41 +0200 |
commit | 50104cc32a498f7517a51c8dc93106c51c7a54b4 (patch) | |
tree | 47af80be259cc7c45d0eaec7d42e61fa38c8e4fb /src/pkg/runtime/freebsd | |
parent | c072558b90f1bbedc2022b0f30c8b1ac4712538e (diff) | |
download | golang-upstream/2011.03.07.1.tar.gz |
Imported Upstream version 2011.03.07.1upstream/2011.03.07.1
Diffstat (limited to 'src/pkg/runtime/freebsd')
-rw-r--r-- | src/pkg/runtime/freebsd/386/signal.c | 10 | ||||
-rw-r--r-- | src/pkg/runtime/freebsd/386/sys.s | 42 | ||||
-rw-r--r-- | src/pkg/runtime/freebsd/amd64/signal.c | 10 | ||||
-rw-r--r-- | src/pkg/runtime/freebsd/amd64/sys.s | 24 | ||||
-rw-r--r-- | src/pkg/runtime/freebsd/thread.c | 3 |
5 files changed, 53 insertions, 36 deletions
diff --git a/src/pkg/runtime/freebsd/386/signal.c b/src/pkg/runtime/freebsd/386/signal.c index ddb11fc3b..8e9d74256 100644 --- a/src/pkg/runtime/freebsd/386/signal.c +++ b/src/pkg/runtime/freebsd/386/signal.c @@ -45,17 +45,16 @@ 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 *r; - G *gp; uintptr *sp; uc = context; r = &uc->uc_mcontext; - if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) { + if(gp != nil && (runtime·sigtab[sig].flags & SigPanic)) { // Make it look like a call to the signal func. // Have to pass arguments out of band since // augmenting the stack frame would break @@ -99,12 +98,11 @@ runtime·sighandler(int32 sig, Siginfo* info, void* context) runtime·printf("\n"); if(runtime·gotraceback()){ - runtime·traceback((void*)r->mc_eip, (void*)r->mc_esp, 0, m->curg); - runtime·tracebackothers(m->curg); + runtime·traceback((void*)r->mc_eip, (void*)r->mc_esp, 0, gp); + runtime·tracebackothers(gp); runtime·dumpregs(r); } - runtime·breakpoint(); runtime·exit(2); } diff --git a/src/pkg/runtime/freebsd/386/sys.s b/src/pkg/runtime/freebsd/386/sys.s index 7110e6924..60c189bf8 100644 --- a/src/pkg/runtime/freebsd/386/sys.s +++ b/src/pkg/runtime/freebsd/386/sys.s @@ -111,30 +111,36 @@ TEXT runtime·sigaction(SB),7,$-4 CALL runtime·notok(SB) RET -TEXT runtime·sigtramp(SB),7,$40 - // g = m->gsignal - get_tls(DX) - MOVL m(DX), BP - MOVL m_gsignal(BP), BP - MOVL BP, g(DX) +TEXT runtime·sigtramp(SB),7,$44 + get_tls(CX) - MOVL signo+0(FP), AX - MOVL siginfo+4(FP), BX - MOVL context+8(FP), CX + // save g + MOVL g(CX), DI + MOVL DI, 20(SP) + + // g = m->gsignal + MOVL m(CX), BX + MOVL m_gsignal(BX), BX + MOVL BX, g(CX) - MOVL AX, 0(SP) + // copy arguments for call to sighandler + MOVL signo+0(FP), BX + MOVL BX, 0(SP) + MOVL info+4(FP), BX MOVL BX, 4(SP) - MOVL CX, 8(SP) - CALL runtime·sighandler(SB) + MOVL context+8(FP), BX + MOVL BX, 8(SP) + MOVL DI, 12(SP) - // g = m->curg - get_tls(DX) - MOVL m(DX), BP - MOVL m_curg(BP), BP - MOVL BP, g(DX) + CALL runtime·sighandler(SB) + // restore g + get_tls(CX) + MOVL 20(SP), BX + MOVL BX, g(CX) + + // call sigreturn MOVL context+8(FP), AX - MOVL $0, 0(SP) // syscall gap MOVL AX, 4(SP) MOVL $417, AX // sigreturn(ucontext) diff --git a/src/pkg/runtime/freebsd/amd64/signal.c b/src/pkg/runtime/freebsd/amd64/signal.c index 9f873d276..f145371b4 100644 --- a/src/pkg/runtime/freebsd/amd64/signal.c +++ b/src/pkg/runtime/freebsd/amd64/signal.c @@ -53,17 +53,16 @@ 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 *r; - G *gp; uintptr *sp; uc = context; r = &uc->uc_mcontext; - if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) { + if(gp != nil && (runtime·sigtab[sig].flags & SigPanic)) { // Make it look like a call to the signal func. // Have to pass arguments out of band since // augmenting the stack frame would break @@ -107,12 +106,11 @@ runtime·sighandler(int32 sig, Siginfo* info, void* context) runtime·printf("\n"); if(runtime·gotraceback()){ - runtime·traceback((void*)r->mc_rip, (void*)r->mc_rsp, 0, g); - runtime·tracebackothers(g); + runtime·traceback((void*)r->mc_rip, (void*)r->mc_rsp, 0, gp); + runtime·tracebackothers(gp); runtime·dumpregs(r); } - runtime·breakpoint(); runtime·exit(2); } diff --git a/src/pkg/runtime/freebsd/amd64/sys.s b/src/pkg/runtime/freebsd/amd64/sys.s index b9cf3832d..d986e9ac0 100644 --- a/src/pkg/runtime/freebsd/amd64/sys.s +++ b/src/pkg/runtime/freebsd/amd64/sys.s @@ -90,15 +90,29 @@ TEXT runtime·sigaction(SB),7,$-8 CALL runtime·notok(SB) RET -TEXT runtime·sigtramp(SB),7,$24-16 - get_tls(CX) - MOVQ m(CX), AX - MOVQ m_gsignal(AX), AX - MOVQ AX, g(CX) +TEXT runtime·sigtramp(SB),7,$64 + get_tls(BX) + + // save g + MOVQ g(BX), R10 + MOVQ R10, 40(SP) + + // g = m->signal + MOVQ m(BX), BP + MOVQ m_gsignal(BP), BP + MOVQ BP, g(BX) + MOVQ DI, 0(SP) MOVQ SI, 8(SP) MOVQ DX, 16(SP) + MOVQ R10, 24(SP) + CALL runtime·sighandler(SB) + + // restore g + get_tls(BX) + MOVQ 40(SP), R10 + MOVQ R10, g(BX) RET TEXT runtime·mmap(SB),7,$0 diff --git a/src/pkg/runtime/freebsd/thread.c b/src/pkg/runtime/freebsd/thread.c index 9bd883833..569098aa2 100644 --- a/src/pkg/runtime/freebsd/thread.c +++ b/src/pkg/runtime/freebsd/thread.c @@ -4,6 +4,7 @@ #include "runtime.h" #include "defs.h" #include "os.h" +#include "stack.h" extern SigTab runtime·sigtab[]; extern int32 runtime·sys_umtx_op(uint32*, int32, uint32, void*, void*); @@ -175,7 +176,7 @@ runtime·minit(void) { // Initialize signal handling m->gsignal = runtime·malg(32*1024); - runtime·signalstack(m->gsignal->stackguard, 32*1024); + runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024); } void |