trace-cmd: Making stat to report when the stack tracer is ON
PATCH 1/1 trace-cmd: Making stat to report when the stack tracer is ON
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) <[email protected]>
--- trace-cmd.h | 3 +++ trace-stack.c | 10 ++++++---- trace-stat.c | 11 +++++++---- 3 files changed, 16 insertions(+), 8 deletions(-)
trace-cmd.h +3 -0
@@ -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);
trace-stack.c +6 -4
@@ -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" );
trace-stat.c +7 -4
@@ -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 ); }
Signature · 1 line
2.14.1