[Pdbg] [PATCH] src/thread.c: Don't print uninitialised thread status
Nicholas Piggin
npiggin at gmail.com
Tue Aug 14 00:43:06 AEST 2018
On Mon, 13 Aug 2018 18:39:43 +1000
Alistair Popple <alistair at popple.id.au> wrote:
> Depending on the selection flags passed to pdbg not all threads will be
> selected. This was leading to random uninitialised values being used to print
> thread status for unselected threads. Instead nothing should be printed for
> those threads.
>
> Signed-off-by: Alistair Popple <alistair at popple.id.au>
Acked-by: Nicholas Piggin <npiggin at gmail.com>
> ---
> src/thread.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/thread.c b/src/thread.c
> index 4b95636..d282307 100644
> --- a/src/thread.c
> +++ b/src/thread.c
> @@ -23,24 +23,30 @@
> #include "main.h"
> #include "optcmd.h"
>
> -static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *arg, uint64_t *unused1)
> +static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *arg, uint64_t *valid)
> {
> struct thread_state *status = (struct thread_state *) arg;
>
> status[index] = thread_status(target);
> + valid[index] = true;
> return 1;
> }
>
> static int print_core_thread_status(struct pdbg_target *core_target, uint32_t index, uint64_t *maxindex, uint64_t *unused1)
> {
> struct thread_state status[8];
> + uint64_t valid[8] = {0};
> int i, rc;
>
> printf("c%02d: ", index);
>
> /* TODO: This cast is gross. Need to rewrite for_each_child_target as an iterator. */
> - rc = for_each_child_target("thread", core_target, print_thread_status, (uint64_t *) &status[0], NULL);
> + rc = for_each_child_target("thread", core_target, print_thread_status, (uint64_t *) &status[0], &valid[0]);
> for (i = 0; i <= *maxindex; i++) {
> + if (!valid[i]) {
> + printf(" ");
> + continue;
> + }
>
> if (status[i].active)
> printf("A");
More information about the Pdbg
mailing list