Commit | Line | Data |
---|---|---|
4552d5dc JB |
1 | #ifndef _LINUX_UNWIND_H |
2 | #define _LINUX_UNWIND_H | |
3 | ||
4 | /* | |
5 | * Copyright (C) 2002-2006 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 | ||
4552d5dc JB |
15 | struct module; |
16 | ||
17 | #ifdef CONFIG_STACK_UNWIND | |
18 | ||
19 | #include <asm/unwind.h> | |
20 | ||
21 | #ifndef ARCH_UNWIND_SECTION_NAME | |
22 | #define ARCH_UNWIND_SECTION_NAME ".eh_frame" | |
23 | #endif | |
24 | ||
25 | /* | |
26 | * Initialize unwind support. | |
27 | */ | |
28 | extern void unwind_init(void); | |
29 | ||
83f4fcce JB |
30 | #ifdef CONFIG_MODULES |
31 | ||
4552d5dc JB |
32 | extern void *unwind_add_table(struct module *, |
33 | const void *table_start, | |
34 | unsigned long table_size); | |
35 | ||
36 | extern void unwind_remove_table(void *handle, int init_only); | |
37 | ||
83f4fcce JB |
38 | #endif |
39 | ||
4552d5dc JB |
40 | extern int unwind_init_frame_info(struct unwind_frame_info *, |
41 | struct task_struct *, | |
42 | /*const*/ struct pt_regs *); | |
43 | ||
44 | /* | |
45 | * Prepare to unwind a blocked task. | |
46 | */ | |
47 | extern int unwind_init_blocked(struct unwind_frame_info *, | |
48 | struct task_struct *); | |
49 | ||
50 | /* | |
51 | * Prepare to unwind the currently running thread. | |
52 | */ | |
53 | extern int unwind_init_running(struct unwind_frame_info *, | |
c33bd9aa JB |
54 | asmlinkage int (*callback)(struct unwind_frame_info *, |
55 | void *arg), | |
4552d5dc JB |
56 | void *arg); |
57 | ||
58 | /* | |
59 | * Unwind to previous to frame. Returns 0 if successful, negative | |
60 | * number in case of an error. | |
61 | */ | |
62 | extern int unwind(struct unwind_frame_info *); | |
63 | ||
64 | /* | |
65 | * Unwind until the return pointer is in user-land (or until an error | |
66 | * occurs). Returns 0 if successful, negative number in case of | |
67 | * error. | |
68 | */ | |
69 | extern int unwind_to_user(struct unwind_frame_info *); | |
70 | ||
71 | #else | |
72 | ||
73 | struct unwind_frame_info {}; | |
74 | ||
75 | static inline void unwind_init(void) {} | |
76 | ||
83f4fcce JB |
77 | #ifdef CONFIG_MODULES |
78 | ||
4552d5dc JB |
79 | static inline void *unwind_add_table(struct module *mod, |
80 | const void *table_start, | |
81 | unsigned long table_size) | |
82 | { | |
83 | return NULL; | |
84 | } | |
85 | ||
83f4fcce JB |
86 | #endif |
87 | ||
4552d5dc JB |
88 | static inline void unwind_remove_table(void *handle, int init_only) |
89 | { | |
90 | } | |
91 | ||
92 | static inline int unwind_init_frame_info(struct unwind_frame_info *info, | |
93 | struct task_struct *tsk, | |
94 | const struct pt_regs *regs) | |
95 | { | |
96 | return -ENOSYS; | |
97 | } | |
98 | ||
99 | static inline int unwind_init_blocked(struct unwind_frame_info *info, | |
100 | struct task_struct *tsk) | |
101 | { | |
102 | return -ENOSYS; | |
103 | } | |
104 | ||
105 | static inline int unwind_init_running(struct unwind_frame_info *info, | |
c33bd9aa JB |
106 | asmlinkage int (*cb)(struct unwind_frame_info *, |
107 | void *arg), | |
4552d5dc JB |
108 | void *arg) |
109 | { | |
110 | return -ENOSYS; | |
111 | } | |
112 | ||
113 | static inline int unwind(struct unwind_frame_info *info) | |
114 | { | |
115 | return -ENOSYS; | |
116 | } | |
117 | ||
118 | static inline int unwind_to_user(struct unwind_frame_info *info) | |
119 | { | |
120 | return -ENOSYS; | |
121 | } | |
122 | ||
123 | #endif | |
124 | ||
125 | #endif /* _LINUX_UNWIND_H */ |