[PATCH] libtraceevent: If function has arguments print them
Steven Rostedt <[email protected]> Fri, 4 Apr 2025 15:30:32 -0400
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
From: "Steven Rostedt (Google)" <[email protected]> Starting with v6.15, function tracer can hold arguments. If the event has them, then print them. Signed-off-by: Steven Rostedt (Google) <[email protected]> --- plugins/plugin_function.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/plugins/plugin_function.c b/plugins/plugin_function.c index 2d6509b..a337446 100644 --- a/plugins/plugin_function.c +++ b/plugins/plugin_function.c @@ -133,6 +133,39 @@ static void show_function(struct trace_seq *s, struct tep_handle *tep, } } +/* Returns true if it printed args, otherwise it returns false */ +static bool print_args(struct trace_seq *s, struct tep_event *event, + struct tep_record *record) +{ + struct tep_format_field *field; + unsigned long arg; + void *args; + int len; + + field = tep_find_field(event, "args"); + if (!field) + return false; + + len = record->size - field->offset; + + /* todo make this tep long size */ + if (len < 3 * sizeof(long)) + return false; + + args = record->data + field->offset; + + trace_seq_putc(s, '('); + + for (int i = 0; i < len; i += sizeof(long), args += sizeof(long)) { + memcpy(&arg, args, sizeof(long)); + trace_seq_printf(s, "%lx", arg); + if (i + sizeof(long) < len) + trace_seq_puts(s, ", "); + } + trace_seq_putc(s, ')'); + return true; +} + static int function_handler(struct trace_seq *s, struct tep_record *record, struct tep_event *event, void *context) { @@ -163,6 +196,8 @@ static int function_handler(struct trace_seq *s, struct tep_record *record, else trace_seq_printf(s, "0x%llx", function); + print_args(s, event, record); + if (ftrace_parent->set) { trace_seq_printf(s, " <-- "); if (parent) -- 2.47.2