Home | History | Annotate | Download | only in runtime
      1 package runtime
      2 
      3 const _PAGESIZE = 0x1000
      4 
      5 type ureg struct {
      6 	di    uint32 /* general registers */
      7 	si    uint32 /* ... */
      8 	bp    uint32 /* ... */
      9 	nsp   uint32
     10 	bx    uint32 /* ... */
     11 	dx    uint32 /* ... */
     12 	cx    uint32 /* ... */
     13 	ax    uint32 /* ... */
     14 	gs    uint32 /* data segments */
     15 	fs    uint32 /* ... */
     16 	es    uint32 /* ... */
     17 	ds    uint32 /* ... */
     18 	trap  uint32 /* trap _type */
     19 	ecode uint32 /* error code (or zero) */
     20 	pc    uint32 /* pc */
     21 	cs    uint32 /* old context */
     22 	flags uint32 /* old flags */
     23 	sp    uint32
     24 	ss    uint32 /* old stack segment */
     25 }
     26 
     27 type sigctxt struct {
     28 	u *ureg
     29 }
     30 
     31 func (c *sigctxt) pc() uintptr { return uintptr(c.u.pc) }
     32 func (c *sigctxt) sp() uintptr { return uintptr(c.u.sp) }
     33 
     34 func (c *sigctxt) setpc(x uintptr) { c.u.pc = uint32(x) }
     35 func (c *sigctxt) setsp(x uintptr) { c.u.sp = uint32(x) }
     36 
     37 func dumpregs(u *ureg) {
     38 	print("ax    ", hex(u.ax), "\n")
     39 	print("bx    ", hex(u.bx), "\n")
     40 	print("cx    ", hex(u.cx), "\n")
     41 	print("dx    ", hex(u.dx), "\n")
     42 	print("di    ", hex(u.di), "\n")
     43 	print("si    ", hex(u.si), "\n")
     44 	print("bp    ", hex(u.bp), "\n")
     45 	print("sp    ", hex(u.sp), "\n")
     46 	print("pc    ", hex(u.pc), "\n")
     47 	print("flags ", hex(u.flags), "\n")
     48 	print("cs    ", hex(u.cs), "\n")
     49 	print("fs    ", hex(u.fs), "\n")
     50 	print("gs    ", hex(u.gs), "\n")
     51 }
     52