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