diff mbox series

[v3,4/4] trace-cmd list: Add ftrace events to listing of events

Message ID 20210506165203.3889058-5-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 9d3b3f80b606ec47053b029d8b936f08cb673828
Headers show
Series trace-cmd list: Include ftrace in event listings | expand

Commit Message

Steven Rostedt May 6, 2021, 4:52 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

If a search of events is done with trace-cmd list -e, check if any matches
the ftrace events. This is useful to get the fields and print fmt of the
events under the ftrace system.

Note, just "trace-cmd list -e" will still not list ftrace events by
default.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-list.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index 1b32af17..d060c810 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -158,6 +158,7 @@  static void match_system_events(process_file_func func, const char *system,
 
 static void process_events(process_file_func func, const char *re, int flags)
 {
+	const char *ftrace = "ftrace";
 	regex_t system_reg;
 	regex_t event_reg;
 	char *str;
@@ -200,6 +201,19 @@  static void process_events(process_file_func func, const char *re, int flags)
 	}
 	free(str);
 
+	/*
+	 * See if this matches the special ftrace system, as ftrace is not included
+	 * in the systems list, but can get events from tracefs_system_events().
+	 */
+	if (regexec(&system_reg, ftrace, 0, NULL, 0) == 0) {
+		if (!event)
+			show_system(func, ftrace, flags);
+		else
+			match_system_events(func, ftrace, &event_reg, flags);
+	} else if (!just_systems) {
+		match_system_events(func, ftrace, &system_reg, flags);
+	}
+
 	for (s = 0; systems[s]; s++) {
 
 		if (regexec(&system_reg, systems[s], 0, NULL, 0) == 0) {