Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_FTRACE_H |
| 2 | #define _LINUX_FTRACE_H |
| 3 | |
| 4 | #ifdef CONFIG_FTRACE |
| 5 | |
| 6 | #include <linux/linkage.h> |
| 7 | |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 8 | extern int ftrace_enabled; |
| 9 | extern int |
| 10 | ftrace_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 Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 14 | typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip); |
| 15 | |
| 16 | struct 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 | */ |
| 28 | int register_ftrace_function(struct ftrace_ops *ops); |
| 29 | int unregister_ftrace_function(struct ftrace_ops *ops); |
| 30 | void clear_ftrace_function(void); |
| 31 | |
| 32 | extern void ftrace_stub(unsigned long a0, unsigned long a1); |
| 33 | extern 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 Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 40 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 41 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 42 | # define FTRACE_HASHBITS 10 |
| 43 | # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS) |
| 44 | |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 45 | enum { |
Steven Rostedt | 5072c59 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 46 | FTRACE_FL_FAILED = (1 << 0), |
| 47 | FTRACE_FL_FILTER = (1 << 1), |
| 48 | FTRACE_FL_ENABLED = (1 << 2), |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 49 | }; |
| 50 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 51 | struct dyn_ftrace { |
| 52 | struct hlist_node node; |
| 53 | unsigned long ip; |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 54 | unsigned long flags; |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 55 | }; |
| 56 | |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 57 | int ftrace_force_update(void); |
Steven Rostedt | 77a2b37 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 58 | void ftrace_set_filter(unsigned char *buf, int len, int reset); |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 59 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 60 | /* defined in arch */ |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 61 | extern int ftrace_ip_converted(unsigned long ip); |
| 62 | extern unsigned char *ftrace_nop_replace(void); |
| 63 | extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr); |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 64 | extern int ftrace_dyn_arch_init(void *data); |
| 65 | extern int ftrace_mcount_set(unsigned long *data); |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 66 | extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
| 67 | unsigned char *new_code); |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 68 | extern int ftrace_update_ftrace_func(ftrace_func_t func); |
| 69 | extern void ftrace_caller(void); |
| 70 | extern void ftrace_call(void); |
| 71 | extern void mcount_call(void); |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 72 | #else |
Ingo Molnar | c7aafc5 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 73 | # define ftrace_force_update() ({ 0; }) |
Steven Rostedt | 77a2b37 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 74 | # define ftrace_set_filter(buf, len, reset) do { } while (0) |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 75 | #endif |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 76 | |
Ingo Molnar | f43fdad | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 77 | static inline void tracer_disable(void) |
| 78 | { |
| 79 | #ifdef CONFIG_FTRACE |
| 80 | ftrace_enabled = 0; |
| 81 | #endif |
| 82 | } |
| 83 | |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 84 | #ifdef CONFIG_FRAME_POINTER |
| 85 | /* TODO: need to fix this for ARM */ |
| 86 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) |
| 87 | # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1)) |
| 88 | # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2)) |
| 89 | # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3)) |
| 90 | # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4)) |
| 91 | # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5)) |
| 92 | #else |
| 93 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) |
| 94 | # define CALLER_ADDR1 0UL |
| 95 | # define CALLER_ADDR2 0UL |
| 96 | # define CALLER_ADDR3 0UL |
| 97 | # define CALLER_ADDR4 0UL |
| 98 | # define CALLER_ADDR5 0UL |
| 99 | #endif |
| 100 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 101 | #ifdef CONFIG_IRQSOFF_TRACER |
| 102 | extern void notrace time_hardirqs_on(unsigned long a0, unsigned long a1); |
| 103 | extern void notrace time_hardirqs_off(unsigned long a0, unsigned long a1); |
| 104 | #else |
| 105 | # define time_hardirqs_on(a0, a1) do { } while (0) |
| 106 | # define time_hardirqs_off(a0, a1) do { } while (0) |
| 107 | #endif |
| 108 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 109 | #ifdef CONFIG_PREEMPT_TRACER |
| 110 | extern void notrace trace_preempt_on(unsigned long a0, unsigned long a1); |
| 111 | extern void notrace trace_preempt_off(unsigned long a0, unsigned long a1); |
| 112 | #else |
| 113 | # define trace_preempt_on(a0, a1) do { } while (0) |
| 114 | # define trace_preempt_off(a0, a1) do { } while (0) |
| 115 | #endif |
| 116 | |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 117 | #endif /* _LINUX_FTRACE_H */ |