Source file
src/runtime/signal_amd64.go
Documentation: runtime
1
2
3
4
5
6
7
8 package runtime
9
10 import (
11 "runtime/internal/sys"
12 "unsafe"
13 )
14
15 func dumpregs(c *sigctxt) {
16 print("rax ", hex(c.rax()), "\n")
17 print("rbx ", hex(c.rbx()), "\n")
18 print("rcx ", hex(c.rcx()), "\n")
19 print("rdx ", hex(c.rdx()), "\n")
20 print("rdi ", hex(c.rdi()), "\n")
21 print("rsi ", hex(c.rsi()), "\n")
22 print("rbp ", hex(c.rbp()), "\n")
23 print("rsp ", hex(c.rsp()), "\n")
24 print("r8 ", hex(c.r8()), "\n")
25 print("r9 ", hex(c.r9()), "\n")
26 print("r10 ", hex(c.r10()), "\n")
27 print("r11 ", hex(c.r11()), "\n")
28 print("r12 ", hex(c.r12()), "\n")
29 print("r13 ", hex(c.r13()), "\n")
30 print("r14 ", hex(c.r14()), "\n")
31 print("r15 ", hex(c.r15()), "\n")
32 print("rip ", hex(c.rip()), "\n")
33 print("rflags ", hex(c.rflags()), "\n")
34 print("cs ", hex(c.cs()), "\n")
35 print("fs ", hex(c.fs()), "\n")
36 print("gs ", hex(c.gs()), "\n")
37 }
38
39
40
41 func (c *sigctxt) sigpc() uintptr { return uintptr(c.rip()) }
42
43 func (c *sigctxt) sigsp() uintptr { return uintptr(c.rsp()) }
44 func (c *sigctxt) siglr() uintptr { return 0 }
45 func (c *sigctxt) fault() uintptr { return uintptr(c.sigaddr()) }
46
47
48 func (c *sigctxt) preparePanic(sig uint32, gp *g) {
49
50
51
52 if GOOS == "darwin" && sig == _SIGFPE && gp.sigcode0 == 0 {
53 pc := (*[4]byte)(unsafe.Pointer(gp.sigpc))
54 i := 0
55 if pc[i]&0xF0 == 0x40 {
56 i++
57 } else if pc[i] == 0x66 {
58 i++
59 }
60 if pc[i] == 0xF6 || pc[i] == 0xF7 {
61 gp.sigcode0 = _FPE_INTDIV
62 }
63 }
64
65 pc := uintptr(c.rip())
66 sp := uintptr(c.rsp())
67
68 if shouldPushSigpanic(gp, pc, *(*uintptr)(unsafe.Pointer(sp))) {
69 c.pushCall(funcPC(sigpanic), pc)
70 } else {
71
72 c.set_rip(uint64(funcPC(sigpanic)))
73 }
74 }
75
76 func (c *sigctxt) pushCall(targetPC, resumePC uintptr) {
77
78 sp := uintptr(c.rsp())
79 sp -= sys.PtrSize
80 *(*uintptr)(unsafe.Pointer(sp)) = resumePC
81 c.set_rsp(uint64(sp))
82 c.set_rip(uint64(targetPC))
83 }
84
View as plain text