Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6] / kernel / trace / trace_events.h
1 #ifndef _LINUX_KERNEL_TRACE_EVENTS_H
2 #define _LINUX_KERNEL_TRACE_EVENTS_H
3
4 #include <linux/debugfs.h>
5 #include <linux/ftrace.h>
6 #include "trace.h"
7
8 struct ftrace_event_call {
9         char            *name;
10         struct dentry   *dir;
11         int             enabled;
12         int             (*regfunc)(void);
13         void            (*unregfunc)(void);
14 };
15
16
17 #undef TPFMT
18 #define TPFMT(fmt, args...)     fmt "\n", ##args
19
20 #undef TRACE_FORMAT
21 #define TRACE_FORMAT(call, proto, args, fmt)                            \
22 static void ftrace_event_##call(proto)                                  \
23 {                                                                       \
24         event_trace_printk(_RET_IP_, "(" #call ") " fmt);               \
25 }                                                                       \
26                                                                         \
27 static int ftrace_reg_event_##call(void)                                \
28 {                                                                       \
29         int ret;                                                        \
30                                                                         \
31         ret = register_trace_##call(ftrace_event_##call);               \
32         if (!ret)                                                       \
33                 pr_info("event trace: Could not activate trace point "  \
34                         "probe to " #call);                             \
35         return ret;                                                     \
36 }                                                                       \
37                                                                         \
38 static void ftrace_unreg_event_##call(void)                             \
39 {                                                                       \
40         unregister_trace_##call(ftrace_event_##call);                   \
41 }                                                                       \
42                                                                         \
43 static struct ftrace_event_call __used                                  \
44 __attribute__((__aligned__(4)))                                         \
45 __attribute__((section("_ftrace_events"))) event_##call = {             \
46         .name                   = #call,                                \
47         .regfunc                = ftrace_reg_event_##call,              \
48         .unregfunc              = ftrace_unreg_event_##call,            \
49 }
50
51 void event_trace_printk(unsigned long ip, const char *fmt, ...);
52 extern struct ftrace_event_call __start_ftrace_events[];
53 extern struct ftrace_event_call __stop_ftrace_events[];
54
55 #endif /* _LINUX_KERNEL_TRACE_EVENTS_H */