aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_kprobe.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-04-22 18:46:14 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-05-14 14:20:32 -0400
commita9a5776380208a3e48a92d0c763ee1a3b486fb73 (patch)
tree5ecd41c3b373e2156f5bf748ae777e022296a30c /kernel/trace/trace_kprobe.c
parent0405ab80aa94afb13bf9ac4a6fc9f2923d4b9114 (diff)
tracing: Allow events to share their print functions
Multiple events may use the same method to print their data. Instead of having all events have a pointer to their print funtions, the trace_event structure now points to a trace_event_functions structure that will hold the way to print ouf the event. The event itself is now passed to the print function to let the print function know what kind of event it should print. This opens the door to consolidating the way several events print their output. text data bss dec hex filename 4913961 1088356 861512 6863829 68bbd5 vmlinux.orig 4900382 1048964 861512 6810858 67ecea vmlinux.init 4900446 1049028 861512 6810986 67ed6a vmlinux.preprint This change slightly increases the size but is needed for the next change. v3: Fix the branch tracer events to handle this change. v2: Fix the new function graph tracer event calls to handle this change. Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Acked-by: Masami Hiramatsu <mhiramat@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_kprobe.c')
-rw-r--r--kernel/trace/trace_kprobe.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 428f4a52de69..b989ae229a20 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1011,16 +1011,15 @@ static __kprobes void kretprobe_trace_func(struct kretprobe_instance *ri,
1011 1011
1012/* Event entry printers */ 1012/* Event entry printers */
1013enum print_line_t 1013enum print_line_t
1014print_kprobe_event(struct trace_iterator *iter, int flags) 1014print_kprobe_event(struct trace_iterator *iter, int flags,
1015 struct trace_event *event)
1015{ 1016{
1016 struct kprobe_trace_entry *field; 1017 struct kprobe_trace_entry *field;
1017 struct trace_seq *s = &iter->seq; 1018 struct trace_seq *s = &iter->seq;
1018 struct trace_event *event;
1019 struct trace_probe *tp; 1019 struct trace_probe *tp;
1020 int i; 1020 int i;
1021 1021
1022 field = (struct kprobe_trace_entry *)iter->ent; 1022 field = (struct kprobe_trace_entry *)iter->ent;
1023 event = ftrace_find_event(field->ent.type);
1024 tp = container_of(event, struct trace_probe, event); 1023 tp = container_of(event, struct trace_probe, event);
1025 1024
1026 if (!trace_seq_printf(s, "%s: (", tp->call.name)) 1025 if (!trace_seq_printf(s, "%s: (", tp->call.name))
@@ -1046,16 +1045,15 @@ partial:
1046} 1045}
1047 1046
1048enum print_line_t 1047enum print_line_t
1049print_kretprobe_event(struct trace_iterator *iter, int flags) 1048print_kretprobe_event(struct trace_iterator *iter, int flags,
1049 struct trace_event *event)
1050{ 1050{
1051 struct kretprobe_trace_entry *field; 1051 struct kretprobe_trace_entry *field;
1052 struct trace_seq *s = &iter->seq; 1052 struct trace_seq *s = &iter->seq;
1053 struct trace_event *event;
1054 struct trace_probe *tp; 1053 struct trace_probe *tp;
1055 int i; 1054 int i;
1056 1055
1057 field = (struct kretprobe_trace_entry *)iter->ent; 1056 field = (struct kretprobe_trace_entry *)iter->ent;
1058 event = ftrace_find_event(field->ent.type);
1059 tp = container_of(event, struct trace_probe, event); 1057 tp = container_of(event, struct trace_probe, event);
1060 1058
1061 if (!trace_seq_printf(s, "%s: (", tp->call.name)) 1059 if (!trace_seq_printf(s, "%s: (", tp->call.name))
@@ -1351,6 +1349,14 @@ int kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs)
1351 return 0; /* We don't tweek kernel, so just return 0 */ 1349 return 0; /* We don't tweek kernel, so just return 0 */
1352} 1350}
1353 1351
1352static struct trace_event_functions kretprobe_funcs = {
1353 .trace = print_kretprobe_event
1354};
1355
1356static struct trace_event_functions kprobe_funcs = {
1357 .trace = print_kprobe_event
1358};
1359
1354static int register_probe_event(struct trace_probe *tp) 1360static int register_probe_event(struct trace_probe *tp)
1355{ 1361{
1356 struct ftrace_event_call *call = &tp->call; 1362 struct ftrace_event_call *call = &tp->call;
@@ -1358,13 +1364,13 @@ static int register_probe_event(struct trace_probe *tp)
1358 1364
1359 /* Initialize ftrace_event_call */ 1365 /* Initialize ftrace_event_call */
1360 if (probe_is_return(tp)) { 1366 if (probe_is_return(tp)) {
1361 tp->event.trace = print_kretprobe_event; 1367 tp->event.funcs = &kretprobe_funcs;
1362 INIT_LIST_HEAD(&call->class->fields); 1368 INIT_LIST_HEAD(&call->class->fields);
1363 call->class->raw_init = probe_event_raw_init; 1369 call->class->raw_init = probe_event_raw_init;
1364 call->class->define_fields = kretprobe_event_define_fields; 1370 call->class->define_fields = kretprobe_event_define_fields;
1365 } else { 1371 } else {
1366 INIT_LIST_HEAD(&call->class->fields); 1372 INIT_LIST_HEAD(&call->class->fields);
1367 tp->event.trace = print_kprobe_event; 1373 tp->event.funcs = &kprobe_funcs;
1368 call->class->raw_init = probe_event_raw_init; 1374 call->class->raw_init = probe_event_raw_init;
1369 call->class->define_fields = kprobe_event_define_fields; 1375 call->class->define_fields = kprobe_event_define_fields;
1370 } 1376 }