* [PATCH] trace-cmd: Add option "-s" to list subcommand, to display available event systems
@ 2020-05-04 8:06 Tzvetomir Stoyanov (VMware)
0 siblings, 0 replies; only message in thread
From: Tzvetomir Stoyanov (VMware) @ 2020-05-04 8:06 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel
Extend "trace-cmd list" command to show available event systems. Printing
the systems is triggered by the "-s" flag, or if no flags are
specified (part of "show all" output).
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207485
Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
tracecmd/trace-list.c | 47 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index f046304d..c9abcd73 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -5,6 +5,7 @@
*/
#include <stdlib.h>
+#include <sys/stat.h>
#include "tracefs.h"
#include "trace-local.h"
@@ -306,6 +307,42 @@ static void show_buffers(void)
}
+static void show_systems(void)
+{
+ struct dirent *dent;
+ char *path;
+ DIR *dir;
+
+ path = tracefs_get_tracing_file("events");
+ dir = opendir(path);
+
+ if (!dir)
+ die("Can not read events directory");
+
+ while ((dent = readdir(dir))) {
+ const char *name = dent->d_name;
+ struct stat st;
+ char *spath;
+ int ret;
+
+ if (strcmp(name, ".") == 0 ||
+ strcmp(name, "..") == 0)
+ continue;
+
+ if (asprintf(&spath, "%s/%s", path, name) < 0)
+ continue;
+ ret = stat(spath, &st);
+ if (!ret && S_ISDIR(st.st_mode))
+ printf("%s\n", name);
+
+ free(spath);
+ }
+
+ printf("\n");
+ closedir(dir);
+ tracefs_put_tracing_file(path);
+}
+
static void show_plugin_options(void)
{
struct tep_handle *pevent;
@@ -366,6 +403,7 @@ void trace_list(int argc, char **argv)
int plug = 0;
int plug_op = 0;
int flags = 0;
+ int systems = 0;
int show_all = 1;
int i;
const char *arg;
@@ -427,6 +465,10 @@ void trace_list(int argc, char **argv)
funcre = arg;
show_all = 0;
break;
+ case 's':
+ systems = 1;
+ show_all = 0;
+ break;
case '-':
if (strcmp(argv[i], "--debug") == 0) {
tracecmd_set_debug(true);
@@ -465,8 +507,11 @@ void trace_list(int argc, char **argv)
if (clocks)
show_clocks();
-
+ if (systems)
+ show_systems();
if (show_all) {
+ printf("event systems:\n");
+ show_systems();
printf("events:\n");
show_events(NULL, 0);
printf("\ntracers:\n");
--
2.26.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-04 8:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 8:06 [PATCH] trace-cmd: Add option "-s" to list subcommand, to display available event systems Tzvetomir Stoyanov (VMware)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).