diff options
author | Mitchell Horne <mhorne@FreeBSD.org> | 2020-12-23 18:37:05 +0000 |
---|---|---|
committer | Mitchell Horne <mhorne@FreeBSD.org> | 2020-12-23 18:37:05 +0000 |
commit | 3f3cc995a35a3e9136204a98af0af5808c11047f (patch) | |
tree | 96ee26d654db69fe15bf1fee166f7d3949ee5060 | |
parent | fd29833d9a7d8355ce21743ed8c706b72ba03363 (diff) | |
download | src-3f3cc995a35a3e9136204a98af0af5808c11047f.tar.gz src-3f3cc995a35a3e9136204a98af0af5808c11047f.zip |
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
-rw-r--r-- | sys/gdb/gdb_main.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/gdb/gdb_main.c b/sys/gdb/gdb_main.c index 588a97c56a40..6e0c9f21f947 100644 --- a/sys/gdb/gdb_main.c +++ b/sys/gdb/gdb_main.c @@ -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; |