Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

runtime: fix netbsd/386 stack pointer handling

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
http://codereview.appspot.com/6465054
  • Loading branch information...
commit 7918211125bf1216bd5133bc7c634b00e3537d4e 1 parent a934d94
authored August 17, 2012

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. 10  src/pkg/runtime/signal_netbsd_386.c
10  src/pkg/runtime/signal_netbsd_386.c
@@ -29,7 +29,7 @@ runtime·dumpregs(McontextT *mc)
29 29
 	runtime·printf("edi     %x\n", mc->__gregs[REG_EDI]);
30 30
 	runtime·printf("esi     %x\n", mc->__gregs[REG_ESI]);
31 31
 	runtime·printf("ebp     %x\n", mc->__gregs[REG_EBP]);
32  
-	runtime·printf("esp     %x\n", mc->__gregs[REG_ESP]);
  32
+	runtime·printf("esp     %x\n", mc->__gregs[REG_UESP]);
33 33
 	runtime·printf("eip     %x\n", mc->__gregs[REG_EIP]);
34 34
 	runtime·printf("eflags  %x\n", mc->__gregs[REG_EFL]);
35 35
 	runtime·printf("cs      %x\n", mc->__gregs[REG_CS]);
@@ -47,7 +47,7 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
47 47
 
48 48
 	if(sig == SIGPROF) {
49 49
 		runtime·sigprof((uint8*)mc->__gregs[REG_EIP],
50  
-			(uint8*)mc->__gregs[REG_ESP], nil, gp);
  50
+			(uint8*)mc->__gregs[REG_UESP], nil, gp);
51 51
 		return;
52 52
 	}
53 53
 
@@ -71,9 +71,9 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
71 71
 		// (Otherwise the trace will end at runtime·sigpanic
72 72
 		// and we won't get to see who faulted.)
73 73
 		if(mc->__gregs[REG_EIP] != 0) {
74  
-			sp = (uintptr*)mc->__gregs[REG_ESP];
  74
+			sp = (uintptr*)mc->__gregs[REG_UESP];
75 75
 			*--sp = mc->__gregs[REG_EIP];
76  
-			mc->__gregs[REG_ESP] = (uintptr)sp;
  76
+			mc->__gregs[REG_UESP] = (uintptr)sp;
77 77
 		}
78 78
 		mc->__gregs[REG_EIP] = (uintptr)runtime·sigpanic;
79 79
 		return;
@@ -100,7 +100,7 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
100 100
 
101 101
 	if(runtime·gotraceback()){
102 102
 		runtime·traceback((void*)mc->__gregs[REG_EIP],
103  
-			(void*)mc->__gregs[REG_ESP], 0, gp);
  103
+			(void*)mc->__gregs[REG_UESP], 0, gp);
104 104
 		runtime·tracebackothers(gp);
105 105
 		runtime·dumpregs(mc);
106 106
 	}

0 notes on commit 7918211

Please sign in to comment.
Something went wrong with that request. Please try again.