diff options
Diffstat (limited to 'kernel/trace/trace_export.c')
-rw-r--r-- | kernel/trace/trace_export.c | 113 |
1 files changed, 25 insertions, 88 deletions
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index 9753fcc61bc5..e091f64ba6ce 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
@@ -48,11 +48,11 @@ | |||
48 | struct ____ftrace_##name { \ | 48 | struct ____ftrace_##name { \ |
49 | tstruct \ | 49 | tstruct \ |
50 | }; \ | 50 | }; \ |
51 | static void __used ____ftrace_check_##name(void) \ | 51 | static void __always_unused ____ftrace_check_##name(void) \ |
52 | { \ | 52 | { \ |
53 | struct ____ftrace_##name *__entry = NULL; \ | 53 | struct ____ftrace_##name *__entry = NULL; \ |
54 | \ | 54 | \ |
55 | /* force cmpile-time check on F_printk() */ \ | 55 | /* force compile-time check on F_printk() */ \ |
56 | printk(print); \ | 56 | printk(print); \ |
57 | } | 57 | } |
58 | 58 | ||
@@ -62,76 +62,6 @@ static void __used ____ftrace_check_##name(void) \ | |||
62 | 62 | ||
63 | #include "trace_entries.h" | 63 | #include "trace_entries.h" |
64 | 64 | ||
65 | |||
66 | #undef __field | ||
67 | #define __field(type, item) \ | ||
68 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | ||
69 | "offset:%zu;\tsize:%zu;\n", \ | ||
70 | offsetof(typeof(field), item), \ | ||
71 | sizeof(field.item)); \ | ||
72 | if (!ret) \ | ||
73 | return 0; | ||
74 | |||
75 | #undef __field_desc | ||
76 | #define __field_desc(type, container, item) \ | ||
77 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | ||
78 | "offset:%zu;\tsize:%zu;\n", \ | ||
79 | offsetof(typeof(field), container.item), \ | ||
80 | sizeof(field.container.item)); \ | ||
81 | if (!ret) \ | ||
82 | return 0; | ||
83 | |||
84 | #undef __array | ||
85 | #define __array(type, item, len) \ | ||
86 | ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ | ||
87 | "offset:%zu;\tsize:%zu;\n", \ | ||
88 | offsetof(typeof(field), item), \ | ||
89 | sizeof(field.item)); \ | ||
90 | if (!ret) \ | ||
91 | return 0; | ||
92 | |||
93 | #undef __array_desc | ||
94 | #define __array_desc(type, container, item, len) \ | ||
95 | ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ | ||
96 | "offset:%zu;\tsize:%zu;\n", \ | ||
97 | offsetof(typeof(field), container.item), \ | ||
98 | sizeof(field.container.item)); \ | ||
99 | if (!ret) \ | ||
100 | return 0; | ||
101 | |||
102 | #undef __dynamic_array | ||
103 | #define __dynamic_array(type, item) \ | ||
104 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | ||
105 | "offset:%zu;\tsize:0;\n", \ | ||
106 | offsetof(typeof(field), item)); \ | ||
107 | if (!ret) \ | ||
108 | return 0; | ||
109 | |||
110 | #undef F_printk | ||
111 | #define F_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args) | ||
112 | |||
113 | #undef __entry | ||
114 | #define __entry REC | ||
115 | |||
116 | #undef FTRACE_ENTRY | ||
117 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ | ||
118 | static int \ | ||
119 | ftrace_format_##name(struct ftrace_event_call *unused, \ | ||
120 | struct trace_seq *s) \ | ||
121 | { \ | ||
122 | struct struct_name field __attribute__((unused)); \ | ||
123 | int ret = 0; \ | ||
124 | \ | ||
125 | tstruct; \ | ||
126 | \ | ||
127 | trace_seq_printf(s, "\nprint fmt: " print); \ | ||
128 | \ | ||
129 | return ret; \ | ||
130 | } | ||
131 | |||
132 | #include "trace_entries.h" | ||
133 | |||
134 | |||
135 | #undef __field | 65 | #undef __field |
136 | #define __field(type, item) \ | 66 | #define __field(type, item) \ |
137 | ret = trace_define_field(event_call, #type, #item, \ | 67 | ret = trace_define_field(event_call, #type, #item, \ |
@@ -156,7 +86,8 @@ ftrace_format_##name(struct ftrace_event_call *unused, \ | |||
156 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | 86 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ |
157 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 87 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
158 | offsetof(typeof(field), item), \ | 88 | offsetof(typeof(field), item), \ |
159 | sizeof(field.item), 0, FILTER_OTHER); \ | 89 | sizeof(field.item), \ |
90 | is_signed_type(type), FILTER_OTHER); \ | ||
160 | if (ret) \ | 91 | if (ret) \ |
161 | return ret; | 92 | return ret; |
162 | 93 | ||
@@ -166,13 +97,18 @@ ftrace_format_##name(struct ftrace_event_call *unused, \ | |||
166 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 97 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
167 | offsetof(typeof(field), \ | 98 | offsetof(typeof(field), \ |
168 | container.item), \ | 99 | container.item), \ |
169 | sizeof(field.container.item), 0, \ | 100 | sizeof(field.container.item), \ |
170 | FILTER_OTHER); \ | 101 | is_signed_type(type), FILTER_OTHER); \ |
171 | if (ret) \ | 102 | if (ret) \ |
172 | return ret; | 103 | return ret; |
173 | 104 | ||
174 | #undef __dynamic_array | 105 | #undef __dynamic_array |
175 | #define __dynamic_array(type, item) | 106 | #define __dynamic_array(type, item) \ |
107 | ret = trace_define_field(event_call, #type, #item, \ | ||
108 | offsetof(typeof(field), item), \ | ||
109 | 0, is_signed_type(type), FILTER_OTHER);\ | ||
110 | if (ret) \ | ||
111 | return ret; | ||
176 | 112 | ||
177 | #undef FTRACE_ENTRY | 113 | #undef FTRACE_ENTRY |
178 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ | 114 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ |
@@ -182,10 +118,6 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ | |||
182 | struct struct_name field; \ | 118 | struct struct_name field; \ |
183 | int ret; \ | 119 | int ret; \ |
184 | \ | 120 | \ |
185 | ret = trace_define_common_fields(event_call); \ | ||
186 | if (ret) \ | ||
187 | return ret; \ | ||
188 | \ | ||
189 | tstruct; \ | 121 | tstruct; \ |
190 | \ | 122 | \ |
191 | return ret; \ | 123 | return ret; \ |
@@ -193,6 +125,14 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ | |||
193 | 125 | ||
194 | #include "trace_entries.h" | 126 | #include "trace_entries.h" |
195 | 127 | ||
128 | static int ftrace_raw_init_event(struct ftrace_event_call *call) | ||
129 | { | ||
130 | INIT_LIST_HEAD(&call->fields); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | #undef __entry | ||
135 | #define __entry REC | ||
196 | 136 | ||
197 | #undef __field | 137 | #undef __field |
198 | #define __field(type, item) | 138 | #define __field(type, item) |
@@ -209,9 +149,11 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ | |||
209 | #undef __dynamic_array | 149 | #undef __dynamic_array |
210 | #define __dynamic_array(type, item) | 150 | #define __dynamic_array(type, item) |
211 | 151 | ||
152 | #undef F_printk | ||
153 | #define F_printk(fmt, args...) #fmt ", " __stringify(args) | ||
154 | |||
212 | #undef FTRACE_ENTRY | 155 | #undef FTRACE_ENTRY |
213 | #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \ | 156 | #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \ |
214 | static int ftrace_raw_init_event_##call(void); \ | ||
215 | \ | 157 | \ |
216 | struct ftrace_event_call __used \ | 158 | struct ftrace_event_call __used \ |
217 | __attribute__((__aligned__(4))) \ | 159 | __attribute__((__aligned__(4))) \ |
@@ -219,14 +161,9 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ | |||
219 | .name = #call, \ | 161 | .name = #call, \ |
220 | .id = type, \ | 162 | .id = type, \ |
221 | .system = __stringify(TRACE_SYSTEM), \ | 163 | .system = __stringify(TRACE_SYSTEM), \ |
222 | .raw_init = ftrace_raw_init_event_##call, \ | 164 | .raw_init = ftrace_raw_init_event, \ |
223 | .show_format = ftrace_format_##call, \ | 165 | .print_fmt = print, \ |
224 | .define_fields = ftrace_define_fields_##call, \ | 166 | .define_fields = ftrace_define_fields_##call, \ |
225 | }; \ | 167 | }; \ |
226 | static int ftrace_raw_init_event_##call(void) \ | ||
227 | { \ | ||
228 | INIT_LIST_HEAD(&event_##call.fields); \ | ||
229 | return 0; \ | ||
230 | } \ | ||
231 | 168 | ||
232 | #include "trace_entries.h" | 169 | #include "trace_entries.h" |