Skip to content

Commit 8b43a96

Browse files
committed
target: cortex_m: add comment for breakpoint of length 3
Add a comment in the breakpoint code to clarify the check for the odd breakpoint length of 3 bytes, introduced by [1]. [1]: commit 0a5e03c ("cortex_m.c: Use two byte breakpoint for 32bit Thumb-2 request"). Change-Id: I024863d10078b5d9062c876aa59ccf70a81bf641 Signed-off-by: Antonio Borneo <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/9139 Reviewed-by: Tomas Vanek <[email protected]> Tested-by: jenkins
1 parent 04da6e2 commit 8b43a96

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/target/cortex_m.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,15 @@ int cortex_m_unset_breakpoint(struct target *target, struct breakpoint *breakpoi
20412041

20422042
int cortex_m_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
20432043
{
2044+
/*
2045+
* GDB packets Z0 and z0 provide the 'kind' parameter that is target-specific
2046+
* and typically indicates the size in bytes of the breakpoint.
2047+
* But for 32-bit Thumb mode (Thumb-2) breakpoint, GDB provides 'kind = 3' to
2048+
* be used to derive the length information. See:
2049+
* https://sourceware.org/gdb/current/onlinedocs/gdb.html/ARM-Breakpoint-Kinds.html
2050+
* Since there isn't a four byte Thumb-2 breakpoint instruction, always use
2051+
* the two bytes breakpoint instruction.
2052+
*/
20442053
if (breakpoint->length == 3) {
20452054
LOG_TARGET_DEBUG(target, "Using a two byte breakpoint for 32bit Thumb-2 request");
20462055
breakpoint->length = 2;

0 commit comments

Comments
 (0)