5a964387b68ea67f4e53b7dbe2eaeb7faef30033
[lttng-modules.git] / wrapper / ftrace.h
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
30 #ifdef CONFIG_KALLSYMS
31
32 #include <linux/kallsyms.h>
33 #include <wrapper/kallsyms.h>
34
35 static inline
36 int wrapper_register_ftrace_function_probe(char *glob,
37 struct ftrace_probe_ops *ops, void *data)
38 {
39 int (*register_ftrace_function_probe_sym)(char *glob,
40 struct ftrace_probe_ops *ops, void *data);
41
42 register_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("register_ftrace_function_probe");
43 if (register_ftrace_function_probe_sym) {
44 return register_ftrace_function_probe_sym(glob, ops, data);
45 } else {
46 printk_once(KERN_WARNING "LTTng: register_ftrace_function_probe symbol lookup failed.\n");
47 return -EINVAL;
48 }
49 }
50
51 static inline
52 void wrapper_unregister_ftrace_function_probe(char *glob,
53 struct ftrace_probe_ops *ops, void *data)
54 {
55 void (*unregister_ftrace_function_probe_sym)(char *glob,
56 struct ftrace_probe_ops *ops, void *data);
57
58 unregister_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("unregister_ftrace_function_probe");
59 if (unregister_ftrace_function_probe_sym) {
60 unregister_ftrace_function_probe_sym(glob, ops, data);
61 } else {
62 printk_once(KERN_WARNING "LTTng: unregister_ftrace_function_probe symbol lookup failed.\n");
63 WARN_ON(1);
64 }
65 }
66
67 #else
68
69 static inline
70 int wrapper_register_ftrace_function_probe(char *glob,
71 struct ftrace_probe_ops *ops, void *data)
72 {
73 return register_ftrace_function_probe(glob, ops, data);
74 }
75
76 static inline
77 void wrapper_unregister_ftrace_function_probe(char *glob,
78 struct ftrace_probe_ops *ops, void *data)
79 {
80 return unregister_ftrace_function_probe(glob, ops, data);
81 }
82 #endif
83
84 #endif /* _LTTNG_WRAPPER_FTRACE_H */
This page took 0.032292 seconds and 3 git commands to generate.