unwind.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef _LINUX_UNWIND_H
  2. #define _LINUX_UNWIND_H
  3. /*
  4. * Copyright (C) 2002-2006 Novell, Inc.
  5. * Jan Beulich <jbeulich@novell.com>
  6. * This code is released under version 2 of the GNU GPL.
  7. *
  8. * A simple API for unwinding kernel stacks. This is used for
  9. * debugging and error reporting purposes. The kernel doesn't need
  10. * full-blown stack unwinding with all the bells and whistles, so there
  11. * is not much point in implementing the full Dwarf2 unwind API.
  12. */
  13. #include <linux/config.h>
  14. struct module;
  15. #ifdef CONFIG_STACK_UNWIND
  16. #include <asm/unwind.h>
  17. #ifndef ARCH_UNWIND_SECTION_NAME
  18. #define ARCH_UNWIND_SECTION_NAME ".eh_frame"
  19. #endif
  20. /*
  21. * Initialize unwind support.
  22. */
  23. extern void unwind_init(void);
  24. #ifdef CONFIG_MODULES
  25. extern void *unwind_add_table(struct module *,
  26. const void *table_start,
  27. unsigned long table_size);
  28. extern void unwind_remove_table(void *handle, int init_only);
  29. #endif
  30. extern int unwind_init_frame_info(struct unwind_frame_info *,
  31. struct task_struct *,
  32. /*const*/ struct pt_regs *);
  33. /*
  34. * Prepare to unwind a blocked task.
  35. */
  36. extern int unwind_init_blocked(struct unwind_frame_info *,
  37. struct task_struct *);
  38. /*
  39. * Prepare to unwind the currently running thread.
  40. */
  41. extern int unwind_init_running(struct unwind_frame_info *,
  42. asmlinkage int (*callback)(struct unwind_frame_info *,
  43. void *arg),
  44. void *arg);
  45. /*
  46. * Unwind to previous to frame. Returns 0 if successful, negative
  47. * number in case of an error.
  48. */
  49. extern int unwind(struct unwind_frame_info *);
  50. /*
  51. * Unwind until the return pointer is in user-land (or until an error
  52. * occurs). Returns 0 if successful, negative number in case of
  53. * error.
  54. */
  55. extern int unwind_to_user(struct unwind_frame_info *);
  56. #else
  57. struct unwind_frame_info {};
  58. static inline void unwind_init(void) {}
  59. #ifdef CONFIG_MODULES
  60. static inline void *unwind_add_table(struct module *mod,
  61. const void *table_start,
  62. unsigned long table_size)
  63. {
  64. return NULL;
  65. }
  66. #endif
  67. static inline void unwind_remove_table(void *handle, int init_only)
  68. {
  69. }
  70. static inline int unwind_init_frame_info(struct unwind_frame_info *info,
  71. struct task_struct *tsk,
  72. const struct pt_regs *regs)
  73. {
  74. return -ENOSYS;
  75. }
  76. static inline int unwind_init_blocked(struct unwind_frame_info *info,
  77. struct task_struct *tsk)
  78. {
  79. return -ENOSYS;
  80. }
  81. static inline int unwind_init_running(struct unwind_frame_info *info,
  82. asmlinkage int (*cb)(struct unwind_frame_info *,
  83. void *arg),
  84. void *arg)
  85. {
  86. return -ENOSYS;
  87. }
  88. static inline int unwind(struct unwind_frame_info *info)
  89. {
  90. return -ENOSYS;
  91. }
  92. static inline int unwind_to_user(struct unwind_frame_info *info)
  93. {
  94. return -ENOSYS;
  95. }
  96. #endif
  97. #endif /* _LINUX_UNWIND_H */