From b1f3a7581928f66f8e87a1cb4307065068747088 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 13 Oct 2022 13:29:15 -0700 Subject: target/riscv: Don't resume unavailable harts. Change-Id: I30a2e9ec6c1b99fb92ab1a160ddb63682167c6d8 Signed-off-by: Tim Newsome --- src/target/breakpoints.c | 12 ++++++++++-- src/target/riscv/riscv.c | 14 +++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index 9e32b5d..1055ed9 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -85,7 +85,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"; @@ -222,6 +222,8 @@ int breakpoint_add(struct target *target, struct target_list *list_node; foreach_smp_target(list_node, target->smp_targets) { struct target *curr = list_node->target; + if (curr->state == TARGET_UNAVAILABLE) + continue; int retval = breakpoint_add_internal(curr, address, length, type); if (retval != ERROR_OK) return retval; @@ -243,6 +245,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; @@ -265,6 +269,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; @@ -441,7 +447,7 @@ 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"; @@ -473,6 +479,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; diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 85c3b99..9351920 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -1625,9 +1625,11 @@ int riscv_resume( struct target_list *tlist; foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) { struct target *t = tlist->target; - if (resume_prep(t, current, address, handle_breakpoints, - debug_execution) != ERROR_OK) - result = ERROR_FAIL; + if (t->state != TARGET_UNAVAILABLE) { + if (resume_prep(t, current, address, handle_breakpoints, + debug_execution) != ERROR_OK) + result = ERROR_FAIL; + } } foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) { @@ -1642,8 +1644,10 @@ int riscv_resume( foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) { struct target *t = tlist->target; - if (resume_finish(t, debug_execution) != ERROR_OK) - result = ERROR_FAIL; + if (t->state != TARGET_UNAVAILABLE) { + if (resume_finish(t, debug_execution) != ERROR_OK) + result = ERROR_FAIL; + } } return result; -- cgit v1.1