unwind.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*===---- unwind.h - Stack unwinding ----------------------------------------===
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. *
  21. *===-----------------------------------------------------------------------===
  22. */
  23. /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
  24. #ifndef __CLANG_UNWIND_H
  25. #define __CLANG_UNWIND_H
  26. #if __has_include_next(<unwind.h>)
  27. /* Darwin and libunwind provide an unwind.h. If that's available, use
  28. * it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
  29. * so define that around the include.*/
  30. # ifndef _GNU_SOURCE
  31. # define _SHOULD_UNDEFINE_GNU_SOURCE
  32. # define _GNU_SOURCE
  33. # endif
  34. // libunwind's unwind.h reflects the current visibility. However, Mozilla
  35. // builds with -fvisibility=hidden and relies on gcc's unwind.h to reset the
  36. // visibility to default and export its contents. gcc also allows users to
  37. // override its override by #defining HIDE_EXPORTS (but note, this only obeys
  38. // the user's -fvisibility setting; it doesn't hide any exports on its own). We
  39. // imitate gcc's header here:
  40. # ifdef HIDE_EXPORTS
  41. # include_next <unwind.h>
  42. # else
  43. # pragma GCC visibility push(default)
  44. # include_next <unwind.h>
  45. # pragma GCC visibility pop
  46. # endif
  47. # ifdef _SHOULD_UNDEFINE_GNU_SOURCE
  48. # undef _GNU_SOURCE
  49. # undef _SHOULD_UNDEFINE_GNU_SOURCE
  50. # endif
  51. #else
  52. #include <stdint.h>
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. /* It is a bit strange for a header to play with the visibility of the
  57. symbols it declares, but this matches gcc's behavior and some programs
  58. depend on it */
  59. #ifndef HIDE_EXPORTS
  60. #pragma GCC visibility push(default)
  61. #endif
  62. struct _Unwind_Context;
  63. typedef enum {
  64. _URC_NO_REASON = 0,
  65. _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
  66. _URC_FATAL_PHASE2_ERROR = 2,
  67. _URC_FATAL_PHASE1_ERROR = 3,
  68. _URC_NORMAL_STOP = 4,
  69. _URC_END_OF_STACK = 5,
  70. _URC_HANDLER_FOUND = 6,
  71. _URC_INSTALL_CONTEXT = 7,
  72. _URC_CONTINUE_UNWIND = 8
  73. } _Unwind_Reason_Code;
  74. #ifdef __arm__
  75. typedef enum {
  76. _UVRSC_CORE = 0, /* integer register */
  77. _UVRSC_VFP = 1, /* vfp */
  78. _UVRSC_WMMXD = 3, /* Intel WMMX data register */
  79. _UVRSC_WMMXC = 4 /* Intel WMMX control register */
  80. } _Unwind_VRS_RegClass;
  81. typedef enum {
  82. _UVRSD_UINT32 = 0,
  83. _UVRSD_VFPX = 1,
  84. _UVRSD_UINT64 = 3,
  85. _UVRSD_FLOAT = 4,
  86. _UVRSD_DOUBLE = 5
  87. } _Unwind_VRS_DataRepresentation;
  88. typedef enum {
  89. _UVRSR_OK = 0,
  90. _UVRSR_NOT_IMPLEMENTED = 1,
  91. _UVRSR_FAILED = 2
  92. } _Unwind_VRS_Result;
  93. _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context,
  94. _Unwind_VRS_RegClass __regclass,
  95. uint32_t __regno,
  96. _Unwind_VRS_DataRepresentation __representation,
  97. void *__valuep);
  98. #else
  99. uintptr_t _Unwind_GetIP(struct _Unwind_Context* __context);
  100. #endif
  101. typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context*, void*);
  102. _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*);
  103. #ifndef HIDE_EXPORTS
  104. #pragma GCC visibility pop
  105. #endif
  106. #ifdef __cplusplus
  107. }
  108. #endif
  109. #endif
  110. #endif /* __CLANG_UNWIND_H */