lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 23 Nov 2017 18:33:25 +0200
From:   "Vladislav Valtchev (VMware)" <vladislav.valtchev@...il.com>
To:     rostedt@...dmis.org
Cc:     linux-kernel@...r.kernel.org, y.karadz@...il.com,
        "Vladislav Valtchev (VMware)" <vladislav.valtchev@...il.com>
Subject: [PATCH 01/11] trace-cmd: Extract trace_stop() from trace_record()

In this patch, an entire trace_stop() function has been extracted from
trace_record() and added to the commands table in trace-cmd.c, without any
ad-hoc changes. Now trace_record() is a little bit smaller and all the code
handling the 'stop' command is in a dedicated function.

Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@...il.com>
---
 trace-cmd.c    |  2 +-
 trace-local.h  |  2 ++
 trace-record.c | 78 ++++++++++++++++++++++++++++++++--------------------------
 3 files changed, 46 insertions(+), 36 deletions(-)

diff --git a/trace-cmd.c b/trace-cmd.c
index 5a10605..de5283c 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -104,7 +104,7 @@ struct command commands[] = {
 	{"record", trace_record},
 	{"start", trace_record},
 	{"extract", trace_record},
-	{"stop", trace_record},
+	{"stop", trace_stop},
 	{"stream", trace_record},
 	{"profile", trace_record},
 	{"restart", trace_record},
diff --git a/trace-local.h b/trace-local.h
index 157b2c6..8010680 100644
--- a/trace-local.h
+++ b/trace-local.h
@@ -58,6 +58,8 @@ int read_trace_files(void);
 
 void trace_record(int argc, char **argv);
 
+void trace_stop(int argc, char **argv);
+
 void trace_report(int argc, char **argv);
 
 void trace_split(int argc, char **argv);
diff --git a/trace-record.c b/trace-record.c
index 06fc0e6..c7f7df7 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -2141,7 +2141,7 @@ static void set_mask(struct buffer_instance *instance)
 		die("could not open %s\n", path);
 
 	write(fd, instance->cpumask, strlen(instance->cpumask));
-	
+
 	close(fd);
  out:
 	tracecmd_put_tracing_file(path);
@@ -4198,7 +4198,48 @@ enum {
 	OPT_module		= 256,
 };
 
-void trace_record (int argc, char **argv)
+void trace_stop(int argc, char **argv)
+{
+	int topt = 0;
+	struct buffer_instance *instance = &top_instance;
+
+	init_instance(instance);
+
+	for (;;) {
+		int c;
+
+		c = getopt(argc-1, argv+1, "hatB:");
+		if (c == -1)
+			break;
+		switch (c) {
+		case 'h':
+			usage(argv);
+			break;
+		case 'B':
+			instance = create_instance(optarg);
+			if (!instance)
+				die("Failed to create instance");
+			add_instance(instance);
+			break;
+		case 'a':
+			add_all_instances();
+			break;
+		case 't':
+			/* Force to use top instance */
+			topt = 1;
+			instance = &top_instance;
+			break;
+		default:
+			usage(argv);
+		}
+
+	}
+	update_first_instance(instance, topt);
+	tracecmd_disable_tracing();
+	exit(0);
+}
+
+void trace_record(int argc, char **argv)
 {
 	const char *plugin = NULL;
 	const char *output = NULL;
@@ -4248,39 +4289,6 @@ void trace_record (int argc, char **argv)
 	else if ((profile = strcmp(argv[1], "profile") == 0)) {
 		handle_init = trace_init_profile;
 		events = 1;
-	} else if (strcmp(argv[1], "stop") == 0) {
-		for (;;) {
-			int c;
-
-			c = getopt(argc-1, argv+1, "hatB:");
-			if (c == -1)
-				break;
-			switch (c) {
-			case 'h':
-				usage(argv);
-				break;
-			case 'B':
-				instance = create_instance(optarg);
-				if (!instance)
-					die("Failed to create instance");
-				add_instance(instance);
-				break;
-			case 'a':
-				add_all_instances();
-				break;
-			case 't':
-				/* Force to use top instance */
-				topt = 1;
-				instance = &top_instance;
-				break;
-			default:
-				usage(argv);
-			}
-
-		}
-		update_first_instance(instance, topt);
-		tracecmd_disable_tracing();
-		exit(0);
 	} else if (strcmp(argv[1], "restart") == 0) {
 		for (;;) {
 			int c;
-- 
2.14.1

Powered by blists - more mailing lists