libunwind-ia64.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2001-2004 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 LIBUNWIND_H
  22. #define LIBUNWIND_H
  23. #include <inttypes.h>
  24. #include <ucontext.h>
  25. #if defined(__cplusplus) || defined(c_plusplus)
  26. extern "C" {
  27. #endif
  28. #ifdef ia64
  29. /* This works around a bug in Intel's ECC v7.0 which defines "ia64"
  30. as "1". */
  31. # undef ia64
  32. #endif
  33. #ifdef __hpux
  34. /* On HP-UX, there is no hope of supporting UNW_LOCAL_ONLY, because
  35. it's impossible to obtain the address of the members in the
  36. sigcontext structure. */
  37. # undef UNW_LOCAL_ONLY
  38. # define UNW_GENERIC_ONLY
  39. #endif
  40. #define UNW_TARGET ia64
  41. #define UNW_TARGET_IA64 1
  42. #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
  43. /* This needs to be big enough to accommodate "struct cursor", while
  44. leaving some slack for future expansion. Changing this value will
  45. require recompiling all users of this library. Stack allocation is
  46. relatively cheap and unwind-state copying is relatively rare, so we
  47. want to err on making it rather too big than too small. */
  48. #define UNW_TDEP_CURSOR_LEN 511
  49. /* If this bit is it indicates that the procedure saved all of ar.bsp,
  50. ar.bspstore, and ar.rnat. If, additionally, ar.bsp != saved ar.bsp,
  51. then this procedure has performed a register-backing-store switch. */
  52. #define UNW_PI_FLAG_IA64_RBS_SWITCH_BIT (UNW_PI_FLAG_FIRST_TDEP_BIT + 0)
  53. #define UNW_PI_FLAG_IA64_RBS_SWITCH (1 << UNW_PI_FLAG_IA64_RBS_SWITCH_BIT)
  54. typedef uint64_t unw_word_t;
  55. typedef int64_t unw_sword_t;
  56. /* On IA-64, we want to access the contents of floating-point
  57. registers as a pair of "words", but to ensure 16-byte alignment, we
  58. make it a union that contains a "long double". This will do the
  59. Right Thing on all known IA-64 platforms, including HP-UX. */
  60. typedef union
  61. {
  62. struct { unw_word_t bits[2]; } raw;
  63. long double dummy; /* dummy to force 16-byte alignment */
  64. }
  65. unw_tdep_fpreg_t;
  66. typedef struct
  67. {
  68. /* no ia64-specific auxiliary proc-info */
  69. }
  70. unw_tdep_proc_info_t;
  71. typedef enum
  72. {
  73. /* Note: general registers are excepted to start with index 0.
  74. This convention facilitates architecture-independent
  75. implementation of the C++ exception handling ABI. See
  76. _Unwind_SetGR() and _Unwind_GetGR() for details. */
  77. UNW_IA64_GR = 0, /* general registers (r0..r127) */
  78. UNW_IA64_GP = UNW_IA64_GR + 1,
  79. UNW_IA64_TP = UNW_IA64_GR + 13,
  80. UNW_IA64_NAT = UNW_IA64_GR + 128, /* NaT registers (nat0..nat127) */
  81. UNW_IA64_FR = UNW_IA64_NAT + 128, /* fp registers (f0..f127) */
  82. UNW_IA64_AR = UNW_IA64_FR + 128, /* application registers (ar0..r127) */
  83. UNW_IA64_AR_RSC = UNW_IA64_AR + 16,
  84. UNW_IA64_AR_BSP = UNW_IA64_AR + 17,
  85. UNW_IA64_AR_BSPSTORE = UNW_IA64_AR + 18,
  86. UNW_IA64_AR_RNAT = UNW_IA64_AR + 19,
  87. UNW_IA64_AR_CSD = UNW_IA64_AR + 25,
  88. UNW_IA64_AR_26 = UNW_IA64_AR + 26,
  89. UNW_IA64_AR_SSD = UNW_IA64_AR_26,
  90. UNW_IA64_AR_CCV = UNW_IA64_AR + 32,
  91. UNW_IA64_AR_UNAT = UNW_IA64_AR + 36,
  92. UNW_IA64_AR_FPSR = UNW_IA64_AR + 40,
  93. UNW_IA64_AR_PFS = UNW_IA64_AR + 64,
  94. UNW_IA64_AR_LC = UNW_IA64_AR + 65,
  95. UNW_IA64_AR_EC = UNW_IA64_AR + 66,
  96. UNW_IA64_BR = UNW_IA64_AR + 128, /* branch registers (b0..p7) */
  97. UNW_IA64_RP = UNW_IA64_BR + 0, /* return pointer (rp) */
  98. UNW_IA64_PR = UNW_IA64_BR + 8, /* predicate registers (p0..p63) */
  99. UNW_IA64_CFM,
  100. /* frame info: */
  101. UNW_IA64_BSP,
  102. UNW_IA64_IP,
  103. UNW_IA64_SP,
  104. UNW_TDEP_LAST_REG = UNW_IA64_SP,
  105. UNW_TDEP_IP = UNW_IA64_IP,
  106. UNW_TDEP_SP = UNW_IA64_SP,
  107. UNW_TDEP_EH = UNW_IA64_GR + 15
  108. }
  109. ia64_regnum_t;
  110. #define UNW_TDEP_NUM_EH_REGS 4 /* r15-r18 are exception args */
  111. typedef struct unw_tdep_save_loc
  112. {
  113. /* Additional target-dependent info on a save location. On IA-64,
  114. we use this to provide the bit number in which a NaT bit gets
  115. saved. */
  116. uint8_t nat_bitnr;
  117. /* Padding reserved for future use. */
  118. uint8_t reserved[7];
  119. }
  120. unw_tdep_save_loc_t;
  121. /* On IA-64, we can directly use ucontext_t as the unwind context. */
  122. typedef ucontext_t unw_tdep_context_t;
  123. #define unw_tdep_is_fpreg(r) ((unsigned) ((r) - UNW_IA64_FR) < 128)
  124. #include "libunwind-dynamic.h"
  125. #include "libunwind-common.h"
  126. #ifdef __hpux
  127. /* In theory, we could use _Uia64_getcontext() on HP-UX as well, but
  128. the benefit of doing so would be marginal given that it can't
  129. support UNW_LOCAL_ONLY. */
  130. # define unw_tdep_getcontext getcontext
  131. #else
  132. # define unw_tdep_getcontext UNW_ARCH_OBJ (getcontext)
  133. extern int unw_tdep_getcontext (unw_tdep_context_t *);
  134. #endif
  135. /* This is a helper routine to search an ia64 unwind table. If the
  136. address-space argument AS points to something other than the local
  137. address-space, the memory for the unwind-info will be allocated
  138. with malloc(), and should be free()d during the put_unwind_info()
  139. callback. This routine is signal-safe for the local-address-space
  140. case ONLY. */
  141. #define unw_search_ia64_unwind_table UNW_OBJ(search_unwind_table)
  142. extern int unw_search_ia64_unwind_table (unw_addr_space_t, unw_word_t,
  143. unw_dyn_info_t *, unw_proc_info_t *,
  144. int, void *);
  145. /* This is a helper routine which the get_dyn_info_list_addr()
  146. callback can use to locate the special dynamic-info list entry in
  147. an IA-64 unwind table. If the entry exists in the table, the
  148. list-address is returned. In all other cases, 0 is returned. */
  149. extern unw_word_t _Uia64_find_dyn_list (unw_addr_space_t, unw_dyn_info_t *,
  150. void *);
  151. /* This is a helper routine to obtain the kernel-unwind info. It is
  152. signal-safe. */
  153. extern int _Uia64_get_kernel_table (unw_dyn_info_t *);
  154. #if defined(__cplusplus) || defined(c_plusplus)
  155. }
  156. #endif
  157. #endif /* LIBUNWIND_H */