| 1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
| 2 | * |
| 3 | * src/wrapper/kprobes.h |
| 4 | * |
| 5 | * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com> |
| 6 | */ |
| 7 | |
| 8 | #ifndef _LTTNG_WRAPPER_KPROBES_H |
| 9 | #define _LTTNG_WRAPPER_KPROBES_H |
| 10 | |
| 11 | #include <linux/kprobes.h> |
| 12 | #include <lttng/kernel-version.h> |
| 13 | |
| 14 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0)) |
| 15 | |
| 16 | static inline |
| 17 | struct kretprobe *lttng_get_kretprobe(struct kretprobe_instance *ri) |
| 18 | { |
| 19 | return get_kretprobe(ri); |
| 20 | } |
| 21 | |
| 22 | #else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0) */ |
| 23 | |
| 24 | static inline |
| 25 | struct kretprobe *lttng_get_kretprobe(struct kretprobe_instance *ri) |
| 26 | { |
| 27 | return ri->rp; |
| 28 | } |
| 29 | |
| 30 | #endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0) */ |
| 31 | |
| 32 | |
| 33 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0)) |
| 34 | static inline |
| 35 | unsigned long lttng_get_kretprobe_retaddr(struct kretprobe_instance *ri) |
| 36 | { |
| 37 | return get_kretprobe_retaddr(ri); |
| 38 | } |
| 39 | |
| 40 | #else |
| 41 | |
| 42 | static inline |
| 43 | unsigned long lttng_get_kretprobe_retaddr(struct kretprobe_instance *ri) |
| 44 | { |
| 45 | return (unsigned long) ri->ret_addr; |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | #endif /* _LTTNG_WRAPPER_KPROBES_H */ |