aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.h
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-08-13 16:35:11 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-08-26 20:31:54 -0400
commit413d37d1eb69c1765b9ace0a612dac9b6c990e66 (patch)
tree6f483714046c388ab9f57b33f17f365cd4e57446 /kernel/trace/trace.h
parentd93f12f3f417e49a175800da85c6fcb2a5096e03 (diff)
tracing: Add kprobe-based event tracer
Add kprobes-based event tracer on ftrace. This tracer is similar to the events tracer which is based on Tracepoint infrastructure. Instead of Tracepoint, this tracer is based on kprobes (kprobe and kretprobe). It probes anywhere where kprobes can probe(this means, all functions body except for __kprobes functions). Similar to the events tracer, this tracer doesn't need to be activated via current_tracer, instead of that, just set probe points via /sys/kernel/debug/tracing/kprobe_events. And you can set filters on each probe events via /sys/kernel/debug/tracing/events/kprobes/<EVENT>/filter. This tracer supports following probe arguments for each probe. %REG : Fetch register REG sN : Fetch Nth entry of stack (N >= 0) sa : Fetch stack address. @ADDR : Fetch memory at ADDR (ADDR should be in kernel) @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol) aN : Fetch function argument. (N >= 0) rv : Fetch return value. ra : Fetch return address. +|-offs(FETCHARG) : fetch memory at FETCHARG +|- offs address. See Documentation/trace/kprobetrace.txt in the next patch for details. Changes from v13: - Support 'sa' for stack address. - Use call->data instead of container_of() macro. [fweisbec@gmail.com: Fixed conflict against latest tracing/core] Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Avi Kivity <avi@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jason Baron <jbaron@redhat.com> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: K.Prasad <prasad@linux.vnet.ibm.com> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Przemysław Pawełczyk <przemyslaw@pawelczyk.it> Cc: Roland McGrath <roland@redhat.com> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Vegard Nossum <vegard.nossum@gmail.com> LKML-Reference: <20090813203510.31965.29123.stgit@localhost.localdomain> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r--kernel/trace/trace.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 654fd657bd03..667f832d16b7 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -38,6 +38,8 @@ enum trace_type {
38 TRACE_KMEM_FREE, 38 TRACE_KMEM_FREE,
39 TRACE_POWER, 39 TRACE_POWER,
40 TRACE_BLK, 40 TRACE_BLK,
41 TRACE_KPROBE,
42 TRACE_KRETPROBE,
41 43
42 __TRACE_LAST_TYPE, 44 __TRACE_LAST_TYPE,
43}; 45};
@@ -205,6 +207,30 @@ struct syscall_trace_exit {
205 unsigned long ret; 207 unsigned long ret;
206}; 208};
207 209
210struct kprobe_trace_entry {
211 struct trace_entry ent;
212 unsigned long ip;
213 int nargs;
214 unsigned long args[];
215};
216
217#define SIZEOF_KPROBE_TRACE_ENTRY(n) \
218 (offsetof(struct kprobe_trace_entry, args) + \
219 (sizeof(unsigned long) * (n)))
220
221struct kretprobe_trace_entry {
222 struct trace_entry ent;
223 unsigned long func;
224 unsigned long ret_ip;
225 int nargs;
226 unsigned long args[];
227};
228
229#define SIZEOF_KRETPROBE_TRACE_ENTRY(n) \
230 (offsetof(struct kretprobe_trace_entry, args) + \
231 (sizeof(unsigned long) * (n)))
232
233
208 234
209/* 235/*
210 * trace_flag_type is an enumeration that holds different 236 * trace_flag_type is an enumeration that holds different
@@ -317,6 +343,10 @@ extern void __ftrace_bad_type(void);
317 TRACE_KMEM_ALLOC); \ 343 TRACE_KMEM_ALLOC); \
318 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \ 344 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \
319 TRACE_KMEM_FREE); \ 345 TRACE_KMEM_FREE); \
346 IF_ASSIGN(var, ent, struct kprobe_trace_entry, \
347 TRACE_KPROBE); \
348 IF_ASSIGN(var, ent, struct kretprobe_trace_entry, \
349 TRACE_KRETPROBE); \
320 __ftrace_bad_type(); \ 350 __ftrace_bad_type(); \
321 } while (0) 351 } while (0)
322 352