summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2011-11-07 11:00:14 +1100
committerAlex Brainman <alex.brainman@gmail.com>2011-11-07 11:00:14 +1100
commit3aae6f05a76ecbd66d907c199010069a56af9717 (patch)
treeb5e5f938d88d92a3f4fb56e349fc3c7f8af541c0
parentce733da38790173777321b721026299d9ac7d1c7 (diff)
downloadgo-3aae6f05a76ecbd66d907c199010069a56af9717.tar.gz
runtime: windows_386 sighandler to use correct g
Fixes issue 2403. R=hectorchu CC=golang-dev http://codereview.appspot.com/5309071
-rw-r--r--src/pkg/runtime/windows/386/signal.c7
-rw-r--r--src/pkg/runtime/windows/386/sys.s52
2 files changed, 19 insertions, 40 deletions
diff --git a/src/pkg/runtime/windows/386/signal.c b/src/pkg/runtime/windows/386/signal.c
index 9c912ede4..8d049c9f3 100644
--- a/src/pkg/runtime/windows/386/signal.c
+++ b/src/pkg/runtime/windows/386/signal.c
@@ -31,12 +31,9 @@ runtime·initsig(int32)
}
uint32
-runtime·sighandler(ExceptionRecord *info, void *frame, Context *r)
+runtime·sighandler(ExceptionRecord *info, Context *r, G *gp)
{
uintptr *sp;
- G *gp;
-
- USED(frame);
switch(info->ExceptionCode) {
case EXCEPTION_BREAKPOINT:
@@ -44,7 +41,7 @@ runtime·sighandler(ExceptionRecord *info, void *frame, Context *r)
return 1;
}
- if((gp = m->curg) != nil && runtime·issigpanic(info->ExceptionCode)) {
+ if(gp != nil && runtime·issigpanic(info->ExceptionCode)) {
// Make it look like a call to the signal func.
// Have to pass arguments out of band since
// augmenting the stack frame would break
diff --git a/src/pkg/runtime/windows/386/sys.s b/src/pkg/runtime/windows/386/sys.s
index 95ae5336b..69b9b82e8 100644
--- a/src/pkg/runtime/windows/386/sys.s
+++ b/src/pkg/runtime/windows/386/sys.s
@@ -48,51 +48,33 @@ TEXT runtime·setlasterror(SB),7,$0
MOVL AX, 0x34(FS)
RET
-TEXT runtime·sigtramp(SB),7,$0
- PUSHL BP // cdecl
- PUSHL BX
- PUSHL SI
- PUSHL DI
- PUSHL 0(FS)
- CALL runtime·sigtramp1(SB)
- POPL 0(FS)
- POPL DI
- POPL SI
- POPL BX
- POPL BP
- RET
-
-TEXT runtime·sigtramp1(SB),0,$16-40
+TEXT runtime·sigtramp(SB),7,$28
// unwinding?
- MOVL info+24(FP), BX
- MOVL 4(BX), CX // exception flags
- ANDL $6, CX
+ MOVL info+0(FP), CX
+ TESTL $6, 4(CX) // exception flags
MOVL $1, AX
JNZ sigdone
- // place ourselves at the top of the SEH chain to
- // ensure SEH frames lie within thread stack bounds
- MOVL frame+28(FP), CX // our SEH frame
- MOVL CX, 0(FS)
-
// copy arguments for call to sighandler
- MOVL BX, 0(SP)
+ MOVL CX, 0(SP)
+ MOVL context+8(FP), CX
MOVL CX, 4(SP)
- MOVL context+32(FP), BX
- MOVL BX, 8(SP)
- MOVL dispatcher+36(FP), BX
+ get_tls(CX)
+ MOVL g(CX), CX
+ MOVL CX, 8(SP)
+
MOVL BX, 12(SP)
+ MOVL BP, 16(SP)
+ MOVL SI, 20(SP)
+ MOVL DI, 24(SP)
CALL runtime·sighandler(SB)
- TESTL AX, AX
- JZ sigdone
-
- // call windows default handler early
- MOVL 4(SP), BX // our SEH frame
- MOVL 0(BX), BX // SEH frame of default handler
- MOVL BX, 4(SP) // set establisher frame
- CALL 4(BX)
+ // AX is set to report result back to Windows
+ MOVL 24(SP), DI
+ MOVL 20(SP), SI
+ MOVL 16(SP), BP
+ MOVL 12(SP), BX
sigdone:
RET