|
From: openocd-gerrit <ope...@us...> - 2022-12-03 09:27:33
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 04887d3b688aef999f83eebf9c521d1bb7d29b0b (commit)
from 4fe3997294e24d9a7bb41290088d6410f7ba1eca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 04887d3b688aef999f83eebf9c521d1bb7d29b0b
Author: Evgeniy Naydanov <evg...@sy...>
Date: Fri Sep 16 16:01:46 2022 +0300
Fix jim_target_smp for smp rtos target
If multiple targets are specified as -rtos <rtos_type>, the
rtos_update_threads was called only if the last target was specified as
rtos, which is inconsistent with other checks of whether or not smp target
is an rtos one.
Signed-off-by: Evgeniy Naydanov <evg...@sy...>
Change-Id: Ie52bc6b6c8f841d31b9590fcbc44e985d3cba0eb
Reviewed-on: https://review.openocd.org/c/openocd/+/7244
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/target/target.c b/src/target/target.c
index 783159fec..e4fe20f72 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -6433,16 +6433,52 @@ static int jim_target_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK;
}
+static struct target_list *
+__attribute__((warn_unused_result))
+create_target_list_node(Jim_Obj *const name) {
+ int len;
+ const char *targetname = Jim_GetString(name, &len);
+ struct target *target = get_target(targetname);
+ LOG_DEBUG("%s ", targetname);
+ if (!target)
+ return NULL;
+
+ struct target_list *new = malloc(sizeof(struct target_list));
+ if (!new) {
+ LOG_ERROR("Out of memory");
+ return new;
+ }
+
+ new->target = target;
+ return new;
+}
+
+static int get_target_with_common_rtos_type(struct list_head *lh, struct target **result)
+{
+ struct target *target = NULL;
+ struct target_list *curr;
+ foreach_smp_target(curr, lh) {
+ struct rtos *curr_rtos = curr->target->rtos;
+ if (curr_rtos) {
+ if (target && target->rtos && target->rtos->type != curr_rtos->type) {
+ LOG_ERROR("Different rtos types in members of one smp target!");
+ return JIM_ERR;
+ }
+ target = curr->target;
+ }
+ }
+ *result = target;
+ return JIM_OK;
+}
+
static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
- int i;
- const char *targetname;
- int retval, len;
static int smp_group = 1;
- struct target *target = NULL;
- struct target_list *head, *new;
- retval = 0;
+ if (argc == 1) {
+ LOG_DEBUG("Empty SMP target");
+ return JIM_OK;
+ }
LOG_DEBUG("%d", argc);
/* argv[1] = target to associate in smp
* argv[2] = target to associate in smp
@@ -6456,27 +6492,24 @@ static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
}
INIT_LIST_HEAD(lh);
- for (i = 1; i < argc; i++) {
-
- targetname = Jim_GetString(argv[i], &len);
- target = get_target(targetname);
- LOG_DEBUG("%s ", targetname);
- if (target) {
- new = malloc(sizeof(struct target_list));
- new->target = target;
+ for (int i = 1; i < argc; i++) {
+ struct target_list *new = create_target_list_node(argv[i]);
+ if (new)
list_add_tail(&new->lh, lh);
- }
}
/* now parse the list of cpu and put the target in smp mode*/
- foreach_smp_target(head, lh) {
- target = head->target;
+ struct target_list *curr;
+ foreach_smp_target(curr, lh) {
+ struct target *target = curr->target;
target->smp = smp_group;
target->smp_targets = lh;
}
smp_group++;
- if (target && target->rtos)
- retval = rtos_smp_init(target);
+ struct target *rtos_target;
+ int retval = get_target_with_common_rtos_type(lh, &rtos_target);
+ if (retval == JIM_OK && rtos_target)
+ retval = rtos_smp_init(rtos_target);
return retval;
}
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 71 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 52 insertions(+), 19 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|