Revert "Remove duplicate of a counter in hwthread_update_threads"
Commit 0cedf10f8f
("Remove duplicate of a counter in
hwthread_update_threads") introduced a code bug.
In the second foreach_smp_target() loop, variable "threads_found"
gets passed to routine hwthread_fill_thread(). By removing the
counting of threads_found from the second loop, the
incorrect thread counter value gets passed to hwthread_fill_thread().
Change-Id: Ie89e53ccd28bb72b6838ef2f12106a1fe8d00994
Suggested-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7307
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
3da0c2504c
commit
09731b69a6
|
@ -78,6 +78,7 @@ static int hwthread_fill_thread(struct rtos *rtos, struct target *curr, int thre
|
|||
static int hwthread_update_threads(struct rtos *rtos)
|
||||
{
|
||||
int threads_found = 0;
|
||||
int thread_list_size = 0;
|
||||
struct target_list *head;
|
||||
struct target *target;
|
||||
int64_t current_thread = 0;
|
||||
|
@ -99,13 +100,13 @@ static int hwthread_update_threads(struct rtos *rtos)
|
|||
if (!target_was_examined(curr))
|
||||
continue;
|
||||
|
||||
++threads_found;
|
||||
++thread_list_size;
|
||||
}
|
||||
} else
|
||||
threads_found = 1;
|
||||
thread_list_size = 1;
|
||||
|
||||
/* create space for new thread details */
|
||||
rtos->thread_details = malloc(sizeof(struct thread_detail) * threads_found);
|
||||
rtos->thread_details = malloc(sizeof(struct thread_detail) * thread_list_size);
|
||||
|
||||
if (target->smp) {
|
||||
/* loop over all threads */
|
||||
|
@ -170,10 +171,13 @@ static int hwthread_update_threads(struct rtos *rtos)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
threads_found++;
|
||||
}
|
||||
} else {
|
||||
hwthread_fill_thread(rtos, target, threads_found);
|
||||
current_thread = threadid_from_target(target);
|
||||
threads_found++;
|
||||
}
|
||||
|
||||
rtos->thread_count = threads_found;
|
||||
|
|
Loading…
Reference in New Issue