target/armv7m: use arch_info[i].value instead of allocated memory
authorTomas Vanek <vanekt@fbl.cz>
Sun, 20 Oct 2019 12:27:36 +0000 (14:27 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 15 Nov 2020 21:08:26 +0000 (21:08 +0000)
Change-Id: I9422cab484d0769404516947e16da1baa001a4e0
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5328
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/target/armv7m.c
src/target/cortex_m.c

index 7e9b72a8e8c4b8f0d1aba14f69d30a8786d97744..13370b54b954600b56afbc214921fc1f003f98a3 100644 (file)
@@ -741,10 +741,7 @@ struct reg_cache *armv7m_build_reg_cache(struct target *target)
 
                reg_list[i].name = armv7m_regs[i].name;
                reg_list[i].size = armv7m_regs[i].bits;
-               size_t storage_size = DIV_ROUND_UP(armv7m_regs[i].bits, 8);
-               if (storage_size < 4)
-                       storage_size = 4;
-               reg_list[i].value = calloc(1, storage_size);
+               reg_list[i].value = arch_info[i].value;
                reg_list[i].dirty = false;
                reg_list[i].valid = false;
                reg_list[i].hidden = i == ARMV7M_PMSK_BPRI_FLTMSK_CTRL;
@@ -798,7 +795,6 @@ void armv7m_free_reg_cache(struct target *target)
 
                free(reg->feature);
                free(reg->reg_data_type);
-               free(reg->value);
        }
 
        free(cache->reg_list[0].arch_info);
index ced7a8a679637525ad522cba415aa2dc125b3fed..7b3f3c70e31d6fc20e559db9de9c31fc47937be1 100644 (file)
@@ -2044,7 +2044,6 @@ int cortex_m_examine(struct target *target)
                        for (idx = ARMV7M_NUM_CORE_REGS_NOFP;
                             idx < armv7m->arm.core_cache->num_regs;
                             idx++) {
-                               free(armv7m->arm.core_cache->reg_list[idx].value);
                                free(armv7m->arm.core_cache->reg_list[idx].feature);
                                free(armv7m->arm.core_cache->reg_list[idx].reg_data_type);
                        }