aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_branch.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2008-12-23 23:24:13 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-29 06:46:12 -0500
commitf633cef0200bbaec539e2dbb0bc4bed7f022f98b (patch)
tree725d0b181b8e417303e27fa9e62d06b780fe4934 /kernel/trace/trace_branch.c
parentf0868d1e23a8efec33beb3aa688aab7fdb1ae093 (diff)
ftrace: change trace.c to use registered events
Impact: rework trace.c to use new event register API Almost every ftrace event has to implement its output display in trace.c through a different function. Some events did not handle all the formats (trace, latency-trace, raw, hex, binary), and this method does not scale well. This patch converts the format functions to use the event API to find the event and and print its format. Currently, we have a print function for trace, latency_trace, raw, hex and binary. A trace_nop_print is available if the event wants to avoid output on a particular format. Perhaps other tracers could use this in the future (like mmiotrace and function_graph). Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_branch.c')
-rw-r--r--kernel/trace/trace_branch.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index 6c00feb3bac7..c15222a01073 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -14,7 +14,9 @@
14#include <linux/hash.h> 14#include <linux/hash.h>
15#include <linux/fs.h> 15#include <linux/fs.h>
16#include <asm/local.h> 16#include <asm/local.h>
17
17#include "trace.h" 18#include "trace.h"
19#include "trace_output.h"
18 20
19#ifdef CONFIG_BRANCH_TRACER 21#ifdef CONFIG_BRANCH_TRACER
20 22
@@ -142,6 +144,49 @@ static void branch_trace_reset(struct trace_array *tr)
142 stop_branch_trace(tr); 144 stop_branch_trace(tr);
143} 145}
144 146
147static int
148trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags)
149{
150 struct print_entry *field;
151
152 trace_assign_type(field, entry);
153
154 if (seq_print_ip_sym(s, field->ip, flags))
155 goto partial;
156
157 if (trace_seq_printf(s, ": %s", field->buf))
158 goto partial;
159
160 partial:
161 return TRACE_TYPE_PARTIAL_LINE;
162}
163
164static int
165trace_branch_print(struct trace_seq *s, struct trace_entry *entry, int flags)
166{
167 struct trace_branch *field;
168
169 trace_assign_type(field, entry);
170
171 if (trace_seq_printf(s, "[%s] %s:%s:%d\n",
172 field->correct ? " ok " : " MISS ",
173 field->func,
174 field->file,
175 field->line))
176 return TRACE_TYPE_PARTIAL_LINE;
177
178 return 0;
179}
180
181static struct trace_event trace_branch_event = {
182 .type = TRACE_BRANCH,
183 .trace = trace_branch_print,
184 .latency_trace = trace_branch_print,
185 .raw = trace_nop_print,
186 .hex = trace_nop_print,
187 .binary = trace_nop_print,
188};
189
145struct tracer branch_trace __read_mostly = 190struct tracer branch_trace __read_mostly =
146{ 191{
147 .name = "branch", 192 .name = "branch",
@@ -154,6 +199,14 @@ struct tracer branch_trace __read_mostly =
154 199
155__init static int init_branch_trace(void) 200__init static int init_branch_trace(void)
156{ 201{
202 int ret;
203
204 ret = register_ftrace_event(&trace_branch_event);
205 if (!ret) {
206 printk(KERN_WARNING "Warning: could not register branch events\n");
207 return 1;
208 }
209
157 return register_tracer(&branch_trace); 210 return register_tracer(&branch_trace);
158} 211}
159 212