1
0
mirror of https://github.com/golang/go synced 2024-11-22 21:20:03 -07:00

new stacktrace format

sys·gosched+0x25 /home/rsc/go/src/runtime/proc.c:477
	sys·gosched()
chanrecv+0x29e /home/rsc/go/src/runtime/chan.c:277
	chanrecv(0x4be80, 0x0, 0x4cf88, 0x0, 0x0, ...)
sys·chanrecv1+0x5b /home/rsc/go/src/runtime/chan.c:355
	sys·chanrecv1(0x4be80, 0x0)
once·Server+0x26 /home/rsc/go/src/lib/strconv/atoi.go:-41
	once·Server()

the last line is broken (atoi.go:-41) but that's not new.

R=r
DELTA=46  (19 added, 14 deleted, 13 changed)
OCL=20018
CL=20026
This commit is contained in:
Russ Cox 2008-11-25 17:17:54 -08:00
parent efc86a74e4
commit d040d26863
2 changed files with 32 additions and 27 deletions

View File

@ -30,7 +30,6 @@ traceback(uint8 *pc, uint8 *sp, void* r15)
} }
counter = 0; counter = 0;
name = gostring((byte*)"panic");
for(;;){ for(;;){
callpc = pc; callpc = pc;
if((uint8*)retfromnewstack == pc) { if((uint8*)retfromnewstack == pc) {
@ -44,9 +43,14 @@ traceback(uint8 *pc, uint8 *sp, void* r15)
continue; continue;
} }
f = findfunc((uint64)callpc); f = findfunc((uint64)callpc);
if(f == nil) if(f == nil) {
printf("%p unknown pc\n", callpc);
return; return;
}
name = f->name; name = f->name;
if(f->frame < 8) // assembly funcs say 0 but lie
sp += 8;
else
sp += f->frame; sp += f->frame;
if(counter++ > 100){ if(counter++ > 100){
prints("stack trace terminated\n"); prints("stack trace terminated\n");
@ -55,32 +59,23 @@ traceback(uint8 *pc, uint8 *sp, void* r15)
if((pc = ((uint8**)sp)[-1]) <= (uint8*)0x1000) if((pc = ((uint8**)sp)[-1]) <= (uint8*)0x1000)
break; break;
/* print this frame */ // print this frame
prints("0x"); // main+0xf /home/rsc/go/src/runtime/x.go:23
sys·printpointer(callpc - 1); // -1 to get to CALL instr. // main(0x1, 0x2, 0x3)
prints("?zi "); printf("%S", name);
sys·printstring(f->src); if((uint64)callpc > f->entry)
prints(":"); printf("+%X", (uint64)callpc - f->entry);
sys·printint(funcline(f, (uint64)callpc-1)); // -1 to get to CALL instr. printf(" %S:%d\n", f->src, funcline(f, (uint64)callpc-1)); // -1 to get to CALL instr.
prints("\n"); printf("\t%S(", name);
prints("\t"); for(i = 0; i < f->args; i++) {
sys·printstring(name);
prints("(");
for(i = 0; i < 3; i++){
if(i != 0) if(i != 0)
prints(", "); prints(", ");
sys·printint(((uint32*)sp)[i]); sys·printhex(((uint32*)sp)[i]);
if(i >= 4) {
prints(", ...");
break;
} }
prints(", ...)\n");
prints("\t");
sys·printstring(name);
prints("(");
for(i = 0; i < 3; i++){
if(i != 0)
prints(", ");
prints("0x");
sys·printpointer(((void**)sp)[i]);
} }
prints(", ...)\n"); prints(")\n");
} }
} }

View File

@ -127,6 +127,16 @@ dofunc(Sym *sym)
if(nfunc > 0 && func != nil) if(nfunc > 0 && func != nil)
func[nfunc-1].frame = sym->value; func[nfunc-1].frame = sym->value;
break; break;
case 'p':
if(nfunc > 0 && func != nil) {
f = &func[nfunc-1];
// args counts 32-bit words.
// sym->value is the arg's offset.
// don't know width of this arg, so assume it is 64 bits.
if(f->args < sym->value/4 + 2)
f->args = sym->value/4 + 2;
}
break;
case 'f': case 'f':
if(fname == nil) { if(fname == nil) {
if(sym->value >= nfname) if(sym->value >= nfname)