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;
150 #undef TRACE_EVENT_FORMAT
151 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
152 _TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \
154 static struct ftrace_event_call event_##call; \
156 static void ftrace_raw_event_##call(proto) \
158 struct ring_buffer_event *event; \
159 struct ftrace_raw_##call *entry; \
160 unsigned long irq_flags; \
163 local_save_flags(irq_flags); \
164 pc = preempt_count(); \
166 event = trace_current_buffer_lock_reserve(event_##call.id, \
167 sizeof(struct ftrace_raw_##call), \
171 entry = ring_buffer_event_data(event); \
175 trace_current_buffer_unlock_commit(event, irq_flags, pc); \
178 static int ftrace_raw_reg_event_##call(void) \
182 ret = register_trace_##call(ftrace_raw_event_##call); \
184 pr_info("event trace: Could not activate trace point " \
185 "probe to " #call); \
189 static void ftrace_raw_unreg_event_##call(void) \
191 unregister_trace_##call(ftrace_raw_event_##call); \
194 static struct trace_event ftrace_event_type_##call = { \
195 .trace = ftrace_raw_output_##call, \
198 static int ftrace_raw_init_event_##call(void) \
202 id = register_ftrace_event(&ftrace_event_type_##call); \
205 event_##call.id = id; \
209 static struct ftrace_event_call __used \
210 __attribute__((__aligned__(4))) \
211 __attribute__((section("_ftrace_events"))) event_##call = { \
213 .system = STR(TRACE_SYSTEM), \
214 .regfunc = ftrace_reg_event_##call, \
215 .unregfunc = ftrace_unreg_event_##call, \
216 .raw_init = ftrace_raw_init_event_##call, \
217 .raw_reg = ftrace_raw_reg_event_##call, \
218 .raw_unreg = ftrace_raw_unreg_event_##call, \