From 4a82be77de9dcfe37c3a8257953737f2b3c9b9d7 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 26 Oct 2021 11:22:34 +0100 Subject: gdbstub: Switch to the thread receiving a signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Respond with Txxthread:yyyy; instead of a plain Sxx to indicate which thread received the signal. Otherwise, the debugger will associate it with the main one. Also automatically select this thread, as that is what gdb expects. Signed-off-by: Pavel Labath Message-Id: <20211019174953.36560-1-pavel@labath.sk> Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20211026102234.3961636-29-alex.bennee@linaro.org> --- gdbstub.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gdbstub.c') diff --git a/gdbstub.c b/gdbstub.c index 36b85aa..23baaef 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -3138,8 +3138,12 @@ gdb_handlesig(CPUState *cpu, int sig) tb_flush(cpu); if (sig != 0) { - snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig)); - put_packet(buf); + gdb_set_stop_cpu(cpu); + g_string_printf(gdbserver_state.str_buf, + "T%02xthread:", target_signal_to_gdb(sig)); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + put_strbuf(); } /* put_packet() might have detected that the peer terminated the connection. */ -- cgit v1.1