blob: 845a5752684caa7396464229647d3d4750b481f6 [file] [log] [blame]
Brad Fitzpatrick51947442016-03-01 22:57:46 +00001// Copyright 2013 The Go Authors. All rights reserved.
Joel Sing0d768872014-11-22 22:09:11 +11002// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package runtime
6
7import "unsafe"
8
9type sigctxt struct {
10 info *siginfo
11 ctxt unsafe.Pointer
12}
13
Ian Lance Taylord03e8b22016-10-04 07:11:55 -070014//go:nosplit
15//go:nowritebarrierrec
Joel Sing0d768872014-11-22 22:09:11 +110016func (c *sigctxt) regs() *mcontextt { return &(*ucontextt)(c.ctxt).uc_mcontext }
Ian Lance Taylord03e8b22016-10-04 07:11:55 -070017
18func (c *sigctxt) eax() uint32 { return c.regs().__gregs[_REG_EAX] }
19func (c *sigctxt) ebx() uint32 { return c.regs().__gregs[_REG_EBX] }
20func (c *sigctxt) ecx() uint32 { return c.regs().__gregs[_REG_ECX] }
21func (c *sigctxt) edx() uint32 { return c.regs().__gregs[_REG_EDX] }
22func (c *sigctxt) edi() uint32 { return c.regs().__gregs[_REG_EDI] }
23func (c *sigctxt) esi() uint32 { return c.regs().__gregs[_REG_ESI] }
24func (c *sigctxt) ebp() uint32 { return c.regs().__gregs[_REG_EBP] }
25func (c *sigctxt) esp() uint32 { return c.regs().__gregs[_REG_UESP] }
26
27//go:nosplit
28//go:nowritebarrierrec
29func (c *sigctxt) eip() uint32 { return c.regs().__gregs[_REG_EIP] }
30
31func (c *sigctxt) eflags() uint32 { return c.regs().__gregs[_REG_EFL] }
32func (c *sigctxt) cs() uint32 { return c.regs().__gregs[_REG_CS] }
33func (c *sigctxt) fs() uint32 { return c.regs().__gregs[_REG_FS] }
34func (c *sigctxt) gs() uint32 { return c.regs().__gregs[_REG_GS] }
35func (c *sigctxt) sigcode() uint32 { return uint32(c.info._code) }
Joel Sing0d768872014-11-22 22:09:11 +110036func (c *sigctxt) sigaddr() uint32 {
Matthew Dempskya03bdc32016-02-29 15:01:00 -080037 return *(*uint32)(unsafe.Pointer(&c.info._reason[0]))
Joel Sing0d768872014-11-22 22:09:11 +110038}
39
40func (c *sigctxt) set_eip(x uint32) { c.regs().__gregs[_REG_EIP] = x }
41func (c *sigctxt) set_esp(x uint32) { c.regs().__gregs[_REG_UESP] = x }
42func (c *sigctxt) set_sigcode(x uint32) { c.info._code = int32(x) }
43func (c *sigctxt) set_sigaddr(x uint32) {
44 *(*uint32)(unsafe.Pointer(&c.info._reason[0])) = x
45}