unwind.h 3.1 KB

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