From 4447fa4c987b03372320f13e576dfc2dcb4846ef Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 14 Sep 2023 13:04:39 -0700 Subject: [PATCH] gdb_server,rtos: Differentiate rtos_get_gdb_reg failing and not implemented If it fails, then pass that failure on. If it's simply not implemented, then we can fall through and try target_get_gdb_reg_list_noread(). This difference matters when the target representing the current hwthread is unavailable, but the target that is linked to the gdb connection is available. In that case we want the operation to return an error to gdb, instead of reading the register from the target that is available. Change-Id: I9c84ca556f818c5580e25ab349a34a226fcf0f43 Signed-off-by: Tim Newsome Reviewed-on: https://review.openocd.org/c/openocd/+/9138 Tested-by: jenkins Reviewed-by: Evgeniy Naydanov Reviewed-by: Tomas Vanek --- src/rtos/rtos.c | 2 +- src/server/gdb_server.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c index 6a5d7b32c..163d882a4 100644 --- a/src/rtos/rtos.c +++ b/src/rtos/rtos.c @@ -600,7 +600,7 @@ int rtos_get_gdb_reg(struct connection *connection, int reg_num) free(reg_list); } - return ERROR_FAIL; + return ERROR_NOT_IMPLEMENTED; } /** Return a list of general registers. */ diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 080e3360a..d18d48a3a 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1411,8 +1411,13 @@ static int gdb_get_register_packet(struct connection *connection, LOG_DEBUG("-"); #endif - if ((target->rtos) && (rtos_get_gdb_reg(connection, reg_num) == ERROR_OK)) - return ERROR_OK; + if (target->rtos) { + retval = rtos_get_gdb_reg(connection, reg_num); + if (retval == ERROR_OK) + return ERROR_OK; + if (retval != ERROR_NOT_IMPLEMENTED) + return gdb_error(connection, retval); + } retval = target_get_gdb_reg_list_noread(target, ®_list, ®_list_size, REG_CLASS_ALL);