tracing/function-return-tracer: change the name into function-graph-tracer
[safe/jmp/linux-2.6] / kernel / trace / trace_functions_graph.c
1 /*
2  *
3  * Function graph 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>
7  *
8  */
9 #include <linux/debugfs.h>
10 #include <linux/uaccess.h>
11 #include <linux/ftrace.h>
12 #include <linux/fs.h>
13
14 #include "trace.h"
15
16
17 #define TRACE_GRAPH_PRINT_OVERRUN       0x1
18 static struct tracer_opt trace_opts[] = {
19         /* Display overruns or not */
20         { TRACER_OPT(overrun, TRACE_GRAPH_PRINT_OVERRUN) },
21         { } /* Empty entry */
22 };
23
24 static struct tracer_flags tracer_flags = {
25         .val = 0, /* Don't display overruns by default */
26         .opts = trace_opts
27 };
28
29
30 static int graph_trace_init(struct trace_array *tr)
31 {
32         int cpu;
33         for_each_online_cpu(cpu)
34                 tracing_reset(tr, cpu);
35
36         return register_ftrace_graph(&trace_function_graph);
37 }
38
39 static void graph_trace_reset(struct trace_array *tr)
40 {
41                 unregister_ftrace_graph();
42 }
43
44
45 enum print_line_t
46 print_graph_function(struct trace_iterator *iter)
47 {
48         struct trace_seq *s = &iter->seq;
49         struct trace_entry *entry = iter->ent;
50         struct ftrace_graph_entry *field;
51         int ret;
52
53         if (entry->type == TRACE_FN_RET) {
54                 trace_assign_type(field, entry);
55                 ret = trace_seq_printf(s, "%pF -> ", (void *)field->parent_ip);
56                 if (!ret)
57                         return TRACE_TYPE_PARTIAL_LINE;
58
59                 ret = seq_print_ip_sym(s, field->ip,
60                                         trace_flags & TRACE_ITER_SYM_MASK);
61                 if (!ret)
62                         return TRACE_TYPE_PARTIAL_LINE;
63
64                 ret = trace_seq_printf(s, " (%llu ns)",
65                                         field->rettime - field->calltime);
66                 if (!ret)
67                         return TRACE_TYPE_PARTIAL_LINE;
68
69                 if (tracer_flags.val & TRACE_GRAPH_PRINT_OVERRUN) {
70                         ret = trace_seq_printf(s, " (Overruns: %lu)",
71                                                 field->overrun);
72                         if (!ret)
73                                 return TRACE_TYPE_PARTIAL_LINE;
74                 }
75
76                 ret = trace_seq_printf(s, "\n");
77                 if (!ret)
78                         return TRACE_TYPE_PARTIAL_LINE;
79
80                 return TRACE_TYPE_HANDLED;
81         }
82         return TRACE_TYPE_UNHANDLED;
83 }
84
85 static struct tracer graph_trace __read_mostly = {
86         .name        = "function-graph",
87         .init        = graph_trace_init,
88         .reset       = graph_trace_reset,
89         .print_line = print_graph_function,
90         .flags          = &tracer_flags,
91 };
92
93 static __init int init_graph_trace(void)
94 {
95         return register_tracer(&graph_trace);
96 }
97
98 device_initcall(init_graph_trace);