diff options
author | Tomas Vanek <vanekt@fbl.cz> | 2022-10-30 08:22:37 +0000 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2022-11-11 20:22:53 +0000 |
commit | 09731b69a6f50c7e0e2f6fa0ba245374034217cb (patch) | |
tree | c905b148e562ef70bf2e42c61dfe5f18e81f70f8 | |
parent | 3da0c2504c14ea0736b973fa0b5085c42a9c6ce8 (diff) | |
download | riscv-openocd-09731b69a6f50c7e0e2f6fa0ba245374034217cb.zip riscv-openocd-09731b69a6f50c7e0e2f6fa0ba245374034217cb.tar.gz riscv-openocd-09731b69a6f50c7e0e2f6fa0ba245374034217cb.tar.bz2 |
Revert "Remove duplicate of a counter in hwthread_update_threads"
Commit 0cedf10f8fd6 ("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>
-rw-r--r-- | src/rtos/hwthread.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c index bdd5835..e5eaf42 100644 --- a/src/rtos/hwthread.c +++ b/src/rtos/hwthread.c @@ -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; |