libunwind-ppc64.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2006-2007 IBM
  3. Contributed by
  4. Corey Ashford <cjashfor@us.ibm.com>
  5. Jose Flavio Aguilar Paulino <jflavio@br.ibm.com> <joseflavio@gmail.com>
  6. Copied from libunwind-x86_64.h, modified slightly for building
  7. frysk successfully on ppc64, by Wu Zhou <woodzltc@cn.ibm.com>
  8. Will be replaced when libunwind is ready on ppc64 platform.
  9. This file is part of libunwind.
  10. Permission is hereby granted, free of charge, to any person obtaining
  11. a copy of this software and associated documentation files (the
  12. "Software"), to deal in the Software without restriction, including
  13. without limitation the rights to use, copy, modify, merge, publish,
  14. distribute, sublicense, and/or sell copies of the Software, and to
  15. permit persons to whom the Software is furnished to do so, subject to
  16. the following conditions:
  17. The above copyright notice and this permission notice shall be
  18. included in all copies or substantial portions of the Software.
  19. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  26. #ifndef LIBUNWIND_H
  27. #define LIBUNWIND_H
  28. #if defined(__cplusplus) || defined(c_plusplus)
  29. extern "C" {
  30. #endif
  31. #include <inttypes.h>
  32. #include <ucontext.h>
  33. #define UNW_TARGET ppc64
  34. #define UNW_TARGET_PPC64 1
  35. #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
  36. /*
  37. * This needs to be big enough to accommodate "struct cursor", while
  38. * leaving some slack for future expansion. Changing this value will
  39. * require recompiling all users of this library. Stack allocation is
  40. * relatively cheap and unwind-state copying is relatively rare, so we want
  41. * to err on making it rather too big than too small.
  42. *
  43. * To simplify this whole process, we are at least initially taking the
  44. * tack that UNW_PPC64_* map straight across to the .eh_frame column register
  45. * numbers. These register numbers come from gcc's source in
  46. * gcc/config/rs6000/rs6000.h
  47. *
  48. * UNW_TDEP_CURSOR_LEN is in terms of unw_word_t size. Since we have 115
  49. * elements in the loc array, each sized 2 * unw_word_t, plus the rest of
  50. * the cursor struct, this puts us at about 2 * 115 + 40 = 270. Let's
  51. * round that up to 280.
  52. */
  53. #define UNW_TDEP_CURSOR_LEN 280
  54. #if __WORDSIZE==32
  55. typedef uint32_t unw_word_t;
  56. typedef int32_t unw_sword_t;
  57. #else
  58. typedef uint64_t unw_word_t;
  59. typedef int64_t unw_sword_t;
  60. #endif
  61. typedef long double unw_tdep_fpreg_t;
  62. /*
  63. * Vector register (in PowerPC64 used for AltiVec registers)
  64. */
  65. typedef struct {
  66. uint64_t halves[2];
  67. } unw_tdep_vreg_t;
  68. typedef enum
  69. {
  70. UNW_PPC64_R0,
  71. UNW_PPC64_R1, /* called STACK_POINTER in gcc */
  72. UNW_PPC64_R2,
  73. UNW_PPC64_R3,
  74. UNW_PPC64_R4,
  75. UNW_PPC64_R5,
  76. UNW_PPC64_R6,
  77. UNW_PPC64_R7,
  78. UNW_PPC64_R8,
  79. UNW_PPC64_R9,
  80. UNW_PPC64_R10,
  81. UNW_PPC64_R11, /* called STATIC_CHAIN in gcc */
  82. UNW_PPC64_R12,
  83. UNW_PPC64_R13,
  84. UNW_PPC64_R14,
  85. UNW_PPC64_R15,
  86. UNW_PPC64_R16,
  87. UNW_PPC64_R17,
  88. UNW_PPC64_R18,
  89. UNW_PPC64_R19,
  90. UNW_PPC64_R20,
  91. UNW_PPC64_R21,
  92. UNW_PPC64_R22,
  93. UNW_PPC64_R23,
  94. UNW_PPC64_R24,
  95. UNW_PPC64_R25,
  96. UNW_PPC64_R26,
  97. UNW_PPC64_R27,
  98. UNW_PPC64_R28,
  99. UNW_PPC64_R29,
  100. UNW_PPC64_R30,
  101. UNW_PPC64_R31, /* called HARD_FRAME_POINTER in gcc */
  102. UNW_PPC64_F0 = 32,
  103. UNW_PPC64_F1,
  104. UNW_PPC64_F2,
  105. UNW_PPC64_F3,
  106. UNW_PPC64_F4,
  107. UNW_PPC64_F5,
  108. UNW_PPC64_F6,
  109. UNW_PPC64_F7,
  110. UNW_PPC64_F8,
  111. UNW_PPC64_F9,
  112. UNW_PPC64_F10,
  113. UNW_PPC64_F11,
  114. UNW_PPC64_F12,
  115. UNW_PPC64_F13,
  116. UNW_PPC64_F14,
  117. UNW_PPC64_F15,
  118. UNW_PPC64_F16,
  119. UNW_PPC64_F17,
  120. UNW_PPC64_F18,
  121. UNW_PPC64_F19,
  122. UNW_PPC64_F20,
  123. UNW_PPC64_F21,
  124. UNW_PPC64_F22,
  125. UNW_PPC64_F23,
  126. UNW_PPC64_F24,
  127. UNW_PPC64_F25,
  128. UNW_PPC64_F26,
  129. UNW_PPC64_F27,
  130. UNW_PPC64_F28,
  131. UNW_PPC64_F29,
  132. UNW_PPC64_F30,
  133. UNW_PPC64_F31,
  134. /* Note that there doesn't appear to be an .eh_frame register column
  135. for the FPSCR register. I don't know why this is. Since .eh_frame
  136. info is what this implementation uses for unwinding, we have no way
  137. to unwind this register, and so we will not expose an FPSCR register
  138. number in the libunwind API.
  139. */
  140. UNW_PPC64_LR = 65,
  141. UNW_PPC64_CTR = 66,
  142. UNW_PPC64_ARG_POINTER = 67,
  143. UNW_PPC64_CR0 = 68,
  144. UNW_PPC64_CR1,
  145. UNW_PPC64_CR2,
  146. UNW_PPC64_CR3,
  147. UNW_PPC64_CR4,
  148. /* CR5 .. CR7 are currently unused */
  149. UNW_PPC64_CR5,
  150. UNW_PPC64_CR6,
  151. UNW_PPC64_CR7,
  152. UNW_PPC64_XER = 76,
  153. UNW_PPC64_V0 = 77,
  154. UNW_PPC64_V1,
  155. UNW_PPC64_V2,
  156. UNW_PPC64_V3,
  157. UNW_PPC64_V4,
  158. UNW_PPC64_V5,
  159. UNW_PPC64_V6,
  160. UNW_PPC64_V7,
  161. UNW_PPC64_V8,
  162. UNW_PPC64_V9,
  163. UNW_PPC64_V10,
  164. UNW_PPC64_V11,
  165. UNW_PPC64_V12,
  166. UNW_PPC64_V13,
  167. UNW_PPC64_V14,
  168. UNW_PPC64_V15,
  169. UNW_PPC64_V16,
  170. UNW_PPC64_V17,
  171. UNW_PPC64_V18,
  172. UNW_PPC64_V19,
  173. UNW_PPC64_V20,
  174. UNW_PPC64_V21,
  175. UNW_PPC64_V22,
  176. UNW_PPC64_V23,
  177. UNW_PPC64_V24,
  178. UNW_PPC64_V25,
  179. UNW_PPC64_V26,
  180. UNW_PPC64_V27,
  181. UNW_PPC64_V28,
  182. UNW_PPC64_V29,
  183. UNW_PPC64_V30,
  184. UNW_PPC64_V31,
  185. UNW_PPC64_VRSAVE = 109,
  186. UNW_PPC64_VSCR = 110,
  187. UNW_PPC64_SPE_ACC = 111,
  188. UNW_PPC64_SPEFSCR = 112,
  189. /* frame info (read-only) */
  190. UNW_PPC64_FRAME_POINTER,
  191. UNW_PPC64_NIP,
  192. UNW_TDEP_LAST_REG = UNW_PPC64_NIP,
  193. UNW_TDEP_IP = UNW_PPC64_NIP,
  194. UNW_TDEP_SP = UNW_PPC64_R1,
  195. UNW_TDEP_EH = UNW_PPC64_R12
  196. }
  197. ppc64_regnum_t;
  198. /*
  199. * According to David Edelsohn, GNU gcc uses R3, R4, R5, and maybe R6 for
  200. * passing parameters to exception handlers.
  201. */
  202. #define UNW_TDEP_NUM_EH_REGS 4
  203. typedef struct unw_tdep_save_loc
  204. {
  205. /* Additional target-dependent info on a save location. */
  206. }
  207. unw_tdep_save_loc_t;
  208. /* On ppc64, we can directly use ucontext_t as the unwind context. */
  209. typedef ucontext_t unw_tdep_context_t;
  210. /* XXX this is not ideal: an application should not be prevented from
  211. using the "getcontext" name just because it's using libunwind. We
  212. can't just use __getcontext() either, because that isn't exported
  213. by glibc... */
  214. #define unw_tdep_getcontext(uc) (getcontext (uc), 0)
  215. #include "libunwind-dynamic.h"
  216. typedef struct
  217. {
  218. /* no ppc64-specific auxiliary proc-info */
  219. }
  220. unw_tdep_proc_info_t;
  221. #include "libunwind-common.h"
  222. #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
  223. extern int unw_tdep_is_fpreg (int);
  224. #if defined(__cplusplus) || defined(c_plusplus)
  225. }
  226. #endif
  227. #endif /* LIBUNWIND_H */