| 1 |
/* SystemTap tracepoint interface header |
| 2 |
* Copyright (C) 2014 Red Hat Inc. |
| 3 |
* |
| 4 |
* This file is part of systemtap, and is free software. You can |
| 5 |
* redistribute it and/or modify it under the terms of the GNU General |
| 6 |
* Public License (GPL); either version 2, or (at your option) any |
| 7 |
* later version. |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef _STP_TRACEPOINT_H_ |
| 11 |
#define _STP_TRACEPOINT_H_ |
| 12 |
|
| 13 |
#include <linux/tracepoint.h> |
| 14 |
|
| 15 |
#define intptr_t long |
| 16 |
|
| 17 |
|
| 18 |
/* Starting in 2.6.35, at the same time NOARGS was added, the callback |
| 19 |
* always has a void* as the first parameter. PR11599 |
| 20 |
* |
| 21 |
* Since NOARGS was removed in 5.7.0, this configuration is now also |
| 22 |
* checked with autoconf-tracepoint-has-data.c. */ |
| 23 |
#ifdef DECLARE_TRACE_NOARGS |
| 24 |
#define STAPCONF_TRACEPOINT_HAS_DATA 1 |
| 25 |
#endif |
| 26 |
|
| 27 |
|
| 28 |
#ifdef STAPCONF_TRACEPOINT_HAS_DATA |
| 29 |
|
| 30 |
#define STP_TRACE_ENTER(fn, args...) \ |
| 31 |
void fn (void *__data __attribute__ ((unused)), ##args) |
| 32 |
#define STP_TRACE_ENTER_NOARGS(fn) STP_TRACE_ENTER(fn) |
| 33 |
|
| 34 |
#ifdef STAPCONF_TRACEPOINT_STRINGS |
| 35 |
|
| 36 |
#define STP_TRACE_REGISTER(name, fn) register_trace_##name(fn, NULL) |
| 37 |
#define STP_TRACE_UNREGISTER(name, fn) unregister_trace_##name(fn, NULL) |
| 38 |
|
| 39 |
#else /* STAPCONF_TRACEPOINT_STRINGS */ |
| 40 |
|
| 41 |
#define STAP_NEED_TRACEPOINTS 1 |
| 42 |
|
| 43 |
int stp_tracepoint_probe_register(const char *name, void *probe, void *data); |
| 44 |
int stp_tracepoint_probe_unregister(const char *name, void *probe, void *data); |
| 45 |
|
| 46 |
/* Type-checked wrappers to make sure the fn signature is correct. */ |
| 47 |
#define STP_TRACE_REGISTER(name, fn) ({ \ |
| 48 |
check_trace_callback_type_##name(fn); \ |
| 49 |
stp_tracepoint_probe_register(#name, (void*)fn, NULL); \ |
| 50 |
}) |
| 51 |
#define STP_TRACE_UNREGISTER(name, fn) ({ \ |
| 52 |
check_trace_callback_type_##name(fn); \ |
| 53 |
stp_tracepoint_probe_unregister(#name, (void*)fn, NULL); \ |
| 54 |
}) |
| 55 |
|
| 56 |
#endif /* STAPCONF_TRACEPOINT_STRINGS */ |
| 57 |
|
| 58 |
#else /* STAPCONF_TRACEPOINT_HAS_DATA */ |
| 59 |
|
| 60 |
#define STP_TRACE_ENTER(fn, args...) void fn (args) |
| 61 |
#define STP_TRACE_ENTER_NOARGS(fn) STP_TRACE_ENTER(fn, void) |
| 62 |
#define STP_TRACE_REGISTER(name, fn) register_trace_##name(fn) |
| 63 |
#define STP_TRACE_UNREGISTER(name, fn) unregister_trace_##name(fn) |
| 64 |
|
| 65 |
#endif /* STAPCONF_TRACEPOINT_HAS_DATA */ |
| 66 |
|
| 67 |
|
| 68 |
#define STP_TRACE_ENTER_REAL(fn, args...) void fn (args) |
| 69 |
#define STP_TRACE_ENTER_REAL_NOARGS(fn) STP_TRACE_ENTER_REAL(fn, void) |
| 70 |
|
| 71 |
|
| 72 |
#endif /* _STP_TRACEPOINT_H_ */ |