1 #ifndef _LINUX_FTRACE_H
2 #define _LINUX_FTRACE_H
6 #include <linux/linkage.h>
8 #include <linux/init.h>
9 #include <linux/types.h>
10 #include <linux/kallsyms.h>
12 extern int ftrace_enabled;
14 ftrace_enable_sysctl(struct ctl_table *table, int write,
15 struct file *filp, void __user *buffer, size_t *lenp,
18 typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
22 struct ftrace_ops *next;
26 * The ftrace_ops must be a static and should also
27 * be read_mostly. These functions do modify read_mostly variables
28 * so use them sparely. Never free an ftrace_op or modify the
29 * next pointer after it has been registered. Even after unregistering
30 * it, the next pointer may still be used internally.
32 int register_ftrace_function(struct ftrace_ops *ops);
33 int unregister_ftrace_function(struct ftrace_ops *ops);
34 void clear_ftrace_function(void);
36 extern void ftrace_stub(unsigned long a0, unsigned long a1);
38 #else /* !CONFIG_FTRACE */
39 # define register_ftrace_function(ops) do { } while (0)
40 # define unregister_ftrace_function(ops) do { } while (0)
41 # define clear_ftrace_function(ops) do { } while (0)
42 static inline void ftrace_kill_atomic(void) { }
43 #endif /* CONFIG_FTRACE */
45 #ifdef CONFIG_DYNAMIC_FTRACE
46 # define FTRACE_HASHBITS 10
47 # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
50 FTRACE_FL_FREE = (1 << 0),
51 FTRACE_FL_FAILED = (1 << 1),
52 FTRACE_FL_FILTER = (1 << 2),
53 FTRACE_FL_ENABLED = (1 << 3),
54 FTRACE_FL_NOTRACE = (1 << 4),
55 FTRACE_FL_CONVERTED = (1 << 5),
56 FTRACE_FL_FROZEN = (1 << 6),
60 struct hlist_node node;
61 unsigned long ip; /* address of mcount call-site */
65 int ftrace_force_update(void);
66 void ftrace_set_filter(unsigned char *buf, int len, int reset);
69 extern int ftrace_ip_converted(unsigned long ip);
70 extern unsigned char *ftrace_nop_replace(void);
71 extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
72 extern int ftrace_dyn_arch_init(void *data);
73 extern int ftrace_mcount_set(unsigned long *data);
74 extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
75 unsigned char *new_code);
76 extern int ftrace_update_ftrace_func(ftrace_func_t func);
77 extern void ftrace_caller(void);
78 extern void ftrace_call(void);
79 extern void mcount_call(void);
81 extern int skip_trace(unsigned long ip);
83 extern void ftrace_release(void *start, unsigned long size);
85 extern void ftrace_disable_daemon(void);
86 extern void ftrace_enable_daemon(void);
89 # define skip_trace(ip) ({ 0; })
90 # define ftrace_force_update() ({ 0; })
91 # define ftrace_set_filter(buf, len, reset) do { } while (0)
92 # define ftrace_disable_daemon() do { } while (0)
93 # define ftrace_enable_daemon() do { } while (0)
94 static inline void ftrace_release(void *start, unsigned long size) { }
95 #endif /* CONFIG_DYNAMIC_FTRACE */
97 /* totally disable ftrace - can not re-enable after this */
98 void ftrace_kill(void);
99 void ftrace_kill_atomic(void);
101 static inline void tracer_disable(void)
109 * Ftrace disable/restore without lock. Some synchronization mechanism
110 * must be used to prevent ftrace_enabled to be changed between
113 static inline int __ftrace_enabled_save(void)
116 int saved_ftrace_enabled = ftrace_enabled;
118 return saved_ftrace_enabled;
124 static inline void __ftrace_enabled_restore(int enabled)
127 ftrace_enabled = enabled;
131 #ifdef CONFIG_FRAME_POINTER
132 /* TODO: need to fix this for ARM */
133 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
134 # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
135 # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
136 # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
137 # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
138 # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
139 # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
141 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
142 # define CALLER_ADDR1 0UL
143 # define CALLER_ADDR2 0UL
144 # define CALLER_ADDR3 0UL
145 # define CALLER_ADDR4 0UL
146 # define CALLER_ADDR5 0UL
147 # define CALLER_ADDR6 0UL
150 #ifdef CONFIG_IRQSOFF_TRACER
151 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
152 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
154 # define time_hardirqs_on(a0, a1) do { } while (0)
155 # define time_hardirqs_off(a0, a1) do { } while (0)
158 #ifdef CONFIG_PREEMPT_TRACER
159 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
160 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
162 # define trace_preempt_on(a0, a1) do { } while (0)
163 # define trace_preempt_off(a0, a1) do { } while (0)
166 #ifdef CONFIG_TRACING
168 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
171 * ftrace_printk - printf formatting in the ftrace buffer
172 * @fmt: the printf format for printing
174 * Note: __ftrace_printk is an internal function for ftrace_printk and
175 * the @ip is passed in via the ftrace_printk macro.
177 * This function allows a kernel developer to debug fast path sections
178 * that printk is not appropriate for. By scattering in various
179 * printk like tracing in the code, a developer can quickly see
180 * where problems are occurring.
182 * This is intended as a debugging tool for the developer only.
183 * Please refrain from leaving ftrace_printks scattered around in
186 # define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)
188 __ftrace_printk(unsigned long ip, const char *fmt, ...)
189 __attribute__ ((format (printf, 2, 3)));
190 extern void ftrace_dump(void);
193 ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
195 ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
198 ftrace_printk(const char *fmt, ...)
202 static inline void ftrace_dump(void) { }
205 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
206 extern void ftrace_init(void);
207 extern void ftrace_init_module(unsigned long *start, unsigned long *end);
209 static inline void ftrace_init(void) { }
211 ftrace_init_module(unsigned long *start, unsigned long *end) { }
217 char func[KSYM_NAME_LEN];
219 unsigned long long duration;
224 #ifdef CONFIG_BOOT_TRACER
225 extern void trace_boot(struct boot_trace *it, initcall_t fn);
226 extern void start_boot_trace(void);
228 static inline void trace_boot(struct boot_trace *it, initcall_t fn) { }
229 static inline void start_boot_trace(void) { }
234 #endif /* _LINUX_FTRACE_H */