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>
This commit is contained in:
parent
da92e2360e
commit
287ca120bd
41
gdbstub.c
41
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':
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user