blob: 73e1751d03dd18e2806d4a018c05f9cf05eaf942 [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
Jan Beulich4552d5d2006-06-26 13:57:28 +020015struct 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 */
28extern void unwind_init(void);
29
Jan Beulich83f4fcc2006-06-26 13:57:50 +020030#ifdef CONFIG_MODULES
31
Jan Beulich4552d5d2006-06-26 13:57:28 +020032extern void *unwind_add_table(struct module *,
33 const void *table_start,
34 unsigned long table_size);
35
36extern void unwind_remove_table(void *handle, int init_only);
37
Jan Beulich83f4fcc2006-06-26 13:57:50 +020038#endif
39
Jan Beulich4552d5d2006-06-26 13:57:28 +020040extern 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 */
47extern int unwind_init_blocked(struct unwind_frame_info *,
48 struct task_struct *);
49
50/*
51 * Prepare to unwind the currently running thread.
52 */
53extern int unwind_init_running(struct unwind_frame_info *,
Jan Beulichc33bd9a2006-06-26 13:57:47 +020054 asmlinkage int (*callback)(struct unwind_frame_info *,
55 void *arg),
Jan Beulich4552d5d2006-06-26 13:57:28 +020056 void *arg);
57
58/*
59 * Unwind to previous to frame. Returns 0 if successful, negative
60 * number in case of an error.
61 */
62extern 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 */
69extern int unwind_to_user(struct unwind_frame_info *);
70
71#else
72
73struct unwind_frame_info {};
74
75static inline void unwind_init(void) {}
76
Jan Beulich83f4fcc2006-06-26 13:57:50 +020077#ifdef CONFIG_MODULES
78
Jan Beulich4552d5d2006-06-26 13:57:28 +020079static inline void *unwind_add_table(struct module *mod,
80 const void *table_start,
81 unsigned long table_size)
82{
83 return NULL;
84}
85
Jan Beulich83f4fcc2006-06-26 13:57:50 +020086#endif
87
Jan Beulich4552d5d2006-06-26 13:57:28 +020088static inline void unwind_remove_table(void *handle, int init_only)
89{
90}
91
92static 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
99static inline int unwind_init_blocked(struct unwind_frame_info *info,
100 struct task_struct *tsk)
101{
102 return -ENOSYS;
103}
104
105static inline int unwind_init_running(struct unwind_frame_info *info,
Jan Beulichc33bd9a2006-06-26 13:57:47 +0200106 asmlinkage int (*cb)(struct unwind_frame_info *,
107 void *arg),
Jan Beulich4552d5d2006-06-26 13:57:28 +0200108 void *arg)
109{
110 return -ENOSYS;
111}
112
113static inline int unwind(struct unwind_frame_info *info)
114{
115 return -ENOSYS;
116}
117
118static inline int unwind_to_user(struct unwind_frame_info *info)
119{
120 return -ENOSYS;
121}
122
123#endif
124
125#endif /* _LINUX_UNWIND_H */