Home | History | Annotate | Download | only in runtime
      1 package runtime
      2 
      3 const _PAGESIZE = 0x1000
      4 
      5 type ureg struct {
      6 	ax  uint64
      7 	bx  uint64
      8 	cx  uint64
      9 	dx  uint64
     10 	si  uint64
     11 	di  uint64
     12 	bp  uint64
     13 	r8  uint64
     14 	r9  uint64
     15 	r10 uint64
     16 	r11 uint64
     17 	r12 uint64
     18 	r13 uint64
     19 	r14 uint64
     20 	r15 uint64
     21 
     22 	ds uint16
     23 	es uint16
     24 	fs uint16
     25 	gs uint16
     26 
     27 	_type uint64
     28 	error uint64 /* error code (or zero) */
     29 	ip    uint64 /* pc */
     30 	cs    uint64 /* old context */
     31 	flags uint64 /* old flags */
     32 	sp    uint64 /* sp */
     33 	ss    uint64 /* old stack segment */
     34 }
     35 
     36 type sigctxt struct {
     37 	u *ureg
     38 }
     39 
     40 func (c *sigctxt) pc() uintptr { return uintptr(c.u.ip) }
     41 func (c *sigctxt) sp() uintptr { return uintptr(c.u.sp) }
     42 
     43 func (c *sigctxt) setpc(x uintptr) { c.u.ip = uint64(x) }
     44 func (c *sigctxt) setsp(x uintptr) { c.u.sp = uint64(x) }
     45 
     46 func dumpregs(u *ureg) {
     47 	print("ax    ", hex(u.ax), "\n")
     48 	print("bx    ", hex(u.bx), "\n")
     49 	print("cx    ", hex(u.cx), "\n")
     50 	print("dx    ", hex(u.dx), "\n")
     51 	print("di    ", hex(u.di), "\n")
     52 	print("si    ", hex(u.si), "\n")
     53 	print("bp    ", hex(u.bp), "\n")
     54 	print("sp    ", hex(u.sp), "\n")
     55 	print("r8    ", hex(u.r8), "\n")
     56 	print("r9    ", hex(u.r9), "\n")
     57 	print("r10   ", hex(u.r10), "\n")
     58 	print("r11   ", hex(u.r11), "\n")
     59 	print("r12   ", hex(u.r12), "\n")
     60 	print("r13   ", hex(u.r13), "\n")
     61 	print("r14   ", hex(u.r14), "\n")
     62 	print("r15   ", hex(u.r15), "\n")
     63 	print("ip    ", hex(u.ip), "\n")
     64 	print("flags ", hex(u.flags), "\n")
     65 	print("cs    ", hex(u.cs), "\n")
     66 	print("fs    ", hex(u.fs), "\n")
     67 	print("gs    ", hex(u.gs), "\n")
     68 }
     69