gdb/ppc-tdep.h - gdb

Data types defined

Macros defined

Source code

  1. /* Target-dependent code for GDB, the GNU debugger.

  2.    Copyright (C) 2000-2015 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 PPC_TDEP_H
  15. #define PPC_TDEP_H

  16. struct gdbarch;
  17. struct frame_info;
  18. struct value;
  19. struct regcache;
  20. struct type;

  21. /* From ppc-sysv-tdep.c ...  */
  22. enum return_value_convention ppc_sysv_abi_return_value (struct gdbarch *gdbarch,
  23.                                                         struct value *function,
  24.                                                         struct type *valtype,
  25.                                                         struct regcache *regcache,
  26.                                                         gdb_byte *readbuf,
  27.                                                         const gdb_byte *writebuf);
  28. enum return_value_convention ppc_sysv_abi_broken_return_value (struct gdbarch *gdbarch,
  29.                                                                struct value *function,
  30.                                                                struct type *valtype,
  31.                                                                struct regcache *regcache,
  32.                                                                gdb_byte *readbuf,
  33.                                                                const gdb_byte *writebuf);
  34. CORE_ADDR ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
  35.                                         struct value *function,
  36.                                         struct regcache *regcache,
  37.                                         CORE_ADDR bp_addr, int nargs,
  38.                                         struct value **args, CORE_ADDR sp,
  39.                                         int struct_return,
  40.                                         CORE_ADDR struct_addr);
  41. CORE_ADDR ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
  42.                                           struct value *function,
  43.                                           struct regcache *regcache,
  44.                                           CORE_ADDR bp_addr, int nargs,
  45.                                           struct value **args, CORE_ADDR sp,
  46.                                           int struct_return,
  47.                                           CORE_ADDR struct_addr);
  48. enum return_value_convention ppc64_sysv_abi_return_value (struct gdbarch *gdbarch,
  49.                                                           struct value *function,
  50.                                                           struct type *valtype,
  51.                                                           struct regcache *regcache,
  52.                                                           gdb_byte *readbuf,
  53.                                                           const gdb_byte *writebuf);

  54. /* From rs6000-tdep.c...  */
  55. int altivec_register_p (struct gdbarch *gdbarch, int regno);
  56. int vsx_register_p (struct gdbarch *gdbarch, int regno);
  57. int spe_register_p (struct gdbarch *gdbarch, int regno);

  58. /* Return non-zero if the architecture described by GDBARCH has
  59.    floating-point registers (f0 --- f31 and fpscr).  */
  60. int ppc_floating_point_unit_p (struct gdbarch *gdbarch);

  61. /* Return non-zero if the architecture described by GDBARCH has
  62.    Altivec registers (vr0 --- vr31, vrsave and vscr).  */
  63. int ppc_altivec_support_p (struct gdbarch *gdbarch);

  64. /* Return non-zero if the architecture described by GDBARCH has
  65.    VSX registers (vsr0 --- vsr63).  */
  66. int vsx_support_p (struct gdbarch *gdbarch);
  67. int ppc_deal_with_atomic_sequence (struct frame_info *frame);


  68. /* Register set description.  */

  69. struct ppc_reg_offsets
  70. {
  71.   /* General-purpose registers.  */
  72.   int r0_offset;
  73.   int gpr_size; /* size for r0-31, pc, ps, lr, ctr.  */
  74.   int xr_size;  /* size for cr, xer, mq.  */
  75.   int pc_offset;
  76.   int ps_offset;
  77.   int cr_offset;
  78.   int lr_offset;
  79.   int ctr_offset;
  80.   int xer_offset;
  81.   int mq_offset;

  82.   /* Floating-point registers.  */
  83.   int f0_offset;
  84.   int fpscr_offset;
  85.   int fpscr_size;

  86.   /* AltiVec registers.  */
  87.   int vr0_offset;
  88.   int vscr_offset;
  89.   int vrsave_offset;
  90. };

  91. extern void ppc_supply_reg (struct regcache *regcache, int regnum,
  92.                             const gdb_byte *regs, size_t offset, int regsize);

  93. extern void ppc_collect_reg (const struct regcache *regcache, int regnum,
  94.                              gdb_byte *regs, size_t offset, int regsize);

  95. /* Supply register REGNUM in the general-purpose register set REGSET
  96.    from the buffer specified by GREGS and LEN to register cache
  97.    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */

  98. extern void ppc_supply_gregset (const struct regset *regset,
  99.                                 struct regcache *regcache,
  100.                                 int regnum, const void *gregs, size_t len);

  101. /* Supply register REGNUM in the floating-point register set REGSET
  102.    from the buffer specified by FPREGS and LEN to register cache
  103.    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */

  104. extern void ppc_supply_fpregset (const struct regset *regset,
  105.                                  struct regcache *regcache,
  106.                                  int regnum, const void *fpregs, size_t len);

  107. /* Supply register REGNUM in the Altivec register set REGSET
  108.    from the buffer specified by VRREGS and LEN to register cache
  109.    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */

  110. extern void ppc_supply_vrregset (const struct regset *regset,
  111.                                  struct regcache *regcache,
  112.                                  int regnum, const void *vrregs, size_t len);

  113. /* Supply register REGNUM in the VSX register set REGSET
  114.    from the buffer specified by VSXREGS and LEN to register cache
  115.    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */

  116. extern void ppc_supply_vsxregset (const struct regset *regset,
  117.                                  struct regcache *regcache,
  118.                                  int regnum, const void *vsxregs, size_t len);

  119. /* Collect register REGNUM in the general-purpose register set
  120.    REGSET, from register cache REGCACHE into the buffer specified by
  121.    GREGS and LEN.  If REGNUM is -1, do this for all registers in
  122.    REGSET.  */

  123. extern void ppc_collect_gregset (const struct regset *regset,
  124.                                  const struct regcache *regcache,
  125.                                  int regnum, void *gregs, size_t len);

  126. /* Collect register REGNUM in the floating-point register set
  127.    REGSET, from register cache REGCACHE into the buffer specified by
  128.    FPREGS and LEN.  If REGNUM is -1, do this for all registers in
  129.    REGSET.  */

  130. extern void ppc_collect_fpregset (const struct regset *regset,
  131.                                   const struct regcache *regcache,
  132.                                   int regnum, void *fpregs, size_t len);

  133. /* Collect register REGNUM in the Altivec register set
  134.    REGSET from register cache REGCACHE into the buffer specified by
  135.    VRREGS and LEN.  If REGNUM is -1, do this for all registers in
  136.    REGSET.  */

  137. extern void ppc_collect_vrregset (const struct regset *regset,
  138.                                   const struct regcache *regcache,
  139.                                   int regnum, void *vrregs, size_t len);

  140. /* Collect register REGNUM in the VSX register set
  141.    REGSET from register cache REGCACHE into the buffer specified by
  142.    VSXREGS and LEN.  If REGNUM is -1, do this for all registers in
  143.    REGSET.  */

  144. extern void ppc_collect_vsxregset (const struct regset *regset,
  145.                                   const struct regcache *regcache,
  146.                                   int regnum, void *vsxregs, size_t len);

  147. /* Private data that this module attaches to struct gdbarch.  */

  148. /* ELF ABI version used by the inferior.  */
  149. enum powerpc_elf_abi
  150. {
  151.   POWERPC_ELF_AUTO,
  152.   POWERPC_ELF_V1,
  153.   POWERPC_ELF_V2,
  154.   POWERPC_ELF_LAST
  155. };

  156. /* Vector ABI used by the inferior.  */
  157. enum powerpc_vector_abi
  158. {
  159.   POWERPC_VEC_AUTO,
  160.   POWERPC_VEC_GENERIC,
  161.   POWERPC_VEC_ALTIVEC,
  162.   POWERPC_VEC_SPE,
  163.   POWERPC_VEC_LAST
  164. };

  165. struct gdbarch_tdep
  166.   {
  167.     int wordsize;                /* Size in bytes of fixed-point word.  */
  168.     int soft_float;                /* Avoid FP registers for arguments?  */

  169.     enum powerpc_elf_abi elf_abi;        /* ELF ABI version.  */

  170.     /* How to pass vector arguments.  Never set to AUTO or LAST.  */
  171.     enum powerpc_vector_abi vector_abi;

  172.     int ppc_gp0_regnum;                /* GPR register 0 */
  173.     int ppc_toc_regnum;                /* TOC register */
  174.     int ppc_ps_regnum;                /* Processor (or machine) status (%msr) */
  175.     int ppc_cr_regnum;                /* Condition register */
  176.     int ppc_lr_regnum;                /* Link register */
  177.     int ppc_ctr_regnum;                /* Count register */
  178.     int ppc_xer_regnum;                /* Integer exception register */

  179.     /* Not all PPC and RS6000 variants will have the registers
  180.        represented below.  A -1 is used to indicate that the register
  181.        is not present in this variant.  */

  182.     /* Floating-point registers.  */
  183.     int ppc_fp0_regnum;         /* Floating-point register 0.  */
  184.     int ppc_fpscr_regnum;        /* fp status and condition register.  */

  185.     /* Multiplier-Quotient Register (older POWER architectures only).  */
  186.     int ppc_mq_regnum;

  187.     /* POWER7 VSX registers.  */
  188.     int ppc_vsr0_regnum;        /* First VSX register.  */
  189.     int ppc_vsr0_upper_regnum;  /* First right most dword vsx register.  */
  190.     int ppc_efpr0_regnum;        /* First Extended FP register.  */

  191.     /* Altivec registers.  */
  192.     int ppc_vr0_regnum;                /* First AltiVec register.  */
  193.     int ppc_vrsave_regnum;        /* Last AltiVec register.  */

  194.     /* SPE registers.  */
  195.     int ppc_ev0_upper_regnum;   /* First GPR upper half register.  */
  196.     int ppc_ev0_regnum;         /* First ev register.  */
  197.     int ppc_acc_regnum;         /* SPE 'acc' register.  */
  198.     int ppc_spefscr_regnum;     /* SPE 'spefscr' register.  */

  199.     /* Decimal 128 registers.  */
  200.     int ppc_dl0_regnum;                /* First Decimal128 argument register pair.  */

  201.     /* Offset to ABI specific location where link register is saved.  */
  202.     int lr_frame_offset;

  203.     /* An array of integers, such that sim_regno[I] is the simulator
  204.        register number for GDB register number I, or -1 if the
  205.        simulator does not implement that register.  */
  206.     int *sim_regno;

  207.     /* ISA-specific types.  */
  208.     struct type *ppc_builtin_type_vec64;
  209.     struct type *ppc_builtin_type_vec128;
  210. };


  211. /* Constants for register set sizes.  */
  212. enum
  213.   {
  214.     ppc_num_gprs = 32,                /* 32 general-purpose registers.  */
  215.     ppc_num_fprs = 32,                /* 32 floating-point registers.  */
  216.     ppc_num_srs = 16,                /* 16 segment registers.  */
  217.     ppc_num_vrs = 32,                /* 32 Altivec vector registers.  */
  218.     ppc_num_vshrs = 32,                /* 32 doublewords (dword 1 of vs0~vs31).  */
  219.     ppc_num_vsrs = 64,                /* 64 VSX vector registers.  */
  220.     ppc_num_efprs = 32                /* 32 Extended FP registers.  */
  221.   };


  222. /* Register number constants.  These are GDB internal register
  223.    numbers; they are not used for the simulator or remote targets.
  224.    Extra SPRs (those other than MQ, CTR, LR, XER, SPEFSCR) are given
  225.    numbers above PPC_NUM_REGS.  So are segment registers and other
  226.    target-defined registers.  */
  227. enum {
  228.   PPC_R0_REGNUM = 0,
  229.   PPC_F0_REGNUM = 32,
  230.   PPC_PC_REGNUM = 64,
  231.   PPC_MSR_REGNUM = 65,
  232.   PPC_CR_REGNUM = 66,
  233.   PPC_LR_REGNUM = 67,
  234.   PPC_CTR_REGNUM = 68,
  235.   PPC_XER_REGNUM = 69,
  236.   PPC_FPSCR_REGNUM = 70,
  237.   PPC_MQ_REGNUM = 71,
  238.   PPC_SPE_UPPER_GP0_REGNUM = 72,
  239.   PPC_SPE_ACC_REGNUM = 104,
  240.   PPC_SPE_FSCR_REGNUM = 105,
  241.   PPC_VR0_REGNUM = 106,
  242.   PPC_VSCR_REGNUM = 138,
  243.   PPC_VRSAVE_REGNUM = 139,
  244.   PPC_VSR0_UPPER_REGNUM = 140,
  245.   PPC_VSR31_UPPER_REGNUM = 171,
  246.   PPC_NUM_REGS
  247. };

  248. /* An instruction to match.  */

  249. struct ppc_insn_pattern
  250. {
  251.   unsigned int mask;            /* mask the insn with this...  */
  252.   unsigned int data;            /* ...and see if it matches this.  */
  253.   int optional;                 /* If non-zero, this insn may be absent.  */
  254. };

  255. extern int ppc_insns_match_pattern (struct frame_info *frame, CORE_ADDR pc,
  256.                                     struct ppc_insn_pattern *pattern,
  257.                                     unsigned int *insns);
  258. extern CORE_ADDR ppc_insn_d_field (unsigned int insn);

  259. extern CORE_ADDR ppc_insn_ds_field (unsigned int insn);

  260. /* Instruction size.  */
  261. #define PPC_INSN_SIZE 4

  262. /* Estimate for the maximum number of instrctions in a function epilogue.  */
  263. #define PPC_MAX_EPILOGUE_INSTRUCTIONS  52

  264. #endif /* ppc-tdep.h */