3 * Function return tracer.
4 * Copyright (c) 2008 Frederic Weisbecker <fweisbec@gmail.com>
5 * Mostly borrowed from function tracer which
6 * is Copyright (c) Steven Rostedt <srostedt@redhat.com>
9 #include <linux/debugfs.h>
10 #include <linux/uaccess.h>
11 #include <linux/ftrace.h>
17 static void start_return_trace(struct trace_array *tr)
19 register_ftrace_return(&trace_function_return);
22 static void stop_return_trace(struct trace_array *tr)
24 unregister_ftrace_return();
27 static void return_trace_init(struct trace_array *tr)
30 for_each_online_cpu(cpu)
31 tracing_reset(tr, cpu);
33 start_return_trace(tr);
36 static void return_trace_reset(struct trace_array *tr)
38 stop_return_trace(tr);
43 print_return_function(struct trace_iterator *iter)
45 struct trace_seq *s = &iter->seq;
46 struct trace_entry *entry = iter->ent;
47 struct ftrace_ret_entry *field;
50 if (entry->type == TRACE_FN_RET) {
51 trace_assign_type(field, entry);
52 ret = trace_seq_printf(s, "%pF -> ", (void *)field->parent_ip);
54 return TRACE_TYPE_PARTIAL_LINE;
55 ret = seq_print_ip_sym(s, field->ip,
56 trace_flags & TRACE_ITER_SYM_MASK);
58 return TRACE_TYPE_PARTIAL_LINE;
59 ret = trace_seq_printf(s, " (%llu ns)\n",
60 field->rettime - field->calltime);
62 return TRACE_TYPE_PARTIAL_LINE;
64 return TRACE_TYPE_HANDLED;
66 return TRACE_TYPE_UNHANDLED;
69 static struct tracer return_trace __read_mostly =
72 .init = return_trace_init,
73 .reset = return_trace_reset,
74 .print_line = print_return_function
77 static __init int init_return_trace(void)
79 return register_tracer(&return_trace);
82 device_initcall(init_return_trace);