1
0
mirror of https://github.com/golang/go synced 2024-11-23 02:10:03 -07:00

print tracebacks for all goroutines, not just the crashing one

R=ken
OCL=13518
CL=13518
This commit is contained in:
Rob Pike 2008-07-28 11:29:41 -07:00
parent ea0569026c
commit 3835e01d97
5 changed files with 21 additions and 2 deletions

View File

@ -74,6 +74,21 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
//prints("\n"); //prints("\n");
} }
void
tracebackothers(G *me)
{
G *g;
for(g = allg; g != nil; g = g->alllink) {
if(g == me)
continue;
prints("\ngoroutine ");
sys·printint(g->goid);
prints(":\n");
traceback(g->sched.PC, g->sched.SP+8, g); // gogo adjusts SP by 8 (not portable!)
}
}
G* G*
select(void) select(void)
{ {

View File

@ -149,6 +149,7 @@ sighandler(int32 sig, siginfo *info, void *context)
prints("\n\n"); prints("\n\n");
traceback((void *)ss->__rip, (void *)ss->__rsp, (void*)ss->__r15); traceback((void *)ss->__rip, (void *)ss->__rsp, (void*)ss->__r15);
tracebackothers((void*)ss->__r15);
print_thread_state(ss); print_thread_state(ss);
sys·exit(2); sys·exit(2);

View File

@ -153,6 +153,7 @@ sighandler(int32 sig, siginfo* info, void** context)
prints("\n\n"); prints("\n\n");
traceback((void *)sc->rip, (void *)sc->rsp, (void *)sc->r15); traceback((void *)sc->rip, (void *)sc->rsp, (void *)sc->r15);
tracebackothers((void*)sc->__r15);
print_sigcontext(sc); print_sigcontext(sc);
sys·breakpoint(); sys·breakpoint();

View File

@ -19,6 +19,7 @@ sys·panicl(int32 lno)
prints("\n"); prints("\n");
sp = (uint8*)&lno; sp = (uint8*)&lno;
traceback(sys·getcallerpc(&lno), sp, g); traceback(sys·getcallerpc(&lno), sp, g);
tracebackothers(g);
sys·breakpoint(); sys·breakpoint();
sys·exit(2); sys·exit(2);
} }

View File

@ -106,7 +106,7 @@ struct G
byte* stackbase; // must not move byte* stackbase; // must not move
byte* stack0; // first stack segment byte* stack0; // first stack segment
Gobuf sched; Gobuf sched;
G* alllink; // on allq G* alllink; // on allg
void* param; // passed parameter on wakeup void* param; // passed parameter on wakeup
int16 status; int16 status;
int32 goid; int32 goid;
@ -189,6 +189,7 @@ void* mal(uint32);
uint32 cmpstring(string, string); uint32 cmpstring(string, string);
void initsig(void); void initsig(void);
void traceback(uint8 *pc, uint8 *sp, G* gp); void traceback(uint8 *pc, uint8 *sp, G* gp);
void tracebackothers(G*);
int32 open(byte*, int32, ...); int32 open(byte*, int32, ...);
int32 read(int32, void*, int32); int32 read(int32, void*, int32);
int32 write(int32, void*, int32); int32 write(int32, void*, int32);