diff options
Diffstat (limited to 'kernel/trace/trace_export.c')
-rw-r--r-- | kernel/trace/trace_export.c | 110 |
1 files changed, 107 insertions, 3 deletions
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index 07a22c33ebf3..d06cf898dc86 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
@@ -19,8 +19,12 @@ | |||
19 | #undef TRACE_STRUCT | 19 | #undef TRACE_STRUCT |
20 | #define TRACE_STRUCT(args...) args | 20 | #define TRACE_STRUCT(args...) args |
21 | 21 | ||
22 | extern void __bad_type_size(void); | ||
23 | |||
22 | #undef TRACE_FIELD | 24 | #undef TRACE_FIELD |
23 | #define TRACE_FIELD(type, item, assign) \ | 25 | #define TRACE_FIELD(type, item, assign) \ |
26 | if (sizeof(type) != sizeof(field.item)) \ | ||
27 | __bad_type_size(); \ | ||
24 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | 28 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ |
25 | "offset:%u;\tsize:%u;\n", \ | 29 | "offset:%u;\tsize:%u;\n", \ |
26 | (unsigned int)offsetof(typeof(field), item), \ | 30 | (unsigned int)offsetof(typeof(field), item), \ |
@@ -30,7 +34,7 @@ | |||
30 | 34 | ||
31 | 35 | ||
32 | #undef TRACE_FIELD_SPECIAL | 36 | #undef TRACE_FIELD_SPECIAL |
33 | #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \ | 37 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ |
34 | ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \ | 38 | ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \ |
35 | "offset:%u;\tsize:%u;\n", \ | 39 | "offset:%u;\tsize:%u;\n", \ |
36 | (unsigned int)offsetof(typeof(field), item), \ | 40 | (unsigned int)offsetof(typeof(field), item), \ |
@@ -46,6 +50,9 @@ | |||
46 | if (!ret) \ | 50 | if (!ret) \ |
47 | return 0; | 51 | return 0; |
48 | 52 | ||
53 | #undef TRACE_FIELD_SIGN | ||
54 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
55 | TRACE_FIELD(type, item, assign) | ||
49 | 56 | ||
50 | #undef TP_RAW_FMT | 57 | #undef TP_RAW_FMT |
51 | #define TP_RAW_FMT(args...) args | 58 | #define TP_RAW_FMT(args...) args |
@@ -65,6 +72,22 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
65 | return ret; \ | 72 | return ret; \ |
66 | } | 73 | } |
67 | 74 | ||
75 | #undef TRACE_EVENT_FORMAT_NOFILTER | ||
76 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ | ||
77 | tpfmt) \ | ||
78 | static int \ | ||
79 | ftrace_format_##call(struct trace_seq *s) \ | ||
80 | { \ | ||
81 | struct args field; \ | ||
82 | int ret; \ | ||
83 | \ | ||
84 | tstruct; \ | ||
85 | \ | ||
86 | trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \ | ||
87 | \ | ||
88 | return ret; \ | ||
89 | } | ||
90 | |||
68 | #include "trace_event_types.h" | 91 | #include "trace_event_types.h" |
69 | 92 | ||
70 | #undef TRACE_ZERO_CHAR | 93 | #undef TRACE_ZERO_CHAR |
@@ -78,6 +101,10 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
78 | #define TRACE_FIELD(type, item, assign)\ | 101 | #define TRACE_FIELD(type, item, assign)\ |
79 | entry->item = assign; | 102 | entry->item = assign; |
80 | 103 | ||
104 | #undef TRACE_FIELD_SIGN | ||
105 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
106 | TRACE_FIELD(type, item, assign) | ||
107 | |||
81 | #undef TP_CMD | 108 | #undef TP_CMD |
82 | #define TP_CMD(cmd...) cmd | 109 | #define TP_CMD(cmd...) cmd |
83 | 110 | ||
@@ -85,18 +112,95 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
85 | #define TRACE_ENTRY entry | 112 | #define TRACE_ENTRY entry |
86 | 113 | ||
87 | #undef TRACE_FIELD_SPECIAL | 114 | #undef TRACE_FIELD_SPECIAL |
88 | #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \ | 115 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ |
89 | cmd; | 116 | cmd; |
90 | 117 | ||
91 | #undef TRACE_EVENT_FORMAT | 118 | #undef TRACE_EVENT_FORMAT |
92 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | 119 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ |
120 | int ftrace_define_fields_##call(void); \ | ||
121 | static int ftrace_raw_init_event_##call(void); \ | ||
122 | \ | ||
123 | struct ftrace_event_call __used \ | ||
124 | __attribute__((__aligned__(4))) \ | ||
125 | __attribute__((section("_ftrace_events"))) event_##call = { \ | ||
126 | .name = #call, \ | ||
127 | .id = proto, \ | ||
128 | .system = __stringify(TRACE_SYSTEM), \ | ||
129 | .raw_init = ftrace_raw_init_event_##call, \ | ||
130 | .show_format = ftrace_format_##call, \ | ||
131 | .define_fields = ftrace_define_fields_##call, \ | ||
132 | }; \ | ||
133 | static int ftrace_raw_init_event_##call(void) \ | ||
134 | { \ | ||
135 | INIT_LIST_HEAD(&event_##call.fields); \ | ||
136 | init_preds(&event_##call); \ | ||
137 | return 0; \ | ||
138 | } \ | ||
139 | |||
140 | #undef TRACE_EVENT_FORMAT_NOFILTER | ||
141 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ | ||
142 | tpfmt) \ | ||
93 | \ | 143 | \ |
94 | static struct ftrace_event_call __used \ | 144 | struct ftrace_event_call __used \ |
95 | __attribute__((__aligned__(4))) \ | 145 | __attribute__((__aligned__(4))) \ |
96 | __attribute__((section("_ftrace_events"))) event_##call = { \ | 146 | __attribute__((section("_ftrace_events"))) event_##call = { \ |
97 | .name = #call, \ | 147 | .name = #call, \ |
98 | .id = proto, \ | 148 | .id = proto, \ |
99 | .system = __stringify(TRACE_SYSTEM), \ | 149 | .system = __stringify(TRACE_SYSTEM), \ |
100 | .show_format = ftrace_format_##call, \ | 150 | .show_format = ftrace_format_##call, \ |
151 | }; | ||
152 | |||
153 | #include "trace_event_types.h" | ||
154 | |||
155 | #undef TRACE_FIELD | ||
156 | #define TRACE_FIELD(type, item, assign) \ | ||
157 | ret = trace_define_field(event_call, #type, #item, \ | ||
158 | offsetof(typeof(field), item), \ | ||
159 | sizeof(field.item), is_signed_type(type)); \ | ||
160 | if (ret) \ | ||
161 | return ret; | ||
162 | |||
163 | #undef TRACE_FIELD_SPECIAL | ||
164 | #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \ | ||
165 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | ||
166 | offsetof(typeof(field), item), \ | ||
167 | sizeof(field.item), 0); \ | ||
168 | if (ret) \ | ||
169 | return ret; | ||
170 | |||
171 | #undef TRACE_FIELD_SIGN | ||
172 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
173 | ret = trace_define_field(event_call, #type, #item, \ | ||
174 | offsetof(typeof(field), item), \ | ||
175 | sizeof(field.item), is_signed); \ | ||
176 | if (ret) \ | ||
177 | return ret; | ||
178 | |||
179 | #undef TRACE_FIELD_ZERO_CHAR | ||
180 | #define TRACE_FIELD_ZERO_CHAR(item) | ||
181 | |||
182 | #undef TRACE_EVENT_FORMAT | ||
183 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | ||
184 | int \ | ||
185 | ftrace_define_fields_##call(void) \ | ||
186 | { \ | ||
187 | struct ftrace_event_call *event_call = &event_##call; \ | ||
188 | struct args field; \ | ||
189 | int ret; \ | ||
190 | \ | ||
191 | __common_field(unsigned char, type, 0); \ | ||
192 | __common_field(unsigned char, flags, 0); \ | ||
193 | __common_field(unsigned char, preempt_count, 0); \ | ||
194 | __common_field(int, pid, 1); \ | ||
195 | __common_field(int, tgid, 1); \ | ||
196 | \ | ||
197 | tstruct; \ | ||
198 | \ | ||
199 | return ret; \ | ||
101 | } | 200 | } |
201 | |||
202 | #undef TRACE_EVENT_FORMAT_NOFILTER | ||
203 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ | ||
204 | tpfmt) | ||
205 | |||
102 | #include "trace_event_types.h" | 206 | #include "trace_event_types.h" |