From e1c6f6783d68f0dcc766b3e6317348e3838a3856 Mon Sep 17 00:00:00 2001 From: Mike Dunn Date: Wed, 8 Sep 2010 19:13:14 -0700 Subject: [PATCH] xscale: mark xscale registers invalid on debug entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Hi everyone, This simple patch fixes a problem I noticed on the xscale where incorrect values are sometimes reported by the reg command. The problem can occur when requesting the value of registers in the xscale-specific register cache. With a couple of exceptions, none of the registers in the xscale register cache are automatically retrieved on debug entry. This is probably fine, as they are unlikely to be needed on a regular basis during a typical debug session, and they can be retrieved when explicitly requested by name using the reg command. The problem is that once this is done, the register remains marked as valid for the remainder of the OpenOCD session, and the reg command will henceforth always report the same value because it is obtained from the cache and is never again retrieved from the debug handler on the target. The fix is to mark all registers in the xscale register cache as invalid on debug entry (before the two exceptions are retrieved), thus forcing retrieval (when requested) from the target across resumptions in execution, and avoiding the reporting of stale values. Small addition change by Øyvind: change 'i' to unsigned to fix compiler warning for xscale_debug_entry() fn. Signed-off-by: Mike Dunn Signed-off-by: Øyvind Harboe --- src/target/xscale.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/target/xscale.c b/src/target/xscale.c index 44358bc3f..2b8bff16a 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -895,7 +895,7 @@ static int xscale_debug_entry(struct target *target) struct arm *armv4_5 = &xscale->armv4_5_common; uint32_t pc; uint32_t buffer[10]; - int i; + unsigned i; int retval; uint32_t moe; @@ -964,6 +964,11 @@ static int xscale_debug_entry(struct target *target) r->valid = true; } + /* mark xscale regs invalid to ensure they are retrieved from the + * debug handler if requested */ + for (i = 0; i < xscale->reg_cache->num_regs; i++) + xscale->reg_cache->reg_list[i].valid = 0; + /* examine debug reason */ xscale_read_dcsr(target); moe = buf_get_u32(xscale->reg_cache->reg_list[XSCALE_DCSR].value, 2, 3); -- 2.11.4.GIT