unwind.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. struct module;
  14. #ifdef CONFIG_STACK_UNWIND
  15. #include <asm/unwind.h>
  16. #ifndef ARCH_UNWIND_SECTION_NAME
  17. #define ARCH_UNWIND_SECTION_NAME ".eh_frame"
  18. #endif
  19. /*
  20. * Initialize unwind support.
  21. */
  22. extern void unwind_init(void);
  23. #ifdef CONFIG_MODULES
  24. extern void *unwind_add_table(struct module *,
  25. const void *table_start,
  26. unsigned long table_size);
  27. extern void unwind_remove_table(void *handle, int init_only);
  28. #endif
  29. extern int unwind_init_frame_info(struct unwind_frame_info *,
  30. struct task_struct *,
  31. /*const*/ struct pt_regs *);
  32. /*
  33. * Prepare to unwind a blocked task.
  34. */
  35. extern int unwind_init_blocked(struct unwind_frame_info *,
  36. struct task_struct *);
  37. /*
  38. * Prepare to unwind the currently running thread.
  39. */
  40. extern int unwind_init_running(struct unwind_frame_info *,
  41. asmlinkage int (*callback)(struct unwind_frame_info *,
  42. void *arg),
  43. void *arg);
  44. /*
  45. * Unwind to previous to frame. Returns 0 if successful, negative
  46. * number in case of an error.
  47. */
  48. extern int unwind(struct unwind_frame_info *);
  49. /*
  50. * Unwind until the return pointer is in user-land (or until an error
  51. * occurs). Returns 0 if successful, negative number in case of
  52. * error.
  53. */
  54. extern int unwind_to_user(struct unwind_frame_info *);
  55. #else
  56. struct unwind_frame_info {};
  57. static inline void unwind_init(void) {}
  58. #ifdef CONFIG_MODULES
  59. static inline void *unwind_add_table(struct module *mod,
  60. const void *table_start,
  61. unsigned long table_size)
  62. {
  63. return NULL;
  64. }
  65. #endif
  66. static inline void unwind_remove_table(void *handle, int init_only)
  67. {
  68. }
  69. static inline int unwind_init_frame_info(struct unwind_frame_info *info,
  70. struct task_struct *tsk,
  71. const struct pt_regs *regs)
  72. {
  73. return -ENOSYS;
  74. }
  75. static inline int unwind_init_blocked(struct unwind_frame_info *info,
  76. struct task_struct *tsk)
  77. {
  78. return -ENOSYS;
  79. }
  80. static inline int unwind_init_running(struct unwind_frame_info *info,
  81. asmlinkage int (*cb)(struct unwind_frame_info *,
  82. void *arg),
  83. void *arg)
  84. {
  85. return -ENOSYS;
  86. }
  87. static inline int unwind(struct unwind_frame_info *info)
  88. {
  89. return -ENOSYS;
  90. }
  91. static inline int unwind_to_user(struct unwind_frame_info *info)
  92. {
  93. return -ENOSYS;
  94. }
  95. #endif
  96. #endif /* _LINUX_UNWIND_H */