]> git.sur5r.net Git - openocd/commitdiff
arm_dpm: avoid duplicating the register cache
authorMatthias Welwarsky <matthias.welwarsky@sysgo.com>
Thu, 19 Jan 2017 15:57:04 +0000 (16:57 +0100)
committerPaul Fertser <fercerpav@gmail.com>
Fri, 20 Jan 2017 08:28:35 +0000 (08:28 +0000)
This bug was already attempted to fix in an earlier patch but
merging the "defer-examine" feature caused a regression, which this patch
tries to fix again.

Change-Id: Ie1ad1516f0d7f130d44e003d6c29dcc1a02a82ca
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/3951
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
src/target/arm_dpm.c

index 8ad6575cf697d74985660994b4e3b91d3832bbd3..62c6175524d71830011055699a8cfcbddad9016e 100644 (file)
@@ -972,11 +972,14 @@ int arm_dpm_setup(struct arm_dpm *dpm)
        arm->read_core_reg = arm_dpm_read_core_reg;
        arm->write_core_reg = arm_dpm_write_core_reg;
 
-       cache = arm_build_reg_cache(target, arm);
-       if (!cache)
-               return ERROR_FAIL;
+       /* avoid duplicating the register cache */
+       if (arm->core_cache == NULL) {
+               cache = arm_build_reg_cache(target, arm);
+               if (!cache)
+                       return ERROR_FAIL;
 
-       *register_get_last_cache_p(&target->reg_cache) = cache;
+               *register_get_last_cache_p(&target->reg_cache) = cache;
+       }
 
        /* coprocessor access setup */
        arm->mrc = dpm_mrc;