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/+/9211

-- gerrit

commit f595972881d37051611624de2ac235bdd477d2a5
Author: Tomas Vanek <[email protected]>
Date:   Mon Nov 3 17:33:12 2025 +0100

    target/cortex_a: fix HW breakpoint length for gdb kind 3
    
    Gdb uses length 3 to set breakpoint on a 4 byte Thumb-2
    instruction. Without this patch a breakpoint on down aligned word
    address was set. If the requested address was not word aligned,
    the breakpoint triggered at previous instruction and was not
    recognised properly by gdb.
    
    Set breakpoint on whole word if aligns with requested address,
    otherwise use length 2 and set byte mask.
    
    Change-Id: I12d1c57b7154e64abdf23dd7cd31714f9d8ec6f0
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index 016ea175c0..a9c034b55d 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -54,6 +54,7 @@
 #include <helper/bits.h>
 #include <helper/nvp.h>
 #include <helper/time_support.h>
+#include <helper/align.h>
 
 static int cortex_a_poll(struct target *target);
 static int cortex_a_debug_entry(struct target *target);
@@ -1341,6 +1342,14 @@ static int cortex_a_set_breakpoint(struct target *target,
                        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
                breakpoint_hw_set(breakpoint, brp_i);
+               if (breakpoint->length == 3) {
+                       /* Thumb-2 breakpoint: fixup to length 4 if word 
aligned,
+                        * set byte mask for length 2 if unaligned */
+                       if (IS_ALIGNED(breakpoint->address, 4))
+                               breakpoint->length = 4;
+                       else
+                               breakpoint->length = 2;
+               }
                if (breakpoint->length == 2)
                        byte_addr_select = (3 << (breakpoint->address & 0x02));
                control = ((matchmode & 0x7) << 20)

-- 

Reply via email to