aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2021-04-16 13:23:29 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-03-15 12:15:29 -0400
commit75bcde2f70b8b5b3f7c46828c0503a9f66c29643 (patch)
tree51bdcd1ac1619deeb483728e552c210260dbd2da
parent37623725105f54a0708f692dca2ffaa169e652f6 (diff)
downloadtrace-cmd-75bcde2f70b8b5b3f7c46828c0503a9f66c29643.tar.gz
trace-cmd list: Have -o read the options directory instead of file
The trace_options file only shows the options that are available when a tracer is set. This is annoying as one needs to enable the tracer in order to see all the options that are available. Starting with Linux v4.4, all tracers options are displayed in the options directory. Walk through the options directory instead of simply reading the trace_options file. Link: https://lore.kernel.org/linux-trace-devel/20210416172331.3870833-2-rostedt@goodmis.org Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--tracecmd/trace-list.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index 900da73b..0574e563 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -399,13 +399,57 @@ static void show_tracers(void)
show_file("available_tracers");
}
-
static void show_options(void)
{
+ struct dirent *dent;
+ struct stat st;
+ char *path;
+ DIR *dir;
+
+ path = tracefs_get_tracing_file("options");
+ if (!path)
+ goto show_file;
+ if (stat(path, &st) < 0)
+ goto show_file;
+
+ if ((st.st_mode & S_IFMT) != S_IFDIR)
+ goto show_file;
+
+ dir = opendir(path);
+ if (!dir)
+ die("Can not read instance directory");
+
+ while ((dent = readdir(dir))) {
+ const char *name = dent->d_name;
+ long long val;
+ char *file;
+ int ret;
+
+ if (strcmp(name, ".") == 0 ||
+ strcmp(name, "..") == 0)
+ continue;
+
+ ret = asprintf(&file, "options/%s", name);
+ if (ret < 0)
+ die("Failed to allocate file name");
+ ret = tracefs_instance_file_read_number(NULL, file, &val);
+ if (!ret) {
+ if (val)
+ printf("%s\n", name);
+ else
+ printf("no%s\n", name);
+ }
+ free(file);
+ }
+ closedir(dir);
+ tracefs_put_tracing_file(path);
+ return;
+
+ show_file:
+ tracefs_put_tracing_file(path);
show_file("trace_options");
}
-
static void show_clocks(void)
{
char *clocks;