]> Cypherpunks repositories - gostls13.git/commitdiff
use correct pc for printing fn+%#x in tracebacks
authorRuss Cox <rsc@golang.org>
Mon, 31 Aug 2009 17:55:24 +0000 (10:55 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 31 Aug 2009 17:55:24 +0000 (10:55 -0700)
R=austin
DELTA=12  (2 added, 0 deleted, 10 changed)
OCL=34098
CL=34120

src/pkg/runtime/386/traceback.c
src/pkg/runtime/amd64/traceback.c

index c143ede3dc5cc84188e9db5c5de5a182613a3ae0..2f5c5e80bef8b65f81d3bcf09b346161d40ef954 100644 (file)
@@ -11,7 +11,7 @@ void
 traceback(byte *pc0, byte *sp, G *g)
 {
        Stktop *stk;
-       uintptr pc;
+       uintptr pc, tracepc;
        int32 i, n;
        Func *f;
        byte *p;
@@ -34,10 +34,11 @@ traceback(byte *pc0, byte *sp, G *g)
                        sp = stk->gobuf.sp;
                        stk = (Stktop*)stk->stackbase;
                }
-                p = (byte*)pc;
+               p = (byte*)pc;
+               tracepc = pc;
                if(n > 0 && pc != (uint64)goexit)
-                       pc--;   // get to CALL instruction
-               f = findfunc(pc);
+                       tracepc--;      // get to CALL instruction
+               f = findfunc(tracepc);
                if(f == nil) {
                        // dangerous, but poke around to see if it is a closure
                        // ADDL $xxx, SP; RET
@@ -62,7 +63,7 @@ traceback(byte *pc0, byte *sp, G *g)
                printf("%S", f->name);
                if(pc > f->entry)
                        printf("+%p", (uintptr)(pc - f->entry));
-               printf(" %S:%d\n", f->src, funcline(f, pc));
+               printf(" %S:%d\n", f->src, funcline(f, tracepc));
                printf("\t%S(", f->name);
                for(i = 0; i < f->args; i++) {
                        if(i != 0)
index f8820c523fd8b3df8b57712a17f8a710dd0dafeb..40e84f5cbf1c44c548e344ebbf3af933267fbb76 100644 (file)
@@ -8,7 +8,7 @@ void
 traceback(byte *pc0, byte *sp, G *g)
 {
        Stktop *stk;
-       uint64 pc;
+       uint64 pc, tracepc;
        int32 i, n;
        Func *f;
        byte *p;
@@ -31,10 +31,11 @@ traceback(byte *pc0, byte *sp, G *g)
                        sp = stk->gobuf.sp;
                        stk = (Stktop*)stk->stackbase;
                }
-                p = (byte*)pc;
+               p = (byte*)pc;
+               tracepc = pc;   // used for line number, function
                if(n > 0 && pc != (uint64)goexit)
-                       pc--;   // get to CALL instruction
-               f = findfunc(pc);
+                       tracepc--;      // get to CALL instruction
+               f = findfunc(tracepc);
                if(f == nil) {
                        // dangerous, but poke around to see if it is a closure
                        // ADDQ $xxx, SP; RET
@@ -59,7 +60,7 @@ traceback(byte *pc0, byte *sp, G *g)
                printf("%S", f->name);
                if(pc > f->entry)
                        printf("+%p", (uintptr)(pc - f->entry));
-               printf(" %S:%d\n", f->src, funcline(f, pc));
+               printf(" %S:%d\n", f->src, funcline(f, tracepc));
                printf("\t%S(", f->name);
                for(i = 0; i < f->args; i++) {
                        if(i != 0)