gdbmach.h File Reference

GDB architecture specifics. More...

#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef unsigned long gdbreg_t

Enumerations

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 )
}
enum  {
  GDBMACH_BPMEM, GDBMACH_BPHW, GDBMACH_WATCH, GDBMACH_RWATCH,
  GDBMACH_AWATCH
}

Functions

static void gdbmach_set_pc (gdbreg_t *regs, gdbreg_t pc)
static void gdbmach_set_single_step (gdbreg_t *regs, int step)
static void gdbmach_breakpoint (void)
int gdbmach_set_breakpoint (int type, unsigned long addr, size_t len, int enable)


Detailed Description

GDB architecture specifics.

This file declares functions for manipulating the machine state and debugging context.

Definition in file gdbmach.h.


Typedef Documentation

typedef unsigned long gdbreg_t

Definition at line 15 of file gdbmach.h.


Enumeration Type Documentation

anonymous enum

Enumerator:
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 

Definition at line 19 of file gdbmach.h.

00019      {
00020         GDBMACH_EAX,
00021         GDBMACH_ECX,
00022         GDBMACH_EDX,
00023         GDBMACH_EBX,
00024         GDBMACH_ESP,
00025         GDBMACH_EBP,
00026         GDBMACH_ESI,
00027         GDBMACH_EDI,
00028         GDBMACH_EIP,
00029         GDBMACH_EFLAGS,
00030         GDBMACH_CS,
00031         GDBMACH_SS,
00032         GDBMACH_DS,
00033         GDBMACH_ES,
00034         GDBMACH_FS,
00035         GDBMACH_GS,
00036         GDBMACH_NREGS,
00037         GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t )
00038 };

anonymous enum

Enumerator:
GDBMACH_BPMEM 
GDBMACH_BPHW 
GDBMACH_WATCH 
GDBMACH_RWATCH 
GDBMACH_AWATCH 

Definition at line 41 of file gdbmach.h.

00041      {
00042         GDBMACH_BPMEM,
00043         GDBMACH_BPHW,
00044         GDBMACH_WATCH,
00045         GDBMACH_RWATCH,
00046         GDBMACH_AWATCH,
00047 };


Function Documentation

static void gdbmach_set_pc ( gdbreg_t regs,
gdbreg_t  pc 
) [inline, static]

Definition at line 49 of file gdbmach.h.

References GDBMACH_EIP.

Referenced by gdbstub_continue().

00049                                                                   {
00050         regs [ GDBMACH_EIP ] = pc;
00051 }

static void gdbmach_set_single_step ( gdbreg_t regs,
int  step 
) [inline, static]

Definition at line 53 of file gdbmach.h.

References GDBMACH_EFLAGS.

Referenced by gdbstub_continue().

00053                                                                         {
00054         regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */
00055         regs [ GDBMACH_EFLAGS ] |= ( step << 8 );
00056 }

static void gdbmach_breakpoint ( void   )  [inline, static]

Definition at line 58 of file gdbmach.h.

References __asm__().

Referenced by gdbstub_start().

00058                                                {
00059         __asm__ __volatile__ ( "int $3\n" );
00060 }

int gdbmach_set_breakpoint ( int  type,
unsigned long  addr,
size_t  len,
int  enable 
)

Definition at line 95 of file gdbmach.c.

References hwbp::addr, hwbp::enabled, GDBMACH_AWATCH, gdbmach_commit_hwbp(), gdbmach_find_hwbp(), GDBMACH_WATCH, hwbp::len, hwbp::type, and virt_offset.

Referenced by gdbstub_breakpoint().

00095                                                                                     {
00096         struct hwbp *bp;
00097         
00098         /* Check and convert breakpoint type to x86 type */
00099         switch ( type ) {
00100                 case GDBMACH_WATCH:
00101                         type = 0x1;
00102                         break;
00103                 case GDBMACH_AWATCH:
00104                         type = 0x3;
00105                         break;
00106                 default:
00107                         return 0; /* unsupported breakpoint type */
00108         }
00109 
00110         /* Only lengths 1, 2, and 4 are supported */
00111         if ( len != 2 && len != 4 ) {
00112                 len = 1;
00113         }
00114         len--; /* convert to x86 breakpoint length bit pattern */
00115 
00116         /* Calculate linear address by adding segment base */
00117         addr += virt_offset;
00118 
00119         /* Set up the breakpoint */
00120         bp = gdbmach_find_hwbp ( type, addr, len );
00121         if ( !bp ) {
00122                 return 0; /* ran out of hardware breakpoints */
00123         }
00124         bp->type = type;
00125         bp->addr = addr;
00126         bp->len = len;
00127         bp->enabled = enable;
00128         gdbmach_commit_hwbp ( bp );
00129         return 1;
00130 }


Generated on Tue Apr 6 20:01:12 2010 for gPXE by  doxygen 1.5.7.1