gdb(4): allow bulk write of registers

Add support for the remote 'G' packet. This is not widely used by gdb
when 'P' is supported, but is technically required by any remote gdb
stub implementation [1].

[1] https://sourceware.org/gdb/current/onlinedocs/gdb/Overview.html

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
NetApp PR:	44
Differential Revision:	https://reviews.freebsd.org/D27644
This commit is contained in:
Mitchell Horne 2020-12-23 14:37:05 -04:00
parent fd29833d9a
commit 3f3cc995a3

View File

@ -700,9 +700,23 @@ gdb_trap(int type, int code)
gdb_tx_end();
break;
}
case 'G': /* Write registers. */
gdb_tx_err(0);
case 'G': { /* Write registers. */
char *val;
bool success;
size_t r;
for (success = true, r = 0; r < GDB_NREGS; r++) {
val = gdb_rxp;
if (!gdb_rx_mem(val, gdb_cpu_regsz(r))) {
gdb_tx_err(EINVAL);
success = false;
break;
}
gdb_cpu_setreg(r, val);
}
if (success)
gdb_tx_ok();
break;
}
case 'H': { /* Set thread. */
intmax_t tid;
struct thread *thr;