Changeset View
Changeset View
Standalone View
Standalone View
sys/gdb/gdb_main.c
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
DATA_SET(gdb_dbgport_set, null_gdb_dbgport); | DATA_SET(gdb_dbgport_set, null_gdb_dbgport); | ||||
SET_DECLARE(gdb_dbgport_set, struct gdb_dbgport); | SET_DECLARE(gdb_dbgport_set, struct gdb_dbgport); | ||||
struct gdb_dbgport *gdb_cur = NULL; | struct gdb_dbgport *gdb_cur = NULL; | ||||
int gdb_listening = 0; | int gdb_listening = 0; | ||||
static unsigned char gdb_bindata[64]; | static unsigned char gdb_bindata[64]; | ||||
#ifdef DDB | |||||
bool gdb_return_to_ddb = false; | |||||
#endif | |||||
static int | static int | ||||
gdb_init(void) | gdb_init(void) | ||||
{ | { | ||||
struct gdb_dbgport *dp, **iter; | struct gdb_dbgport *dp, **iter; | ||||
int cur_pri, pri; | int cur_pri, pri; | ||||
gdb_cur = NULL; | gdb_cur = NULL; | ||||
cur_pri = -1; | cur_pri = -1; | ||||
▲ Show 20 Lines • Show All 493 Lines • ▼ Show 20 Lines | do_qXfer(void) | ||||
do_qXfer_threads_read(); | do_qXfer_threads_read(); | ||||
return; | return; | ||||
unrecognized: | unrecognized: | ||||
gdb_tx_empty(); | gdb_tx_empty(); | ||||
return; | return; | ||||
} | } | ||||
static void | |||||
gdb_handle_detach(void) | |||||
{ | |||||
kdb_cpu_clear_singlestep(); | |||||
gdb_listening = 0; | |||||
if (gdb_cur->gdb_dbfeatures & GDB_DBGP_FEAT_WANTTERM) | |||||
gdb_cur->gdb_term(); | |||||
#ifdef DDB | |||||
if (!gdb_return_to_ddb) | |||||
return; | |||||
gdb_return_to_ddb = false; | |||||
if (kdb_dbbe_select("ddb") != 0) | |||||
printf("The ddb backend could not be selected.\n"); | |||||
#endif | |||||
} | |||||
static int | static int | ||||
gdb_trap(int type, int code) | gdb_trap(int type, int code) | ||||
{ | { | ||||
jmp_buf jb; | jmp_buf jb; | ||||
struct thread *thr_iter; | struct thread *thr_iter; | ||||
void *prev_jb; | void *prev_jb; | ||||
uint32_t host_features; | uint32_t host_features; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | case 'C': { /* Continue with signal. */ | ||||
gdb_cpu_setreg(GDB_REG_PC, &pc); | gdb_cpu_setreg(GDB_REG_PC, &pc); | ||||
} | } | ||||
kdb_cpu_clear_singlestep(); | kdb_cpu_clear_singlestep(); | ||||
gdb_listening = 1; | gdb_listening = 1; | ||||
return (1); | return (1); | ||||
} | } | ||||
case 'D': { /* Detach */ | case 'D': { /* Detach */ | ||||
gdb_tx_ok(); | gdb_tx_ok(); | ||||
kdb_cpu_clear_singlestep(); | gdb_handle_detach(); | ||||
return (1); | return (1); | ||||
} | } | ||||
case 'g': { /* Read registers. */ | case 'g': { /* Read registers. */ | ||||
size_t r; | size_t r; | ||||
gdb_tx_begin(0); | gdb_tx_begin(0); | ||||
for (r = 0; r < GDB_NREGS; r++) | for (r = 0; r < GDB_NREGS; r++) | ||||
gdb_tx_reg(r); | gdb_tx_reg(r); | ||||
gdb_tx_end(); | gdb_tx_end(); | ||||
Show All 20 Lines | case 'H': { /* Set thread. */ | ||||
break; | break; | ||||
} | } | ||||
kdb_thr_select(thr); | kdb_thr_select(thr); | ||||
} | } | ||||
gdb_tx_ok(); | gdb_tx_ok(); | ||||
break; | break; | ||||
} | } | ||||
case 'k': /* Kill request. */ | case 'k': /* Kill request. */ | ||||
kdb_cpu_clear_singlestep(); | gdb_handle_detach(); | ||||
gdb_listening = 1; | |||||
return (1); | return (1); | ||||
case 'm': { /* Read memory. */ | case 'm': { /* Read memory. */ | ||||
uintmax_t addr, size; | uintmax_t addr, size; | ||||
if (gdb_rx_varhex(&addr) || gdb_rx_char() != ',' || | if (gdb_rx_varhex(&addr) || gdb_rx_char() != ',' || | ||||
gdb_rx_varhex(&size)) { | gdb_rx_varhex(&size)) { | ||||
gdb_tx_err(EINVAL); | gdb_tx_err(EINVAL); | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |