mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
gdbstub: only send stop-reply packets when allowed to
GDB's remote serial protocol allows stop-reply messages to be sent by the stub either as a notification packet or as a reply to a GDB command (provided that the cmd accepts such a response). QEMU currently does not implement notification packets, so it should only send stop-replies synchronously and when requested. Nevertheless, it still issues unsolicited stop messages through gdb_vm_state_change(). Although this behavior doesn't seem to cause problems with GDB itself (the messages are just ignored), it can impact other debuggers that implement the GDB remote serial protocol, like hexagon-lldb. Let's change the gdbstub to send stop messages only as a response to a previous GDB command that accepts such a reply. Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Acked-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Message-Id: <a49c0897fc22a6a7827c8dfc32aef2e1d933ec6b.1683214375.git.quic_mathbern@quicinc.com>
This commit is contained in:
parent
9e6d4938d1
commit
758370052f
4 changed files with 60 additions and 19 deletions
|
@ -108,8 +108,11 @@ void gdb_exit(int code)
|
|||
|
||||
trace_gdbstub_op_exiting((uint8_t)code);
|
||||
|
||||
snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
|
||||
gdb_put_packet(buf);
|
||||
if (gdbserver_state.allow_stop_reply) {
|
||||
snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
|
||||
gdb_put_packet(buf);
|
||||
gdbserver_state.allow_stop_reply = false;
|
||||
}
|
||||
}
|
||||
|
||||
int gdb_handlesig(CPUState *cpu, int sig)
|
||||
|
@ -127,11 +130,14 @@ int gdb_handlesig(CPUState *cpu, int sig)
|
|||
|
||||
if (sig != 0) {
|
||||
gdb_set_stop_cpu(cpu);
|
||||
g_string_printf(gdbserver_state.str_buf,
|
||||
"T%02xthread:", gdb_target_signal_to_gdb(sig));
|
||||
gdb_append_thread_id(cpu, gdbserver_state.str_buf);
|
||||
g_string_append_c(gdbserver_state.str_buf, ';');
|
||||
gdb_put_strbuf();
|
||||
if (gdbserver_state.allow_stop_reply) {
|
||||
g_string_printf(gdbserver_state.str_buf,
|
||||
"T%02xthread:", gdb_target_signal_to_gdb(sig));
|
||||
gdb_append_thread_id(cpu, gdbserver_state.str_buf);
|
||||
g_string_append_c(gdbserver_state.str_buf, ';');
|
||||
gdb_put_strbuf();
|
||||
gdbserver_state.allow_stop_reply = false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* gdb_put_packet() might have detected that the peer terminated the
|
||||
|
@ -174,12 +180,14 @@ void gdb_signalled(CPUArchState *env, int sig)
|
|||
{
|
||||
char buf[4];
|
||||
|
||||
if (!gdbserver_state.init || gdbserver_user_state.fd < 0) {
|
||||
if (!gdbserver_state.init || gdbserver_user_state.fd < 0 ||
|
||||
!gdbserver_state.allow_stop_reply) {
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "X%02x", gdb_target_signal_to_gdb(sig));
|
||||
gdb_put_packet(buf);
|
||||
gdbserver_state.allow_stop_reply = false;
|
||||
}
|
||||
|
||||
static void gdb_accept_init(int fd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue