libunwind-ppc32.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 ppc32
  34. #define UNW_TARGET_PPC32 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_PPC32_* 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 200
  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. typedef enum
  63. {
  64. UNW_PPC32_R0,
  65. UNW_PPC32_R1, /* called STACK_POINTER in gcc */
  66. UNW_PPC32_R2,
  67. UNW_PPC32_R3,
  68. UNW_PPC32_R4,
  69. UNW_PPC32_R5,
  70. UNW_PPC32_R6,
  71. UNW_PPC32_R7,
  72. UNW_PPC32_R8,
  73. UNW_PPC32_R9,
  74. UNW_PPC32_R10,
  75. UNW_PPC32_R11, /* called STATIC_CHAIN in gcc */
  76. UNW_PPC32_R12,
  77. UNW_PPC32_R13,
  78. UNW_PPC32_R14,
  79. UNW_PPC32_R15,
  80. UNW_PPC32_R16,
  81. UNW_PPC32_R17,
  82. UNW_PPC32_R18,
  83. UNW_PPC32_R19,
  84. UNW_PPC32_R20,
  85. UNW_PPC32_R21,
  86. UNW_PPC32_R22,
  87. UNW_PPC32_R23,
  88. UNW_PPC32_R24,
  89. UNW_PPC32_R25,
  90. UNW_PPC32_R26,
  91. UNW_PPC32_R27,
  92. UNW_PPC32_R28,
  93. UNW_PPC32_R29,
  94. UNW_PPC32_R30,
  95. UNW_PPC32_R31, /* called HARD_FRAME_POINTER in gcc */
  96. /* Count Register */
  97. UNW_PPC32_CTR = 32,
  98. /* Fixed-Point Status and Control Register */
  99. UNW_PPC32_XER = 33,
  100. /* Condition Register */
  101. UNW_PPC32_CCR = 34,
  102. /* Machine State Register */
  103. //UNW_PPC32_MSR = 35,
  104. /* MQ or SPR0, not part of generic Power, part of MPC601 */
  105. //UNW_PPC32_MQ = 36,
  106. /* Link Register */
  107. UNW_PPC32_LR = 36,
  108. /* Floating Pointer Status and Control Register */
  109. UNW_PPC32_FPSCR = 37,
  110. UNW_PPC32_F0 = 48,
  111. UNW_PPC32_F1,
  112. UNW_PPC32_F2,
  113. UNW_PPC32_F3,
  114. UNW_PPC32_F4,
  115. UNW_PPC32_F5,
  116. UNW_PPC32_F6,
  117. UNW_PPC32_F7,
  118. UNW_PPC32_F8,
  119. UNW_PPC32_F9,
  120. UNW_PPC32_F10,
  121. UNW_PPC32_F11,
  122. UNW_PPC32_F12,
  123. UNW_PPC32_F13,
  124. UNW_PPC32_F14,
  125. UNW_PPC32_F15,
  126. UNW_PPC32_F16,
  127. UNW_PPC32_F17,
  128. UNW_PPC32_F18,
  129. UNW_PPC32_F19,
  130. UNW_PPC32_F20,
  131. UNW_PPC32_F21,
  132. UNW_PPC32_F22,
  133. UNW_PPC32_F23,
  134. UNW_PPC32_F24,
  135. UNW_PPC32_F25,
  136. UNW_PPC32_F26,
  137. UNW_PPC32_F27,
  138. UNW_PPC32_F28,
  139. UNW_PPC32_F29,
  140. UNW_PPC32_F30,
  141. UNW_PPC32_F31,
  142. UNW_TDEP_LAST_REG = UNW_PPC32_F31,
  143. UNW_TDEP_IP = UNW_PPC32_LR,
  144. UNW_TDEP_SP = UNW_PPC32_R1,
  145. UNW_TDEP_EH = UNW_PPC32_R12
  146. }
  147. ppc32_regnum_t;
  148. /*
  149. * According to David Edelsohn, GNU gcc uses R3, R4, R5, and maybe R6 for
  150. * passing parameters to exception handlers.
  151. */
  152. #define UNW_TDEP_NUM_EH_REGS 4
  153. typedef struct unw_tdep_save_loc
  154. {
  155. /* Additional target-dependent info on a save location. */
  156. }
  157. unw_tdep_save_loc_t;
  158. /* On ppc, we can directly use ucontext_t as the unwind context. */
  159. typedef ucontext_t unw_tdep_context_t;
  160. /* XXX this is not ideal: an application should not be prevented from
  161. using the "getcontext" name just because it's using libunwind. We
  162. can't just use __getcontext() either, because that isn't exported
  163. by glibc... */
  164. #define unw_tdep_getcontext(uc) (getcontext (uc), 0)
  165. #include "libunwind-dynamic.h"
  166. typedef struct
  167. {
  168. /* no ppc32-specific auxiliary proc-info */
  169. }
  170. unw_tdep_proc_info_t;
  171. #include "libunwind-common.h"
  172. #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
  173. extern int unw_tdep_is_fpreg (int);
  174. #if defined(__cplusplus) || defined(c_plusplus)
  175. }
  176. #endif
  177. #endif /* LIBUNWIND_H */