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