diff mbox series

[1/4] libtracefs: Reuse logic for loading events inside the library

Message ID 20211130050057.336228-2-tz.stoyanov@gmail.com (mailing list archive)
State Superseded
Headers show
Series New tracefs APIs | expand

Commit Message

Tzvetomir Stoyanov (VMware) Nov. 30, 2021, 5 a.m. UTC
The logic for parsing and loading new tep events could be reused in
tracefs library. The function load_events() is exposed as internal API.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 include/tracefs-local.h |  3 +++
 src/tracefs-events.c    | 11 +++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/include/tracefs-local.h b/include/tracefs-local.h
index a59e806..0540956 100644
--- a/include/tracefs-local.h
+++ b/include/tracefs-local.h
@@ -112,4 +112,7 @@  dynevent_alloc(enum tracefs_dynevent_type type, const char *system,
 	       const char *event, const char *address, const char *format);
 int dynevent_get_count(unsigned int types, const char *system);
 
+int trace_load_events(struct tep_handle *tep,
+		      const char *tracing_dir, const char *system);
+
 #endif /* _TRACE_FS_LOCAL_H */
diff --git a/src/tracefs-events.c b/src/tracefs-events.c
index 4679926..e3962e5 100644
--- a/src/tracefs-events.c
+++ b/src/tracefs-events.c
@@ -688,8 +688,8 @@  char **tracefs_tracers(const char *tracing_dir)
 	return plugins;
 }
 
-static int load_events(struct tep_handle *tep,
-		       const char *tracing_dir, const char *system)
+__hidden int trace_load_events(struct tep_handle *tep,
+			       const char *tracing_dir, const char *system)
 {
 	int ret = 0, failure = 0;
 	char **events = NULL;
@@ -697,6 +697,9 @@  static int load_events(struct tep_handle *tep,
 	int len = 0;
 	int i;
 
+	if (!tracing_dir)
+		tracing_dir = tracefs_tracing_dir();
+
 	events = tracefs_system_events(tracing_dir, system);
 	if (!events)
 		return -ENOENT;
@@ -886,14 +889,14 @@  static int fill_local_events_system(const char *tracing_dir,
 	for (i = 0; systems[i]; i++) {
 		if (sys_names && !contains(systems[i], sys_names))
 			continue;
-		ret = load_events(tep, tracing_dir, systems[i]);
+		ret = trace_load_events(tep, tracing_dir, systems[i]);
 		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");
+		trace_load_events(tep, tracing_dir, "ftrace");
 
 	load_mappings(tracing_dir, tep);