[Pdbg] [PATCH] src/htm.c: Only run on selected targets

Alistair Popple alistair at popple.id.au
Mon Apr 30 17:28:24 AEST 2018


The HTM does not call the same target iterators as the rest of the pdbg
application. Therefore the changes to device selection were not carried
over. Longer term we should change the HTM code to call the same iterators
as the rest of the pdbg application, but for the moment just copy the
device selection code across as the longer term fix really requires
rewritting the iterators to not use callbacks.

Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
 src/htm.c  | 18 ++++++++++++++++++
 src/main.c |  4 ++--
 src/main.h |  2 ++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/htm.c b/src/htm.c
index 4c41f0d..566687e 100644
--- a/src/htm.c
+++ b/src/htm.c
@@ -80,6 +80,8 @@ static int run_start(enum htm_type type, int optind, int argc, char *argv[])
 	int rc = 0;
 
 	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
+		if (!target_selected(target))
+			continue;
 		pdbg_target_probe(target);
 		if (target_is_disabled(target))
 			continue;
@@ -102,6 +104,8 @@ static int run_stop(enum htm_type type, int optind, int argc, char *argv[])
 	int rc = 0;
 
 	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
+		if (!target_selected(target))
+			continue;
 		pdbg_target_probe(target);
 		if (target_is_disabled(target))
 			continue;
@@ -124,6 +128,8 @@ static int run_status(enum htm_type type, int optind, int argc, char *argv[])
 	int rc = 0;
 
 	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
+		if (!target_selected(target))
+			continue;
 		pdbg_target_probe(target);
 		if (target_is_disabled(target))
 			continue;
@@ -148,6 +154,8 @@ static int run_reset(enum htm_type type, int optind, int argc, char *argv[])
 	int rc = 0;
 
 	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
+		if (!target_selected(target))
+			continue;
 		pdbg_target_probe(target);
 		if (target_is_disabled(target))
 			continue;
@@ -185,6 +193,8 @@ static int run_dump(enum htm_type type, int optind, int argc, char *argv[])
 	/* size = 0 will dump everything */
 	printf("Dumping HTM trace to file [chip].[#]%s\n", filename);
 	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
+		if (!target_selected(target))
+			continue;
 		pdbg_target_probe(target);
 		if (target_is_disabled(target))
 			continue;
@@ -326,6 +336,14 @@ int run_htm(int optind, int argc, char *argv[])
 				return 0;
 			}
 		}
+
+		/* Select the correct chtm target */
+		pdbg_for_each_child_target(core_target, target) {
+			if (!strcmp(pdbg_target_class_name(target), "chtm")) {
+				target_select(target);
+				pdbg_target_probe(target);
+			}
+		}
 	}
 
 	optind++;
diff --git a/src/main.c b/src/main.c
index 025ad56..a121972 100644
--- a/src/main.c
+++ b/src/main.c
@@ -257,14 +257,14 @@ static bool parse_options(int argc, char *argv[])
 	return opt_error;
 }
 
-static void target_select(struct pdbg_target *target)
+void target_select(struct pdbg_target *target)
 {
 	/* We abuse the private data pointer atm to indicate the target is
 	 * selected */
 	pdbg_target_priv_set(target, (void *) 1);
 }
 
-static void target_unselect(struct pdbg_target *target)
+void target_unselect(struct pdbg_target *target)
 {
 	pdbg_target_priv_set(target, NULL);
 }
diff --git a/src/main.h b/src/main.h
index 6db74aa..02645e3 100644
--- a/src/main.h
+++ b/src/main.h
@@ -25,6 +25,8 @@ static inline bool target_is_disabled(struct pdbg_target *target)
 		pdbg_target_status(target) == PDBG_TARGET_NONEXISTENT;
 }
 
+void target_select(struct pdbg_target *target);
+void target_unselect(struct pdbg_target *target);
 bool target_selected(struct pdbg_target *target);
 
 /* Returns the sum of return codes. This can be used to count how many targets the callback was run on. */
-- 
2.11.0



More information about the Pdbg mailing list