Brad Fitzpatrick | 5194744 | 2016-03-01 22:57:46 +0000 | [diff] [blame] | 1 | // Copyright 2013 The Go Authors. All rights reserved. |
Joel Sing | 0d76887 | 2014-11-22 22:09:11 +1100 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package runtime |
| 6 | |
| 7 | import "unsafe" |
| 8 | |
| 9 | type sigctxt struct { |
| 10 | info *siginfo |
| 11 | ctxt unsafe.Pointer |
| 12 | } |
| 13 | |
Ian Lance Taylor | d03e8b2 | 2016-10-04 07:11:55 -0700 | [diff] [blame] | 14 | //go:nosplit |
| 15 | //go:nowritebarrierrec |
Joel Sing | 0d76887 | 2014-11-22 22:09:11 +1100 | [diff] [blame] | 16 | func (c *sigctxt) regs() *mcontextt { return &(*ucontextt)(c.ctxt).uc_mcontext } |
Ian Lance Taylor | d03e8b2 | 2016-10-04 07:11:55 -0700 | [diff] [blame] | 17 | |
| 18 | func (c *sigctxt) eax() uint32 { return c.regs().__gregs[_REG_EAX] } |
| 19 | func (c *sigctxt) ebx() uint32 { return c.regs().__gregs[_REG_EBX] } |
| 20 | func (c *sigctxt) ecx() uint32 { return c.regs().__gregs[_REG_ECX] } |
| 21 | func (c *sigctxt) edx() uint32 { return c.regs().__gregs[_REG_EDX] } |
| 22 | func (c *sigctxt) edi() uint32 { return c.regs().__gregs[_REG_EDI] } |
| 23 | func (c *sigctxt) esi() uint32 { return c.regs().__gregs[_REG_ESI] } |
| 24 | func (c *sigctxt) ebp() uint32 { return c.regs().__gregs[_REG_EBP] } |
| 25 | func (c *sigctxt) esp() uint32 { return c.regs().__gregs[_REG_UESP] } |
| 26 | |
| 27 | //go:nosplit |
| 28 | //go:nowritebarrierrec |
| 29 | func (c *sigctxt) eip() uint32 { return c.regs().__gregs[_REG_EIP] } |
| 30 | |
| 31 | func (c *sigctxt) eflags() uint32 { return c.regs().__gregs[_REG_EFL] } |
| 32 | func (c *sigctxt) cs() uint32 { return c.regs().__gregs[_REG_CS] } |
| 33 | func (c *sigctxt) fs() uint32 { return c.regs().__gregs[_REG_FS] } |
| 34 | func (c *sigctxt) gs() uint32 { return c.regs().__gregs[_REG_GS] } |
| 35 | func (c *sigctxt) sigcode() uint32 { return uint32(c.info._code) } |
Joel Sing | 0d76887 | 2014-11-22 22:09:11 +1100 | [diff] [blame] | 36 | func (c *sigctxt) sigaddr() uint32 { |
Matthew Dempsky | a03bdc3 | 2016-02-29 15:01:00 -0800 | [diff] [blame] | 37 | return *(*uint32)(unsafe.Pointer(&c.info._reason[0])) |
Joel Sing | 0d76887 | 2014-11-22 22:09:11 +1100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | func (c *sigctxt) set_eip(x uint32) { c.regs().__gregs[_REG_EIP] = x } |
| 41 | func (c *sigctxt) set_esp(x uint32) { c.regs().__gregs[_REG_UESP] = x } |
| 42 | func (c *sigctxt) set_sigcode(x uint32) { c.info._code = int32(x) } |
| 43 | func (c *sigctxt) set_sigaddr(x uint32) { |
| 44 | *(*uint32)(unsafe.Pointer(&c.info._reason[0])) = x |
| 45 | } |