LEFT | RIGHT |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "arch_GOARCH.h" | 6 #include "arch_GOARCH.h" |
7 #include "stack.h" | 7 #include "stack.h" |
8 | 8 |
9 // Code related to defer, panic and recover. | 9 // Code related to defer, panic and recover. |
10 | 10 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 runtime·throw("no return at end of a typed function - compiler is broken
"); | 354 runtime·throw("no return at end of a typed function - compiler is broken
"); |
355 } | 355 } |
356 | 356 |
357 void | 357 void |
358 runtime·throwinit(void) | 358 runtime·throwinit(void) |
359 { | 359 { |
360 // can only happen with linker skew | 360 // can only happen with linker skew |
361 runtime·throw("recursive call during initialization - linker skew"); | 361 runtime·throw("recursive call during initialization - linker skew"); |
362 } | 362 } |
363 | 363 |
364 void runtime·mallocgc(void); | 364 void |
| 365 runtime·dumpcurrentstack(void) |
| 366 { |
| 367 » uintptr pcs[16]; |
| 368 » int32 n, l, i; |
| 369 » Func *f; |
| 370 |
| 371 » n = runtime·callers(1, pcs, nelem(pcs)); |
| 372 » for(i=0; i<n; i++) { |
| 373 » » f = runtime·findfunc(pcs[i]); |
| 374 » » if(f == nil) |
| 375 » » » break; |
| 376 » » l = runtime·funcline(f, pcs[i]); |
| 377 » » runtime·printf(" #%d: %p %S %S:%d\n", i, pcs[i], f->name, f->sr
c, l); |
| 378 » } |
| 379 } |
365 | 380 |
366 void | 381 void |
367 runtime·throw(int8 *s) | 382 runtime·throw(int8 *s) |
368 { | 383 { |
369 if(m->mcache == nil) | 384 if(m->mcache == nil) |
370 m->mcache = runtime·allocmcache(); | 385 m->mcache = runtime·allocmcache(); |
371 runtime·printf("%d: throw: %s\n", m->id, s); | |
372 uintptr pcs[16]; | |
373 runtime·callers(1, pcs, 16); | |
374 int32 i; | |
375 for(i=0; i<16; i++) { | |
376 Func *f = runtime·findfunc(pcs[i]); | |
377 if(f) { | |
378 int32 l = runtime·funcline(f, pcs[i]); | |
379 runtime·printf(" #%d: %p %s:%d\n", i, pcs[i], f->name.s
tr, l); | |
380 } | |
381 } | |
382 runtime·startpanic(); | 386 runtime·startpanic(); |
383 runtime·printf("throw: %s\n", s); | 387 runtime·printf("throw: %s\n", s); |
| 388 runtime·dumpcurrentstack(); |
384 runtime·dopanic(0); | 389 runtime·dopanic(0); |
385 *(int32*)0 = 0; // not reached | 390 *(int32*)0 = 0; // not reached |
386 runtime·exit(1); // even more not reached | 391 runtime·exit(1); // even more not reached |
387 } | 392 } |
388 | 393 |
389 void | 394 void |
390 runtime·panicstring(int8 *s) | 395 runtime·panicstring(int8 *s) |
391 { | 396 { |
392 Eface err; | 397 Eface err; |
393 | 398 |
394 if(m->gcing) { | 399 if(m->gcing) { |
395 runtime·printf("panic: %s\n", s); | 400 runtime·printf("panic: %s\n", s); |
396 runtime·throw("panic during gc"); | 401 runtime·throw("panic during gc"); |
397 } | 402 } |
398 runtime·newErrorString(runtime·gostringnocopy((byte*)s), &err); | 403 runtime·newErrorString(runtime·gostringnocopy((byte*)s), &err); |
399 runtime·panic(err); | 404 runtime·panic(err); |
400 } | 405 } |
401 | 406 |
402 void | 407 void |
403 runtime·Goexit(void) | 408 runtime·Goexit(void) |
404 { | 409 { |
405 rundefer(); | 410 rundefer(); |
406 runtime·goexit(); | 411 runtime·goexit(); |
407 } | 412 } |
LEFT | RIGHT |