blob: ce48e2cd37a28d52c1e15e8497e4b3c74da769ab [file] [log] [blame]
Jan Beulich4552d5d2006-06-26 13:57:28 +02001#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
15#include <linux/config.h>
16
17struct module;
18
19#ifdef CONFIG_STACK_UNWIND
20
21#include <asm/unwind.h>
22
23#ifndef ARCH_UNWIND_SECTION_NAME
24#define ARCH_UNWIND_SECTION_NAME ".eh_frame"
25#endif
26
27/*
28 * Initialize unwind support.
29 */
30extern void unwind_init(void);
31
Jan Beulich83f4fcc2006-06-26 13:57:50 +020032#ifdef CONFIG_MODULES
33
Jan Beulich4552d5d2006-06-26 13:57:28 +020034extern void *unwind_add_table(struct module *,
35 const void *table_start,
36 unsigned long table_size);
37
38extern void unwind_remove_table(void *handle, int init_only);
39
Jan Beulich83f4fcc2006-06-26 13:57:50 +020040#endif
41
Jan Beulich4552d5d2006-06-26 13:57:28 +020042extern int unwind_init_frame_info(struct unwind_frame_info *,
43 struct task_struct *,
44 /*const*/ struct pt_regs *);
45
46/*
47 * Prepare to unwind a blocked task.
48 */
49extern int unwind_init_blocked(struct unwind_frame_info *,
50 struct task_struct *);
51
52/*
53 * Prepare to unwind the currently running thread.
54 */
55extern int unwind_init_running(struct unwind_frame_info *,
Jan Beulichc33bd9a2006-06-26 13:57:47 +020056 asmlinkage int (*callback)(struct unwind_frame_info *,
57 void *arg),
Jan Beulich4552d5d2006-06-26 13:57:28 +020058 void *arg);
59
60/*
61 * Unwind to previous to frame. Returns 0 if successful, negative
62 * number in case of an error.
63 */
64extern int unwind(struct unwind_frame_info *);
65
66/*
67 * Unwind until the return pointer is in user-land (or until an error
68 * occurs). Returns 0 if successful, negative number in case of
69 * error.
70 */
71extern int unwind_to_user(struct unwind_frame_info *);
72
73#else
74
75struct unwind_frame_info {};
76
77static inline void unwind_init(void) {}
78
Jan Beulich83f4fcc2006-06-26 13:57:50 +020079#ifdef CONFIG_MODULES
80
Jan Beulich4552d5d2006-06-26 13:57:28 +020081static inline void *unwind_add_table(struct module *mod,
82 const void *table_start,
83 unsigned long table_size)
84{
85 return NULL;
86}
87
Jan Beulich83f4fcc2006-06-26 13:57:50 +020088#endif
89
Jan Beulich4552d5d2006-06-26 13:57:28 +020090static inline void unwind_remove_table(void *handle, int init_only)
91{
92}
93
94static inline int unwind_init_frame_info(struct unwind_frame_info *info,
95 struct task_struct *tsk,
96 const struct pt_regs *regs)
97{
98 return -ENOSYS;
99}
100
101static inline int unwind_init_blocked(struct unwind_frame_info *info,
102 struct task_struct *tsk)
103{
104 return -ENOSYS;
105}
106
107static inline int unwind_init_running(struct unwind_frame_info *info,
Jan Beulichc33bd9a2006-06-26 13:57:47 +0200108 asmlinkage int (*cb)(struct unwind_frame_info *,
109 void *arg),
Jan Beulich4552d5d2006-06-26 13:57:28 +0200110 void *arg)
111{
112 return -ENOSYS;
113}
114
115static inline int unwind(struct unwind_frame_info *info)
116{
117 return -ENOSYS;
118}
119
120static inline int unwind_to_user(struct unwind_frame_info *info)
121{
122 return -ENOSYS;
123}
124
125#endif
126
127#endif /* _LINUX_UNWIND_H */