OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 "defs.h" | 6 #include "defs.h" |
7 #include "signals.h" | 7 #include "signals.h" |
8 #include "os.h" | 8 #include "os.h" |
9 | 9 |
10 void | 10 void |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 String | 44 String |
45 runtime·signame(int32 sig) | 45 runtime·signame(int32 sig) |
46 { | 46 { |
47 if(sig < 0 || sig >= NSIG) | 47 if(sig < 0 || sig >= NSIG) |
48 return runtime·emptystring; | 48 return runtime·emptystring; |
49 return runtime·gostringnocopy((byte*)runtime·sigtab[sig].name); | 49 return runtime·gostringnocopy((byte*)runtime·sigtab[sig].name); |
50 } | 50 } |
51 | 51 |
52 void | 52 void |
53 runtime·sighandler(int32 sig, Siginfo* info, void* context) | 53 runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp) |
54 { | 54 { |
55 Ucontext *uc; | 55 Ucontext *uc; |
56 Mcontext *mc; | 56 Mcontext *mc; |
57 Sigcontext *r; | 57 Sigcontext *r; |
58 uintptr *sp; | 58 uintptr *sp; |
59 G *gp; | |
60 | 59 |
61 uc = context; | 60 uc = context; |
62 mc = &uc->uc_mcontext; | 61 mc = &uc->uc_mcontext; |
63 r = (Sigcontext*)mc; // same layout, more conveient names | 62 r = (Sigcontext*)mc; // same layout, more conveient names |
64 | 63 |
65 » if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) { | 64 » if(gp != nil && (runtime·sigtab[sig].flags & SigPanic)) { |
66 // Make it look like a call to the signal func. | 65 // Make it look like a call to the signal func. |
67 // Have to pass arguments out of band since | 66 // Have to pass arguments out of band since |
68 // augmenting the stack frame would break | 67 // augmenting the stack frame would break |
69 // the unwinding code. | 68 // the unwinding code. |
70 gp->sig = sig; | 69 gp->sig = sig; |
71 gp->sigcode0 = info->si_code; | 70 gp->sigcode0 = info->si_code; |
72 gp->sigcode1 = ((uintptr*)info)[2]; | 71 gp->sigcode1 = ((uintptr*)info)[2]; |
73 gp->sigpc = r->rip; | 72 gp->sigpc = r->rip; |
74 | 73 |
75 // Only push runtime·sigpanic if r->rip != 0. | 74 // Only push runtime·sigpanic if r->rip != 0. |
(...skipping 23 matching lines...) Expand all Loading... |
99 | 98 |
100 if(sig < 0 || sig >= NSIG) | 99 if(sig < 0 || sig >= NSIG) |
101 runtime·printf("Signal %d\n", sig); | 100 runtime·printf("Signal %d\n", sig); |
102 else | 101 else |
103 runtime·printf("%s\n", runtime·sigtab[sig].name); | 102 runtime·printf("%s\n", runtime·sigtab[sig].name); |
104 | 103 |
105 runtime·printf("PC=%X\n", r->rip); | 104 runtime·printf("PC=%X\n", r->rip); |
106 runtime·printf("\n"); | 105 runtime·printf("\n"); |
107 | 106 |
108 if(runtime·gotraceback()){ | 107 if(runtime·gotraceback()){ |
109 » » runtime·traceback((void*)r->rip, (void*)r->rsp, 0, g); | 108 » » runtime·traceback((void*)r->rip, (void*)r->rsp, 0, gp); |
110 » » runtime·tracebackothers(g); | 109 » » runtime·tracebackothers(gp); |
111 runtime·dumpregs(r); | 110 runtime·dumpregs(r); |
112 } | 111 } |
113 | 112 |
114 runtime·breakpoint(); | 113 runtime·breakpoint(); |
115 runtime·exit(2); | 114 runtime·exit(2); |
116 } | 115 } |
117 | 116 |
118 void | 117 void |
119 runtime·signalstack(byte *p, int32 n) | 118 runtime·signalstack(byte *p, int32 n) |
120 { | 119 { |
(...skipping 25 matching lines...) Expand all Loading... |
146 else | 145 else |
147 sa.sa_handler = (void*)runtime·sigignore; | 146 sa.sa_handler = (void*)runtime·sigignore; |
148 if(runtime·sigtab[i].flags & SigRestart) | 147 if(runtime·sigtab[i].flags & SigRestart) |
149 sa.sa_flags |= SA_RESTART; | 148 sa.sa_flags |= SA_RESTART; |
150 else | 149 else |
151 sa.sa_flags &= ~SA_RESTART; | 150 sa.sa_flags &= ~SA_RESTART; |
152 runtime·rt_sigaction(i, &sa, nil, 8); | 151 runtime·rt_sigaction(i, &sa, nil, 8); |
153 } | 152 } |
154 } | 153 } |
155 } | 154 } |
OLD | NEW |