Index: src/pkg/runtime/panic.c |
=================================================================== |
--- a/src/pkg/runtime/panic.c |
+++ b/src/pkg/runtime/panic.c |
@@ -362,10 +362,30 @@ |
} |
void |
+runtime·dumpcurrentstack(void) |
+{ |
+ uintptr pcs[16]; |
+ int32 n, l, i; |
+ Func *f; |
+ |
+ n = runtime·callers(1, pcs, nelem(pcs)); |
+ for(i=0; i<n; i++) { |
+ f = runtime·findfunc(pcs[i]); |
+ if(f == nil) |
+ break; |
+ l = runtime·funcline(f, pcs[i]); |
+ runtime·printf(" #%d: %p %S %S:%d\n", i, pcs[i], f->name, f->src, l); |
+ } |
+} |
+ |
+void |
runtime·throw(int8 *s) |
{ |
+ if(m->mcache == nil) |
+ m->mcache = runtime·allocmcache(); |
runtime·startpanic(); |
runtime·printf("throw: %s\n", s); |
+ runtime·dumpcurrentstack(); |
runtime·dopanic(0); |
*(int32*)0 = 0; // not reached |
runtime·exit(1); // even more not reached |