Update to 3.4-final.
[linux-flexiantxendom0-3.2.10.git] / include / linux / unwind.h
1 #ifndef _LINUX_UNWIND_H
2 #define _LINUX_UNWIND_H
3
4 /*
5  * Copyright (C) 2002-2009 Novell, Inc.
6  *     Jan Beulich <jbeulich@novell.com>
7  * This code is released under version 2 of the GNU GPL.
8  *
9  * A simple API for unwinding kernel stacks.  This is used for
10  * debugging and error reporting purposes.  The kernel doesn't need
11  * full-blown stack unwinding with all the bells and whistles, so there
12  * is not much point in implementing the full Dwarf2 unwind API.
13  */
14
15 #include <linux/linkage.h>
16
17 struct module;
18 struct stacktrace_ops;
19 struct unwind_frame_info;
20
21 typedef asmlinkage int (*unwind_callback_fn)(struct unwind_frame_info *,
22                                              const struct stacktrace_ops *,
23                                              void *);
24
25 #ifdef CONFIG_STACK_UNWIND
26
27 #include <asm/unwind.h>
28 #include <asm/stacktrace.h>
29
30 #ifndef ARCH_UNWIND_SECTION_NAME
31 #define ARCH_UNWIND_SECTION_NAME ".eh_frame"
32 #endif
33
34 /*
35  * Initialize unwind support.
36  */
37 extern void unwind_init(void);
38 extern void unwind_setup(void);
39
40 #ifdef CONFIG_MODULES
41
42 extern void *unwind_add_table(struct module *,
43                               const void *table_start,
44                               unsigned long table_size);
45
46 extern void unwind_remove_table(void *handle, int init_only);
47
48 #endif
49
50 extern int unwind_init_frame_info(struct unwind_frame_info *,
51                                   struct task_struct *,
52                                   /*const*/ struct pt_regs *);
53
54 /*
55  * Prepare to unwind a blocked task.
56  */
57 extern int unwind_init_blocked(struct unwind_frame_info *,
58                                struct task_struct *);
59
60 /*
61  * Prepare to unwind the currently running thread.
62  */
63 extern int unwind_init_running(struct unwind_frame_info *,
64                                unwind_callback_fn,
65                                const struct stacktrace_ops *,
66                                void *data);
67
68 /*
69  * Unwind to previous to frame.  Returns 0 if successful, negative
70  * number in case of an error.
71  */
72 extern int unwind(struct unwind_frame_info *);
73
74 /*
75  * Unwind until the return pointer is in user-land (or until an error
76  * occurs).  Returns 0 if successful, negative number in case of
77  * error.
78  */
79 extern int unwind_to_user(struct unwind_frame_info *);
80
81 #else /* CONFIG_STACK_UNWIND */
82
83 struct unwind_frame_info {};
84
85 static inline void unwind_init(void) {}
86 static inline void unwind_setup(void) {}
87
88 #ifdef CONFIG_MODULES
89
90 static inline void *unwind_add_table(struct module *mod,
91                                      const void *table_start,
92                                      unsigned long table_size)
93 {
94         return NULL;
95 }
96
97 #endif
98
99 static inline void unwind_remove_table(void *handle, int init_only)
100 {
101 }
102
103 static inline int unwind_init_frame_info(struct unwind_frame_info *info,
104                                          struct task_struct *tsk,
105                                          const struct pt_regs *regs)
106 {
107         return -ENOSYS;
108 }
109
110 static inline int unwind_init_blocked(struct unwind_frame_info *info,
111                                       struct task_struct *tsk)
112 {
113         return -ENOSYS;
114 }
115
116 static inline int unwind_init_running(struct unwind_frame_info *info,
117                                unwind_callback_fn cb,
118                                const struct stacktrace_ops *ops,
119                                       void *data)
120 {
121         return -ENOSYS;
122 }
123
124 static inline int unwind(struct unwind_frame_info *info)
125 {
126         return -ENOSYS;
127 }
128
129 static inline int unwind_to_user(struct unwind_frame_info *info)
130 {
131         return -ENOSYS;
132 }
133
134 #endif /* CONFIG_STACK_UNWIND */
135 #endif /* _LINUX_UNWIND_H */