Fix: update ftrace probe for kernel 4.12
[lttng-modules.git] / wrapper / ftrace.h
... / ...
CommitLineData
1#ifndef _LTTNG_WRAPPER_FTRACE_H
2#define _LTTNG_WRAPPER_FTRACE_H
3
4/*
5 * wrapper/ftrace.h
6 *
7 * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
8 * available, else we need to have a kernel that exports this function to GPL
9 * modules.
10 *
11 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; only
16 * version 2.1 of the License.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27
28#include <linux/ftrace.h>
29#include <linux/version.h>
30#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0))
31#include <../kernel/trace/trace.h>
32#endif
33
34#ifdef CONFIG_KALLSYMS
35
36#include <linux/kallsyms.h>
37#include <wrapper/kallsyms.h>
38
39static inline
40int wrapper_register_ftrace_function_probe(char *glob,
41 struct ftrace_probe_ops *ops, void *data)
42{
43 int (*register_ftrace_function_probe_sym)(char *glob,
44 struct ftrace_probe_ops *ops, void *data);
45
46 register_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("register_ftrace_function_probe");
47 if (register_ftrace_function_probe_sym) {
48 return register_ftrace_function_probe_sym(glob, ops, data);
49 } else {
50 printk_once(KERN_WARNING "LTTng: register_ftrace_function_probe symbol lookup failed.\n");
51 return -EINVAL;
52 }
53}
54
55static inline
56void wrapper_unregister_ftrace_function_probe(char *glob,
57 struct ftrace_probe_ops *ops, void *data)
58{
59 void (*unregister_ftrace_function_probe_sym)(char *glob,
60 struct ftrace_probe_ops *ops, void *data);
61
62 unregister_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("unregister_ftrace_function_probe");
63 if (unregister_ftrace_function_probe_sym) {
64 unregister_ftrace_function_probe_sym(glob, ops, data);
65 } else {
66 printk_once(KERN_WARNING "LTTng: unregister_ftrace_function_probe symbol lookup failed.\n");
67 WARN_ON(1);
68 }
69}
70
71#else
72
73static inline
74int wrapper_register_ftrace_function_probe(char *glob,
75 struct ftrace_probe_ops *ops, void *data)
76{
77 return register_ftrace_function_probe(glob, ops, data);
78}
79
80static inline
81void wrapper_unregister_ftrace_function_probe(char *glob,
82 struct ftrace_probe_ops *ops, void *data)
83{
84 return unregister_ftrace_function_probe(glob, ops, data);
85}
86#endif
87
88#endif /* _LTTNG_WRAPPER_FTRACE_H */
This page took 0.022764 seconds and 4 git commands to generate.