diff mbox series

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

Message ID 20181120041953.402413-8-amitay@ozlabs.org
State Accepted
Headers show
Series Convert more commands to path based targeting | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Amitay Isaacs Nov. 20, 2018, 4:19 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 src/htm.c | 57 +++++++++++++++++++------------------------------------
 1 file changed, 20 insertions(+), 37 deletions(-)
diff mbox series

Patch

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);
+			}
 		}
 	}