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