2 * Stage 3 of the trace events.
4 * Override the macros in <trace/trace_event_types.h> to include the following:
6 * static void ftrace_event_<call>(proto)
8 * event_trace_printk(_RET_IP_, "(<call>) " <fmt>);
11 * static int ftrace_reg_event_<call>(void)
15 * ret = register_trace_<call>(ftrace_event_<call>);
17 * pr_info("event trace: Could not activate trace point "
22 * static void ftrace_unreg_event_<call>(void)
24 * unregister_trace_<call>(ftrace_event_<call>);
27 * For those macros defined with TRACE_FORMAT:
29 * static struct ftrace_event_call __used
30 * __attribute__((__aligned__(4)))
31 * __attribute__((section("_ftrace_events"))) event_<call> = {
33 * .regfunc = ftrace_reg_event_<call>,
34 * .unregfunc = ftrace_unreg_event_<call>,
38 * For those macros defined with TRACE_EVENT_FORMAT:
40 * static struct ftrace_event_call event_<call>;
42 * static void ftrace_raw_event_<call>(proto)
44 * struct ring_buffer_event *event;
45 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
46 * unsigned long irq_flags;
49 * local_save_flags(irq_flags);
50 * pc = preempt_count();
52 * event = trace_current_buffer_lock_reserve(event_<call>.id,
53 * sizeof(struct ftrace_raw_<call>),
57 * entry = ring_buffer_event_data(event);
59 * <tstruct>; <-- Here we assign the entries by the TRACE_FIELD.
61 * trace_current_buffer_unlock_commit(event, irq_flags, pc);
64 * static int ftrace_raw_reg_event_<call>(void)
68 * ret = register_trace_<call>(ftrace_raw_event_<call>);
70 * pr_info("event trace: Could not activate trace point "
75 * static void ftrace_unreg_event_<call>(void)
77 * unregister_trace_<call>(ftrace_raw_event_<call>);
80 * static struct trace_event ftrace_event_type_<call> = {
81 * .trace = ftrace_raw_output_<call>, <-- stage 2
84 * static int ftrace_raw_init_event_<call>(void)
88 * id = register_ftrace_event(&ftrace_event_type_<call>);
91 * event_<call>.id = id;
95 * static struct ftrace_event_call __used
96 * __attribute__((__aligned__(4)))
97 * __attribute__((section("_ftrace_events"))) event_<call> = {
99 * .regfunc = ftrace_reg_event_<call>,
100 * .unregfunc = ftrace_unreg_event_<call>,
101 * .raw_init = ftrace_raw_init_event_<call>,
102 * .raw_reg = ftrace_raw_reg_event_<call>,
103 * .raw_unreg = ftrace_raw_unreg_event_<call>,
109 #define TPFMT(fmt, args...) fmt "\n", ##args
111 #define _TRACE_FORMAT(call, proto, args, fmt) \
112 static void ftrace_event_##call(proto) \
114 event_trace_printk(_RET_IP_, "(" #call ") " fmt); \
117 static int ftrace_reg_event_##call(void) \
121 ret = register_trace_##call(ftrace_event_##call); \
123 pr_info("event trace: Could not activate trace point " \
124 "probe to " #call); \
128 static void ftrace_unreg_event_##call(void) \
130 unregister_trace_##call(ftrace_event_##call); \
135 #define TRACE_FORMAT(call, proto, args, fmt) \
136 _TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \
137 static struct ftrace_event_call __used \
138 __attribute__((__aligned__(4))) \
139 __attribute__((section("_ftrace_events"))) event_##call = { \
141 .system = STR(TRACE_SYSTEM), \
142 .regfunc = ftrace_reg_event_##call, \
143 .unregfunc = ftrace_unreg_event_##call, \
147 #define TRACE_FIELD(type, item, assign)\
148 entry->item = assign;
151 #define TRACE_FIELD(type, item, assign)\
152 entry->item = assign;
155 #define TPCMD(cmd...) cmd
158 #define TRACE_ENTRY entry
160 #undef TRACE_FIELD_SPECIAL
161 #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
164 #undef TRACE_EVENT_FORMAT
165 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
166 _TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \
168 static struct ftrace_event_call event_##call; \
170 static void ftrace_raw_event_##call(proto) \
172 struct ring_buffer_event *event; \
173 struct ftrace_raw_##call *entry; \
174 unsigned long irq_flags; \
177 local_save_flags(irq_flags); \
178 pc = preempt_count(); \
180 event = trace_current_buffer_lock_reserve(event_##call.id, \
181 sizeof(struct ftrace_raw_##call), \
185 entry = ring_buffer_event_data(event); \
189 trace_current_buffer_unlock_commit(event, irq_flags, pc); \
192 static int ftrace_raw_reg_event_##call(void) \
196 ret = register_trace_##call(ftrace_raw_event_##call); \
198 pr_info("event trace: Could not activate trace point " \
199 "probe to " #call); \
203 static void ftrace_raw_unreg_event_##call(void) \
205 unregister_trace_##call(ftrace_raw_event_##call); \
208 static struct trace_event ftrace_event_type_##call = { \
209 .trace = ftrace_raw_output_##call, \
212 static int ftrace_raw_init_event_##call(void) \
216 id = register_ftrace_event(&ftrace_event_type_##call); \
219 event_##call.id = id; \
223 static struct ftrace_event_call __used \
224 __attribute__((__aligned__(4))) \
225 __attribute__((section("_ftrace_events"))) event_##call = { \
227 .system = STR(TRACE_SYSTEM), \
228 .regfunc = ftrace_reg_event_##call, \
229 .unregfunc = ftrace_unreg_event_##call, \
230 .raw_init = ftrace_raw_init_event_##call, \
231 .raw_reg = ftrace_raw_reg_event_##call, \
232 .raw_unreg = ftrace_raw_unreg_event_##call, \