From 1601c1a40be5be45dd7b4192afc16d256f0ebe0d Mon Sep 17 00:00:00 2001 From: Jon Burgess Date: Thu, 18 Sep 2014 19:57:34 +0100 Subject: [PATCH] gdb_server: Include current RTOS thread in signal packets This allows GDB to automatically switch to the thread that has been interrupted and show you where it has stopped. Change-Id: Icb9500dc42a61eb977e9fac55ce9503c9926bf5d Signed-off-by: Jon Burgess Reviewed-on: http://openocd.zylin.com/2303 Tested-by: jenkins Reviewed-by: Spencer Oliver --- src/server/gdb_server.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 2912c7433c..152a06c72e 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -714,11 +714,14 @@ static int gdb_output(struct command_context *context, const char *line) static void gdb_signal_reply(struct target *target, struct connection *connection) { struct gdb_connection *gdb_connection = connection->priv; - char sig_reply[20]; + char sig_reply[45]; char stop_reason[20]; + char current_thread[25]; int sig_reply_len; int signal_var; + rtos_update_threads(target); + if (target->debug_reason == DBG_REASON_EXIT) { sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "W00"); } else { @@ -754,13 +757,18 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio } } - sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s", - signal_var, stop_reason); + current_thread[0] = '\0'; + if (target->rtos != NULL) { + snprintf(current_thread, sizeof(current_thread), "thread:%016" PRIx64 ";", target->rtos->current_thread); + target->rtos->current_threadid = target->rtos->current_thread; + } + + sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s%s", + signal_var, stop_reason, current_thread); } gdb_put_packet(connection, sig_reply, sig_reply_len); gdb_connection->frontend_state = TARGET_HALTED; - rtos_update_threads(target); } static void gdb_fileio_reply(struct target *target, struct connection *connection) -- 2.30.2