This is an automated email from Gerrit. "Tomas Vanek <[email protected]>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9208
-- gerrit commit b8b6f3ec67c381fa094e31d5a59f2fd50aaca69d Author: Tomas Vanek <[email protected]> Date: Mon Nov 3 08:50:32 2025 +0100 target/armv4_5.c: mark registers as 'save-restore' gdb uses this mark when creating a dummy frame for manual call of a function by gdb command. With the original setting all registers as caller_save = false call command in gdb always clobbers r0, r1 and pc and some other registers depending on the called function. Set 'save-restore' for registers which are not preserved across function call. Change-Id: I16c49e4bf8001e38d18ce8861ca65988b08ccc88 Signed-off-by: Tomas Vanek <[email protected]> diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index d1a81614e8..8a4d2a0a77 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -690,8 +690,6 @@ struct reg_cache *arm_build_reg_cache(struct target *target, struct arm *arm) && arm->core_type != ARM_CORE_TYPE_VIRT_EXT) continue; - /* REVISIT handle Cortex-M, which only shadows R13/SP */ - reg_arch_info[i].num = arm_core_regs[i].cookie; reg_arch_info[i].mode = arm_core_regs[i].mode; reg_arch_info[i].target = target; @@ -705,8 +703,11 @@ struct reg_cache *arm_build_reg_cache(struct target *target, struct arm *arm) reg_list[i].arch_info = ®_arch_info[i]; reg_list[i].exist = true; - /* This really depends on the calling convention in use */ - reg_list[i].caller_save = false; + /* This really depends on the calling convention in use. + * Set to loosely reflect AAPCS and checked with gdb function + * call command not to change the registers of the debugged program. */ + reg_list[i].caller_save = i < 4 || i == 9 + || i == 15; // PC /* Registers data type, as used by GDB target description */ reg_list[i].reg_data_type = malloc(sizeof(struct reg_data_type)); @@ -750,7 +751,8 @@ struct reg_cache *arm_build_reg_cache(struct target *target, struct arm *arm) reg_list[i].arch_info = ®_arch_info[i]; reg_list[i].exist = true; - reg_list[i].caller_save = false; + /* Mark d0 - d7, d16 - d31 as save-restore for gdb */ + reg_list[i].caller_save = j < 8 || (j >= 16 && j < 32); reg_list[i].reg_data_type = malloc(sizeof(struct reg_data_type)); reg_list[i].reg_data_type->type = arm_vfp_v3_regs[j].type; --
