diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2008-11-25 15:07:04 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-25 19:59:45 -0500 |
commit | fb52607afcd0629776f1dc9e657647ceae81dd50 (patch) | |
tree | 7bf43b41ff8510d3098c089913cce56a9049f0fd /kernel/trace/trace_functions_graph.c | |
parent | 509dceef6470442d8c7b8a43ec34125205840b3c (diff) |
tracing/function-return-tracer: change the name into function-graph-tracer
Impact: cleanup
This patch changes the name of the "return function tracer" into
function-graph-tracer which is a more suitable name for a tracing
which makes one able to retrieve the ordered call stack during
the code flow.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_functions_graph.c')
-rw-r--r-- | kernel/trace/trace_functions_graph.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c new file mode 100644 index 000000000000..f5bad4624d2b --- /dev/null +++ b/kernel/trace/trace_functions_graph.c | |||
@@ -0,0 +1,98 @@ | |||
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); | ||