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/+/9210
-- gerrit commit 56d6e6dee415d12c42979c3f49ba31a3bf9cdf3b Author: Tomas Vanek <[email protected]> Date: Mon Nov 3 11:07:31 2025 +0100 target, breakpoints: report hit watchpoint in trivial case Some targets have no means to find out which watchpoint triggered the debug halt. Resolve properly the trivial and most used case when only one watchpoint is set. Change-Id: I683933ec43e6ca0fed84a08a2aa222ed8a6e277f Signed-off-by: Tomas Vanek <[email protected]> diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index 7254eac7dc..44272df2f5 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -629,6 +629,20 @@ int watchpoint_hit(struct target *target, enum watchpoint_rw *rw, struct watchpoint *hit_watchpoint; retval = target_hit_watchpoint(target, &hit_watchpoint); + if (retval == ERROR_NOT_IMPLEMENTED + && target->debug_reason == DBG_REASON_WATCHPOINT) { + // Handle the trivial case: only one watchpoint is set + unsigned int cnt = 0; + struct watchpoint *wp = target->watchpoints; + while (wp) { + cnt++; + wp = wp->next; + } + if (cnt == 1) { + retval = ERROR_OK; + hit_watchpoint = target->watchpoints; + } + } if (retval != ERROR_OK) return ERROR_FAIL; diff --git a/src/target/target.c b/src/target/target.c index bdf0ff244d..cee9be0bf0 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1360,9 +1360,9 @@ int target_hit_watchpoint(struct target *target, if (!target->type->hit_watchpoint) { /* For backward compatible, if hit_watchpoint is not implemented, - * return ERROR_FAIL such that gdb_server will not take the nonsense + * return error such that gdb_server will not take the nonsense * information. */ - return ERROR_FAIL; + return ERROR_NOT_IMPLEMENTED; } return target->type->hit_watchpoint(target, hit_watchpoint); --
