This is an automated email from Gerrit. "Tim Newsome <t...@sifive.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6777
-- gerrit commit a259e259c84b334e2b4a9765cff175c120c5a2ae Author: Tim Newsome <t...@sifive.com> Date: Wed Nov 3 10:42:59 2021 -0700 Revive `riscv resume_order` This functionality was lost in #567. Now it works as expected again. Change-Id: I11a36e076867c0268034ceee763e28b2d4e6ff0f Signed-off-by: Tim Newsome <t...@sifive.com> diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 407b7e279..0793fc4c0 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -1452,6 +1452,32 @@ static int resume_finish(struct target *target) return target_call_event_callbacks(target, TARGET_EVENT_RESUMED); } +/* Return a newly allocated target list, that contains the same targets as in + * tlist bit in the opposite order. */ +static struct target_list *tlist_reverse(struct target_list *tlist) +{ + struct target_list *previous = NULL; + struct target_list *reversed = NULL; + for (struct target_list *node = tlist; node; node = node->next) { + reversed = calloc(1, sizeof(struct target_list)); + reversed->target = node->target; + reversed->next = previous; + previous = reversed; + } + return reversed; +} + +/* Free a target list, but not the targets that are referenced. */ +static void tlist_free(struct target_list *tlist) +{ + struct target_list *node = tlist; + while (node) { + struct target_list *previous = node; + node = node->next; + free(previous); + } +} + /** * @par single_hart When true, only resume a single hart even if SMP is * configured. This is used to run algorithms on just one hart. @@ -1467,14 +1493,21 @@ int riscv_resume( LOG_DEBUG("handle_breakpoints=%d", handle_breakpoints); int result = ERROR_OK; if (target->smp && !single_hart) { - for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) { + struct target_list *ordered_tlist; + + if (resume_order == RO_REVERSED) + ordered_tlist = tlist_reverse(target->head); + else + ordered_tlist = target->head; + + for (struct target_list *tlist = ordered_tlist; tlist; tlist = tlist->next) { struct target *t = tlist->target; if (resume_prep(t, current, address, handle_breakpoints, debug_execution) != ERROR_OK) result = ERROR_FAIL; } - for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) { + for (struct target_list *tlist = ordered_tlist; tlist; tlist = tlist->next) { struct target *t = tlist->target; riscv_info_t *i = riscv_info(t); if (i->prepped) { @@ -1484,12 +1517,15 @@ int riscv_resume( } } - for (struct target_list *tlist = target->head; tlist; tlist = tlist->next) { + for (struct target_list *tlist = ordered_tlist; tlist; tlist = tlist->next) { struct target *t = tlist->target; if (resume_finish(t) != ERROR_OK) - return ERROR_FAIL; + result = ERROR_FAIL; } + if (resume_order == RO_REVERSED) + tlist_free(ordered_tlist); + } else { if (resume_prep(target, current, address, handle_breakpoints, debug_execution) != ERROR_OK) --