This is an automated email from Gerrit.

"Name of user not set <ad...@hifiphile.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8731

-- gerrit

commit b1be2eba2b50a1fb2cd559b49b73b01d337e49a5
Author: HiFiPhile <ad...@hifiphile.com>
Date:   Thu Jan 30 16:14:24 2025 +0100

    ARMv7-M: add a xPSR register alias at id 25.
    
    Some debuggers such IAR EWARM expect GDB's register map, where xPSR is
    at index 25. In which case OpenOCD will panic with error "gdb requested
    a non-existing register (reg_num=25)" at the start of a debug session.
    
    Tested with IAR EWARM 9.60.3.
    
    Change-Id: Ia119fc56cbd098a96c8913d83031ad71b123bcfc
    Signed-off-by: HiFiPhile <ad...@hifiphile.com>

diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index 440ca49d16..dea8de840e 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -139,6 +139,11 @@ static const struct {
        { ARMV7M_FAULTMASK, "faultmask", 1, REG_TYPE_INT8, "system", 
"org.gnu.gdb.arm.m-system", NULL, },
        { ARMV7M_CONTROL, "control", 3, REG_TYPE_INT8, "system", 
"org.gnu.gdb.arm.m-system", NULL, },
 
+       /* Add a xPSR register alias at index 25 in align with GDB
+        * Some IDEs like IAR EWARM expect xPSR to be at index 25 */
+       { ARMV7M_FILLER, "filler", 32, REG_TYPE_INT, NULL, NULL, NULL, },
+       { ARMV7M_XPSR_GDB, "xpsr", 32, REG_TYPE_INT, "general", 
"org.gnu.gdb.arm.m-profile", NULL, },
+
        /* ARMv8-M security extension (TrustZone) specific registers */
        { ARMV8M_MSP_NS, "msp_ns", 32, REG_TYPE_DATA_PTR, "stack", 
"org.gnu.gdb.arm.secext", NULL, },
        { ARMV8M_PSP_NS, "psp_ns", 32, REG_TYPE_DATA_PTR, "stack", 
"org.gnu.gdb.arm.secext", NULL, },
@@ -282,6 +287,9 @@ uint32_t armv7m_map_id_to_regsel(unsigned int arm_reg_id)
                 */
                return arm_reg_id;
 
+       case ARMV7M_XPSR_GDB:
+               return ARMV7M_XPSR;
+
        case ARMV7M_PMSK_BPRI_FLTMSK_CTRL:
                return ARMV7M_REGSEL_PMSK_BPRI_FLTMSK_CTRL;
 
@@ -825,7 +833,7 @@ struct reg_cache *armv7m_build_reg_cache(struct target 
*target)
 
                reg_list[i].group = armv7m_regs[i].group;
                reg_list[i].number = i;
-               reg_list[i].exist = true;
+               reg_list[i].exist = !(i == ARMV7M_FILLER);
                reg_list[i].caller_save = true; /* gdb defaults to true */
 
                if (reg_list[i].hidden)
diff --git a/src/target/armv7m.h b/src/target/armv7m.h
index 86c45f7f26..bb50ccf5fe 100644
--- a/src/target/armv7m.h
+++ b/src/target/armv7m.h
@@ -148,6 +148,10 @@ enum {
        ARMV7M_CONTROL,
        /* The end of block of container and contained registers */
 
+       /* Add xPSR alias at index 25 in align with GDB */
+       ARMV7M_FILLER,
+       ARMV7M_XPSR_GDB = 25,
+
        /* ARMv8-M specific registers */
        ARMV8M_MSP_NS,
        ARMV8M_PSP_NS,

-- 

Reply via email to