Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(12)

Side by Side Diff: src/pkg/runtime/linux/amd64/signal.c

Issue 4203042: code review 4203042: runtime: pass to signal handler value of g at time of signal (Closed)
Patch Set: diff -r ef0c9689828e https://go.googlecode.com/hg Created 14 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/linux/386/sys.s ('k') | src/pkg/runtime/linux/amd64/sys.s » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/linux/386/sys.s ('k') | src/pkg/runtime/linux/amd64/sys.s » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b