gdbstub: don't use target_ulong while handling registers
This is a hangover from the original code. addr is misleading as it is only really a register id. While len will never exceed MAX_PACKET_LENGTH I've used size_t as that is what strlen returns. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230302190846.2593720-20-alex.bennee@linaro.org> Message-Id: <20230303025805.625589-20-richard.henderson@linaro.org>
This commit is contained in:
parent
b428ad1234
commit
379b42e8b7
@ -1193,7 +1193,8 @@ static void handle_read_mem(GArray *params, void *user_ctx)
|
||||
|
||||
static void handle_write_all_regs(GArray *params, void *user_ctx)
|
||||
{
|
||||
target_ulong addr, len;
|
||||
int reg_id;
|
||||
size_t len;
|
||||
uint8_t *registers;
|
||||
int reg_size;
|
||||
|
||||
@ -1205,9 +1206,10 @@ static void handle_write_all_regs(GArray *params, void *user_ctx)
|
||||
len = strlen(get_param(params, 0)->data) / 2;
|
||||
gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len);
|
||||
registers = gdbserver_state.mem_buf->data;
|
||||
for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0;
|
||||
addr++) {
|
||||
reg_size = gdb_write_register(gdbserver_state.g_cpu, registers, addr);
|
||||
for (reg_id = 0;
|
||||
reg_id < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0;
|
||||
reg_id++) {
|
||||
reg_size = gdb_write_register(gdbserver_state.g_cpu, registers, reg_id);
|
||||
len -= reg_size;
|
||||
registers += reg_size;
|
||||
}
|
||||
@ -1216,15 +1218,16 @@ static void handle_write_all_regs(GArray *params, void *user_ctx)
|
||||
|
||||
static void handle_read_all_regs(GArray *params, void *user_ctx)
|
||||
{
|
||||
target_ulong addr, len;
|
||||
int reg_id;
|
||||
size_t len;
|
||||
|
||||
cpu_synchronize_state(gdbserver_state.g_cpu);
|
||||
g_byte_array_set_size(gdbserver_state.mem_buf, 0);
|
||||
len = 0;
|
||||
for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++) {
|
||||
for (reg_id = 0; reg_id < gdbserver_state.g_cpu->gdb_num_g_regs; reg_id++) {
|
||||
len += gdb_read_register(gdbserver_state.g_cpu,
|
||||
gdbserver_state.mem_buf,
|
||||
addr);
|
||||
reg_id);
|
||||
}
|
||||
g_assert(len == gdbserver_state.mem_buf->len);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user