Changeset View
Changeset View
Standalone View
Standalone View
head/sys/gdb/gdb_main.c
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
KDB_BACKEND(gdb, gdb_init, NULL, NULL, gdb_trap); | KDB_BACKEND(gdb, gdb_init, NULL, NULL, gdb_trap); | ||||
static struct gdb_dbgport null_gdb_dbgport; | static struct gdb_dbgport null_gdb_dbgport; | ||||
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; | ||||
bool gdb_ackmode = true; | |||||
static unsigned char gdb_bindata[64]; | static unsigned char gdb_bindata[64]; | ||||
#ifdef DDB | #ifdef DDB | ||||
bool gdb_return_to_ddb = false; | bool gdb_return_to_ddb = false; | ||||
#endif | #endif | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | gdb_do_qsupported(uint32_t *feat) | ||||
* We don't buffer framing bytes, but we do need to retain a byte for a | * We don't buffer framing bytes, but we do need to retain a byte for a | ||||
* trailing nul. | * trailing nul. | ||||
*/ | */ | ||||
gdb_tx_varhex(GDB_BUFSZ + strlen("$#nn") - 1); | gdb_tx_varhex(GDB_BUFSZ + strlen("$#nn") - 1); | ||||
gdb_tx_str(";qXfer:threads:read+"); | gdb_tx_str(";qXfer:threads:read+"); | ||||
/* | /* | ||||
* If the debugport is a reliable transport, request No Ack mode from | |||||
* the server. The server may or may not choose to enter No Ack mode. | |||||
* https://sourceware.org/gdb/onlinedocs/gdb/Packet-Acknowledgment.html | |||||
*/ | |||||
if (gdb_cur->gdb_dbfeatures & GDB_DBGP_FEAT_RELIABLE) | |||||
gdb_tx_str(";QStartNoAckMode+"); | |||||
/* | |||||
* Future consideration: | * Future consideration: | ||||
* - vCont | * - vCont | ||||
* - multiprocess | * - multiprocess | ||||
*/ | */ | ||||
gdb_tx_end(); | gdb_tx_end(); | ||||
return; | return; | ||||
error: | error: | ||||
▲ Show 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | gdb_trap(int type, int code) | ||||
if (setjmp(jb) != 0) { | if (setjmp(jb) != 0) { | ||||
printf("%s bailing, hopefully back to ddb!\n", __func__); | printf("%s bailing, hopefully back to ddb!\n", __func__); | ||||
gdb_listening = 0; | gdb_listening = 0; | ||||
(void)kdb_jmpbuf(prev_jb); | (void)kdb_jmpbuf(prev_jb); | ||||
return (1); | return (1); | ||||
} | } | ||||
gdb_listening = 0; | gdb_listening = 0; | ||||
gdb_ackmode = true; | |||||
/* | /* | ||||
* Send a T packet. We currently do not support watchpoints (the | * Send a T packet. We currently do not support watchpoints (the | ||||
* awatch, rwatch or watch elements). | * awatch, rwatch or watch elements). | ||||
*/ | */ | ||||
gdb_tx_begin('T'); | gdb_tx_begin('T'); | ||||
gdb_tx_hex(gdb_cpu_signal(type, code), 2); | gdb_tx_hex(gdb_cpu_signal(type, code), 2); | ||||
gdb_tx_varhex(GDB_REG_PC); | gdb_tx_varhex(GDB_REG_PC); | ||||
gdb_tx_char(':'); | gdb_tx_char(':'); | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | case 'q': /* General query. */ | ||||
gdb_do_threadinfo(&thr_iter); | gdb_do_threadinfo(&thr_iter); | ||||
} else if (gdb_rx_equal("sThreadInfo")) { | } else if (gdb_rx_equal("sThreadInfo")) { | ||||
gdb_do_threadinfo(&thr_iter); | gdb_do_threadinfo(&thr_iter); | ||||
} else if (gdb_rx_equal("Xfer:")) { | } else if (gdb_rx_equal("Xfer:")) { | ||||
do_qXfer(); | do_qXfer(); | ||||
} else if (gdb_rx_equal("Search:memory:")) { | } else if (gdb_rx_equal("Search:memory:")) { | ||||
gdb_do_mem_search(); | gdb_do_mem_search(); | ||||
} else if (!gdb_cpu_query()) | } else if (!gdb_cpu_query()) | ||||
gdb_tx_empty(); | |||||
break; | |||||
case 'Q': | |||||
if (gdb_rx_equal("StartNoAckMode")) { | |||||
if ((gdb_cur->gdb_dbfeatures & | |||||
GDB_DBGP_FEAT_RELIABLE) == 0) { | |||||
/* | |||||
* Shouldn't happen if we didn't | |||||
* advertise support. Reject. | |||||
*/ | |||||
gdb_tx_empty(); | |||||
break; | |||||
} | |||||
gdb_ackmode = false; | |||||
gdb_tx_ok(); | |||||
} else | |||||
gdb_tx_empty(); | gdb_tx_empty(); | ||||
break; | break; | ||||
case 's': { /* Step. */ | case 's': { /* Step. */ | ||||
uintmax_t addr; | uintmax_t addr; | ||||
register_t pc; | register_t pc; | ||||
if (!gdb_rx_varhex(&addr)) { | if (!gdb_rx_varhex(&addr)) { | ||||
pc = addr; | pc = addr; | ||||
gdb_cpu_setreg(GDB_REG_PC, &pc); | gdb_cpu_setreg(GDB_REG_PC, &pc); | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |