Skip to contentSkip to conversation

libtraceevent: Allow stack traces to show offset too

PATCH New Steven Rostedt 1 participant 1 message Dec 20, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtraceevent: Allow stack traces to show offset too

From: "Steven Rostedt (Google)" <[email protected]>

The stack traces only show the function name and the full address, which can be useless for running under gdb, because the address could be randomized, and to find the locations within the functions, the offsets from the start of the function really need to be displayed and not just the full address, as the address isn't known by gdb.

Have the function plugin "offset" option affect stack traces too. That way, there's a way to display the offsets of the functions too.

---
 plugins/plugin_function.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
plugins/plugin_function.c +5 -3
index 7777569f63b5..2d6509b430e4 100644
@@ -233,9 +233,11 @@ trace_stack_handler(struct trace_seq *s, struct tep_record *record,
 			break;
 
 		func = tep_find_function(event->tep, addr);
-		if (func)
-			trace_seq_printf(s, "=> %s (%llx)\n", func, addr);
-		else
+		if (func) {
+			trace_seq_puts(s, "=> ");
+			show_function(s, event->tep, func, addr);
+			trace_seq_printf(s, " (%llx)\n", addr);
+		} else
 			trace_seq_printf(s, "=> %llx\n", addr);
 	}
 
Signature · 1 line
2.35.1