Skip to contentSkip to conversation

libtracefs: Update tracing_dir in loading mapping files

PATCH New Steven Rostedt 1 participant 1 message Apr 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracefs: Update tracing_dir in loading mapping files

From 7209fe6bc43f79cb8d900ddb801050ff20e9b5a0 Mon Sep 17 00:00:00 2001
From: "Steven Rostedt (VMware)" <[email protected]>
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.

---
 src/tracefs-events.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
src/tracefs-events.c +15 -0
index 3a6196b..2d90739 100644
@@ -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);
 }
 
Signature · 1 line
2.29.2