1 #ifndef _LINUX_FTRACE_H
2 #define _LINUX_FTRACE_H
4 #include <linux/linkage.h>
6 #include <linux/ktime.h>
7 #include <linux/init.h>
8 #include <linux/types.h>
9 #include <linux/module.h>
10 #include <linux/kallsyms.h>
12 #ifdef CONFIG_FUNCTION_TRACER
14 extern int ftrace_enabled
;
16 ftrace_enable_sysctl(struct ctl_table
*table
, int write
,
17 struct file
*filp
, void __user
*buffer
, size_t *lenp
,
20 typedef void (*ftrace_func_t
)(unsigned long ip
, unsigned long parent_ip
);
24 struct ftrace_ops
*next
;
28 * The ftrace_ops must be a static and should also
29 * be read_mostly. These functions do modify read_mostly variables
30 * so use them sparely. Never free an ftrace_op or modify the
31 * next pointer after it has been registered. Even after unregistering
32 * it, the next pointer may still be used internally.
34 int register_ftrace_function(struct ftrace_ops
*ops
);
35 int unregister_ftrace_function(struct ftrace_ops
*ops
);
36 void clear_ftrace_function(void);
38 extern void ftrace_stub(unsigned long a0
, unsigned long a1
);
40 #else /* !CONFIG_FUNCTION_TRACER */
41 # define register_ftrace_function(ops) do { } while (0)
42 # define unregister_ftrace_function(ops) do { } while (0)
43 # define clear_ftrace_function(ops) do { } while (0)
44 static inline void ftrace_kill(void) { }
45 #endif /* CONFIG_FUNCTION_TRACER */
47 #ifdef CONFIG_DYNAMIC_FTRACE
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 list_head list
;
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_update_ftrace_func(ftrace_func_t func
);
74 extern void ftrace_caller(void);
75 extern void ftrace_call(void);
76 extern void mcount_call(void);
79 * ftrace_modify_code - modify code segment
80 * @ip: the address of the code segment
81 * @old_code: the contents of what is expected to be there
82 * @new_code: the code to patch in
84 * This is a very sensitive operation and great care needs
85 * to be taken by the arch. The operation should carefully
86 * read the location, check to see if what is read is indeed
87 * what we expect it to be, and then on success of the compare,
88 * it should write to the location.
92 * -EFAULT on error reading the location
93 * -EINVAL on a failed compare of the contents
94 * -EPERM on error writing to the location
95 * Any other value will be considered a failure.
97 extern int ftrace_modify_code(unsigned long ip
, unsigned char *old_code
,
98 unsigned char *new_code
);
100 extern int skip_trace(unsigned long ip
);
102 extern void ftrace_release(void *start
, unsigned long size
);
104 extern void ftrace_disable_daemon(void);
105 extern void ftrace_enable_daemon(void);
108 # define skip_trace(ip) ({ 0; })
109 # define ftrace_force_update() ({ 0; })
110 # define ftrace_set_filter(buf, len, reset) do { } while (0)
111 # define ftrace_disable_daemon() do { } while (0)
112 # define ftrace_enable_daemon() do { } while (0)
113 static inline void ftrace_release(void *start
, unsigned long size
) { }
114 #endif /* CONFIG_DYNAMIC_FTRACE */
116 /* totally disable ftrace - can not re-enable after this */
117 void ftrace_kill(void);
119 static inline void tracer_disable(void)
121 #ifdef CONFIG_FUNCTION_TRACER
127 * Ftrace disable/restore without lock. Some synchronization mechanism
128 * must be used to prevent ftrace_enabled to be changed between
131 static inline int __ftrace_enabled_save(void)
133 #ifdef CONFIG_FUNCTION_TRACER
134 int saved_ftrace_enabled
= ftrace_enabled
;
136 return saved_ftrace_enabled
;
142 static inline void __ftrace_enabled_restore(int enabled
)
144 #ifdef CONFIG_FUNCTION_TRACER
145 ftrace_enabled
= enabled
;
149 #ifdef CONFIG_FRAME_POINTER
150 /* TODO: need to fix this for ARM */
151 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
152 # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
153 # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
154 # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
155 # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
156 # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
157 # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
159 # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
160 # define CALLER_ADDR1 0UL
161 # define CALLER_ADDR2 0UL
162 # define CALLER_ADDR3 0UL
163 # define CALLER_ADDR4 0UL
164 # define CALLER_ADDR5 0UL
165 # define CALLER_ADDR6 0UL
168 #ifdef CONFIG_IRQSOFF_TRACER
169 extern void time_hardirqs_on(unsigned long a0
, unsigned long a1
);
170 extern void time_hardirqs_off(unsigned long a0
, unsigned long a1
);
172 # define time_hardirqs_on(a0, a1) do { } while (0)
173 # define time_hardirqs_off(a0, a1) do { } while (0)
176 #ifdef CONFIG_PREEMPT_TRACER
177 extern void trace_preempt_on(unsigned long a0
, unsigned long a1
);
178 extern void trace_preempt_off(unsigned long a0
, unsigned long a1
);
180 # define trace_preempt_on(a0, a1) do { } while (0)
181 # define trace_preempt_off(a0, a1) do { } while (0)
184 #ifdef CONFIG_TRACING
186 ftrace_special(unsigned long arg1
, unsigned long arg2
, unsigned long arg3
);
189 * ftrace_printk - printf formatting in the ftrace buffer
190 * @fmt: the printf format for printing
192 * Note: __ftrace_printk is an internal function for ftrace_printk and
193 * the @ip is passed in via the ftrace_printk macro.
195 * This function allows a kernel developer to debug fast path sections
196 * that printk is not appropriate for. By scattering in various
197 * printk like tracing in the code, a developer can quickly see
198 * where problems are occurring.
200 * This is intended as a debugging tool for the developer only.
201 * Please refrain from leaving ftrace_printks scattered around in
204 # define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)
206 __ftrace_printk(unsigned long ip
, const char *fmt
, ...)
207 __attribute__ ((format (printf
, 2, 3)));
208 extern void ftrace_dump(void);
211 ftrace_special(unsigned long arg1
, unsigned long arg2
, unsigned long arg3
) { }
213 ftrace_printk(const char *fmt
, ...) __attribute__ ((format (printf
, 1, 0)));
216 ftrace_printk(const char *fmt
, ...)
220 static inline void ftrace_dump(void) { }
223 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
224 extern void ftrace_init(void);
225 extern void ftrace_init_module(unsigned long *start
, unsigned long *end
);
227 static inline void ftrace_init(void) { }
229 ftrace_init_module(unsigned long *start
, unsigned long *end
) { }
235 char func
[KSYM_SYMBOL_LEN
];
237 unsigned long long duration
; /* usecs */
242 #ifdef CONFIG_BOOT_TRACER
243 extern void trace_boot(struct boot_trace
*it
, initcall_t fn
);
244 extern void start_boot_trace(void);
245 extern void stop_boot_trace(void);
247 static inline void trace_boot(struct boot_trace
*it
, initcall_t fn
) { }
248 static inline void start_boot_trace(void) { }
249 static inline void stop_boot_trace(void) { }
254 #endif /* _LINUX_FTRACE_H */