blob: 61e757bd235086804615312b79b8720d65241ac0 [file] [log] [blame]
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +02001#ifndef _LINUX_FTRACE_H
2#define _LINUX_FTRACE_H
3
4#ifdef CONFIG_FTRACE
5
6#include <linux/linkage.h>
7
Steven Rostedtb0fc4942008-05-12 21:20:43 +02008extern int ftrace_enabled;
9extern int
10ftrace_enable_sysctl(struct ctl_table *table, int write,
11 struct file *filp, void __user *buffer, size_t *lenp,
12 loff_t *ppos);
13
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020014typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
15
16struct ftrace_ops {
17 ftrace_func_t func;
18 struct ftrace_ops *next;
19};
20
21/*
22 * The ftrace_ops must be a static and should also
23 * be read_mostly. These functions do modify read_mostly variables
24 * so use them sparely. Never free an ftrace_op or modify the
25 * next pointer after it has been registered. Even after unregistering
26 * it, the next pointer may still be used internally.
27 */
28int register_ftrace_function(struct ftrace_ops *ops);
29int unregister_ftrace_function(struct ftrace_ops *ops);
30void clear_ftrace_function(void);
31
32extern void ftrace_stub(unsigned long a0, unsigned long a1);
33extern void mcount(void);
34
35#else /* !CONFIG_FTRACE */
36# define register_ftrace_function(ops) do { } while (0)
37# define unregister_ftrace_function(ops) do { } while (0)
38# define clear_ftrace_function(ops) do { } while (0)
39#endif /* CONFIG_FTRACE */
Steven Rostedt352ad252008-05-12 21:20:42 +020040
Steven Rostedt3d083392008-05-12 21:20:42 +020041#ifdef CONFIG_DYNAMIC_FTRACE
42# define FTRACE_HASHBITS 10
43# define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
44
Steven Rostedt3c1720f2008-05-12 21:20:43 +020045enum {
Steven Rostedt37ad5082008-05-12 21:20:48 +020046 FTRACE_FL_FREE = (1 << 0),
47 FTRACE_FL_FAILED = (1 << 1),
48 FTRACE_FL_FILTER = (1 << 2),
49 FTRACE_FL_ENABLED = (1 << 3),
Steven Rostedt3c1720f2008-05-12 21:20:43 +020050};
51
Steven Rostedt3d083392008-05-12 21:20:42 +020052struct dyn_ftrace {
53 struct hlist_node node;
54 unsigned long ip;
Steven Rostedt3c1720f2008-05-12 21:20:43 +020055 unsigned long flags;
Steven Rostedt3d083392008-05-12 21:20:42 +020056};
57
Steven Rostedte1c08bd2008-05-12 21:20:44 +020058int ftrace_force_update(void);
Steven Rostedt77a2b372008-05-12 21:20:45 +020059void ftrace_set_filter(unsigned char *buf, int len, int reset);
Steven Rostedte1c08bd2008-05-12 21:20:44 +020060
Steven Rostedt3d083392008-05-12 21:20:42 +020061/* defined in arch */
Steven Rostedt3c1720f2008-05-12 21:20:43 +020062extern int ftrace_ip_converted(unsigned long ip);
63extern unsigned char *ftrace_nop_replace(void);
64extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
Steven Rostedtd61f82d2008-05-12 21:20:43 +020065extern int ftrace_dyn_arch_init(void *data);
66extern int ftrace_mcount_set(unsigned long *data);
Steven Rostedt3c1720f2008-05-12 21:20:43 +020067extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
68 unsigned char *new_code);
Steven Rostedtd61f82d2008-05-12 21:20:43 +020069extern int ftrace_update_ftrace_func(ftrace_func_t func);
70extern void ftrace_caller(void);
71extern void ftrace_call(void);
72extern void mcount_call(void);
Steven Rostedte1c08bd2008-05-12 21:20:44 +020073#else
Ingo Molnarc7aafc52008-05-12 21:20:45 +020074# define ftrace_force_update() ({ 0; })
Steven Rostedt77a2b372008-05-12 21:20:45 +020075# define ftrace_set_filter(buf, len, reset) do { } while (0)
Steven Rostedt3d083392008-05-12 21:20:42 +020076#endif
Steven Rostedt352ad252008-05-12 21:20:42 +020077
Ingo Molnarf43fdad2008-05-12 21:20:43 +020078static inline void tracer_disable(void)
79{
80#ifdef CONFIG_FTRACE
81 ftrace_enabled = 0;
82#endif
83}
84
Steven Rostedt352ad252008-05-12 21:20:42 +020085#ifdef CONFIG_FRAME_POINTER
86/* TODO: need to fix this for ARM */
87# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
88# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
89# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
90# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
91# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
92# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
93#else
94# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
95# define CALLER_ADDR1 0UL
96# define CALLER_ADDR2 0UL
97# define CALLER_ADDR3 0UL
98# define CALLER_ADDR4 0UL
99# define CALLER_ADDR5 0UL
100#endif
101
Steven Rostedt81d68a92008-05-12 21:20:42 +0200102#ifdef CONFIG_IRQSOFF_TRACER
103 extern void notrace time_hardirqs_on(unsigned long a0, unsigned long a1);
104 extern void notrace time_hardirqs_off(unsigned long a0, unsigned long a1);
105#else
106# define time_hardirqs_on(a0, a1) do { } while (0)
107# define time_hardirqs_off(a0, a1) do { } while (0)
108#endif
109
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200110#ifdef CONFIG_PREEMPT_TRACER
111 extern void notrace trace_preempt_on(unsigned long a0, unsigned long a1);
112 extern void notrace trace_preempt_off(unsigned long a0, unsigned long a1);
113#else
114# define trace_preempt_on(a0, a1) do { } while (0)
115# define trace_preempt_off(a0, a1) do { } while (0)
116#endif
117
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +0200118#endif /* _LINUX_FTRACE_H */