aboutsummaryrefslogtreecommitdiffstats
path: root/samples/trace_events
diff options
context:
space:
mode:
Diffstat (limited to 'samples/trace_events')
-rw-r--r--samples/trace_events/trace-events-sample.h84
1 files changed, 82 insertions, 2 deletions
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h
index a2c8b02b6359..8965d1bb8811 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -22,7 +22,25 @@
22 * protection, just like TRACE_INCLUDE_FILE. 22 * protection, just like TRACE_INCLUDE_FILE.
23 */ 23 */
24#undef TRACE_SYSTEM 24#undef TRACE_SYSTEM
25#define TRACE_SYSTEM sample 25#define TRACE_SYSTEM sample-trace
26
27/*
28 * TRACE_SYSTEM is expected to be a C valid variable (alpha-numeric
29 * and underscore), although it may start with numbers. If for some
30 * reason it is not, you need to add the following lines:
31 */
32#undef TRACE_SYSTEM_VAR
33#define TRACE_SYSTEM_VAR sample_trace
34/*
35 * But the above is only needed if TRACE_SYSTEM is not alpha-numeric
36 * and underscored. By default, TRACE_SYSTEM_VAR will be equal to
37 * TRACE_SYSTEM. As TRACE_SYSTEM_VAR must be alpha-numeric, if
38 * TRACE_SYSTEM is not, then TRACE_SYSTEM_VAR must be defined with
39 * only alpha-numeric and underscores.
40 *
41 * The TRACE_SYSTEM_VAR is only used internally and not visible to
42 * user space.
43 */
26 44
27/* 45/*
28 * Notice that this file is not protected like a normal header. 46 * Notice that this file is not protected like a normal header.
@@ -180,8 +198,30 @@ static inline int __length_of(const int *list)
180 ; 198 ;
181 return i; 199 return i;
182} 200}
201
202enum {
203 TRACE_SAMPLE_FOO = 2,
204 TRACE_SAMPLE_BAR = 4,
205 TRACE_SAMPLE_ZOO = 8,
206};
183#endif 207#endif
184 208
209/*
210 * If enums are used in the TP_printk(), their names will be shown in
211 * format files and not their values. This can cause problems with user
212 * space programs that parse the format files to know how to translate
213 * the raw binary trace output into human readable text.
214 *
215 * To help out user space programs, any enum that is used in the TP_printk()
216 * should be defined by TRACE_DEFINE_ENUM() macro. All that is needed to
217 * be done is to add this macro with the enum within it in the trace
218 * header file, and it will be converted in the output.
219 */
220
221TRACE_DEFINE_ENUM(TRACE_SAMPLE_FOO);
222TRACE_DEFINE_ENUM(TRACE_SAMPLE_BAR);
223TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO);
224
185TRACE_EVENT(foo_bar, 225TRACE_EVENT(foo_bar,
186 226
187 TP_PROTO(const char *foo, int bar, const int *lst, 227 TP_PROTO(const char *foo, int bar, const int *lst,
@@ -206,7 +246,47 @@ TRACE_EVENT(foo_bar,
206 __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); 246 __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus());
207 ), 247 ),
208 248
209 TP_printk("foo %s %d %s %s (%s)", __entry->foo, __entry->bar, 249 TP_printk("foo %s %d %s %s %s %s (%s)", __entry->foo, __entry->bar,
250
251/*
252 * Notice here the use of some helper functions. This includes:
253 *
254 * __print_symbolic( variable, { value, "string" }, ... ),
255 *
256 * The variable is tested against each value of the { } pair. If
257 * the variable matches one of the values, then it will print the
258 * string in that pair. If non are matched, it returns a string
259 * version of the number (if __entry->bar == 7 then "7" is returned).
260 */
261 __print_symbolic(__entry->bar,
262 { 0, "zero" },
263 { TRACE_SAMPLE_FOO, "TWO" },
264 { TRACE_SAMPLE_BAR, "FOUR" },
265 { TRACE_SAMPLE_ZOO, "EIGHT" },
266 { 10, "TEN" }
267 ),
268
269/*
270 * __print_flags( variable, "delim", { value, "flag" }, ... ),
271 *
272 * This is similar to __print_symbolic, except that it tests the bits
273 * of the value. If ((FLAG & variable) == FLAG) then the string is
274 * printed. If more than one flag matches, then each one that does is
275 * also printed with delim in between them.
276 * If not all bits are accounted for, then the not found bits will be
277 * added in hex format: 0x506 will show BIT2|BIT4|0x500
278 */
279 __print_flags(__entry->bar, "|",
280 { 1, "BIT1" },
281 { 2, "BIT2" },
282 { 4, "BIT3" },
283 { 8, "BIT4" }
284 ),
285/*
286 * __print_array( array, len, element_size )
287 *
288 * This prints out the array that is defined by __array in a nice format.
289 */
210 __print_array(__get_dynamic_array(list), 290 __print_array(__get_dynamic_array(list),
211 __get_dynamic_array_len(list), 291 __get_dynamic_array_len(list),
212 sizeof(int)), 292 sizeof(int)),