comparison libgo/runtime/panic.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
14 } 14 }
15 15
16 void 16 void
17 runtime_panicstring(const char *s) 17 runtime_panicstring(const char *s)
18 { 18 {
19 M* mp; 19 G *gp;
20 Eface err; 20 Eface err;
21 21
22 mp = runtime_m(); 22 gp = runtime_g();
23 if (mp != nil) { 23 if (gp == nil) {
24 if(mp->mallocing) { 24 runtime_printf("panic: %s\n", s);
25 runtime_printf("panic: %s\n", s); 25 runtime_throw("panic with no g");
26 runtime_throw("panic during malloc");
27 }
28 if(mp->gcing) {
29 runtime_printf("panic: %s\n", s);
30 runtime_throw("panic during gc");
31 }
32 if(mp->locks) {
33 runtime_printf("panic: %s\n", s);
34 runtime_throw("panic holding locks");
35 }
36 } 26 }
37 runtime_newErrorCString(s, &err); 27 if (gp->m == nil) {
28 runtime_printf("panic: %s\n", s);
29 runtime_throw("panic with no m");
30 }
31 if (gp->m->curg != gp) {
32 runtime_printf("panic: %s\n", s);
33 runtime_throw("panic on system stack");
34 }
35 if (gp->m->mallocing != 0) {
36 runtime_printf("panic: %s\n", s);
37 runtime_throw("panic during malloc");
38 }
39 if (gp->m->preemptoff.len != 0) {
40 runtime_printf("panic: %s\n", s);
41 runtime_printf("preempt off reason: %S\n", gp->m->preemptoff);
42 runtime_throw("panic during preemptoff");
43 }
44 if (gp->m->locks != 0) {
45 runtime_printf("panic: %s\n", s);
46 runtime_throw("panic holding locks");
47 }
48 runtime_newErrorCString((uintptr) s, &err);
38 runtime_panic(err); 49 runtime_panic(err);
39 } 50 }
40 51
41 extern void runtime_abort(void) __asm__(GOSYM_PREFIX "runtime.abort"); 52 extern void runtime_abort(void) __asm__(GOSYM_PREFIX "runtime.abort");
42 53