diff mbox series

libtracefs: Load ftrace events in fill_local_events_systems()

Message ID 20201204170119.220692d8@gandalf.local.home (mailing list archive)
State Accepted
Headers show
Series libtracefs: Load ftrace events in fill_local_events_systems() | expand

Commit Message

Steven Rostedt Dec. 4, 2020, 10:01 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

While writing some code that used tracefs to access the tracefs directory,
and to load the tep events, I found that it was missing the ftrace events. I
enabled the userstacktrace option, but found that the tep handler returned
by tracefs_local_events_system() did not contain any ftrace event, and thus
I could not parse the user_stack events.

This was due to the fill_local_events_systems() checking against the list of
system names returned by tracefs_event_systems(), which returns the names of
all the system directories that have an "enable" file in them. As ftrace
events are special, and the directory is only for parsing purposes (not to
enable events), it was skipped due to the lack of an "enable" file.

Instead, after processing all the systems returned by tracefs_event_systems(),
check if the sys_names is NULL or matches "ftrace", and if it does, add the
ftrace events as well.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracefs-events.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/tracefs-events.c b/tracefs-events.c
index a792aeb..e2928d9 100644
--- a/tracefs-events.c
+++ b/tracefs-events.c
@@ -564,6 +564,11 @@  static int fill_local_events_system(const char *tracing_dir,
 		if (ret && parsing_failures)
 			(*parsing_failures)++;
 	}
+
+	/* Include ftrace, as it is excluded for not having "enable" file */
+	if (!sys_names || contains("ftrace", sys_names))
+		load_events(tep, tracing_dir, "ftrace");
+
 	/* always succeed because parsing failures are not critical */
 	ret = 0;
 out: