aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2021-04-16 13:23:31 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-03-16 15:35:04 -0400
commit5b3832acbd01a26aca67cbd8f9fdecfb83d0c582 (patch)
tree9672d8343d67a443a187f9d191c105074598a1b1
parentcfde37f5bdf90823260960e105a570f2382cba71 (diff)
downloadtrace-cmd-5b3832acbd01a26aca67cbd8f9fdecfb83d0c582.tar.gz
trace-cmd stat: Add -o option to show options
Add "-o" to trace-cmd stat to list the options that are enabled or disable (like it does with trace-cmd list). The difference with stat is that it allows you to see the available options for an instance, where as trace-cmd list does not. trace-cmd stat -B foo -o Will list the options that are set for instance foo. Link: https://lore.kernel.org/linux-trace-devel/20210416172331.3870833-4-rostedt@goodmis.org Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--Documentation/trace-cmd/trace-cmd-stat.1.txt4
-rw-r--r--tracecmd/include/trace-local.h1
-rw-r--r--tracecmd/trace-list.c18
-rw-r--r--tracecmd/trace-stat.c14
-rw-r--r--tracecmd/trace-usage.c3
5 files changed, 29 insertions, 11 deletions
diff --git a/Documentation/trace-cmd/trace-cmd-stat.1.txt b/Documentation/trace-cmd/trace-cmd-stat.1.txt
index 1be9e609..fb800f91 100644
--- a/Documentation/trace-cmd/trace-cmd-stat.1.txt
+++ b/Documentation/trace-cmd/trace-cmd-stat.1.txt
@@ -55,6 +55,10 @@ OPTIONS
If *-B* is also specified, show the status of the top level tracing directory
as well as the instance(s).
+*-o*::
+ Display the all the options along with their values. If they start with "no", then
+ the option is disabled.
+
SEE ALSO
--------
trace-cmd(1), trace-cmd-record(1), trace-cmd-report(1), trace-cmd-start(1),
diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
index 13dab44c..bb33de06 100644
--- a/tracecmd/include/trace-local.h
+++ b/tracecmd/include/trace-local.h
@@ -300,6 +300,7 @@ void add_instance(struct buffer_instance *instance, int cpu_count);
void update_first_instance(struct buffer_instance *instance, int topt);
void show_instance_file(struct buffer_instance *instance, const char *name);
+void show_options(const char *prefix, struct buffer_instance *buffer);
struct trace_guest {
struct tracefs_instance *instance;
diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index 0574e563..fbf2882e 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -399,14 +399,18 @@ static void show_tracers(void)
show_file("available_tracers");
}
-static void show_options(void)
+void show_options(const char *prefix, struct buffer_instance *buffer)
{
+ struct tracefs_instance *instance = buffer ? buffer->tracefs : NULL;
struct dirent *dent;
struct stat st;
char *path;
DIR *dir;
- path = tracefs_get_tracing_file("options");
+ if (!prefix)
+ prefix = "";
+
+ path = tracefs_instance_get_file(instance, "options");
if (!path)
goto show_file;
if (stat(path, &st) < 0)
@@ -432,12 +436,12 @@ static void show_options(void)
ret = asprintf(&file, "options/%s", name);
if (ret < 0)
die("Failed to allocate file name");
- ret = tracefs_instance_file_read_number(NULL, file, &val);
+ ret = tracefs_instance_file_read_number(instance, file, &val);
if (!ret) {
if (val)
- printf("%s\n", name);
+ printf("%s%s\n", prefix, name);
else
- printf("no%s\n", name);
+ printf("%sno%s\n", prefix, name);
}
free(file);
}
@@ -719,7 +723,7 @@ void trace_list(int argc, char **argv)
show_tracers();
if (options)
- show_options();
+ show_options(NULL, NULL);
if (plug)
show_plugins();
@@ -747,7 +751,7 @@ void trace_list(int argc, char **argv)
printf("\ntracers:\n");
show_tracers();
printf("\noptions:\n");
- show_options();
+ show_options(NULL, NULL);
show_compression();
}
diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
index b4428e49..a5fb777b 100644
--- a/tracecmd/trace-stat.c
+++ b/tracecmd/trace-stat.c
@@ -835,7 +835,7 @@ static void report_traceon(struct buffer_instance *instance)
free(str);
}
-static void stat_instance(struct buffer_instance *instance)
+static void stat_instance(struct buffer_instance *instance, bool opt)
{
if (instance != &top_instance) {
if (instance != first_instance)
@@ -859,6 +859,10 @@ static void stat_instance(struct buffer_instance *instance)
report_file(instance, "set_event_pid", "", "Filtered event PIDs:\n");
report_file(instance, "set_ftrace_pid", "no pid",
"Filtered function tracer PIDs:\n");
+ if (opt) {
+ printf("\nOptions:\n");
+ show_options(" ", instance);
+ }
report_traceon(instance);
report_file(instance, "error_log", "", "Error log:\n");
if (instance == &top_instance)
@@ -868,6 +872,7 @@ static void stat_instance(struct buffer_instance *instance)
void trace_stat (int argc, char **argv)
{
struct buffer_instance *instance = &top_instance;
+ bool opt = false;
int topt = 0;
int status;
int c;
@@ -875,7 +880,7 @@ void trace_stat (int argc, char **argv)
init_top_instance();
for (;;) {
- c = getopt(argc-1, argv+1, "htB:");
+ c = getopt(argc-1, argv+1, "htoB:");
if (c == -1)
break;
switch (c) {
@@ -896,6 +901,9 @@ void trace_stat (int argc, char **argv)
topt = 1;
instance = &top_instance;
break;
+ case 'o':
+ opt = 1;
+ break;
default:
usage(argv);
}
@@ -904,7 +912,7 @@ void trace_stat (int argc, char **argv)
update_first_instance(instance, topt);
for_all_instances(instance) {
- stat_instance(instance);
+ stat_instance(instance, opt);
}
if (tracecmd_stack_tracer_status(&status) >= 0) {
diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c
index b5ef7733..20995fab 100644
--- a/tracecmd/trace-usage.c
+++ b/tracecmd/trace-usage.c
@@ -283,9 +283,10 @@ static struct usage_help usage_help[] = {
{
"stat",
"show the status of the running tracing (ftrace) system",
- " %s stat [-B buf][-t]"
+ " %s stat [-B buf][-t][-o]"
" -B show the status of a instance buffer\n"
" -t show the top level status along with buffer specified by -B\n"
+ " -o list tracing options\n"
},
{
"split",