1
0
mirror of https://github.com/golang/go synced 2024-11-26 08:07:57 -07:00

use correct pc for printing fn+%#x in tracebacks

R=austin
DELTA=12  (2 added, 0 deleted, 10 changed)
OCL=34098
CL=34120
This commit is contained in:
Russ Cox 2009-08-31 10:55:24 -07:00
parent 3dc7b382f9
commit 4962e7ee9b
2 changed files with 12 additions and 10 deletions

View File

@ -11,7 +11,7 @@ void
traceback(byte *pc0, byte *sp, G *g) traceback(byte *pc0, byte *sp, G *g)
{ {
Stktop *stk; Stktop *stk;
uintptr pc; uintptr pc, tracepc;
int32 i, n; int32 i, n;
Func *f; Func *f;
byte *p; byte *p;
@ -35,9 +35,10 @@ traceback(byte *pc0, byte *sp, G *g)
stk = (Stktop*)stk->stackbase; stk = (Stktop*)stk->stackbase;
} }
p = (byte*)pc; p = (byte*)pc;
tracepc = pc;
if(n > 0 && pc != (uint64)goexit) if(n > 0 && pc != (uint64)goexit)
pc--; // get to CALL instruction tracepc--; // get to CALL instruction
f = findfunc(pc); f = findfunc(tracepc);
if(f == nil) { if(f == nil) {
// dangerous, but poke around to see if it is a closure // dangerous, but poke around to see if it is a closure
// ADDL $xxx, SP; RET // ADDL $xxx, SP; RET
@ -62,7 +63,7 @@ traceback(byte *pc0, byte *sp, G *g)
printf("%S", f->name); printf("%S", f->name);
if(pc > f->entry) if(pc > f->entry)
printf("+%p", (uintptr)(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); printf("\t%S(", f->name);
for(i = 0; i < f->args; i++) { for(i = 0; i < f->args; i++) {
if(i != 0) if(i != 0)

View File

@ -8,7 +8,7 @@ void
traceback(byte *pc0, byte *sp, G *g) traceback(byte *pc0, byte *sp, G *g)
{ {
Stktop *stk; Stktop *stk;
uint64 pc; uint64 pc, tracepc;
int32 i, n; int32 i, n;
Func *f; Func *f;
byte *p; byte *p;
@ -32,9 +32,10 @@ traceback(byte *pc0, byte *sp, G *g)
stk = (Stktop*)stk->stackbase; stk = (Stktop*)stk->stackbase;
} }
p = (byte*)pc; p = (byte*)pc;
tracepc = pc; // used for line number, function
if(n > 0 && pc != (uint64)goexit) if(n > 0 && pc != (uint64)goexit)
pc--; // get to CALL instruction tracepc--; // get to CALL instruction
f = findfunc(pc); f = findfunc(tracepc);
if(f == nil) { if(f == nil) {
// dangerous, but poke around to see if it is a closure // dangerous, but poke around to see if it is a closure
// ADDQ $xxx, SP; RET // ADDQ $xxx, SP; RET
@ -59,7 +60,7 @@ traceback(byte *pc0, byte *sp, G *g)
printf("%S", f->name); printf("%S", f->name);
if(pc > f->entry) if(pc > f->entry)
printf("+%p", (uintptr)(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); printf("\t%S(", f->name);
for(i = 0; i < f->args; i++) { for(i = 0; i < f->args; i++) {
if(i != 0) if(i != 0)