Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/gdb_machdep.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <machine/psl.h> | #include <machine/psl.h> | ||||
#include <machine/reg.h> | #include <machine/reg.h> | ||||
#include <machine/specialreg.h> | #include <machine/specialreg.h> | ||||
#include <machine/trap.h> | #include <machine/trap.h> | ||||
#include <machine/frame.h> | #include <machine/frame.h> | ||||
#include <machine/endian.h> | #include <machine/endian.h> | ||||
#include <gdb/gdb.h> | #include <gdb/gdb.h> | ||||
#include <gdb/gdb_int.h> | |||||
void * | void * | ||||
gdb_cpu_getreg(int regnum, size_t *regsz) | gdb_cpu_getreg(int regnum, size_t *regsz) | ||||
{ | { | ||||
static uint32_t _kcodesel = GSEL(GCODE_SEL, SEL_KPL); | static uint32_t _kcodesel = GSEL(GCODE_SEL, SEL_KPL); | ||||
static uint32_t _kdatasel = GSEL(GDATA_SEL, SEL_KPL); | static uint32_t _kdatasel = GSEL(GDATA_SEL, SEL_KPL); | ||||
*regsz = gdb_cpu_regsz(regnum); | *regsz = gdb_cpu_regsz(regnum); | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | gdb_cpu_signal(int type, int code) | ||||
case T_NMI: return (SIGTRAP); | case T_NMI: return (SIGTRAP); | ||||
case T_FPOPFLT: return (SIGILL); | case T_FPOPFLT: return (SIGILL); | ||||
case T_TSSFLT: return (SIGSEGV); | case T_TSSFLT: return (SIGSEGV); | ||||
case T_SEGNPFLT: return (SIGSEGV); | case T_SEGNPFLT: return (SIGSEGV); | ||||
case T_STKFLT: return (SIGSEGV); | case T_STKFLT: return (SIGSEGV); | ||||
case T_XMMFLT: return (SIGFPE); | case T_XMMFLT: return (SIGFPE); | ||||
} | } | ||||
return (SIGEMT); | return (SIGEMT); | ||||
} | |||||
void | |||||
gdb_cpu_stop_reason(int type, int code) | |||||
{ | |||||
uintmax_t val; | |||||
val = 0; | |||||
if (type == T_TRCTRAP) { | |||||
/* NB: 'code' contains the value of dr6 at the trap. */ | |||||
if ((code & DBREG_DR6_B(0)) != 0) { | |||||
val = rdr0(); | |||||
} | |||||
if ((code & DBREG_DR6_B(1)) != 0) { | |||||
val = rdr1(); | |||||
} | |||||
if ((code & DBREG_DR6_B(2)) != 0) { | |||||
val = rdr2(); | |||||
} | |||||
if ((code & DBREG_DR6_B(3)) != 0) { | |||||
val = rdr3(); | |||||
} | |||||
/* | |||||
* TODO: validate the bits in DR7 to differentiate between a | |||||
* watchpoint trap and a hardware breakpoint trap (currently | |||||
* unsupported). | |||||
*/ | |||||
if (val != 0) { | |||||
gdb_tx_str("watch:"); | |||||
gdb_tx_varhex(val); | |||||
gdb_tx_char(';'); | |||||
} | |||||
} | |||||
} | } | ||||
void * | void * | ||||
gdb_begin_write(void) | gdb_begin_write(void) | ||||
{ | { | ||||
return (disable_wp() ? &gdb_begin_write : NULL); | return (disable_wp() ? &gdb_begin_write : NULL); | ||||
} | } | ||||
void | void | ||||
gdb_end_write(void *arg) | gdb_end_write(void *arg) | ||||
{ | { | ||||
restore_wp(arg != NULL); | restore_wp(arg != NULL); | ||||
} | } |