This is an automated email from Gerrit. "Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8921
-- gerrit commit ea98a805b5510b297bef87c7c38988b149f94f0f Author: Tim Newsome <t...@sifive.com> Date: Thu Oct 13 13:29:15 2022 -0700 target/breakpoints: Do not add/remove bp/wp on unavailable targets Imported from https://github.com/riscv-collab/riscv-openocd/pull/767 Extracted part of target/riscv: Don't resume unavailable harts. Change-Id: Id6617230cfdadf93ba402e60fb704bdfe7af5c1e Signed-off-by: Tim Newsome <t...@sifive.com> diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index a080416291..eb50587153 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -78,7 +78,7 @@ static int breakpoint_add_internal(struct target *target, reason = "resource not available"; goto fail; case ERROR_TARGET_NOT_HALTED: - reason = "target running"; + reason = "target not halted"; goto fail; default: reason = "unknown reason"; @@ -210,16 +210,12 @@ int breakpoint_add(struct target *target, unsigned int length, enum breakpoint_type type) { - if (target->smp) { + if (target->smp && type == BKPT_HARD) { struct target_list *head; - - if (type == BKPT_SOFT) { - head = list_first_entry(target->smp_targets, struct target_list, lh); - return breakpoint_add_internal(head->target, address, length, type); - } - foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; + if (curr->state == TARGET_UNAVAILABLE) + continue; int retval = breakpoint_add_internal(curr, address, length, type); if (retval != ERROR_OK) return retval; @@ -241,6 +237,8 @@ int context_breakpoint_add(struct target *target, foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; + if (curr->state == TARGET_UNAVAILABLE) + continue; int retval = context_breakpoint_add_internal(curr, asid, length, type); if (retval != ERROR_OK) return retval; @@ -263,6 +261,8 @@ int hybrid_breakpoint_add(struct target *target, foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; + if (curr->state == TARGET_UNAVAILABLE) + continue; int retval = hybrid_breakpoint_add_internal(curr, address, asid, length, type); if (retval != ERROR_OK) return retval; @@ -542,7 +542,7 @@ static int watchpoint_add_internal(struct target *target, target_addr_t address, reason = "resource not available"; goto bye; case ERROR_TARGET_NOT_HALTED: - reason = "target running"; + reason = "target not halted"; goto bye; default: reason = "unrecognized error"; @@ -573,6 +573,8 @@ int watchpoint_add(struct target *target, target_addr_t address, foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; + if (curr->state == TARGET_UNAVAILABLE) + continue; int retval = watchpoint_add_internal(curr, address, length, rw, value, mask); if (retval != ERROR_OK) return retval; --