]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix netbsd/386 stack pointer handling
authorJoel Sing <jsing@google.com>
Fri, 17 Aug 2012 11:53:02 +0000 (21:53 +1000)
committerJoel Sing <jsing@google.com>
Fri, 17 Aug 2012 11:53:02 +0000 (21:53 +1000)
When manipulating the stack pointer use the UESP register instead
of the ESP register, since the UESP register is the one that gets
restored from the machine context. Fixes broken tests on netbsd/386.

R=golang-dev, minux.ma, r, bsiegert
CC=golang-dev
https://golang.org/cl/6465054

src/pkg/runtime/signal_netbsd_386.c

index e50c5267884866f0f95f4dc0d15743827f340e2a..fcb92f3b209d235781c2f76d0e1b81b23066b2cb 100644 (file)
@@ -29,7 +29,7 @@ runtime·dumpregs(McontextT *mc)
        runtime·printf("edi     %x\n", mc->__gregs[REG_EDI]);
        runtime·printf("esi     %x\n", mc->__gregs[REG_ESI]);
        runtime·printf("ebp     %x\n", mc->__gregs[REG_EBP]);
-       runtime·printf("esp     %x\n", mc->__gregs[REG_ESP]);
+       runtime·printf("esp     %x\n", mc->__gregs[REG_UESP]);
        runtime·printf("eip     %x\n", mc->__gregs[REG_EIP]);
        runtime·printf("eflags  %x\n", mc->__gregs[REG_EFL]);
        runtime·printf("cs      %x\n", mc->__gregs[REG_CS]);
@@ -47,7 +47,7 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
 
        if(sig == SIGPROF) {
                runtime·sigprof((uint8*)mc->__gregs[REG_EIP],
-                       (uint8*)mc->__gregs[REG_ESP], nil, gp);
+                       (uint8*)mc->__gregs[REG_UESP], nil, gp);
                return;
        }
 
@@ -71,9 +71,9 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
                // (Otherwise the trace will end at runtime·sigpanic
                // and we won't get to see who faulted.)
                if(mc->__gregs[REG_EIP] != 0) {
-                       sp = (uintptr*)mc->__gregs[REG_ESP];
+                       sp = (uintptr*)mc->__gregs[REG_UESP];
                        *--sp = mc->__gregs[REG_EIP];
-                       mc->__gregs[REG_ESP] = (uintptr)sp;
+                       mc->__gregs[REG_UESP] = (uintptr)sp;
                }
                mc->__gregs[REG_EIP] = (uintptr)runtime·sigpanic;
                return;
@@ -100,7 +100,7 @@ Throw:
 
        if(runtime·gotraceback()){
                runtime·traceback((void*)mc->__gregs[REG_EIP],
-                       (void*)mc->__gregs[REG_ESP], 0, gp);
+                       (void*)mc->__gregs[REG_UESP], 0, gp);
                runtime·tracebackothers(gp);
                runtime·dumpregs(mc);
        }