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>,
104 * .show_format = ftrace_format_<call>,
110 #define TP_FMT(fmt, args...) fmt "\n", ##args
112 #define _TRACE_FORMAT(call, proto, args, fmt) \
113 static void ftrace_event_##call(proto) \
115 event_trace_printk(_RET_IP_, #call ": " fmt); \
118 static int ftrace_reg_event_##call(void) \
122 ret = register_trace_##call(ftrace_event_##call); \
124 pr_info("event trace: Could not activate trace point " \
125 "probe to " #call "\n"); \
129 static void ftrace_unreg_event_##call(void) \
131 unregister_trace_##call(ftrace_event_##call); \
136 #define TRACE_FORMAT(call, proto, args, fmt) \
137 _TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \
138 static struct ftrace_event_call __used \
139 __attribute__((__aligned__(4))) \
140 __attribute__((section("_ftrace_events"))) event_##call = { \
142 .system = STR(TRACE_SYSTEM), \
143 .regfunc = ftrace_reg_event_##call, \
144 .unregfunc = ftrace_unreg_event_##call, \
148 #define TRACE_FIELD(type, item, assign)\
149 entry->item = assign;
152 #define TRACE_FIELD(type, item, assign)\
153 entry->item = assign;
156 #define TP_CMD(cmd...) cmd
159 #define TRACE_ENTRY entry
161 #undef TRACE_FIELD_SPECIAL
162 #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
165 #undef TRACE_EVENT_FORMAT
166 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
167 _TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \
169 static struct ftrace_event_call event_##call; \
171 static void ftrace_raw_event_##call(proto) \
173 struct ring_buffer_event *event; \
174 struct ftrace_raw_##call *entry; \
175 unsigned long irq_flags; \
178 local_save_flags(irq_flags); \
179 pc = preempt_count(); \
181 event = trace_current_buffer_lock_reserve(event_##call.id, \
182 sizeof(struct ftrace_raw_##call), \
186 entry = ring_buffer_event_data(event); \
190 trace_current_buffer_unlock_commit(event, irq_flags, pc); \
193 static int ftrace_raw_reg_event_##call(void) \
197 ret = register_trace_##call(ftrace_raw_event_##call); \
199 pr_info("event trace: Could not activate trace point " \
200 "probe to " #call "\n"); \
204 static void ftrace_raw_unreg_event_##call(void) \
206 unregister_trace_##call(ftrace_raw_event_##call); \
209 static struct trace_event ftrace_event_type_##call = { \
210 .trace = ftrace_raw_output_##call, \
213 static int ftrace_raw_init_event_##call(void) \
217 id = register_ftrace_event(&ftrace_event_type_##call); \
220 event_##call.id = id; \
224 static struct ftrace_event_call __used \
225 __attribute__((__aligned__(4))) \
226 __attribute__((section("_ftrace_events"))) event_##call = { \
228 .system = STR(TRACE_SYSTEM), \
229 .regfunc = ftrace_reg_event_##call, \
230 .unregfunc = ftrace_unreg_event_##call, \
231 .raw_init = ftrace_raw_init_event_##call, \
232 .raw_reg = ftrace_raw_reg_event_##call, \
233 .raw_unreg = ftrace_raw_unreg_event_##call, \
234 .show_format = ftrace_format_##call, \