LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 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 // +build darwin dragonfly freebsd linux nacl netbsd openbsd | 5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd |
6 | 6 |
7 #include "runtime.h" | 7 #include "runtime.h" |
8 #include "defs_GOOS_GOARCH.h" | 8 #include "defs_GOOS_GOARCH.h" |
9 #include "os_GOOS.h" | 9 #include "os_GOOS.h" |
10 #include "signal_GOOS_GOARCH.h" | 10 #include "signal_GOOS_GOARCH.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 void | 34 void |
35 runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp) | 35 runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp) |
36 { | 36 { |
37 uintptr *sp; | 37 uintptr *sp; |
38 SigTab *t; | 38 SigTab *t; |
39 bool crash; | 39 bool crash; |
40 | 40 |
41 if(sig == SIGPROF) { | 41 if(sig == SIGPROF) { |
42 » » runtime·sigprof((byte*)SIG_EIP(info, ctxt), (byte*)SIG_ESP(info,
ctxt), nil, gp, m); | 42 » » runtime·sigprof((byte*)SIG_EIP(info, ctxt), (byte*)SIG_ESP(info,
ctxt), nil, gp, g->m); |
43 return; | 43 return; |
44 } | 44 } |
45 | 45 |
46 t = &runtime·sigtab[sig]; | 46 t = &runtime·sigtab[sig]; |
47 if(SIG_CODE0(info, ctxt) != SI_USER && (t->flags & SigPanic)) { | 47 if(SIG_CODE0(info, ctxt) != SI_USER && (t->flags & SigPanic)) { |
48 // Make it look like a call to the signal func. | 48 // Make it look like a call to the signal func. |
49 // Have to pass arguments out of band since | 49 // Have to pass arguments out of band since |
50 // augmenting the stack frame would break | 50 // augmenting the stack frame would break |
51 // the unwinding code. | 51 // the unwinding code. |
52 gp->sig = sig; | 52 gp->sig = sig; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 if(SIG_CODE0(info, ctxt) == SI_USER || (t->flags & SigNotify)) | 86 if(SIG_CODE0(info, ctxt) == SI_USER || (t->flags & SigNotify)) |
87 if(runtime·sigsend(sig)) | 87 if(runtime·sigsend(sig)) |
88 return; | 88 return; |
89 if(t->flags & SigKill) | 89 if(t->flags & SigKill) |
90 runtime·exit(2); | 90 runtime·exit(2); |
91 if(!(t->flags & SigThrow)) | 91 if(!(t->flags & SigThrow)) |
92 return; | 92 return; |
93 | 93 |
94 » m->throwing = 1; | 94 » g->m->throwing = 1; |
95 » m->caughtsig = gp; | 95 » g->m->caughtsig = gp; |
96 runtime·startpanic(); | 96 runtime·startpanic(); |
97 | 97 |
98 if(sig < 0 || sig >= NSIG) | 98 if(sig < 0 || sig >= NSIG) |
99 runtime·printf("Signal %d\n", sig); | 99 runtime·printf("Signal %d\n", sig); |
100 else | 100 else |
101 runtime·printf("%s\n", runtime·sigtab[sig].name); | 101 runtime·printf("%s\n", runtime·sigtab[sig].name); |
102 | 102 |
103 runtime·printf("PC=%x\n", SIG_EIP(info, ctxt)); | 103 runtime·printf("PC=%x\n", SIG_EIP(info, ctxt)); |
104 » if(m->lockedg != nil && m->ncgo > 0 && gp == m->g0) { | 104 » if(g->m->lockedg != nil && g->m->ncgo > 0 && gp == g->m->g0) { |
105 runtime·printf("signal arrived during cgo execution\n"); | 105 runtime·printf("signal arrived during cgo execution\n"); |
106 » » gp = m->lockedg; | 106 » » gp = g->m->lockedg; |
107 » }» | 107 » } |
108 runtime·printf("\n"); | 108 runtime·printf("\n"); |
109 | 109 |
110 if(runtime·gotraceback(&crash)){ | 110 if(runtime·gotraceback(&crash)){ |
111 runtime·goroutineheader(gp); | 111 runtime·goroutineheader(gp); |
112 runtime·traceback(SIG_EIP(info, ctxt), SIG_ESP(info, ctxt), 0, g
p); | 112 runtime·traceback(SIG_EIP(info, ctxt), SIG_ESP(info, ctxt), 0, g
p); |
113 runtime·tracebackothers(gp); | 113 runtime·tracebackothers(gp); |
114 runtime·printf("\n"); | 114 runtime·printf("\n"); |
115 runtime·dumpregs(info, ctxt); | 115 runtime·dumpregs(info, ctxt); |
116 } | 116 } |
117 ········ | 117 ········ |
118 if(crash) | 118 if(crash) |
119 runtime·crash(); | 119 runtime·crash(); |
120 | 120 |
121 runtime·exit(2); | 121 runtime·exit(2); |
122 } | 122 } |
LEFT | RIGHT |