diff options
author | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2017-05-09 17:16:40 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2017-05-09 17:16:40 -0400 |
commit | 1785022e12cf0079889c519ffc7157f2143326ea (patch) | |
tree | a983e8d6527eda284dc095d87699a4d375c82895 | |
parent | c189fab6b30c1c7240addf6f1fdf732591e758c7 (diff) | |
download | trace-cmd-1785022e12cf0079889c519ffc7157f2143326ea.tar.gz |
When -O offset is added to trace-cmd report with the function plugin
enabled, it will display the offset of the functions along with their names.
This helps in finding exactly where a function was called by its parent.
trace-cmd report -O parent -O offset
[..]
rcuc/163-1330 [163] 740.653251: function: _raw_spin_lock+0x0 <-- rcu_cpu_kthread+0x4d8
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | plugin_function.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/plugin_function.c b/plugin_function.c index 1e88a7f7..5f13a21f 100644 --- a/plugin_function.c +++ b/plugin_function.c @@ -49,12 +49,20 @@ struct pevent_plugin_option plugin_options[] = .set = 1, }, { + .name = "offset", + .plugin_alias = "ftrace", + .description = + "Show function names as well as their offsets", + .set = 0, + }, + { .name = NULL, } }; static struct pevent_plugin_option *ftrace_parent = &plugin_options[0]; static struct pevent_plugin_option *ftrace_indent = &plugin_options[1]; +static struct pevent_plugin_option *ftrace_offset = &plugin_options[2]; static void add_child(struct func_stack *stack, const char *child, int pos) { @@ -122,6 +130,18 @@ static int add_and_get_index(const char *parent, const char *child, int cpu) return 0; } +static void show_function(struct trace_seq *s, struct pevent *pevent, + const char *func, unsigned long long function) +{ + unsigned long long offset; + + trace_seq_printf(s, "%s", func); + if (ftrace_offset->set) { + offset = pevent_find_function_address(pevent, function); + trace_seq_printf(s, "+0x%x ", (int)(function - offset)); + } +} + static int function_handler(struct trace_seq *s, struct pevent_record *record, struct event_format *event, void *context) { @@ -148,14 +168,14 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record, trace_seq_printf(s, "%*s", index*3, ""); if (func) - trace_seq_printf(s, "%s", func); + show_function(s, pevent, func, function); else trace_seq_printf(s, "0x%llx", function); if (ftrace_parent->set) { trace_seq_printf(s, " <-- "); if (parent) - trace_seq_printf(s, "%s", parent); + show_function(s, pevent, parent, pfunction); else trace_seq_printf(s, "0x%llx", pfunction); } |