diff options
| author | Stefan Hajnoczi | 2008-06-04 22:09:59 +0200 |
|---|---|---|
| committer | Michael Brown | 2008-06-05 01:45:50 +0200 |
| commit | 04bc50f0253da1a8fe29ed029ee2134126b664db (patch) | |
| tree | 06d3945d6c4166f06c1c9f44db3737ee8b3c8ca2 /src/arch/i386/include/gdbmach.h | |
| parent | [Serial] Split serial console from serial driver (diff) | |
| download | ipxe-04bc50f0253da1a8fe29ed029ee2134126b664db.tar.gz ipxe-04bc50f0253da1a8fe29ed029ee2134126b664db.tar.xz ipxe-04bc50f0253da1a8fe29ed029ee2134126b664db.zip | |
[GDB] Add GDB stub for remote debugging
See http://etherboot.org/wiki/dev/gdbstub for documentation.
Diffstat (limited to 'src/arch/i386/include/gdbmach.h')
| -rw-r--r-- | src/arch/i386/include/gdbmach.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/arch/i386/include/gdbmach.h b/src/arch/i386/include/gdbmach.h new file mode 100644 index 000000000..9f6dc8f02 --- /dev/null +++ b/src/arch/i386/include/gdbmach.h @@ -0,0 +1,51 @@ +#ifndef GDBMACH_H +#define GDBMACH_H + +/** @file + * + * GDB architecture specifics + * + * This file declares functions for manipulating the machine state and + * debugging context. + * + */ + +typedef uint32_t gdbreg_t; + +/* The register snapshot, this must be in sync with interrupt handler and the + * GDB protocol. */ +enum { + GDBMACH_EAX, + GDBMACH_ECX, + GDBMACH_EDX, + GDBMACH_EBX, + GDBMACH_ESP, + GDBMACH_EBP, + GDBMACH_ESI, + GDBMACH_EDI, + GDBMACH_EIP, + GDBMACH_EFLAGS, + GDBMACH_CS, + GDBMACH_SS, + GDBMACH_DS, + GDBMACH_ES, + GDBMACH_FS, + GDBMACH_GS, + GDBMACH_NREGS, + GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t ) +}; + +static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) { + regs [ GDBMACH_EIP ] = pc; +} + +static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) { + regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */ + regs [ GDBMACH_EFLAGS ] |= ( step << 8 ); +} + +static inline void gdbmach_breakpoint ( void ) { + __asm__ __volatile__ ( "int $3\n" ); +} + +#endif /* GDBMACH_H */ |
