unwind-itanium.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2003 Hewlett-Packard Co
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of libunwind.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. "Software"), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  21. #ifndef _UNWIND_H
  22. #define _UNWIND_H
  23. /* For uint64_t */
  24. #include <stdint.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Minimal interface as per C++ ABI draft standard:
  29. http://www.codesourcery.com/cxx-abi/abi-eh.html */
  30. typedef enum
  31. {
  32. _URC_NO_REASON = 0,
  33. _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
  34. _URC_FATAL_PHASE2_ERROR = 2,
  35. _URC_FATAL_PHASE1_ERROR = 3,
  36. _URC_NORMAL_STOP = 4,
  37. _URC_END_OF_STACK = 5,
  38. _URC_HANDLER_FOUND = 6,
  39. _URC_INSTALL_CONTEXT = 7,
  40. _URC_CONTINUE_UNWIND = 8
  41. }
  42. _Unwind_Reason_Code;
  43. typedef int _Unwind_Action;
  44. #define _UA_SEARCH_PHASE 1
  45. #define _UA_CLEANUP_PHASE 2
  46. #define _UA_HANDLER_FRAME 4
  47. #define _UA_FORCE_UNWIND 8
  48. struct _Unwind_Context; /* opaque data-structure */
  49. struct _Unwind_Exception; /* forward-declaration */
  50. typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
  51. struct _Unwind_Exception *);
  52. typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action,
  53. uint64_t,
  54. struct _Unwind_Exception *,
  55. struct _Unwind_Context *,
  56. void *);
  57. /* The C++ ABI requires exception_class, private_1, and private_2 to
  58. be of type uint64 and the entire structure to be
  59. double-word-aligned. Please note that exception_class stays 64-bit
  60. even on 32-bit machines for gcc compatibility. */
  61. struct _Unwind_Exception
  62. {
  63. uint64_t exception_class;
  64. _Unwind_Exception_Cleanup_Fn exception_cleanup;
  65. unsigned long private_1;
  66. unsigned long private_2;
  67. } __attribute__((__aligned__));
  68. extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
  69. extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
  70. _Unwind_Stop_Fn, void *);
  71. extern void _Unwind_Resume (struct _Unwind_Exception *);
  72. extern void _Unwind_DeleteException (struct _Unwind_Exception *);
  73. extern unsigned long _Unwind_GetGR (struct _Unwind_Context *, int);
  74. extern void _Unwind_SetGR (struct _Unwind_Context *, int, unsigned long);
  75. extern unsigned long _Unwind_GetIP (struct _Unwind_Context *);
  76. extern unsigned long _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
  77. extern void _Unwind_SetIP (struct _Unwind_Context *, unsigned long);
  78. extern unsigned long _Unwind_GetLanguageSpecificData (struct _Unwind_Context*);
  79. extern unsigned long _Unwind_GetRegionStart (struct _Unwind_Context *);
  80. #ifdef _GNU_SOURCE
  81. /* Callback for _Unwind_Backtrace(). The backtrace stops immediately
  82. if the callback returns any value other than _URC_NO_REASON. */
  83. typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *,
  84. void *);
  85. /* See http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00082.html for why
  86. _UA_END_OF_STACK exists. */
  87. # define _UA_END_OF_STACK 16
  88. /* If the unwind was initiated due to a forced unwind, resume that
  89. operation, else re-raise the exception. This is used by
  90. __cxa_rethrow(). */
  91. extern _Unwind_Reason_Code
  92. _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *);
  93. /* See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00154.html for why
  94. _Unwind_GetBSP() exists. */
  95. extern unsigned long _Unwind_GetBSP (struct _Unwind_Context *);
  96. /* Return the "canonical frame address" for the given context.
  97. This is used by NPTL... */
  98. extern unsigned long _Unwind_GetCFA (struct _Unwind_Context *);
  99. /* Return the base-address for data references. */
  100. extern unsigned long _Unwind_GetDataRelBase (struct _Unwind_Context *);
  101. /* Return the base-address for text references. */
  102. extern unsigned long _Unwind_GetTextRelBase (struct _Unwind_Context *);
  103. /* Call _Unwind_Trace_Fn once for each stack-frame, without doing any
  104. cleanup. The first frame for which the callback is invoked is the
  105. one for the caller of _Unwind_Backtrace(). _Unwind_Backtrace()
  106. returns _URC_END_OF_STACK when the backtrace stopped due to
  107. reaching the end of the call-chain or _URC_FATAL_PHASE1_ERROR if it
  108. stops for any other reason. */
  109. extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
  110. /* Find the start-address of the procedure containing the specified IP
  111. or NULL if it cannot be found (e.g., because the function has no
  112. unwind info). Note: there is not necessarily a one-to-one
  113. correspondence between source-level functions and procedures: some
  114. functions don't have unwind-info and others are split into multiple
  115. procedures. */
  116. extern void *_Unwind_FindEnclosingFunction (void *);
  117. /* See also Linux Standard Base Spec:
  118. http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/libgcc-s.html */
  119. #endif /* _GNU_SOURCE */
  120. #define DECLARE_PERSONALITY_FUNCTION(name) \
  121. _Unwind_Reason_Code name(int version,\
  122. _Unwind_Action actions,\
  123. uint64_t exceptionClass,\
  124. struct _Unwind_Exception *exceptionObject,\
  125. struct _Unwind_Context *context);
  126. #define BEGIN_PERSONALITY_FUNCTION(name) \
  127. _Unwind_Reason_Code name(int version,\
  128. _Unwind_Action actions,\
  129. uint64_t exceptionClass,\
  130. struct _Unwind_Exception *exceptionObject,\
  131. struct _Unwind_Context *context)\
  132. {
  133. #define CALL_PERSONALITY_FUNCTION(name) name(version, actions, exceptionClass, exceptionObject, context)
  134. #ifdef __cplusplus
  135. }
  136. #endif
  137. #endif /* _UNWIND_H */