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

Delta Between Two Patch Sets: src/pkg/runtime/signal_arm.c

Issue 109050043: code review 109050043: all: remove 'extern register M *m' from runtime (Closed)
Left Patch Set: Created 10 years, 9 months ago
Right Patch Set: diff -r 2699961d1143 https://code.google.com/p/go/ Created 10 years, 9 months 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/signal_amd64x.c ('k') | src/pkg/runtime/signal_unix.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 // +build darwin dragonfly freebsd linux netbsd openbsd 5 // +build darwin dragonfly freebsd linux 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 28 matching lines...) Expand all
39 runtime·printf("fault %x\n", SIG_FAULT(info, ctxt)); 39 runtime·printf("fault %x\n", SIG_FAULT(info, ctxt));
40 } 40 }
41 41
42 void 42 void
43 runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp) 43 runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp)
44 { 44 {
45 SigTab *t; 45 SigTab *t;
46 bool crash; 46 bool crash;
47 47
48 if(sig == SIGPROF) { 48 if(sig == SIGPROF) {
49 » » runtime·sigprof((uint8*)SIG_PC(info, ctxt), (uint8*)SIG_SP(info, ctxt), (uint8*)SIG_LR(info, ctxt), gp, m); 49 » » runtime·sigprof((uint8*)SIG_PC(info, ctxt), (uint8*)SIG_SP(info, ctxt), (uint8*)SIG_LR(info, ctxt), gp, g->m);
50 return; 50 return;
51 } 51 }
52 52
53 t = &runtime·sigtab[sig]; 53 t = &runtime·sigtab[sig];
54 if(SIG_CODE0(info, ctxt) != SI_USER && (t->flags & SigPanic)) { 54 if(SIG_CODE0(info, ctxt) != SI_USER && (t->flags & SigPanic)) {
55 // Make it look like a call to the signal func. 55 // Make it look like a call to the signal func.
56 // Have to pass arguments out of band since 56 // Have to pass arguments out of band since
57 // augmenting the stack frame would break 57 // augmenting the stack frame would break
58 // the unwinding code. 58 // the unwinding code.
59 gp->sig = sig; 59 gp->sig = sig;
60 gp->sigcode0 = SIG_CODE0(info, ctxt); 60 gp->sigcode0 = SIG_CODE0(info, ctxt);
61 gp->sigcode1 = SIG_FAULT(info, ctxt); 61 gp->sigcode1 = SIG_FAULT(info, ctxt);
62 gp->sigpc = SIG_PC(info, ctxt); 62 gp->sigpc = SIG_PC(info, ctxt);
63 63
64 // We arrange lr, and pc to pretend the panicking 64 // We arrange lr, and pc to pretend the panicking
65 // function calls sigpanic directly. 65 // function calls sigpanic directly.
66 // Always save LR to stack so that panics in leaf 66 // Always save LR to stack so that panics in leaf
67 // functions are correctly handled. This smashes 67 // functions are correctly handled. This smashes
68 // the stack frame but we're not going back there 68 // the stack frame but we're not going back there
69 // anyway. 69 // anyway.
70 SIG_SP(info, ctxt) -= 4; 70 SIG_SP(info, ctxt) -= 4;
71 *(uint32*)SIG_SP(info, ctxt) = SIG_LR(info, ctxt); 71 *(uint32*)SIG_SP(info, ctxt) = SIG_LR(info, ctxt);
72 // Don't bother saving PC if it's zero, which is 72 // Don't bother saving PC if it's zero, which is
73 // probably a call to a nil func: the old link register 73 // probably a call to a nil func: the old link register
74 // is more useful in the stack trace. 74 // is more useful in the stack trace.
75 if(gp->sigpc != 0) 75 if(gp->sigpc != 0)
76 SIG_LR(info, ctxt) = gp->sigpc; 76 SIG_LR(info, ctxt) = gp->sigpc;
77 // In case we are panicking from external C code 77 // In case we are panicking from external C code
78 SIG_R10(info, ctxt) = (uintptr)gp; 78 SIG_R10(info, ctxt) = (uintptr)gp;
79 » » SIG_R9(info, ctxt) = (uintptr)m; 79 » » SIG_R9(info, ctxt) = (uintptr)g->m;
80 SIG_PC(info, ctxt) = (uintptr)runtime·sigpanic; 80 SIG_PC(info, ctxt) = (uintptr)runtime·sigpanic;
81 return; 81 return;
82 } 82 }
83 83
84 if(SIG_CODE0(info, ctxt) == SI_USER || (t->flags & SigNotify)) 84 if(SIG_CODE0(info, ctxt) == SI_USER || (t->flags & SigNotify))
85 if(runtime·sigsend(sig)) 85 if(runtime·sigsend(sig))
86 return; 86 return;
87 if(t->flags & SigKill) 87 if(t->flags & SigKill)
88 runtime·exit(2); 88 runtime·exit(2);
89 if(!(t->flags & SigThrow)) 89 if(!(t->flags & SigThrow))
90 return; 90 return;
91 91
92 » m->throwing = 1; 92 » g->m->throwing = 1;
93 » m->caughtsig = gp; 93 » g->m->caughtsig = gp;
94 if(runtime·panicking) // traceback already printed 94 if(runtime·panicking) // traceback already printed
95 runtime·exit(2); 95 runtime·exit(2);
96 runtime·panicking = 1; 96 runtime·panicking = 1;
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_PC(info, ctxt)); 103 runtime·printf("PC=%x\n", SIG_PC(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_PC(info, ctxt), SIG_SP(info, ctxt), SIG_LR (info, ctxt), gp); 112 runtime·traceback(SIG_PC(info, ctxt), SIG_SP(info, ctxt), SIG_LR (info, ctxt), gp);
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 }
LEFTRIGHT

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