diff options
Diffstat (limited to 'samples/trace_events/trace-events-sample.h')
-rw-r--r-- | samples/trace_events/trace-events-sample.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index c3232340914d..d0be8411b527 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h | |||
@@ -270,6 +270,50 @@ TRACE_EVENT_CONDITION(foo_bar_with_cond, | |||
270 | 270 | ||
271 | TP_printk("foo %s %d", __get_str(foo), __entry->bar) | 271 | TP_printk("foo %s %d", __get_str(foo), __entry->bar) |
272 | ); | 272 | ); |
273 | |||
274 | void foo_bar_reg(void); | ||
275 | void foo_bar_unreg(void); | ||
276 | |||
277 | /* | ||
278 | * Now in the case that some function needs to be called when the | ||
279 | * tracepoint is enabled and/or when it is disabled, the | ||
280 | * TRACE_EVENT_FN() serves this purpose. This is just like TRACE_EVENT() | ||
281 | * but adds two more parameters at the end: | ||
282 | * | ||
283 | * TRACE_EVENT_FN( name, proto, args, struct, assign, printk, reg, unreg) | ||
284 | * | ||
285 | * reg and unreg are functions with the prototype of: | ||
286 | * | ||
287 | * void reg(void) | ||
288 | * | ||
289 | * The reg function gets called before the tracepoint is enabled, and | ||
290 | * the unreg function gets called after the tracepoint is disabled. | ||
291 | * | ||
292 | * Note, reg and unreg are allowed to be NULL. If you only need to | ||
293 | * call a function before enabling, or after disabling, just set one | ||
294 | * function and pass in NULL for the other parameter. | ||
295 | */ | ||
296 | TRACE_EVENT_FN(foo_bar_with_fn, | ||
297 | |||
298 | TP_PROTO(const char *foo, int bar), | ||
299 | |||
300 | TP_ARGS(foo, bar), | ||
301 | |||
302 | TP_STRUCT__entry( | ||
303 | __string( foo, foo ) | ||
304 | __field( int, bar ) | ||
305 | ), | ||
306 | |||
307 | TP_fast_assign( | ||
308 | __assign_str(foo, foo); | ||
309 | __entry->bar = bar; | ||
310 | ), | ||
311 | |||
312 | TP_printk("foo %s %d", __get_str(foo), __entry->bar), | ||
313 | |||
314 | foo_bar_reg, foo_bar_unreg | ||
315 | ); | ||
316 | |||
273 | #endif | 317 | #endif |
274 | 318 | ||
275 | /***** NOTICE! The #if protection ends here. *****/ | 319 | /***** NOTICE! The #if protection ends here. *****/ |