mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
To: rostedt@goodmis.org, linux-kernel@vger.kernel.org
Cc: "Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
Subject: [PATCH 3/3] trace-cmd: Making stat to report when the stack tracer is ON
Date: Wed, 22 Nov 2017 20:02:02 +0200	[thread overview]
Message-ID: <20171122180202.9519-4-vladislav.valtchev@gmail.com> (raw)
In-Reply-To: <20171122180202.9519-1-vladislav.valtchev@gmail.com>

trace-cmd stat is a handy way for users to see what tracing is currently going
on, but currently is does not say anything about the stack tracing. This simple
patch makes the command to show a message when the stack tracer is ON.

Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@gmail.com>
---
 trace-cmd.h   |  3 +++
 trace-stack.c | 10 ++++++----
 trace-stat.c  | 11 +++++++----
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/trace-cmd.h b/trace-cmd.h
index 485907f..62c5ea7 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -351,6 +351,9 @@ struct hook_list {
 struct hook_list *tracecmd_create_event_hook(const char *arg);
 void tracecmd_free_hooks(struct hook_list *hooks);
 
+/* Stack tracer public functions */
+int is_stack_tracer_enabled(void);
+
 /* --- Hack! --- */
 int tracecmd_blk_hack(struct tracecmd_input *handle);
 
diff --git a/trace-stack.c b/trace-stack.c
index aa79ae3..0bd43a8 100644
--- a/trace-stack.c
+++ b/trace-stack.c
@@ -49,7 +49,7 @@ static void test_available(void)
 		die("stack tracer not configured on running kernel");
 }
 
-static char read_proc(void)
+int is_stack_tracer_enabled(void)
 {
 	char buf[1];
 	int fd;
@@ -62,8 +62,10 @@ static char read_proc(void)
 	close(fd);
 	if (n != 1)
 		die("error reading %s", PROC_FILE);
+	if (buf[0] != '0' && buf[0] != '1')
+		die("Invalid value '%c' in %s", buf[0], PROC_FILE);
 
-	return buf[0];
+	return buf[0] == '1';
 }
 
 static void start_stop_trace(char val)
@@ -72,7 +74,7 @@ static void start_stop_trace(char val)
 	int fd;
 	int n;
 
-	buf[0] = read_proc();
+	buf[0] = '0' + is_stack_tracer_enabled();
 	if (buf[0] == val)
 		return;
 
@@ -124,7 +126,7 @@ static void read_trace(void)
 	size_t n;
 	int r;
 
-	if (read_proc() == '1')
+	if (is_stack_tracer_enabled())
 		printf("(stack tracer running)\n");
 	else
 		printf("(stack tracer not running)\n");
diff --git a/trace-stat.c b/trace-stat.c
index fd16354..3094d25 100644
--- a/trace-stat.c
+++ b/trace-stat.c
@@ -617,7 +617,7 @@ static void report_graph_funcs(struct buffer_instance *instance)
 		die("malloc");
 
 	list_functions(path, "Function Graph Filter");
-	
+
 	tracecmd_put_tracing_file(path);
 
 	path = get_instance_file(instance, "set_graph_notrace");
@@ -625,7 +625,7 @@ static void report_graph_funcs(struct buffer_instance *instance)
 		die("malloc");
 
 	list_functions(path, "Function Graph No Trace");
-	
+
 	tracecmd_put_tracing_file(path);
 }
 
@@ -638,7 +638,7 @@ static void report_ftrace_filters(struct buffer_instance *instance)
 		die("malloc");
 
 	list_functions(path, "Function Filter");
-	
+
 	tracecmd_put_tracing_file(path);
 
 	path = get_instance_file(instance, "set_ftrace_notrace");
@@ -646,7 +646,7 @@ static void report_ftrace_filters(struct buffer_instance *instance)
 		die("malloc");
 
 	list_functions(path, "Function No Trace");
-	
+
 	tracecmd_put_tracing_file(path);
 }
 
@@ -928,5 +928,8 @@ void trace_stat (int argc, char **argv)
 		stat_instance(instance);
 	}
 
+	if (is_stack_tracer_enabled())
+		printf("Stack tracing is enabled\n\n");
+
 	exit(0);
 }
-- 
2.14.1

  parent reply	other threads:[~2017-11-22 18:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 18:01 [PATCH 0/3] trace-cmd: fixing three minor user experience issues Vladislav Valtchev (VMware)
2017-11-22 18:02 ` [PATCH 1/3] trace-cmd: Fix err msg for record w/o the -e option Vladislav Valtchev (VMware)
2017-11-22 18:02 ` [PATCH 2/3] trace-cmd: s/plugin/tracer/ in record's man page Vladislav Valtchev (VMware)
2017-11-22 18:02 ` Vladislav Valtchev (VMware) [this message]
2017-11-22 19:50   ` [PATCH 3/3] trace-cmd: Making stat to report when the stack tracer is ON Steven Rostedt
2017-11-23 12:32     ` Vladislav Valtchev
2017-11-29 12:57       ` Steven Rostedt
2017-11-29 14:00         ` Vladislav Valtchev
2017-11-29 16:18           ` Steven Rostedt
2017-11-30 11:26             ` Vladislav Valtchev
2017-11-30 14:56               ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171122180202.9519-4-vladislav.valtchev@gmail.com \
    --to=vladislav.valtchev@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome