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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 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 } |
| 380 |
| 381 void |
365 runtime·throw(int8 *s) | 382 runtime·throw(int8 *s) |
366 { | 383 { |
367 » runtime·printf("%d: throw: %s\n", m->id, s); | 384 » if(m->mcache == nil) |
| 385 » » m->mcache = runtime·allocmcache(); |
368 runtime·startpanic(); | 386 runtime·startpanic(); |
369 runtime·printf("throw: %s\n", s); | 387 runtime·printf("throw: %s\n", s); |
| 388 runtime·dumpcurrentstack(); |
370 runtime·dopanic(0); | 389 runtime·dopanic(0); |
371 *(int32*)0 = 0; // not reached | 390 *(int32*)0 = 0; // not reached |
372 runtime·exit(1); // even more not reached | 391 runtime·exit(1); // even more not reached |
373 } | 392 } |
374 | 393 |
375 void | 394 void |
376 runtime·panicstring(int8 *s) | 395 runtime·panicstring(int8 *s) |
377 { | 396 { |
378 Eface err; | 397 Eface err; |
379 | 398 |
380 if(m->gcing) { | 399 if(m->gcing) { |
381 runtime·printf("panic: %s\n", s); | 400 runtime·printf("panic: %s\n", s); |
382 runtime·throw("panic during gc"); | 401 runtime·throw("panic during gc"); |
383 } | 402 } |
384 runtime·newErrorString(runtime·gostringnocopy((byte*)s), &err); | 403 runtime·newErrorString(runtime·gostringnocopy((byte*)s), &err); |
385 runtime·panic(err); | 404 runtime·panic(err); |
386 } | 405 } |
387 | 406 |
388 void | 407 void |
389 runtime·Goexit(void) | 408 runtime·Goexit(void) |
390 { | 409 { |
391 rundefer(); | 410 rundefer(); |
392 runtime·goexit(); | 411 runtime·goexit(); |
393 } | 412 } |
LEFT | RIGHT |