diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index d65e5594f..fa6b635f0 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 3d807ba35..ababa57fb 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);