summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@ozlabs.org>2018-11-23 15:40:13 +1100
committerAlistair Popple <alistair@popple.id.au>2018-12-03 14:49:27 +1100
commita9a67cf4a4f526147180e05cb4b77a07169c5681 (patch)
tree7ff9d172d79e00dfe1d0d400742d7f25686263a9
parent5a460e817b72d39d361b95950a1060a09adae064 (diff)
downloadpdbg-a9a67cf4a4f526147180e05cb4b77a07169c5681.tar.gz
pdbg-a9a67cf4a4f526147180e05cb4b77a07169c5681.zip
main: Convert thread commands start/stop/step/sreset
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
-rw-r--r--src/thread.c75
1 files changed, 50 insertions, 25 deletions
diff --git a/src/thread.c b/src/thread.c
index 4401384..97becc4 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -22,6 +22,7 @@
#include "main.h"
#include "optcmd.h"
+#include "path.h"
static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *arg, uint64_t *valid)
{
@@ -240,26 +241,6 @@ static int print_proc_thread_status(struct pdbg_target *pib_target, uint32_t ind
return for_each_child_target("core", pib_target, print_core_thread_status, &maxindex, NULL);
};
-static int start_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- return ram_start_thread(thread_target) ? 0 : 1;
-}
-
-static int step_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *count, uint64_t *unused1)
-{
- return ram_step_thread(thread_target, *count) ? 0 : 1;
-}
-
-static int stop_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- return ram_stop_thread(thread_target) ? 0 : 1;
-}
-
-static int sreset_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- return ram_sreset_thread(thread_target) ? 0 : 1;
-}
-
static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *i_doBacktrace, uint64_t *unused)
{
struct thread_regs regs;
@@ -276,19 +257,52 @@ static int state_thread(struct pdbg_target *thread_target, uint32_t index, uint6
static int thread_start(void)
{
- return for_each_target("thread", start_thread, NULL, NULL);
+ struct pdbg_target *target;
+ int count = 0;
+
+ for_each_path_target_class("thread", target) {
+ if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
+ continue;
+
+ ram_start_thread(target);
+ count++;
+ }
+
+ return count;
}
OPTCMD_DEFINE_CMD(start, thread_start);
-static int thread_step(uint64_t count)
+static int thread_step(uint64_t steps)
{
- return for_each_target("thread", step_thread, &count, NULL);
+ struct pdbg_target *target;
+ int count = 0;
+
+ for_each_path_target_class("thread", target) {
+ if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
+ continue;
+
+ ram_step_thread(target, (int)steps);
+ count++;
+ }
+
+ return count;
}
OPTCMD_DEFINE_CMD_WITH_ARGS(step, thread_step, (DATA));
static int thread_stop(void)
{
- return for_each_target("thread", stop_thread, NULL, NULL);
+ struct pdbg_target *target;
+ int count = 0;
+
+ for_each_path_target_class("thread", target) {
+ if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
+ continue;
+
+ ram_stop_thread(target);
+ count++;
+ }
+
+ return count;
}
OPTCMD_DEFINE_CMD(stop, thread_stop);
@@ -300,7 +314,18 @@ OPTCMD_DEFINE_CMD(threadstatus, thread_status_print);
static int thread_sreset(void)
{
- return for_each_target("thread", sreset_thread, NULL, NULL);
+ struct pdbg_target *target;
+ int count = 0;
+
+ for_each_path_target_class("thread", target) {
+ if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
+ continue;
+
+ ram_sreset_thread(target);
+ count++;
+ }
+
+ return count;
}
OPTCMD_DEFINE_CMD(sreset, thread_sreset);
OpenPOWER on IntegriCloud