aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Doron <arilou@gmail.com>2019-05-29 09:41:40 +0300
committerAlex Bennée <alex.bennee@linaro.org>2019-06-12 17:53:23 +0100
commit287ca120bdf918b324b1fc374363ed400f143806 (patch)
treefb5925f4b65a4bb4ca6841bc1944e0d89a149fd2
parentda92e2360e42ef8fd9dadcd2dc2a3b846d883800 (diff)
gdbstub: Implement write all registers (G pkt) with new infra
Signed-off-by: Jon Doron <arilou@gmail.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20190529064148.19856-13-arilou@gmail.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
-rw-r--r--gdbstub.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/gdbstub.c b/gdbstub.c
index 291349854a..bfa4177d45 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1755,6 +1755,29 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx)
put_packet(gdb_ctx->s, gdb_ctx->str_buf);
}
+static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx)
+{
+ target_ulong addr, len;
+ uint8_t *registers;
+ int reg_size;
+
+ if (!gdb_ctx->num_params) {
+ return;
+ }
+
+ cpu_synchronize_state(gdb_ctx->s->g_cpu);
+ registers = gdb_ctx->mem_buf;
+ len = strlen(gdb_ctx->params[0].data) / 2;
+ hextomem(registers, gdb_ctx->params[0].data, len);
+ for (addr = 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs && len > 0;
+ addr++) {
+ reg_size = gdb_write_register(gdb_ctx->s->g_cpu, registers, addr);
+ len -= reg_size;
+ registers += reg_size;
+ }
+ put_packet(gdb_ctx->s, "OK");
+}
+
static int gdb_handle_packet(GDBState *s, const char *line_buf)
{
CPUState *cpu;
@@ -1766,7 +1789,6 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
uint8_t mem_buf[MAX_PACKET_LENGTH];
char buf[sizeof(mem_buf) + 1 /* trailing NUL */];
char thread_id[16];
- uint8_t *registers;
target_ulong addr, len;
const GdbCmdParseEntry *cmd_parser = NULL;
@@ -1932,16 +1954,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
put_packet(s, buf);
break;
case 'G':
- cpu_synchronize_state(s->g_cpu);
- registers = mem_buf;
- len = strlen(p) / 2;
- hextomem((uint8_t *)registers, p, len);
- for (addr = 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; addr++) {
- reg_size = gdb_write_register(s->g_cpu, registers, addr);
- len -= reg_size;
- registers += reg_size;
+ {
+ static const GdbCmdParseEntry write_all_regs_cmd_desc = {
+ .handler = handle_write_all_regs,
+ .cmd = "G",
+ .cmd_startswith = 1,
+ .schema = "s0"
+ };
+ cmd_parser = &write_all_regs_cmd_desc;
}
- put_packet(s, "OK");
break;
case 'm':
{