Commit 4962e7ee authored by Russ Cox's avatar Russ Cox

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

R=austin
DELTA=12  (2 added, 0 deleted, 10 changed)
OCL=34098
CL=34120
parent 3dc7b382
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment