5 #define SIZEOF_I386_REGS 32
6 #define SIZEOF_I386_FLAGS 4
8 /* When invoked, the stack contains: eflags, cs, eip, signo. */
9 #define IH_OFFSET_GDB_REGS ( 0 )
10 #define IH_OFFSET_GDB_EIP ( IH_OFFSET_GDB_REGS + SIZEOF_I386_REGS )
11 #define IH_OFFSET_GDB_EFLAGS ( IH_OFFSET_GDB_EIP + 4 )
12 #define IH_OFFSET_GDB_SEG_REGS ( IH_OFFSET_GDB_EFLAGS + SIZEOF_I386_FLAGS )
13 #define IH_OFFSET_GDB_END ( IH_OFFSET_GDB_SEG_REGS + 6 * 4 )
14 #define IH_OFFSET_OLD_EIP ( IH_OFFSET_GDB_END )
15 #define IH_OFFSET_OLD_CS ( IH_OFFSET_OLD_EIP + 4 )
16 #define IH_OFFSET_OLD_EFLAGS ( IH_OFFSET_OLD_CS + 4 )
17 #define IH_OFFSET_END ( IH_OFFSET_OLD_EFLAGS + 4 )
19 /* We also access the stack whilst still storing or restoring
20 * the register snapshot. Since ESP is in flux, we need
23 #define IH_OFFSET_FLUX_OLD_CS ( IH_OFFSET_OLD_CS - 44 )
24 #define IH_OFFSET_FLUX_OLD_EFLAGS ( IH_OFFSET_OLD_EFLAGS - 40 )
25 #define IH_OFFSET_FLUX_OLD_EIP ( IH_OFFSET_OLD_EIP - 36 )
26 #define IH_OFFSET_FLUX_END ( IH_OFFSET_END - 20 )
30 /* Store CPU state in GDB register snapshot */
42 pushw IH_OFFSET_FLUX_OLD_CS + 2(%esp)
43 pushl IH_OFFSET_FLUX_OLD_EFLAGS(%esp)
44 pushl IH_OFFSET_FLUX_OLD_EIP(%esp)
48 leal IH_OFFSET_FLUX_END(%esp), %edi
49 pushl %edi /* old ESP */
55 /* Call GDB stub exception handler */
60 /* Restore CPU state from GDB register snapshot */
65 addl $4, %esp /* Changing ESP currently not supported */
69 popl IH_OFFSET_FLUX_OLD_EIP(%esp)
70 popl IH_OFFSET_FLUX_OLD_EFLAGS(%esp)
71 popl IH_OFFSET_FLUX_OLD_CS(%esp)