ftrace: dynamic enabling/disabling of function calls
[deliverable/linux.git] / include / linux / ftrace.h
1 #ifndef _LINUX_FTRACE_H
2 #define _LINUX_FTRACE_H
3
4 #ifdef CONFIG_FTRACE
5
6 #include <linux/linkage.h>
7
8 typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
9
10 struct ftrace_ops {
11 ftrace_func_t func;
12 struct ftrace_ops *next;
13 };
14
15 /*
16 * The ftrace_ops must be a static and should also
17 * be read_mostly. These functions do modify read_mostly variables
18 * so use them sparely. Never free an ftrace_op or modify the
19 * next pointer after it has been registered. Even after unregistering
20 * it, the next pointer may still be used internally.
21 */
22 int register_ftrace_function(struct ftrace_ops *ops);
23 int unregister_ftrace_function(struct ftrace_ops *ops);
24 void clear_ftrace_function(void);
25
26 extern void ftrace_stub(unsigned long a0, unsigned long a1);
27 extern void mcount(void);
28
29 #else /* !CONFIG_FTRACE */
30 # define register_ftrace_function(ops) do { } while (0)
31 # define unregister_ftrace_function(ops) do { } while (0)
32 # define clear_ftrace_function(ops) do { } while (0)
33 #endif /* CONFIG_FTRACE */
34
35 #ifdef CONFIG_DYNAMIC_FTRACE
36 # define FTRACE_HASHBITS 10
37 # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
38
39 struct dyn_ftrace {
40 struct hlist_node node;
41 unsigned long ip;
42 };
43
44 /* defined in arch */
45 extern struct dyn_ftrace *
46 ftrace_alloc_shutdown_node(unsigned long ip);
47 extern int ftrace_shutdown_arch_init(void);
48 extern void ftrace_code_disable(struct dyn_ftrace *rec);
49 extern void ftrace_startup_code(void);
50 extern void ftrace_shutdown_code(void);
51 extern void ftrace_shutdown_replenish(void);
52 #endif
53
54 #ifdef CONFIG_FRAME_POINTER
55 /* TODO: need to fix this for ARM */
56 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
57 # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
58 # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
59 # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
60 # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
61 # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
62 #else
63 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
64 # define CALLER_ADDR1 0UL
65 # define CALLER_ADDR2 0UL
66 # define CALLER_ADDR3 0UL
67 # define CALLER_ADDR4 0UL
68 # define CALLER_ADDR5 0UL
69 #endif
70
71 #ifdef CONFIG_IRQSOFF_TRACER
72 extern void notrace time_hardirqs_on(unsigned long a0, unsigned long a1);
73 extern void notrace time_hardirqs_off(unsigned long a0, unsigned long a1);
74 #else
75 # define time_hardirqs_on(a0, a1) do { } while (0)
76 # define time_hardirqs_off(a0, a1) do { } while (0)
77 #endif
78
79 #ifdef CONFIG_PREEMPT_TRACER
80 extern void notrace trace_preempt_on(unsigned long a0, unsigned long a1);
81 extern void notrace trace_preempt_off(unsigned long a0, unsigned long a1);
82 #else
83 # define trace_preempt_on(a0, a1) do { } while (0)
84 # define trace_preempt_off(a0, a1) do { } while (0)
85 #endif
86
87 #endif /* _LINUX_FTRACE_H */
This page took 0.032419 seconds and 5 git commands to generate.