[Pdbg] [PATCH 7/9] main: Convert htm commands to path based targeting

Amitay Isaacs amitay at ozlabs.org
Tue Nov 20 15:19:51 AEDT 2018


Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 src/htm.c | 57 +++++++++++++++++++------------------------------------
 1 file changed, 20 insertions(+), 37 deletions(-)

diff --git a/src/htm.c b/src/htm.c
index 10e35ae..b0e25a3 100644
--- a/src/htm.c
+++ b/src/htm.c
@@ -37,6 +37,7 @@
 #include <bitutils.h>
 
 #include "main.h"
+#include "path.h"
 
 #define HTM_ENUM_TO_STRING(e) ((e == HTM_NEST) ? "nhtm" : "chtm")
 
@@ -78,10 +79,7 @@ static int run_start(enum htm_type type)
 	struct pdbg_target *target;
 	int rc = 0;
 
-	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
-		if (!target_selected(target))
-			continue;
-		pdbg_target_probe(target);
+	for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) {
 		if (target_is_disabled(target))
 			continue;
 
@@ -102,10 +100,7 @@ static int run_stop(enum htm_type type)
 	struct pdbg_target *target;
 	int rc = 0;
 
-	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
-		if (!target_selected(target))
-			continue;
-		pdbg_target_probe(target);
+	for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) {
 		if (target_is_disabled(target))
 			continue;
 
@@ -126,10 +121,7 @@ static int run_status(enum htm_type type)
 	struct pdbg_target *target;
 	int rc = 0;
 
-	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
-		if (!target_selected(target))
-			continue;
-		pdbg_target_probe(target);
+	for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) {
 		if (target_is_disabled(target))
 			continue;
 
@@ -151,10 +143,7 @@ static int run_dump(enum htm_type type)
 	char *filename;
 	int rc = 0;
 
-	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
-		if (!target_selected(target))
-			continue;
-		pdbg_target_probe(target);
+	for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) {
 		if (target_is_disabled(target))
 			continue;
 
@@ -182,10 +171,7 @@ static int run_record(enum htm_type type)
 	char *filename;
 	int rc = 0;
 
-	pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) {
-		if (!target_selected(target))
-			continue;
-		pdbg_target_probe(target);
+	for_each_path_target_class(HTM_ENUM_TO_STRING(type), target) {
 		if (target_is_disabled(target))
 			continue;
 
@@ -283,16 +269,14 @@ int run_htm(int optind, int argc, char *argv[])
 	}
 
 	if (type == HTM_CORE) {
-		pdbg_for_each_class_target("core", target) {
-			if (target_selected(target)) {
-				if (!core_target) {
-					core_target = target;
-				} else {
-					fprintf(stderr, "It doesn't make sense to core trace on"
-						" multiple cores at once.\n");
-					fprintf(stderr, "What you probably want is -p 0 -c x\n");
-					return 0;
-				}
+		for_each_path_target_class("core", target) {
+			if (!core_target) {
+				core_target = target;
+			} else {
+				fprintf(stderr, "It doesn't make sense to core trace on"
+					" multiple cores at once.\n");
+				fprintf(stderr, "What you probably want is -p 0 -c x\n");
+				return 0;
 			}
 		}
 
@@ -315,19 +299,18 @@ int run_htm(int optind, int argc, char *argv[])
 		/* Select the correct chtm target */
 		pdbg_for_each_child_target(core_target, target) {
 			if (!strcmp(pdbg_target_class_name(target), "chtm")) {
-				target_select(target);
+				assert(path_target_add(target));
 				pdbg_target_probe(target);
 			}
 		}
 	}
 
 	if (type == HTM_NEST) {
-		pdbg_for_each_class_target("pib", target) {
-			if (!target_selected(target))
-				continue;
-
-			pdbg_for_each_target("nhtm", target, nhtm)
-				target_select(nhtm);
+		for_each_path_target_class("pib", target) {
+			pdbg_for_each_target("nhtm", target, nhtm) {
+				assert(path_target_add(nhtm));
+				pdbg_target_probe(nhtm);
+			}
 		}
 	}
 
-- 
2.19.1



More information about the Pdbg mailing list