1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
5 * wrapper around uprobes. Using KALLSYMS to get its address when
6 * available, else we need to have a kernel that exports this function to GPL
9 * Copyright (C) 2013 Yannick Brosseau <yannick.brosseau@gmail.com>
10 * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
14 #ifndef _LTTNG_WRAPPER_UPROBES_H
15 #define _LTTNG_WRAPPER_UPROBES_H
17 #include <lttng-kernel-version.h>
19 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,5,0))
20 #include <linux/uprobes.h>
22 /* Use kallsym lookup for version before 3.9. */
23 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,9,0))
26 int wrapper_uprobe_register(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
)
28 return uprobe_register(inode
, offset
, uc
);
32 void wrapper_uprobe_unregister(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
)
34 uprobe_unregister(inode
, offset
, uc
);
37 #else /* Version < 3.9, use kallsym lookup. */
41 int wrapper_uprobe_register(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
)
43 int (*uprobe_register_sym
)(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
);
45 uprobe_register_sym
= (void *) kallsyms_lookup_funcptr("uprobe_register");
47 if (uprobe_register_sym
) {
48 return uprobe_register_sym(inode
, offset
, uc
);
50 printk(KERN_WARNING
"LTTng: uprobe_register symbol lookup failed.\n");
56 * Canary function to check for 'uprobe_register()' at compile time.
58 * From 'include/linux/uprobes.h':
60 * extern int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
63 int __canary__uprobe_register(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
)
65 return uprobe_register(inode
, offset
, uc
);
69 void wrapper_uprobe_unregister(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
)
71 int (*uprobe_unregister_sym
)(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
);
73 uprobe_unregister_sym
= (void *) kallsyms_lookup_funcptr("uprobe_unregister");
75 if (uprobe_unregister_sym
) {
76 uprobe_unregister_sym(inode
, offset
, uc
);
78 printk(KERN_WARNING
"LTTng: uprobe_unregister symbol lookup failed.\n");
84 * Canary function to check for 'uprobe_unregister()' at compile time.
86 * From 'include/linux/uprobes.h':
88 * extern void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
91 void __canary__uprobe_unregister(struct inode
*inode
, loff_t offset
, struct uprobe_consumer
*uc
)
93 uprobe_unregister(inode
, offset
, uc
);
98 /* Version < 3.5, before uprobe was added. */
99 struct uprobe_consumer
{};
This page took 0.031888 seconds and 4 git commands to generate.