sparc-tdep.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /* Target-dependent code for SPARC.
  2. Copyright (C) 2003-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef SPARC_TDEP_H
  15. #define SPARC_TDEP_H 1
  16. #include "gdbarch.h"
  17. #define SPARC_CORE_REGISTERS \
  18. "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \
  19. "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7", \
  20. "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", \
  21. "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7"
  22. struct frame_info;
  23. struct gdbarch;
  24. struct regcache;
  25. struct regset;
  26. struct trad_frame_saved_reg;
  27. /* Register offsets for the general-purpose register set. */
  28. struct sparc_gregmap
  29. {
  30. int r_psr_offset;
  31. int r_pc_offset;
  32. int r_npc_offset;
  33. int r_y_offset;
  34. int r_wim_offset;
  35. int r_tbr_offset;
  36. int r_g1_offset;
  37. int r_l0_offset;
  38. int r_y_size;
  39. };
  40. struct sparc_fpregmap
  41. {
  42. int r_f0_offset;
  43. int r_fsr_offset;
  44. };
  45. /* SPARC architecture-specific information. */
  46. struct sparc_gdbarch_tdep : gdbarch_tdep
  47. {
  48. /* Register numbers for the PN and nPC registers. The definitions
  49. for (64-bit) UltraSPARC differ from the (32-bit) SPARC
  50. definitions. */
  51. int pc_regnum = 0;
  52. int npc_regnum = 0;
  53. /* Register names specific for architecture (sparc32 vs. sparc64) */
  54. const char * const *fpu_register_names = nullptr;
  55. size_t fpu_registers_num = 0;
  56. const char * const *cp0_register_names = nullptr;
  57. size_t cp0_registers_num = 0;
  58. /* Register sets. */
  59. const struct regset *gregset = nullptr;
  60. size_t sizeof_gregset = 0;
  61. const struct regset *fpregset = nullptr;
  62. size_t sizeof_fpregset = 0;
  63. /* Offset of saved PC in jmp_buf. */
  64. int jb_pc_offset = 0;
  65. /* Size of an Procedure Linkage Table (PLT) entry, 0 if we shouldn't
  66. treat the PLT special when doing prologue analysis. */
  67. size_t plt_entry_size = 0;
  68. /* Alternative location for trap return. Used for single-stepping. */
  69. CORE_ADDR (*step_trap) (struct frame_info *frame, unsigned long insn)
  70. = nullptr;
  71. /* ISA-specific data types. */
  72. struct type *sparc_psr_type = nullptr;
  73. struct type *sparc_fsr_type = nullptr;
  74. struct type *sparc64_ccr_type = nullptr;
  75. struct type *sparc64_pstate_type = nullptr;
  76. struct type *sparc64_fsr_type = nullptr;
  77. struct type *sparc64_fprs_type = nullptr;
  78. };
  79. /* Register numbers of various important registers. */
  80. enum sparc_regnum
  81. {
  82. SPARC_G0_REGNUM = 0, /* %g0 */
  83. SPARC_G1_REGNUM,
  84. SPARC_G2_REGNUM,
  85. SPARC_G3_REGNUM,
  86. SPARC_G4_REGNUM,
  87. SPARC_G5_REGNUM,
  88. SPARC_G6_REGNUM,
  89. SPARC_G7_REGNUM, /* %g7 */
  90. SPARC_O0_REGNUM, /* %o0 */
  91. SPARC_O1_REGNUM,
  92. SPARC_O2_REGNUM,
  93. SPARC_O3_REGNUM,
  94. SPARC_O4_REGNUM,
  95. SPARC_O5_REGNUM,
  96. SPARC_SP_REGNUM, /* %sp (%o6) */
  97. SPARC_O7_REGNUM, /* %o7 */
  98. SPARC_L0_REGNUM, /* %l0 */
  99. SPARC_L1_REGNUM,
  100. SPARC_L2_REGNUM,
  101. SPARC_L3_REGNUM,
  102. SPARC_L4_REGNUM,
  103. SPARC_L5_REGNUM,
  104. SPARC_L6_REGNUM,
  105. SPARC_L7_REGNUM, /* %l7 */
  106. SPARC_I0_REGNUM, /* %i0 */
  107. SPARC_I1_REGNUM,
  108. SPARC_I2_REGNUM,
  109. SPARC_I3_REGNUM,
  110. SPARC_I4_REGNUM,
  111. SPARC_I5_REGNUM,
  112. SPARC_FP_REGNUM, /* %fp (%i6) */
  113. SPARC_I7_REGNUM, /* %i7 */
  114. SPARC_F0_REGNUM, /* %f0 */
  115. SPARC_F1_REGNUM,
  116. SPARC_F2_REGNUM,
  117. SPARC_F3_REGNUM,
  118. SPARC_F4_REGNUM,
  119. SPARC_F5_REGNUM,
  120. SPARC_F6_REGNUM,
  121. SPARC_F7_REGNUM,
  122. SPARC_F31_REGNUM /* %f31 */
  123. = SPARC_F0_REGNUM + 31
  124. };
  125. enum sparc32_regnum
  126. {
  127. SPARC32_Y_REGNUM /* %y */
  128. = SPARC_F31_REGNUM + 1,
  129. SPARC32_PSR_REGNUM, /* %psr */
  130. SPARC32_WIM_REGNUM, /* %wim */
  131. SPARC32_TBR_REGNUM, /* %tbr */
  132. SPARC32_PC_REGNUM, /* %pc */
  133. SPARC32_NPC_REGNUM, /* %npc */
  134. SPARC32_FSR_REGNUM, /* %fsr */
  135. SPARC32_CSR_REGNUM, /* %csr */
  136. };
  137. /* Pseudo registers. */
  138. enum sparc32_pseudo_regnum
  139. {
  140. SPARC32_D0_REGNUM = 0, /* %d0 */
  141. SPARC32_D30_REGNUM /* %d30 */
  142. = SPARC32_D0_REGNUM + 15
  143. };
  144. struct sparc_frame_cache
  145. {
  146. /* Base address. */
  147. CORE_ADDR base;
  148. CORE_ADDR pc;
  149. /* Do we have a frame? */
  150. int frameless_p;
  151. /* The offset from the base register to the CFA. */
  152. int frame_offset;
  153. /* Mask of `local' and `in' registers saved in the register save area. */
  154. unsigned short int saved_regs_mask;
  155. /* Mask of `out' registers copied or renamed to their `in' sibling. */
  156. unsigned char copied_regs_mask;
  157. /* Do we have a Structure, Union or Quad-Precision return value? */
  158. int struct_return_p;
  159. /* Table of saved registers. */
  160. struct trad_frame_saved_reg *saved_regs;
  161. };
  162. /* Fetch the instruction at PC. */
  163. extern unsigned long sparc_fetch_instruction (CORE_ADDR pc);
  164. /* Fetch StackGhost Per-Process XOR cookie. */
  165. extern ULONGEST sparc_fetch_wcookie (struct gdbarch *gdbarch);
  166. /* Record the effect of a SAVE instruction on CACHE. */
  167. extern void sparc_record_save_insn (struct sparc_frame_cache *cache);
  168. /* Do a full analysis of the prologue at PC and update CACHE accordingly. */
  169. extern CORE_ADDR sparc_analyze_prologue (struct gdbarch *gdbarch,
  170. CORE_ADDR pc, CORE_ADDR current_pc,
  171. struct sparc_frame_cache *cache);
  172. extern struct sparc_frame_cache *
  173. sparc_frame_cache (struct frame_info *this_frame, void **this_cache);
  174. extern struct sparc_frame_cache *
  175. sparc32_frame_cache (struct frame_info *this_frame, void **this_cache);
  176. extern int
  177. sparc_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc);
  178. extern void sparc_supply_rwindow (struct regcache *regcache,
  179. CORE_ADDR sp, int regnum);
  180. extern void sparc_collect_rwindow (const struct regcache *regcache,
  181. CORE_ADDR sp, int regnum);
  182. /* Register offsets for SunOS 4. */
  183. extern const struct sparc_gregmap sparc32_sunos4_gregmap;
  184. extern const struct sparc_fpregmap sparc32_sunos4_fpregmap;
  185. extern const struct sparc_fpregmap sparc32_bsd_fpregmap;
  186. extern void sparc32_supply_gregset (const struct sparc_gregmap *gregmap,
  187. struct regcache *regcache,
  188. int regnum, const void *gregs);
  189. extern void sparc32_collect_gregset (const struct sparc_gregmap *gregmap,
  190. const struct regcache *regcache,
  191. int regnum, void *gregs);
  192. extern void sparc32_supply_fpregset (const struct sparc_fpregmap *fpregmap,
  193. struct regcache *regcache,
  194. int regnum, const void *fpregs);
  195. extern void sparc32_collect_fpregset (const struct sparc_fpregmap *fpregmap,
  196. const struct regcache *regcache,
  197. int regnum, void *fpregs);
  198. extern int sparc_is_annulled_branch_insn (CORE_ADDR pc);
  199. /* Functions and variables exported from sparc-sol2-tdep.c. */
  200. /* Register offsets for Solaris 2. */
  201. extern const struct sparc_gregmap sparc32_sol2_gregmap;
  202. extern const struct sparc_fpregmap sparc32_sol2_fpregmap;
  203. /* Functions and variables exported from sparc-netbsd-tdep.c. */
  204. /* Register offsets for NetBSD. */
  205. extern const struct sparc_gregmap sparc32nbsd_gregmap;
  206. /* Return the address of a system call's alternative return
  207. address. */
  208. extern CORE_ADDR sparcnbsd_step_trap (struct frame_info *frame,
  209. unsigned long insn);
  210. extern void sparc32nbsd_init_abi (struct gdbarch_info info,
  211. struct gdbarch *gdbarch);
  212. extern struct trad_frame_saved_reg *
  213. sparc32nbsd_sigcontext_saved_regs (struct frame_info *next_frame);
  214. #endif /* sparc-tdep.h */