aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ftrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r--include/linux/ftrace.h69
1 files changed, 56 insertions, 13 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 4fbc4a8b86a5..f1af1aab00e6 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -25,6 +25,17 @@ struct ftrace_ops {
25 25
26extern int function_trace_stop; 26extern int function_trace_stop;
27 27
28/*
29 * Type of the current tracing.
30 */
31enum ftrace_tracing_type_t {
32 FTRACE_TYPE_ENTER = 0, /* Hook the call of the function */
33 FTRACE_TYPE_RETURN, /* Hook the return of the function */
34};
35
36/* Current tracing type, default is FTRACE_TYPE_ENTER */
37extern enum ftrace_tracing_type_t ftrace_tracing_type;
38
28/** 39/**
29 * ftrace_stop - stop function tracer. 40 * ftrace_stop - stop function tracer.
30 * 41 *
@@ -74,6 +85,9 @@ static inline void ftrace_start(void) { }
74#endif /* CONFIG_FUNCTION_TRACER */ 85#endif /* CONFIG_FUNCTION_TRACER */
75 86
76#ifdef CONFIG_DYNAMIC_FTRACE 87#ifdef CONFIG_DYNAMIC_FTRACE
88/* asm/ftrace.h must be defined for archs supporting dynamic ftrace */
89#include <asm/ftrace.h>
90
77enum { 91enum {
78 FTRACE_FL_FREE = (1 << 0), 92 FTRACE_FL_FREE = (1 << 0),
79 FTRACE_FL_FAILED = (1 << 1), 93 FTRACE_FL_FAILED = (1 << 1),
@@ -88,6 +102,7 @@ struct dyn_ftrace {
88 struct list_head list; 102 struct list_head list;
89 unsigned long ip; /* address of mcount call-site */ 103 unsigned long ip; /* address of mcount call-site */
90 unsigned long flags; 104 unsigned long flags;
105 struct dyn_arch_ftrace arch;
91}; 106};
92 107
93int ftrace_force_update(void); 108int ftrace_force_update(void);
@@ -95,22 +110,43 @@ void ftrace_set_filter(unsigned char *buf, int len, int reset);
95 110
96/* defined in arch */ 111/* defined in arch */
97extern int ftrace_ip_converted(unsigned long ip); 112extern int ftrace_ip_converted(unsigned long ip);
98extern unsigned char *ftrace_nop_replace(void);
99extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
100extern int ftrace_dyn_arch_init(void *data); 113extern int ftrace_dyn_arch_init(void *data);
101extern int ftrace_update_ftrace_func(ftrace_func_t func); 114extern int ftrace_update_ftrace_func(ftrace_func_t func);
102extern void ftrace_caller(void); 115extern void ftrace_caller(void);
103extern void ftrace_call(void); 116extern void ftrace_call(void);
104extern void mcount_call(void); 117extern void mcount_call(void);
118#ifdef CONFIG_FUNCTION_RET_TRACER
119extern void ftrace_return_caller(void);
120#endif
105 121
106/* May be defined in arch */ 122/**
107extern int ftrace_arch_read_dyn_info(char *buf, int size); 123 * ftrace_make_nop - convert code into top
124 * @mod: module structure if called by module load initialization
125 * @rec: the mcount call site record
126 * @addr: the address that the call site should be calling
127 *
128 * This is a very sensitive operation and great care needs
129 * to be taken by the arch. The operation should carefully
130 * read the location, check to see if what is read is indeed
131 * what we expect it to be, and then on success of the compare,
132 * it should write to the location.
133 *
134 * The code segment at @rec->ip should be a caller to @addr
135 *
136 * Return must be:
137 * 0 on success
138 * -EFAULT on error reading the location
139 * -EINVAL on a failed compare of the contents
140 * -EPERM on error writing to the location
141 * Any other value will be considered a failure.
142 */
143extern int ftrace_make_nop(struct module *mod,
144 struct dyn_ftrace *rec, unsigned long addr);
108 145
109/** 146/**
110 * ftrace_modify_code - modify code segment 147 * ftrace_make_call - convert a nop call site into a call to addr
111 * @ip: the address of the code segment 148 * @rec: the mcount call site record
112 * @old_code: the contents of what is expected to be there 149 * @addr: the address that the call site should call
113 * @new_code: the code to patch in
114 * 150 *
115 * This is a very sensitive operation and great care needs 151 * This is a very sensitive operation and great care needs
116 * to be taken by the arch. The operation should carefully 152 * to be taken by the arch. The operation should carefully
@@ -118,6 +154,8 @@ extern int ftrace_arch_read_dyn_info(char *buf, int size);
118 * what we expect it to be, and then on success of the compare, 154 * what we expect it to be, and then on success of the compare,
119 * it should write to the location. 155 * it should write to the location.
120 * 156 *
157 * The code segment at @rec->ip should be a nop
158 *
121 * Return must be: 159 * Return must be:
122 * 0 on success 160 * 0 on success
123 * -EFAULT on error reading the location 161 * -EFAULT on error reading the location
@@ -125,8 +163,11 @@ extern int ftrace_arch_read_dyn_info(char *buf, int size);
125 * -EPERM on error writing to the location 163 * -EPERM on error writing to the location
126 * Any other value will be considered a failure. 164 * Any other value will be considered a failure.
127 */ 165 */
128extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code, 166extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
129 unsigned char *new_code); 167
168
169/* May be defined in arch */
170extern int ftrace_arch_read_dyn_info(char *buf, int size);
130 171
131extern int skip_trace(unsigned long ip); 172extern int skip_trace(unsigned long ip);
132 173
@@ -259,11 +300,13 @@ static inline void ftrace_dump(void) { }
259 300
260#ifdef CONFIG_FTRACE_MCOUNT_RECORD 301#ifdef CONFIG_FTRACE_MCOUNT_RECORD
261extern void ftrace_init(void); 302extern void ftrace_init(void);
262extern void ftrace_init_module(unsigned long *start, unsigned long *end); 303extern void ftrace_init_module(struct module *mod,
304 unsigned long *start, unsigned long *end);
263#else 305#else
264static inline void ftrace_init(void) { } 306static inline void ftrace_init(void) { }
265static inline void 307static inline void
266ftrace_init_module(unsigned long *start, unsigned long *end) { } 308ftrace_init_module(struct module *mod,
309 unsigned long *start, unsigned long *end) { }
267#endif 310#endif
268 311
269 312
@@ -281,7 +324,7 @@ struct ftrace_retfunc {
281/* Type of a callback handler of tracing return function */ 324/* Type of a callback handler of tracing return function */
282typedef void (*trace_function_return_t)(struct ftrace_retfunc *); 325typedef void (*trace_function_return_t)(struct ftrace_retfunc *);
283 326
284extern void register_ftrace_return(trace_function_return_t func); 327extern int register_ftrace_return(trace_function_return_t func);
285/* The current handler in use */ 328/* The current handler in use */
286extern trace_function_return_t ftrace_function_return; 329extern trace_function_return_t ftrace_function_return;
287extern void unregister_ftrace_return(void); 330extern void unregister_ftrace_return(void);