mirror of
https://github.com/qemu/qemu.git
synced 2026-04-05 22:00:58 +00:00
gdbstub: extract stop reply message construction
The stop reply message we send can include a lot of extra information and a bunch is mode dependant. Extract the construction into a helper and add specialised versions for system and user mode. The correct response for system mode should be of the form: T05core:N; Where N is the core ID. We pass GString to gdb_build_stop_packet as other functions we are going to clean-up work variously with their own dynamically allocated GStrings or with the common shared buffer. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260203115201.2387721-5-alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
@@ -1432,9 +1432,7 @@ static void handle_v_attach(GArray *params, void *user_ctx)
|
||||
gdbserver_state.c_cpu = cpu;
|
||||
|
||||
if (gdbserver_state.allow_stop_reply) {
|
||||
g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
|
||||
gdb_append_thread_id(cpu, gdbserver_state.str_buf);
|
||||
g_string_append_c(gdbserver_state.str_buf, ';');
|
||||
gdb_build_stop_packet(gdbserver_state.str_buf, cpu);
|
||||
gdbserver_state.allow_stop_reply = false;
|
||||
}
|
||||
}
|
||||
@@ -2038,11 +2036,9 @@ static void handle_gen_set(GArray *params, void *user_ctx)
|
||||
static void handle_target_halt(GArray *params, void *user_ctx)
|
||||
{
|
||||
if (gdbserver_state.allow_stop_reply) {
|
||||
g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
|
||||
gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf);
|
||||
g_string_append_c(gdbserver_state.str_buf, ';');
|
||||
gdb_put_strbuf();
|
||||
gdb_build_stop_packet(gdbserver_state.str_buf, gdbserver_state.c_cpu);
|
||||
gdbserver_state.allow_stop_reply = false;
|
||||
gdb_put_strbuf();
|
||||
}
|
||||
/*
|
||||
* Remove all the breakpoints when this query is issued,
|
||||
|
||||
@@ -237,4 +237,14 @@ void gdb_breakpoint_remove_all(CPUState *cs);
|
||||
int gdb_target_memory_rw_debug(CPUState *cs, hwaddr addr,
|
||||
uint8_t *buf, int len, bool is_write);
|
||||
|
||||
/**
|
||||
* gdb_build_stop_packet() - craft the stop packet
|
||||
* @buf: GString buffer for building the packet
|
||||
* @cs: CPUState
|
||||
*
|
||||
* Craft the Stop/Reply packet when we halt.
|
||||
*/
|
||||
|
||||
void gdb_build_stop_packet(GString *buf, CPUState *cs);
|
||||
|
||||
#endif /* GDBSTUB_INTERNALS_H */
|
||||
|
||||
@@ -662,3 +662,14 @@ void gdb_breakpoint_remove_all(CPUState *cs)
|
||||
ops->remove_all_breakpoints(cs);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The minimal system-mode stop reply packet is:
|
||||
* T05core:{id};
|
||||
*/
|
||||
|
||||
void gdb_build_stop_packet(GString *buf, CPUState *cs)
|
||||
{
|
||||
g_string_printf(buf,
|
||||
"T%02xcore:%02x;", GDB_SIGNAL_TRAP, gdb_get_cpu_index(cs));
|
||||
}
|
||||
|
||||
@@ -974,3 +974,15 @@ void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx)
|
||||
gdb_put_packet_binary(gdbserver_state.str_buf->str,
|
||||
gdbserver_state.str_buf->len, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* The minimal user-mode stop reply packet is:
|
||||
* T05thread:{id};
|
||||
*/
|
||||
|
||||
void gdb_build_stop_packet(GString *buf, CPUState *cs)
|
||||
{
|
||||
g_string_printf(buf, "T%02xthread:", GDB_SIGNAL_TRAP);
|
||||
gdb_append_thread_id(cs, buf);
|
||||
g_string_append_c(buf, ';');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user