[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 18/21] gdbstub: don't use target_ulong while handling register
From: |
Alex Bennée |
Subject: |
[PATCH v2 18/21] gdbstub: don't use target_ulong while handling registers |
Date: |
Thu, 5 Jan 2023 16:43:17 +0000 |
This is a hangover from the original code. addr is misleading as it is
only a really a register id. While len will never exceed
MAX_PACKET_LENGTH I've used size_t as that is what strlen returns.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
gdbstub/gdbstub.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 4547ca3367..c50c2f8e0f 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -1192,7 +1192,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;
@@ -1204,9 +1205,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;
}
@@ -1215,15 +1217,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);
--
2.34.1
- [PATCH v2 13/21] gdbstub: specialise handle_query_attached, (continued)
- [PATCH v2 13/21] gdbstub: specialise handle_query_attached, Alex Bennée, 2023/01/05
- [PATCH v2 21/21] gdbstub: only compile gdbstub twice for whole build, Alex Bennée, 2023/01/05
- [PATCH v2 14/21] gdbstub: specialise target_memory_rw_debug, Alex Bennée, 2023/01/05
- [PATCH v2 11/21] gdbstub: move chunks of user code into own files, Alex Bennée, 2023/01/05
- [PATCH v2 10/21] gdbstub: move chunk of softmmu functionality to own file, Alex Bennée, 2023/01/05
- [PATCH v2 17/21] gdbstub: fix address type of gdb_set_cpu_pc, Alex Bennée, 2023/01/05
- [PATCH v2 16/21] gdbstub: specialise stub_can_reverse, Alex Bennée, 2023/01/05
- [PATCH v2 18/21] gdbstub: don't use target_ulong while handling registers,
Alex Bennée <=
- [PATCH v2 15/21] gdbstub: introduce gdb_get_max_cpus, Alex Bennée, 2023/01/05
- [PATCH v2 19/21] gdbstub: move register helpers into standalone include, Alex Bennée, 2023/01/05
- [PATCH v2 20/21] gdbstub: move syscall handling to new file, Alex Bennée, 2023/01/05