diff options
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index a921ba5d292d..f02042d0d828 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -177,6 +177,48 @@ struct trace_array { | |||
177 | struct trace_array_cpu *data[NR_CPUS]; | 177 | struct trace_array_cpu *data[NR_CPUS]; |
178 | }; | 178 | }; |
179 | 179 | ||
180 | #define FTRACE_CMP_TYPE(var, type) \ | ||
181 | __builtin_types_compatible_p(typeof(var), type *) | ||
182 | |||
183 | #undef IF_ASSIGN | ||
184 | #define IF_ASSIGN(var, entry, etype, id) \ | ||
185 | if (FTRACE_CMP_TYPE(var, etype)) { \ | ||
186 | var = (typeof(var))(entry); \ | ||
187 | WARN_ON(id && (entry)->type != id); \ | ||
188 | break; \ | ||
189 | } | ||
190 | |||
191 | /* Will cause compile errors if type is not found. */ | ||
192 | extern void __ftrace_bad_type(void); | ||
193 | |||
194 | /* | ||
195 | * The trace_assign_type is a verifier that the entry type is | ||
196 | * the same as the type being assigned. To add new types simply | ||
197 | * add a line with the following format: | ||
198 | * | ||
199 | * IF_ASSIGN(var, ent, type, id); | ||
200 | * | ||
201 | * Where "type" is the trace type that includes the trace_entry | ||
202 | * as the "ent" item. And "id" is the trace identifier that is | ||
203 | * used in the trace_type enum. | ||
204 | * | ||
205 | * If the type can have more than one id, then use zero. | ||
206 | */ | ||
207 | #define trace_assign_type(var, ent) \ | ||
208 | do { \ | ||
209 | IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \ | ||
210 | IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \ | ||
211 | IF_ASSIGN(var, ent, struct trace_field_cont, TRACE_CONT); \ | ||
212 | IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \ | ||
213 | IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \ | ||
214 | IF_ASSIGN(var, ent, struct special_entry, 0); \ | ||
215 | IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \ | ||
216 | TRACE_MMIO_RW); \ | ||
217 | IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \ | ||
218 | TRACE_MMIO_MAP); \ | ||
219 | IF_ASSIGN(var, ent, struct trace_boot, TRACE_BOOT); \ | ||
220 | __ftrace_bad_type(); \ | ||
221 | } while (0) | ||
180 | 222 | ||
181 | /* Return values for print_line callback */ | 223 | /* Return values for print_line callback */ |
182 | enum print_line_t { | 224 | enum print_line_t { |