summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2018-08-13 18:35:42 +1000
committerAlistair Popple <alistair@popple.id.au>2018-08-14 11:40:53 +1000
commite815c3ab43c652040213e519f346c5438b2f42f3 (patch)
treed717cd9774b788d3f9962feb3ae535bd47531af5 /src
parentbe070ea7ee4558b0b8b7b0b7dc6c2fb8a66da580 (diff)
downloadpdbg-e815c3ab43c652040213e519f346c5438b2f42f3.tar.gz
pdbg-e815c3ab43c652040213e519f346c5438b2f42f3.zip
src/thread.c: Don't print uninitialised thread status
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@popple.id.au> Acked-by: Nicholas Piggin <npiggin@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/thread.c10
1 files 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");
OpenPOWER on IntegriCloud