From 7d1f132cea58017003534a45ad444e55c23fd5be Mon Sep 17 00:00:00 2001 From: Marek Vrbka Date: Fri, 3 Nov 2023 10:48:02 +0100 Subject: [PATCH] target: Fix get_reg, prevent returning invalid data This patch forces a read of register from the target in the get_reg command in case the register cache does not hold a valid value at that moment. Note that the command "reg" already handles it correctly, no fix is needed there. Change-Id: I75fad25188e94ee4e06162ab6d600ea24dbf590a Signed-off-by: Marek Vrbka Reviewed-on: https://review.openocd.org/c/openocd/+/7958 Reviewed-by: Jan Matyas Reviewed-by: zapb Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/target/target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/target.c b/src/target/target.c index 384b4ec84f..61c243510a 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5149,7 +5149,7 @@ static int target_jim_get_reg(Jim_Interp *interp, int argc, return JIM_ERR; } - if (force) { + if (force || !reg->valid) { int retval = reg->type->get(reg); if (retval != ERROR_OK) { -- 2.30.2