History

tracing: do not translate event helper macros in print format

By moving the macro that creates the print format code above the defining of the event macro helpers (__get_str, __print_symbolic, and __get_dynamic_array), we get a little cleaner print format. Instead of: (char *)((void *)REC + REC->__data_loc_name) we get: __get_str(name) Instead of: ({ static const struct trace_print_flags symbols[] = { { HI_SOFTIRQ, "HI" }, { we get: __print_symbolic(REC->vec, { HI_SOFTIRQ, "HI" }, {

Steven Rostedt committed 17 years ago

Commit 6ff9a641 parent bc5c6c01 file · +81 −77Browse files

Showing the changes to include/trace (1 of 1 file). Show all

Unified · Split

include/trace/ftrace.h+81−77
@@ -80,6 +80,87 @@ · 79 unmodified lines
8080
8181 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
8282
83+/*
84+ * Setup the showing format of trace point.
85+ *
86+ * int
87+ * ftrace_format_##call(struct trace_seq *s)
88+ * {
89+ * struct ftrace_raw_##call field;
90+ * int ret;
91+ *
92+ * ret = trace_seq_printf(s, #type " " #item ";"
93+ * " offset:%u; size:%u;\n",
94+ * offsetof(struct ftrace_raw_##call, item),
95+ * sizeof(field.type));
96+ *
97+ * }
98+ */
99+
100+#undef TP_STRUCT__entry
101+#define TP_STRUCT__entry(args...) args
102+
103+#undef __field
104+#define __field(type, item) \
105+ ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
106+ "offset:%u;\tsize:%u;\n", \
107+ (unsigned int)offsetof(typeof(field), item), \
108+ (unsigned int)sizeof(field.item)); \
109+ if (!ret) \
110+ return 0;
111+
112+#undef __array
113+#define __array(type, item, len) \
114+ ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
115+ "offset:%u;\tsize:%u;\n", \
116+ (unsigned int)offsetof(typeof(field), item), \
117+ (unsigned int)sizeof(field.item)); \
118+ if (!ret) \
119+ return 0;
120+
121+#undef __dynamic_array
122+#define __dynamic_array(type, item, len) \
123+ ret = trace_seq_printf(s, "\tfield:__data_loc " #item ";\t" \
124+ "offset:%u;\tsize:%u;\n", \
125+ (unsigned int)offsetof(typeof(field), \
126+ __data_loc_##item), \
127+ (unsigned int)sizeof(field.__data_loc_##item)); \
128+ if (!ret) \
129+ return 0;
130+
131+#undef __string
132+#define __string(item, src) __dynamic_array(char, item, -1)
133+
134+#undef __entry
135+#define __entry REC
136+
137+#undef __print_symbolic
138+#undef __get_dynamic_array
139+#undef __get_str
140+
141+#undef TP_printk
142+#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
143+
144+#undef TP_fast_assign
145+#define TP_fast_assign(args...) args
146+
147+#undef TRACE_EVENT
148+#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
149+static int \
150+ftrace_format_##call(struct trace_seq *s) \
151+{ \
152+ struct ftrace_raw_##call field __attribute__((unused)); \
153+ int ret = 0; \
154+ \
155+ tstruct; \
156+ \
157+ trace_seq_printf(s, "\nprint fmt: " print); \
158+ \
159+ return ret; \
160+}
161+
162+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
163+
83164 /*
84165 * Stage 3 of the trace events.
85166 *
@@ -179,83 +260,6 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ · 93 unmodified lines
179260
180261 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
181262
182−/*
183− * Setup the showing format of trace point.
184− *
185− * int
186− * ftrace_format_##call(struct trace_seq *s)
187− * {
188− * struct ftrace_raw_##call field;
189− * int ret;
190− *
191− * ret = trace_seq_printf(s, #type " " #item ";"
192− * " offset:%u; size:%u;\n",
193− * offsetof(struct ftrace_raw_##call, item),
194− * sizeof(field.type));
195− *
196− * }
197− */
198−
199−#undef TP_STRUCT__entry
200−#define TP_STRUCT__entry(args...) args
201−
202−#undef __field
203−#define __field(type, item) \
204− ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
205− "offset:%u;\tsize:%u;\n", \
206− (unsigned int)offsetof(typeof(field), item), \
207− (unsigned int)sizeof(field.item)); \
208− if (!ret) \
209− return 0;
210−
211−#undef __array
212−#define __array(type, item, len) \
213− ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
214− "offset:%u;\tsize:%u;\n", \
215− (unsigned int)offsetof(typeof(field), item), \
216− (unsigned int)sizeof(field.item)); \
217− if (!ret) \
218− return 0;
219−
220−#undef __dynamic_array
221−#define __dynamic_array(type, item, len) \
222− ret = trace_seq_printf(s, "\tfield:__data_loc " #item ";\t" \
223− "offset:%u;\tsize:%u;\n", \
224− (unsigned int)offsetof(typeof(field), \
225− __data_loc_##item), \
226− (unsigned int)sizeof(field.__data_loc_##item)); \
227− if (!ret) \
228− return 0;
229−
230−#undef __string
231−#define __string(item, src) __dynamic_array(char, item, -1)
232−
233−#undef __entry
234−#define __entry REC
235−
236−#undef TP_printk
237−#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
238−
239−#undef TP_fast_assign
240−#define TP_fast_assign(args...) args
241−
242−#undef TRACE_EVENT
243−#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
244−static int \
245−ftrace_format_##call(struct trace_seq *s) \
246−{ \
247− struct ftrace_raw_##call field __attribute__((unused)); \
248− int ret = 0; \
249− \
250− tstruct; \
251− \
252− trace_seq_printf(s, "\nprint fmt: " print); \
253− \
254− return ret; \
255−}
256−
257−#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
258−
259263 #undef __field
260264 #define __field(type, item) \
261265 ret = trace_define_field(event_call, #type, #item, \