Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1657467 > unrolled thread

[PATCH 2/2] trace-cmd: replace show_file() -> show_instance_file()

Started byFederico Vaga <federico.vaga@vaga.pv.it>
First post2017-06-05 11:40 +0200
Last post2017-06-05 11:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] trace-cmd: replace show_file() -> show_instance_file() Federico Vaga <federico.vaga@vaga.pv.it> - 2017-06-05 11:40 +0200

#1657467 — [PATCH 2/2] trace-cmd: replace show_file() -> show_instance_file()

FromFederico Vaga <federico.vaga@vaga.pv.it>
Date2017-06-05 11:40 +0200
Subject[PATCH 2/2] trace-cmd: replace show_file() -> show_instance_file()
Message-ID<tOWEq-193-27@gated-at.bofh.it>
show_file(name) and show_instance_file(&top_instance, name) are
equivalent.

Remove the show_file() function in order to have a single function for
this task.

Signed-off-by: Federico Vaga <federico.vaga@vaga.pv.it>
---
 trace-list.c     | 21 ++++++---------------
 trace-local.h    |  2 --
 trace-show.c     | 18 ++----------------
 trace-snapshot.c |  2 +-
 4 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/trace-list.c b/trace-list.c
index 32b19bc..933397f 100644
--- a/trace-list.c
+++ b/trace-list.c
@@ -59,15 +59,6 @@ enum {
 };
 
 
-void show_file(const char *name)
-{
-	char *path;
-
-	path = tracecmd_get_tracing_file(name);
-	dump_file_content(path);
-	tracecmd_put_tracing_file(path);
-}
-
 typedef int (*process_file_func)(char *buf, int len);
 
 static void process_file_re(process_file_func func,
@@ -83,7 +74,7 @@ static void process_file_re(process_file_func func,
 
 	/* Just in case :-p */
 	if (!re || l == 0) {
-		show_file(name);
+		show_instance_file( &top_instance, name);
 		return;
 	}
 
@@ -258,25 +249,25 @@ static void show_events(const char *eventre, int flags)
 		else
 			show_file_re("available_events", eventre);
 	} else
-		show_file("available_events");
+		show_instance_file(&top_instance, "available_events");
 }
 
 
 static void show_tracers(void)
 {
-	show_file("available_tracers");
+	show_instance_file(&top_instance, "available_tracers");
 }
 
 
 static void show_options(void)
 {
-	show_file("trace_options");
+	show_instance_file(&top_instance, "trace_options");
 }
 
 
 static void show_clocks(void)
 {
-	show_file("trace_clock");
+	show_instance_file(&top_instance, "trace_clock");
 }
 
 
@@ -285,7 +276,7 @@ static void show_functions(const char *funcre)
 	if (funcre)
 		show_file_re("available_filter_functions", funcre);
 	else
-		show_file("available_filter_functions");
+		show_instance_file(&top_instance, "available_filter_functions");
 }
 
 
diff --git a/trace-local.h b/trace-local.h
index fa987bc..0e4ce61 100644
--- a/trace-local.h
+++ b/trace-local.h
@@ -50,8 +50,6 @@ struct pid_record_data {
 	struct pevent_record	*record;
 };
 
-void show_file(const char *name);
-
 struct tracecmd_input *read_trace_header(const char *file);
 int read_trace_files(void);
 
diff --git a/trace-show.c b/trace-show.c
index f13db31..7d5a805 100644
--- a/trace-show.c
+++ b/trace-show.c
@@ -38,12 +38,10 @@ enum {
 
 void trace_show(int argc, char **argv)
 {
-	const char *buffer = NULL;
 	const char *file = "trace";
 	const char *cpu = NULL;
 	struct buffer_instance *instance = &top_instance;
 	char cpu_path[128];
-	char *path;
 	int snap = 0;
 	int pipe = 0;
 	int show_name = 0;
@@ -72,9 +70,8 @@ void trace_show(int argc, char **argv)
 			usage(argv);
 			break;
 		case 'B':
-			if (buffer)
+			if (instance != &top_instance)
 				die("Can only show one buffer at a time");
-			buffer = optarg;
 			instance = create_instance(optarg);
 			if (!instance)
 				die("Failed to create instance");
@@ -153,24 +150,13 @@ void trace_show(int argc, char **argv)
 		file = cpu_path;
 	}
 
-	if (buffer) {
-		int ret;
-
-		ret = asprintf(&path, "instances/%s/%s", buffer, file);
-		if (ret < 0)
-			die("Failed to allocate instance path %s", file);
-		file = path;
-	}
-
 	if (show_name) {
 		char *name;
 		name = tracecmd_get_tracing_file(file);
 		printf("%s\n", name);
 		tracecmd_put_tracing_file(name);
 	}
-	show_file(file);
-	if (buffer)
-		free(path);
+	show_instance_file(instance, file);
 
 	return;
 }
diff --git a/trace-snapshot.c b/trace-snapshot.c
index 771b065..1e11438 100644
--- a/trace-snapshot.c
+++ b/trace-snapshot.c
@@ -113,7 +113,7 @@ void trace_snapshot (int argc, char **argv)
 	tracecmd_put_tracing_file(name);
 
 	if (!reset_snap && !take_snap && !free_snap) {
-		show_file(file);
+		show_instance_file(&top_instance, file);
 		exit(0);
 	}
 
-- 
2.9.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web