Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 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 | |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 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); |
Jan Beulich | 690a973 | 2006-10-21 18:37:01 +0200 | [diff] [blame^] | 29 | extern void unwind_setup(void); |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 30 | |
Jan Beulich | 83f4fcc | 2006-06-26 13:57:50 +0200 | [diff] [blame] | 31 | #ifdef CONFIG_MODULES |
| 32 | |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 33 | extern void *unwind_add_table(struct module *, |
| 34 | const void *table_start, |
| 35 | unsigned long table_size); |
| 36 | |
| 37 | extern void unwind_remove_table(void *handle, int init_only); |
| 38 | |
Jan Beulich | 83f4fcc | 2006-06-26 13:57:50 +0200 | [diff] [blame] | 39 | #endif |
| 40 | |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 41 | extern int unwind_init_frame_info(struct unwind_frame_info *, |
| 42 | struct task_struct *, |
| 43 | /*const*/ struct pt_regs *); |
| 44 | |
| 45 | /* |
| 46 | * Prepare to unwind a blocked task. |
| 47 | */ |
| 48 | extern int unwind_init_blocked(struct unwind_frame_info *, |
| 49 | struct task_struct *); |
| 50 | |
| 51 | /* |
| 52 | * Prepare to unwind the currently running thread. |
| 53 | */ |
| 54 | extern int unwind_init_running(struct unwind_frame_info *, |
Jan Beulich | c33bd9a | 2006-06-26 13:57:47 +0200 | [diff] [blame] | 55 | asmlinkage int (*callback)(struct unwind_frame_info *, |
| 56 | void *arg), |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 57 | void *arg); |
| 58 | |
| 59 | /* |
| 60 | * Unwind to previous to frame. Returns 0 if successful, negative |
| 61 | * number in case of an error. |
| 62 | */ |
| 63 | extern int unwind(struct unwind_frame_info *); |
| 64 | |
| 65 | /* |
| 66 | * Unwind until the return pointer is in user-land (or until an error |
| 67 | * occurs). Returns 0 if successful, negative number in case of |
| 68 | * error. |
| 69 | */ |
| 70 | extern int unwind_to_user(struct unwind_frame_info *); |
| 71 | |
| 72 | #else |
| 73 | |
| 74 | struct unwind_frame_info {}; |
| 75 | |
| 76 | static inline void unwind_init(void) {} |
Jan Beulich | 690a973 | 2006-10-21 18:37:01 +0200 | [diff] [blame^] | 77 | static inline void unwind_setup(void) {} |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 78 | |
Jan Beulich | 83f4fcc | 2006-06-26 13:57:50 +0200 | [diff] [blame] | 79 | #ifdef CONFIG_MODULES |
| 80 | |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 81 | static 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 Beulich | 83f4fcc | 2006-06-26 13:57:50 +0200 | [diff] [blame] | 88 | #endif |
| 89 | |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 90 | static inline void unwind_remove_table(void *handle, int init_only) |
| 91 | { |
| 92 | } |
| 93 | |
| 94 | static 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 | |
| 101 | static inline int unwind_init_blocked(struct unwind_frame_info *info, |
| 102 | struct task_struct *tsk) |
| 103 | { |
| 104 | return -ENOSYS; |
| 105 | } |
| 106 | |
| 107 | static inline int unwind_init_running(struct unwind_frame_info *info, |
Jan Beulich | c33bd9a | 2006-06-26 13:57:47 +0200 | [diff] [blame] | 108 | asmlinkage int (*cb)(struct unwind_frame_info *, |
| 109 | void *arg), |
Jan Beulich | 4552d5d | 2006-06-26 13:57:28 +0200 | [diff] [blame] | 110 | void *arg) |
| 111 | { |
| 112 | return -ENOSYS; |
| 113 | } |
| 114 | |
| 115 | static inline int unwind(struct unwind_frame_info *info) |
| 116 | { |
| 117 | return -ENOSYS; |
| 118 | } |
| 119 | |
| 120 | static inline int unwind_to_user(struct unwind_frame_info *info) |
| 121 | { |
| 122 | return -ENOSYS; |
| 123 | } |
| 124 | |
| 125 | #endif |
| 126 | |
| 127 | #endif /* _LINUX_UNWIND_H */ |