Łukasz Langa | a785c87 | 2016-09-09 17:37:37 -0700 | [diff] [blame] | 1 | /* Static DTrace probes interface */ |
| 2 | |
| 3 | #ifndef Py_DTRACE_H |
| 4 | #define Py_DTRACE_H |
Benjamin Peterson | 39e1061 | 2016-09-10 17:34:15 -0700 | [diff] [blame] | 5 | #ifdef __cplusplus |
| 6 | extern "C" { |
| 7 | #endif |
Łukasz Langa | a785c87 | 2016-09-09 17:37:37 -0700 | [diff] [blame] | 8 | |
| 9 | #ifdef WITH_DTRACE |
| 10 | |
| 11 | #include "pydtrace_probes.h" |
| 12 | |
| 13 | /* pydtrace_probes.h, on systems with DTrace, is auto-generated to include |
| 14 | `PyDTrace_{PROBE}` and `PyDTrace_{PROBE}_ENABLED()` macros for every probe |
| 15 | defined in pydtrace_provider.d. |
| 16 | |
| 17 | Calling these functions must be guarded by a `PyDTrace_{PROBE}_ENABLED()` |
| 18 | check to minimize performance impact when probing is off. For example: |
| 19 | |
| 20 | if (PyDTrace_FUNCTION_ENTRY_ENABLED()) |
| 21 | PyDTrace_FUNCTION_ENTRY(f); |
| 22 | */ |
| 23 | |
| 24 | #else |
| 25 | |
| 26 | /* Without DTrace, compile to nothing. */ |
| 27 | |
Victor Stinner | 542497a | 2018-10-29 14:49:24 +0100 | [diff] [blame] | 28 | static inline void PyDTrace_LINE(const char *arg0, const char *arg1, int arg2) {} |
| 29 | static inline void PyDTrace_FUNCTION_ENTRY(const char *arg0, const char *arg1, int arg2) {} |
| 30 | static inline void PyDTrace_FUNCTION_RETURN(const char *arg0, const char *arg1, int arg2) {} |
| 31 | static inline void PyDTrace_GC_START(int arg0) {} |
Jeremy Kloth | edad38e | 2019-03-06 09:54:12 -0700 | [diff] [blame] | 32 | static inline void PyDTrace_GC_DONE(Py_ssize_t arg0) {} |
Victor Stinner | 542497a | 2018-10-29 14:49:24 +0100 | [diff] [blame] | 33 | static inline void PyDTrace_INSTANCE_NEW_START(int arg0) {} |
| 34 | static inline void PyDTrace_INSTANCE_NEW_DONE(int arg0) {} |
| 35 | static inline void PyDTrace_INSTANCE_DELETE_START(int arg0) {} |
| 36 | static inline void PyDTrace_INSTANCE_DELETE_DONE(int arg0) {} |
| 37 | static inline void PyDTrace_IMPORT_FIND_LOAD_START(const char *arg0) {} |
| 38 | static inline void PyDTrace_IMPORT_FIND_LOAD_DONE(const char *arg0, int arg1) {} |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 39 | static inline void PyDTrace_AUDIT(const char *arg0, void *arg1) {} |
Łukasz Langa | a785c87 | 2016-09-09 17:37:37 -0700 | [diff] [blame] | 40 | |
Victor Stinner | 542497a | 2018-10-29 14:49:24 +0100 | [diff] [blame] | 41 | static inline int PyDTrace_LINE_ENABLED(void) { return 0; } |
| 42 | static inline int PyDTrace_FUNCTION_ENTRY_ENABLED(void) { return 0; } |
| 43 | static inline int PyDTrace_FUNCTION_RETURN_ENABLED(void) { return 0; } |
| 44 | static inline int PyDTrace_GC_START_ENABLED(void) { return 0; } |
| 45 | static inline int PyDTrace_GC_DONE_ENABLED(void) { return 0; } |
| 46 | static inline int PyDTrace_INSTANCE_NEW_START_ENABLED(void) { return 0; } |
| 47 | static inline int PyDTrace_INSTANCE_NEW_DONE_ENABLED(void) { return 0; } |
| 48 | static inline int PyDTrace_INSTANCE_DELETE_START_ENABLED(void) { return 0; } |
| 49 | static inline int PyDTrace_INSTANCE_DELETE_DONE_ENABLED(void) { return 0; } |
| 50 | static inline int PyDTrace_IMPORT_FIND_LOAD_START_ENABLED(void) { return 0; } |
| 51 | static inline int PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED(void) { return 0; } |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 52 | static inline int PyDTrace_AUDIT_ENABLED(void) { return 0; } |
Łukasz Langa | a785c87 | 2016-09-09 17:37:37 -0700 | [diff] [blame] | 53 | |
| 54 | #endif /* !WITH_DTRACE */ |
| 55 | |
Benjamin Peterson | 39e1061 | 2016-09-10 17:34:15 -0700 | [diff] [blame] | 56 | #ifdef __cplusplus |
| 57 | } |
| 58 | #endif |
Łukasz Langa | a785c87 | 2016-09-09 17:37:37 -0700 | [diff] [blame] | 59 | #endif /* !Py_DTRACE_H */ |