Source file
src/runtime/os3_plan9.go
1
2
3
4
5 package runtime
6
7 import (
8 "internal/abi"
9 "internal/goarch"
10 "internal/stringslite"
11 "unsafe"
12 )
13
14
15
16
17 func sighandler(_ureg *ureg, note *byte, gp *g) int {
18 gsignal := getg()
19 mp := gsignal.m
20
21 var t sigTabT
22 var docrash bool
23 var sig int
24 var flags int
25 var level int32
26
27 c := &sigctxt{_ureg}
28 notestr := gostringnocopy(note)
29
30
31
32 if _ureg == nil || note == nil {
33 print("sighandler: ureg ", _ureg, " note ", note, "\n")
34 goto Throw
35 }
36
37
38 if len(notestr) > _ERRMAX-1 {
39 print("sighandler: note is longer than ERRMAX\n")
40 goto Throw
41 }
42 if isAbortPC(c.pc()) {
43
44 goto Throw
45 }
46
47
48
49 flags = _SigNotify
50 for sig, t = range sigtable {
51 if stringslite.HasPrefix(notestr, t.name) {
52 flags = t.flags
53 break
54 }
55 }
56 if flags&_SigPanic != 0 && gp.throwsplit {
57
58
59 flags = (flags &^ _SigPanic) | _SigThrow
60 }
61 if flags&_SigGoExit != 0 {
62 exits((*byte)(add(unsafe.Pointer(note), 9)))
63 }
64 if flags&_SigPanic != 0 {
65
66
67 memmove(unsafe.Pointer(mp.notesig), unsafe.Pointer(note), uintptr(len(notestr)+1))
68 gp.sig = uint32(sig)
69 gp.sigpc = c.pc()
70
71 pc := c.pc()
72 sp := c.sp()
73
74
75
76
77
78 if pc != 0 && !findfunc(pc).valid() && findfunc(*(*uintptr)(unsafe.Pointer(sp))).valid() {
79 pc = 0
80 }
81
82
83
84
85
86
87 if usesLR {
88 c.savelr(c.lr())
89 }
90
91
92
93
94
95 if pc != 0 {
96 if usesLR {
97 c.setlr(pc)
98 } else {
99 sp -= goarch.PtrSize
100 *(*uintptr)(unsafe.Pointer(sp)) = pc
101 c.setsp(sp)
102 }
103 }
104 if usesLR {
105 c.setpc(abi.FuncPCABI0(sigpanictramp))
106 } else {
107 c.setpc(abi.FuncPCABI0(sigpanic0))
108 }
109 return _NCONT
110 }
111 if flags&_SigNotify != 0 {
112 if ignoredNote(note) {
113 return _NCONT
114 }
115 if sendNote(note) {
116 return _NCONT
117 }
118 }
119 if flags&_SigKill != 0 {
120 goto Exit
121 }
122 if flags&_SigThrow == 0 {
123 return _NCONT
124 }
125 Throw:
126 mp.throwing = throwTypeRuntime
127 mp.caughtsig.set(gp)
128 startpanic_m()
129 print(notestr, "\n")
130 print("PC=", hex(c.pc()), "\n")
131 print("\n")
132 level, _, docrash = gotraceback()
133 if level > 0 {
134 goroutineheader(gp)
135 tracebacktrap(c.pc(), c.sp(), c.lr(), gp)
136 tracebackothers(gp)
137 print("\n")
138 dumpregs(_ureg)
139 }
140 if docrash {
141 crash()
142 }
143 Exit:
144 goexitsall(note)
145 exits(note)
146 return _NDFLT
147 }
148
149 func sigenable(sig uint32) {
150 }
151
152 func sigdisable(sig uint32) {
153 }
154
155 func sigignore(sig uint32) {
156 }
157
158 func setProcessCPUProfiler(hz int32) {
159 }
160
161 func setThreadCPUProfiler(hz int32) {
162
163 getg().m.profilehz = hz
164 }
165
166
167 type gsignalStack struct{}
168
View as plain text