diff mbox series

libtracefs: Update tracing_dir in loading mapping files

Message ID 20210412104349.4d8f83b8@gandalf.local.home (mailing list archive)
State Accepted
Commit 4832d3cefddda1fb2efe3ec704c41ddf4d5941fd
Headers show
Series libtracefs: Update tracing_dir in loading mapping files | expand

Commit Message

Steven Rostedt April 12, 2021, 2:43 p.m. UTC
From 7209fe6bc43f79cb8d900ddb801050ff20e9b5a0 Mon Sep 17 00:00:00 2001
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Date: Mon, 12 Apr 2021 10:37:49 -0400
Subject: [PATCH] libtracefs: Update tracing_dir in loading mapping files

If tracing_dir is not a path to a tracing dir or simply NULL, then
load_saved_cmdlines() and load_printk_formats() will fail to load any
mappings.

Add a check for tracing_dir in the callers of those functions
(load_mappings() and tracefs_load_cmdlines()) to update tracing_dir to the
appropriate directory.

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

Patch

diff --git a/src/tracefs-events.c b/src/tracefs-events.c
index 3a6196b..2d90739 100644
--- a/src/tracefs-events.c
+++ b/src/tracefs-events.c
@@ -661,12 +661,27 @@  static void load_mappings(const char *tracing_dir,
 			  struct tep_handle *tep)
 {
 	load_kallsyms(tep);
+
+	/* If there's no tracing_dir no reason to go further */
+	if (!tracing_dir)
+		tracing_dir = tracefs_tracing_dir();
+
+	if (!tracing_dir)
+		return;
+
 	load_saved_cmdlines(tracing_dir, tep, false);
 	load_printk_formats(tracing_dir, tep);
 }
 
 int tracefs_load_cmdlines(const char *tracing_dir, struct tep_handle *tep)
 {
+
+	if (!tracing_dir)
+		tracing_dir = tracefs_tracing_dir();
+
+	if (!tracing_dir)
+		return -1;
+
 	return load_saved_cmdlines(tracing_dir, tep, true);
 }