blob: 623819433ed516a5867fb87992c2d52c027a9603 [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>
Ingo Molnard49dbf32008-05-16 10:41:53 +02007#include <linux/fs.h>
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +02008
Steven Rostedtb0fc4942008-05-12 21:20:43 +02009extern int ftrace_enabled;
10extern int
11ftrace_enable_sysctl(struct ctl_table *table, int write,
12 struct file *filp, void __user *buffer, size_t *lenp,
13 loff_t *ppos);
14
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +020015typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
16
17struct ftrace_ops {
18 ftrace_func_t func;
19 struct ftrace_ops *next;
20};
21
22/*
23 * The ftrace_ops must be a static and should also
24 * be read_mostly. These functions do modify read_mostly variables
25 * so use them sparely. Never free an ftrace_op or modify the
26 * next pointer after it has been registered. Even after unregistering
27 * it, the next pointer may still be used internally.
28 */
29int register_ftrace_function(struct ftrace_ops *ops);
30int unregister_ftrace_function(struct ftrace_ops *ops);
31void clear_ftrace_function(void);
32
33extern void ftrace_stub(unsigned long a0, unsigned long a1);
34extern void mcount(void);
35
36#else /* !CONFIG_FTRACE */
37# define register_ftrace_function(ops) do { } while (0)
38# define unregister_ftrace_function(ops) do { } while (0)
39# define clear_ftrace_function(ops) do { } while (0)
40#endif /* CONFIG_FTRACE */
Steven Rostedt352ad252008-05-12 21:20:42 +020041
Steven Rostedt3d083392008-05-12 21:20:42 +020042#ifdef CONFIG_DYNAMIC_FTRACE
43# define FTRACE_HASHBITS 10
44# define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
45
Steven Rostedt3c1720f2008-05-12 21:20:43 +020046enum {
Steven Rostedt37ad5082008-05-12 21:20:48 +020047 FTRACE_FL_FREE = (1 << 0),
48 FTRACE_FL_FAILED = (1 << 1),
49 FTRACE_FL_FILTER = (1 << 2),
50 FTRACE_FL_ENABLED = (1 << 3),
Steven Rostedt41c52c02008-05-22 11:46:33 -040051 FTRACE_FL_NOTRACE = (1 << 4),
Steven Rostedt3c1720f2008-05-12 21:20:43 +020052};
53
Steven Rostedt3d083392008-05-12 21:20:42 +020054struct dyn_ftrace {
55 struct hlist_node node;
56 unsigned long ip;
Steven Rostedt3c1720f2008-05-12 21:20:43 +020057 unsigned long flags;
Steven Rostedt3d083392008-05-12 21:20:42 +020058};
59
Steven Rostedte1c08bd2008-05-12 21:20:44 +020060int ftrace_force_update(void);
Steven Rostedt77a2b372008-05-12 21:20:45 +020061void ftrace_set_filter(unsigned char *buf, int len, int reset);
Steven Rostedte1c08bd2008-05-12 21:20:44 +020062
Steven Rostedt3d083392008-05-12 21:20:42 +020063/* defined in arch */
Steven Rostedt3c1720f2008-05-12 21:20:43 +020064extern int ftrace_ip_converted(unsigned long ip);
65extern unsigned char *ftrace_nop_replace(void);
66extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
Steven Rostedtd61f82d2008-05-12 21:20:43 +020067extern int ftrace_dyn_arch_init(void *data);
68extern int ftrace_mcount_set(unsigned long *data);
Steven Rostedt3c1720f2008-05-12 21:20:43 +020069extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
70 unsigned char *new_code);
Steven Rostedtd61f82d2008-05-12 21:20:43 +020071extern int ftrace_update_ftrace_func(ftrace_func_t func);
72extern void ftrace_caller(void);
73extern void ftrace_call(void);
74extern void mcount_call(void);
Steven Rostedtad90c0e2008-05-27 20:48:37 -040075
76void ftrace_disable_daemon(void);
77void ftrace_enable_daemon(void);
78
Steven Rostedte1c08bd2008-05-12 21:20:44 +020079#else
Ingo Molnaraeaee8a2008-05-12 21:20:49 +020080# define ftrace_force_update() ({ 0; })
81# define ftrace_set_filter(buf, len, reset) do { } while (0)
Steven Rostedtad90c0e2008-05-27 20:48:37 -040082# define ftrace_disable_daemon() do { } while (0)
83# define ftrace_enable_daemon() do { } while (0)
Steven Rostedt3d083392008-05-12 21:20:42 +020084#endif
Steven Rostedt352ad252008-05-12 21:20:42 +020085
Ingo Molnaraeaee8a2008-05-12 21:20:49 +020086/* totally disable ftrace - can not re-enable after this */
87void ftrace_kill(void);
88
Ingo Molnarf43fdad2008-05-12 21:20:43 +020089static inline void tracer_disable(void)
90{
91#ifdef CONFIG_FTRACE
92 ftrace_enabled = 0;
93#endif
94}
95
Steven Rostedt352ad252008-05-12 21:20:42 +020096#ifdef CONFIG_FRAME_POINTER
97/* TODO: need to fix this for ARM */
98# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
99# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
100# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
101# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
102# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
103# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
Ingo Molnar86387f72008-05-12 21:20:51 +0200104# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
Steven Rostedt352ad252008-05-12 21:20:42 +0200105#else
106# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
107# define CALLER_ADDR1 0UL
108# define CALLER_ADDR2 0UL
109# define CALLER_ADDR3 0UL
110# define CALLER_ADDR4 0UL
111# define CALLER_ADDR5 0UL
Ingo Molnar86387f72008-05-12 21:20:51 +0200112# define CALLER_ADDR6 0UL
Steven Rostedt352ad252008-05-12 21:20:42 +0200113#endif
114
Steven Rostedt81d68a92008-05-12 21:20:42 +0200115#ifdef CONFIG_IRQSOFF_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100116 extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
117 extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
Steven Rostedt81d68a92008-05-12 21:20:42 +0200118#else
119# define time_hardirqs_on(a0, a1) do { } while (0)
120# define time_hardirqs_off(a0, a1) do { } while (0)
121#endif
122
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200123#ifdef CONFIG_PREEMPT_TRACER
Ingo Molnar489f1392008-02-25 13:38:05 +0100124 extern void trace_preempt_on(unsigned long a0, unsigned long a1);
125 extern void trace_preempt_off(unsigned long a0, unsigned long a1);
Steven Rostedt6cd8a4b2008-05-12 21:20:42 +0200126#else
127# define trace_preempt_on(a0, a1) do { } while (0)
128# define trace_preempt_off(a0, a1) do { } while (0)
129#endif
130
Ingo Molnarb1829d22008-05-28 01:22:08 +0200131#ifdef CONFIG_TRACING
Ingo Molnar74f4e362008-05-12 21:21:15 +0200132extern void
133ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
134#else
135static inline void
136ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
137#endif
138
Arnaldo Carvalho de Melo16444a82008-05-12 21:20:42 +0200139#endif /* _LINUX_FTRACE_H */