2 * trace_export.c - export basic ftrace utilities to user space
4 * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com>
6 #include <linux/stringify.h>
7 #include <linux/kallsyms.h>
8 #include <linux/seq_file.h>
9 #include <linux/debugfs.h>
10 #include <linux/uaccess.h>
11 #include <linux/ftrace.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
16 #include "trace_output.h"
19 #define TRACE_SYSTEM ftrace
21 /* not needed for this file */
23 #define __field_struct(type, item)
26 #define __field(type, item) \
27 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
28 "offset:%zu;\tsize:%zu;\n", \
29 offsetof(typeof(field), item), \
30 sizeof(field.item)); \
35 #define __field_desc(type, container, item) \
36 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
37 "offset:%zu;\tsize:%zu;\n", \
38 offsetof(typeof(field), container.item), \
39 sizeof(field.container.item)); \
44 #define __array(type, item, len) \
45 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
46 "offset:%zu;\tsize:%zu;\n", \
47 offsetof(typeof(field), item), \
48 sizeof(field.item)); \
53 #define __array_desc(type, container, item, len) \
54 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
55 "offset:%zu;\tsize:%zu;\n", \
56 offsetof(typeof(field), container.item), \
57 sizeof(field.container.item)); \
61 #undef __dynamic_array
62 #define __dynamic_array(type, item) \
63 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
64 "offset:%zu;\tsize:0;\n", \
65 offsetof(typeof(field), item)); \
70 #define F_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
76 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
78 ftrace_format_##name(struct ftrace_event_call *unused, \
79 struct trace_seq *s) \
81 struct struct_name field __attribute__((unused)); \
86 trace_seq_printf(s, "\nprint fmt: " print); \
91 #undef FTRACE_ENTRY_DUP
92 #define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \
93 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
95 #include "trace_entries.h"
99 #define __field(type, item) \
100 ret = trace_define_field(event_call, #type, #item, \
101 offsetof(typeof(field), item), \
102 sizeof(field.item), \
103 is_signed_type(type), FILTER_OTHER); \
108 #define __field_desc(type, container, item) \
109 ret = trace_define_field(event_call, #type, #item, \
110 offsetof(typeof(field), \
112 sizeof(field.container.item), \
113 is_signed_type(type), FILTER_OTHER); \
118 #define __array(type, item, len) \
119 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
120 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
121 offsetof(typeof(field), item), \
122 sizeof(field.item), 0, FILTER_OTHER); \
127 #define __array_desc(type, container, item, len) \
128 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
129 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
130 offsetof(typeof(field), \
132 sizeof(field.container.item), 0, \
137 #undef __dynamic_array
138 #define __dynamic_array(type, item)
141 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
143 ftrace_define_fields_##name(struct ftrace_event_call *event_call) \
145 struct struct_name field; \
148 ret = trace_define_common_fields(event_call); \
157 #include "trace_entries.h"
161 #define __field(type, item)
164 #define __field_desc(type, container, item)
167 #define __array(type, item, len)
170 #define __array_desc(type, container, item, len)
172 #undef __dynamic_array
173 #define __dynamic_array(type, item)
176 #undef TRACE_ZERO_CHAR
177 #define TRACE_ZERO_CHAR(arg)
180 #define TRACE_FIELD(type, item, assign)\
181 entry->item = assign;
184 #define TRACE_FIELD(type, item, assign)\
185 entry->item = assign;
187 #undef TRACE_FIELD_SIGN
188 #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
189 TRACE_FIELD(type, item, assign)
192 #define TP_CMD(cmd...) cmd
195 #define TRACE_ENTRY entry
197 #undef TRACE_FIELD_SPECIAL
198 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
202 #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \
203 static int ftrace_raw_init_event_##call(void); \
205 struct ftrace_event_call __used \
206 __attribute__((__aligned__(4))) \
207 __attribute__((section("_ftrace_events"))) event_##call = { \
210 .system = __stringify(TRACE_SYSTEM), \
211 .raw_init = ftrace_raw_init_event_##call, \
212 .show_format = ftrace_format_##call, \
213 .define_fields = ftrace_define_fields_##call, \
215 static int ftrace_raw_init_event_##call(void) \
217 INIT_LIST_HEAD(&event_##call.fields); \
221 #include "trace_entries.h"