1 #ifndef _LINUX_UNWIND_H
2 #define _LINUX_UNWIND_H
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.
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.
15 #include <linux/linkage.h>
18 struct stacktrace_ops;
19 struct unwind_frame_info;
21 typedef asmlinkage int (*unwind_callback_fn)(struct unwind_frame_info *,
22 const struct stacktrace_ops *,
25 #ifdef CONFIG_STACK_UNWIND
27 #include <asm/unwind.h>
28 #include <asm/stacktrace.h>
30 #ifndef ARCH_UNWIND_SECTION_NAME
31 #define ARCH_UNWIND_SECTION_NAME ".eh_frame"
35 * Initialize unwind support.
37 extern void unwind_init(void);
38 extern void unwind_setup(void);
42 extern void *unwind_add_table(struct module *,
43 const void *table_start,
44 unsigned long table_size);
46 extern void unwind_remove_table(void *handle, int init_only);
50 extern int unwind_init_frame_info(struct unwind_frame_info *,
52 /*const*/ struct pt_regs *);
55 * Prepare to unwind a blocked task.
57 extern int unwind_init_blocked(struct unwind_frame_info *,
58 struct task_struct *);
61 * Prepare to unwind the currently running thread.
63 extern int unwind_init_running(struct unwind_frame_info *,
65 const struct stacktrace_ops *,
69 * Unwind to previous to frame. Returns 0 if successful, negative
70 * number in case of an error.
72 extern int unwind(struct unwind_frame_info *);
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
79 extern int unwind_to_user(struct unwind_frame_info *);
81 #else /* CONFIG_STACK_UNWIND */
83 struct unwind_frame_info {};
85 static inline void unwind_init(void) {}
86 static inline void unwind_setup(void) {}
90 static inline void *unwind_add_table(struct module *mod,
91 const void *table_start,
92 unsigned long table_size)
99 static inline void unwind_remove_table(void *handle, int init_only)
103 static inline int unwind_init_frame_info(struct unwind_frame_info *info,
104 struct task_struct *tsk,
105 const struct pt_regs *regs)
110 static inline int unwind_init_blocked(struct unwind_frame_info *info,
111 struct task_struct *tsk)
116 static inline int unwind_init_running(struct unwind_frame_info *info,
117 unwind_callback_fn cb,
118 const struct stacktrace_ops *ops,
124 static inline int unwind(struct unwind_frame_info *info)
129 static inline int unwind_to_user(struct unwind_frame_info *info)
134 #endif /* CONFIG_STACK_UNWIND */
135 #endif /* _LINUX_UNWIND_H */