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> |
Ingo Molnar | d49dbf3 | 2008-05-16 10:41:53 +0200 | [diff] [blame] | 7 | #include <linux/fs.h> |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 8 | |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 9 | extern int ftrace_enabled; |
| 10 | extern int |
| 11 | ftrace_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 Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 15 | typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip); |
| 16 | |
| 17 | struct 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 | */ |
| 29 | int register_ftrace_function(struct ftrace_ops *ops); |
| 30 | int unregister_ftrace_function(struct ftrace_ops *ops); |
| 31 | void clear_ftrace_function(void); |
| 32 | |
| 33 | extern void ftrace_stub(unsigned long a0, unsigned long a1); |
| 34 | extern 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 Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 41 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 42 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 43 | # define FTRACE_HASHBITS 10 |
| 44 | # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS) |
| 45 | |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 46 | enum { |
Steven Rostedt | 37ad508 | 2008-05-12 21:20:48 +0200 | [diff] [blame] | 47 | FTRACE_FL_FREE = (1 << 0), |
| 48 | FTRACE_FL_FAILED = (1 << 1), |
| 49 | FTRACE_FL_FILTER = (1 << 2), |
| 50 | FTRACE_FL_ENABLED = (1 << 3), |
Steven Rostedt | 41c52c0 | 2008-05-22 11:46:33 -0400 | [diff] [blame] | 51 | FTRACE_FL_NOTRACE = (1 << 4), |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 52 | }; |
| 53 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 54 | struct dyn_ftrace { |
| 55 | struct hlist_node node; |
| 56 | unsigned long ip; |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 57 | unsigned long flags; |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 58 | }; |
| 59 | |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 60 | int ftrace_force_update(void); |
Steven Rostedt | 77a2b37 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 61 | void ftrace_set_filter(unsigned char *buf, int len, int reset); |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 62 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 63 | /* defined in arch */ |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 64 | extern int ftrace_ip_converted(unsigned long ip); |
| 65 | extern unsigned char *ftrace_nop_replace(void); |
| 66 | extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr); |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 67 | extern int ftrace_dyn_arch_init(void *data); |
| 68 | extern int ftrace_mcount_set(unsigned long *data); |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 69 | extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
| 70 | unsigned char *new_code); |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 71 | extern int ftrace_update_ftrace_func(ftrace_func_t func); |
| 72 | extern void ftrace_caller(void); |
| 73 | extern void ftrace_call(void); |
| 74 | extern void mcount_call(void); |
Steven Rostedt | ad90c0e | 2008-05-27 20:48:37 -0400 | [diff] [blame^] | 75 | |
| 76 | void ftrace_disable_daemon(void); |
| 77 | void ftrace_enable_daemon(void); |
| 78 | |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 79 | #else |
Ingo Molnar | aeaee8a | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 80 | # define ftrace_force_update() ({ 0; }) |
| 81 | # define ftrace_set_filter(buf, len, reset) do { } while (0) |
Steven Rostedt | ad90c0e | 2008-05-27 20:48:37 -0400 | [diff] [blame^] | 82 | # define ftrace_disable_daemon() do { } while (0) |
| 83 | # define ftrace_enable_daemon() do { } while (0) |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 84 | #endif |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 85 | |
Ingo Molnar | aeaee8a | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 86 | /* totally disable ftrace - can not re-enable after this */ |
| 87 | void ftrace_kill(void); |
| 88 | |
Ingo Molnar | f43fdad | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 89 | static inline void tracer_disable(void) |
| 90 | { |
| 91 | #ifdef CONFIG_FTRACE |
| 92 | ftrace_enabled = 0; |
| 93 | #endif |
| 94 | } |
| 95 | |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 96 | #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 Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 104 | # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6)) |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 105 | #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 Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 112 | # define CALLER_ADDR6 0UL |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 113 | #endif |
| 114 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 115 | #ifdef CONFIG_IRQSOFF_TRACER |
Ingo Molnar | 489f139 | 2008-02-25 13:38:05 +0100 | [diff] [blame] | 116 | extern void time_hardirqs_on(unsigned long a0, unsigned long a1); |
| 117 | extern void time_hardirqs_off(unsigned long a0, unsigned long a1); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 118 | #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 Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 123 | #ifdef CONFIG_PREEMPT_TRACER |
Ingo Molnar | 489f139 | 2008-02-25 13:38:05 +0100 | [diff] [blame] | 124 | extern void trace_preempt_on(unsigned long a0, unsigned long a1); |
| 125 | extern void trace_preempt_off(unsigned long a0, unsigned long a1); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 126 | #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 Molnar | b1829d2 | 2008-05-28 01:22:08 +0200 | [diff] [blame] | 131 | #ifdef CONFIG_TRACING |
Ingo Molnar | 74f4e36 | 2008-05-12 21:21:15 +0200 | [diff] [blame] | 132 | extern void |
| 133 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); |
| 134 | #else |
| 135 | static inline void |
| 136 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } |
| 137 | #endif |
| 138 | |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 139 | #endif /* _LINUX_FTRACE_H */ |