aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_export.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_export.c')
-rw-r--r--kernel/trace/trace_export.c287
1 files changed, 158 insertions, 129 deletions
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index df1bf6e48bb9..31da218ee10f 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -15,146 +15,128 @@
15 15
16#include "trace_output.h" 16#include "trace_output.h"
17 17
18#undef TRACE_SYSTEM
19#define TRACE_SYSTEM ftrace
18 20
19#undef TRACE_STRUCT 21/* not needed for this file */
20#define TRACE_STRUCT(args...) args 22#undef __field_struct
23#define __field_struct(type, item)
21 24
22extern void __bad_type_size(void); 25#undef __field
26#define __field(type, item) type item;
23 27
24#undef TRACE_FIELD 28#undef __field_desc
25#define TRACE_FIELD(type, item, assign) \ 29#define __field_desc(type, container, item) type item;
26 if (sizeof(type) != sizeof(field.item)) \ 30
27 __bad_type_size(); \ 31#undef __array
32#define __array(type, item, size) type item[size];
33
34#undef __array_desc
35#define __array_desc(type, container, item, size) type item[size];
36
37#undef __dynamic_array
38#define __dynamic_array(type, item) type item[];
39
40#undef F_STRUCT
41#define F_STRUCT(args...) args
42
43#undef F_printk
44#define F_printk(fmt, args...) fmt, args
45
46#undef FTRACE_ENTRY
47#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
48struct ____ftrace_##name { \
49 tstruct \
50}; \
51static void __used ____ftrace_check_##name(void) \
52{ \
53 struct ____ftrace_##name *__entry = NULL; \
54 \
55 /* force cmpile-time check on F_printk() */ \
56 printk(print); \
57}
58
59#undef FTRACE_ENTRY_DUP
60#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \
61 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
62
63#include "trace_entries.h"
64
65
66#undef __field
67#define __field(type, item) \
28 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ 68 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
29 "offset:%u;\tsize:%u;\n", \ 69 "offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
30 (unsigned int)offsetof(typeof(field), item), \ 70 offsetof(typeof(field), item), \
31 (unsigned int)sizeof(field.item)); \ 71 sizeof(field.item), is_signed_type(type)); \
32 if (!ret) \ 72 if (!ret) \
33 return 0; 73 return 0;
34 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;\tsigned:%u;\n", \
79 offsetof(typeof(field), container.item), \
80 sizeof(field.container.item), \
81 is_signed_type(type)); \
82 if (!ret) \
83 return 0;
35 84
36#undef TRACE_FIELD_SPECIAL 85#undef __array
37#define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ 86#define __array(type, item, len) \
38 ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \ 87 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
39 "offset:%u;\tsize:%u;\n", \ 88 "offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
40 (unsigned int)offsetof(typeof(field), item), \ 89 offsetof(typeof(field), item), \
41 (unsigned int)sizeof(field.item)); \ 90 sizeof(field.item), is_signed_type(type)); \
42 if (!ret) \ 91 if (!ret) \
43 return 0; 92 return 0;
44 93
45#undef TRACE_FIELD_ZERO_CHAR 94#undef __array_desc
46#define TRACE_FIELD_ZERO_CHAR(item) \ 95#define __array_desc(type, container, item, len) \
47 ret = trace_seq_printf(s, "\tfield:char " #item ";\t" \ 96 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
48 "offset:%u;\tsize:0;\n", \ 97 "offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
49 (unsigned int)offsetof(typeof(field), item)); \ 98 offsetof(typeof(field), container.item), \
99 sizeof(field.container.item), \
100 is_signed_type(type)); \
50 if (!ret) \ 101 if (!ret) \
51 return 0; 102 return 0;
52 103
53#undef TRACE_FIELD_SIGN 104#undef __dynamic_array
54#define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ 105#define __dynamic_array(type, item) \
55 TRACE_FIELD(type, item, assign) 106 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
107 "offset:%zu;\tsize:0;\tsigned:%u;\n", \
108 offsetof(typeof(field), item), \
109 is_signed_type(type)); \
110 if (!ret) \
111 return 0;
56 112
57#undef TP_RAW_FMT 113#undef F_printk
58#define TP_RAW_FMT(args...) args 114#define F_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
59 115
60#undef TRACE_EVENT_FORMAT 116#undef __entry
61#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ 117#define __entry REC
62static int \
63ftrace_format_##call(struct ftrace_event_call *unused, \
64 struct trace_seq *s) \
65{ \
66 struct args field; \
67 int ret; \
68 \
69 tstruct; \
70 \
71 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
72 \
73 return ret; \
74}
75 118
76#undef TRACE_EVENT_FORMAT_NOFILTER 119#undef FTRACE_ENTRY
77#define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ 120#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
78 tpfmt) \
79static int \ 121static int \
80ftrace_format_##call(struct ftrace_event_call *unused, \ 122ftrace_format_##name(struct ftrace_event_call *unused, \
81 struct trace_seq *s) \ 123 struct trace_seq *s) \
82{ \ 124{ \
83 struct args field; \ 125 struct struct_name field __attribute__((unused)); \
84 int ret; \ 126 int ret = 0; \
85 \ 127 \
86 tstruct; \ 128 tstruct; \
87 \ 129 \
88 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \ 130 trace_seq_printf(s, "\nprint fmt: " print); \
89 \ 131 \
90 return ret; \ 132 return ret; \
91} 133}
92 134
93#include "trace_event_types.h" 135#include "trace_entries.h"
94
95#undef TRACE_ZERO_CHAR
96#define TRACE_ZERO_CHAR(arg)
97
98#undef TRACE_FIELD
99#define TRACE_FIELD(type, item, assign)\
100 entry->item = assign;
101
102#undef TRACE_FIELD
103#define TRACE_FIELD(type, item, assign)\
104 entry->item = assign;
105
106#undef TRACE_FIELD_SIGN
107#define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
108 TRACE_FIELD(type, item, assign)
109
110#undef TP_CMD
111#define TP_CMD(cmd...) cmd
112
113#undef TRACE_ENTRY
114#define TRACE_ENTRY entry
115
116#undef TRACE_FIELD_SPECIAL
117#define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
118 cmd;
119
120#undef TRACE_EVENT_FORMAT
121#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
122int ftrace_define_fields_##call(struct ftrace_event_call *event_call); \
123static int ftrace_raw_init_event_##call(void); \
124 \
125struct ftrace_event_call __used \
126__attribute__((__aligned__(4))) \
127__attribute__((section("_ftrace_events"))) event_##call = { \
128 .name = #call, \
129 .id = proto, \
130 .system = __stringify(TRACE_SYSTEM), \
131 .raw_init = ftrace_raw_init_event_##call, \
132 .show_format = ftrace_format_##call, \
133 .define_fields = ftrace_define_fields_##call, \
134}; \
135static int ftrace_raw_init_event_##call(void) \
136{ \
137 INIT_LIST_HEAD(&event_##call.fields); \
138 return 0; \
139} \
140
141#undef TRACE_EVENT_FORMAT_NOFILTER
142#define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
143 tpfmt) \
144 \
145struct ftrace_event_call __used \
146__attribute__((__aligned__(4))) \
147__attribute__((section("_ftrace_events"))) event_##call = { \
148 .name = #call, \
149 .id = proto, \
150 .system = __stringify(TRACE_SYSTEM), \
151 .show_format = ftrace_format_##call, \
152};
153 136
154#include "trace_event_types.h"
155 137
156#undef TRACE_FIELD 138#undef __field
157#define TRACE_FIELD(type, item, assign) \ 139#define __field(type, item) \
158 ret = trace_define_field(event_call, #type, #item, \ 140 ret = trace_define_field(event_call, #type, #item, \
159 offsetof(typeof(field), item), \ 141 offsetof(typeof(field), item), \
160 sizeof(field.item), \ 142 sizeof(field.item), \
@@ -162,32 +144,45 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
162 if (ret) \ 144 if (ret) \
163 return ret; 145 return ret;
164 146
165#undef TRACE_FIELD_SPECIAL 147#undef __field_desc
166#define TRACE_FIELD_SPECIAL(type, item, len, cmd) \ 148#define __field_desc(type, container, item) \
149 ret = trace_define_field(event_call, #type, #item, \
150 offsetof(typeof(field), \
151 container.item), \
152 sizeof(field.container.item), \
153 is_signed_type(type), FILTER_OTHER); \
154 if (ret) \
155 return ret;
156
157#undef __array
158#define __array(type, item, len) \
159 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
167 ret = trace_define_field(event_call, #type "[" #len "]", #item, \ 160 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
168 offsetof(typeof(field), item), \ 161 offsetof(typeof(field), item), \
169 sizeof(field.item), 0, FILTER_OTHER); \ 162 sizeof(field.item), 0, FILTER_OTHER); \
170 if (ret) \ 163 if (ret) \
171 return ret; 164 return ret;
172 165
173#undef TRACE_FIELD_SIGN 166#undef __array_desc
174#define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ 167#define __array_desc(type, container, item, len) \
175 ret = trace_define_field(event_call, #type, #item, \ 168 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
176 offsetof(typeof(field), item), \ 169 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
177 sizeof(field.item), is_signed, \ 170 offsetof(typeof(field), \
171 container.item), \
172 sizeof(field.container.item), 0, \
178 FILTER_OTHER); \ 173 FILTER_OTHER); \
179 if (ret) \ 174 if (ret) \
180 return ret; 175 return ret;
181 176
182#undef TRACE_FIELD_ZERO_CHAR 177#undef __dynamic_array
183#define TRACE_FIELD_ZERO_CHAR(item) 178#define __dynamic_array(type, item)
184 179
185#undef TRACE_EVENT_FORMAT 180#undef FTRACE_ENTRY
186#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ 181#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
187int \ 182int \
188ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ 183ftrace_define_fields_##name(struct ftrace_event_call *event_call) \
189{ \ 184{ \
190 struct args field; \ 185 struct struct_name field; \
191 int ret; \ 186 int ret; \
192 \ 187 \
193 ret = trace_define_common_fields(event_call); \ 188 ret = trace_define_common_fields(event_call); \
@@ -199,8 +194,42 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
199 return ret; \ 194 return ret; \
200} 195}
201 196
202#undef TRACE_EVENT_FORMAT_NOFILTER 197#include "trace_entries.h"
203#define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ 198
204 tpfmt) 199
200#undef __field
201#define __field(type, item)
202
203#undef __field_desc
204#define __field_desc(type, container, item)
205
206#undef __array
207#define __array(type, item, len)
208
209#undef __array_desc
210#define __array_desc(type, container, item, len)
211
212#undef __dynamic_array
213#define __dynamic_array(type, item)
214
215#undef FTRACE_ENTRY
216#define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \
217static int ftrace_raw_init_event_##call(void); \
218 \
219struct ftrace_event_call __used \
220__attribute__((__aligned__(4))) \
221__attribute__((section("_ftrace_events"))) event_##call = { \
222 .name = #call, \
223 .id = type, \
224 .system = __stringify(TRACE_SYSTEM), \
225 .raw_init = ftrace_raw_init_event_##call, \
226 .show_format = ftrace_format_##call, \
227 .define_fields = ftrace_define_fields_##call, \
228}; \
229static int ftrace_raw_init_event_##call(void) \
230{ \
231 INIT_LIST_HEAD(&event_##call.fields); \
232 return 0; \
233} \
205 234
206#include "trace_event_types.h" 235#include "trace_entries.h"