gdb/i386-tdep.h - gdb

Data types defined

Macros defined

Source code

  1. /* Target-dependent code for the i386.

  2.    Copyright (C) 2001-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 I386_TDEP_H
  15. #define I386_TDEP_H

  16. struct frame_info;
  17. struct gdbarch;
  18. struct reggroup;
  19. struct regset;
  20. struct regcache;

  21. /* GDB's i386 target supports both the 32-bit Intel Architecture
  22.    (IA-32) and the 64-bit AMD x86-64 architecture.  Internally it uses
  23.    a similar register layout for both.

  24.    - General purpose registers
  25.    - FPU data registers
  26.    - FPU control registers
  27.    - SSE data registers
  28.    - SSE control register

  29.    The general purpose registers for the x86-64 architecture are quite
  30.    different from IA-32.  Therefore, gdbarch_fp0_regnum
  31.    determines the register number at which the FPU data registers
  32.    start.  The number of FPU data and control registers is the same
  33.    for both architectures.  The number of SSE registers however,
  34.    differs and is determined by the num_xmm_regs member of `struct
  35.    gdbarch_tdep'.  */

  36. /* Convention for returning structures.  */

  37. enum struct_return
  38. {
  39.   pcc_struct_return,                /* Return "short" structures in memory.  */
  40.   reg_struct_return                /* Return "short" structures in registers.  */
  41. };

  42. /* i386 architecture specific information.  */
  43. struct gdbarch_tdep
  44. {
  45.   /* General-purpose registers.  */
  46.   int *gregset_reg_offset;
  47.   int gregset_num_regs;
  48.   size_t sizeof_gregset;

  49.   /* Floating-point registers.  */
  50.   size_t sizeof_fpregset;

  51.   /* Register number for %st(0).  The register numbers for the other
  52.      registers follow from this one.  Set this to -1 to indicate the
  53.      absence of an FPU.  */
  54.   int st0_regnum;

  55.   /* Number of MMX registers.  */
  56.   int num_mmx_regs;

  57.   /* Register number for %mm0.  Set this to -1 to indicate the absence
  58.      of MMX support.  */
  59.   int mm0_regnum;

  60.   /* Number of pseudo YMM registers.  */
  61.   int num_ymm_regs;

  62.   /* Register number for %ymm0.  Set this to -1 to indicate the absence
  63.      of pseudo YMM register support.  */
  64.   int ymm0_regnum;

  65.   /* Number of AVX512 OpMask registers (K-registers)  */
  66.   int num_k_regs;

  67.   /* Register number for %k0.  Set this to -1 to indicate the absence
  68.      of AVX512 OpMask register support.  */
  69.   int k0_regnum;

  70.   /* Number of pseudo ZMM registers ($zmm0-$zmm31).  */
  71.   int num_zmm_regs;

  72.   /* Register number for %zmm0.  Set this to -1 to indicate the absence
  73.      of pseudo ZMM register support.  */
  74.   int zmm0_regnum;

  75.   /* Number of byte registers.  */
  76.   int num_byte_regs;

  77.   /* Register pseudo number for %al.  */
  78.   int al_regnum;

  79.   /* Number of pseudo word registers.  */
  80.   int num_word_regs;

  81.   /* Register number for %ax.  */
  82.   int ax_regnum;

  83.   /* Number of pseudo dword registers.  */
  84.   int num_dword_regs;

  85.   /* Register number for %eax.  Set this to -1 to indicate the absence
  86.      of pseudo dword register support.  */
  87.   int eax_regnum;

  88.   /* Number of core registers.  */
  89.   int num_core_regs;

  90.   /* Number of SSE registers.  */
  91.   int num_xmm_regs;

  92.   /* Number of SSE registers added in AVX512.  */
  93.   int num_xmm_avx512_regs;

  94.   /* Register number of XMM16, the first XMM register added in AVX512.  */
  95.   int xmm16_regnum;

  96.   /* Number of YMM registers added in AVX512.  */
  97.   int num_ymm_avx512_regs;

  98.   /* Register number of YMM16, the first YMM register added in AVX512.  */
  99.   int ymm16_regnum;

  100.   /* Bits of the extended control register 0 (the XFEATURE_ENABLED_MASK
  101.      register), excluding the x87 bit, which are supported by this GDB.  */

  102.   uint64_t xcr0;

  103.   /* Offset of XCR0 in XSAVE extended state.  */
  104.   int xsave_xcr0_offset;

  105.   /* Register names.  */
  106.   const char **register_names;

  107.   /* Register number for %ymm0h.  Set this to -1 to indicate the absence
  108.      of upper YMM register support.  */
  109.   int ymm0h_regnum;

  110.   /* Upper YMM register names.  Only used for tdesc_numbered_register.  */
  111.   const char **ymmh_register_names;

  112.   /* Register number for %ymm16h.  Set this to -1 to indicate the absence
  113.   of support for YMM16-31.  */
  114.   int ymm16h_regnum;

  115.   /* YMM16-31 register names.  Only used for tdesc_numbered_register.  */
  116.   const char **ymm16h_register_names;

  117.   /* Register number for %bnd0r.  Set this to -1 to indicate the absence
  118.      bound registers.  */
  119.   int bnd0r_regnum;

  120.   /* Register number for pseudo register %bnd0.  Set this to -1 to indicate the absence
  121.      bound registers.  */
  122.   int bnd0_regnum;

  123.   /* Register number for %bndcfgu. Set this to -1 to indicate the absence
  124.      bound control registers.  */
  125.   int bndcfgu_regnum;

  126.   /* MPX register names.  Only used for tdesc_numbered_register.  */
  127.   const char **mpx_register_names;

  128.   /* Register number for %zmm0h.  Set this to -1 to indicate the absence
  129.      of ZMM_HI256 register support.  */
  130.   int zmm0h_regnum;

  131.   /* OpMask register names.  */
  132.   const char **k_register_names;

  133.   /* ZMM register names.  Only used for tdesc_numbered_register.  */
  134.   const char **zmmh_register_names;

  135.   /* XMM16-31 register names.  Only used for tdesc_numbered_register.  */
  136.   const char **xmm_avx512_register_names;

  137.   /* YMM16-31 register names.  Only used for tdesc_numbered_register.  */
  138.   const char **ymm_avx512_register_names;

  139.   /* Target description.  */
  140.   const struct target_desc *tdesc;

  141.   /* Register group function.  */
  142.   const void *register_reggroup_p;

  143.   /* Offset of saved PC in jmp_buf.  */
  144.   int jb_pc_offset;

  145.   /* Convention for returning structures.  */
  146.   enum struct_return struct_return;

  147.   /* Address range where sigtramp lives.  */
  148.   CORE_ADDR sigtramp_start;
  149.   CORE_ADDR sigtramp_end;

  150.   /* Detect sigtramp.  */
  151.   int (*sigtramp_p) (struct frame_info *);

  152.   /* Get address of sigcontext for sigtramp.  */
  153.   CORE_ADDR (*sigcontext_addr) (struct frame_info *);

  154.   /* Offset of registers in `struct sigcontext'.  */
  155.   int *sc_reg_offset;
  156.   int sc_num_regs;

  157.   /* Offset of saved PC and SP in `struct sigcontext'.  Usage of these
  158.      is deprecated, please use `sc_reg_offset' instead.  */
  159.   int sc_pc_offset;
  160.   int sc_sp_offset;

  161.   /* ISA-specific data types.  */
  162.   struct type *i386_mmx_type;
  163.   struct type *i386_ymm_type;
  164.   struct type *i386_zmm_type;
  165.   struct type *i387_ext_type;
  166.   struct type *i386_bnd_type;

  167.   /* Process record/replay target.  */
  168.   /* The map for registers because the AMD64's registers order
  169.      in GDB is not same as I386 instructions.  */
  170.   const int *record_regmap;
  171.   /* Parse intx80 args.  */
  172.   int (*i386_intx80_record) (struct regcache *regcache);
  173.   /* Parse sysenter args.  */
  174.   int (*i386_sysenter_record) (struct regcache *regcache);
  175.   /* Parse syscall args.  */
  176.   int (*i386_syscall_record) (struct regcache *regcache);

  177.   /* Regsets. */
  178.   const struct regset *fpregset;
  179. };

  180. /* Floating-point registers.  */

  181. /* All FPU control regusters (except for FIOFF and FOOFF) are 16-bit
  182.    (at most) in the FPU, but are zero-extended to 32 bits in GDB's
  183.    register cache.  */

  184. /* Return non-zero if REGNUM matches the FP register and the FP
  185.    register set is active.  */
  186. extern int i386_fp_regnum_p (struct gdbarch *, int);
  187. extern int i386_fpc_regnum_p (struct gdbarch *, int);

  188. /* Register numbers of various important registers.  */

  189. enum i386_regnum
  190. {
  191.   I386_EAX_REGNUM,                /* %eax */
  192.   I386_ECX_REGNUM,                /* %ecx */
  193.   I386_EDX_REGNUM,                /* %edx */
  194.   I386_EBX_REGNUM,                /* %ebx */
  195.   I386_ESP_REGNUM,                /* %esp */
  196.   I386_EBP_REGNUM,                /* %ebp */
  197.   I386_ESI_REGNUM,                /* %esi */
  198.   I386_EDI_REGNUM,                /* %edi */
  199.   I386_EIP_REGNUM,                /* %eip */
  200.   I386_EFLAGS_REGNUM,                /* %eflags */
  201.   I386_CS_REGNUM,                /* %cs */
  202.   I386_SS_REGNUM,                /* %ss */
  203.   I386_DS_REGNUM,                /* %ds */
  204.   I386_ES_REGNUM,                /* %es */
  205.   I386_FS_REGNUM,                /* %fs */
  206.   I386_GS_REGNUM,                /* %gs */
  207.   I386_ST0_REGNUM,                /* %st(0) */
  208.   I386_MXCSR_REGNUM = 40,        /* %mxcsr */
  209.   I386_YMM0H_REGNUM,                /* %ymm0h */
  210.   I386_YMM7H_REGNUM = I386_YMM0H_REGNUM + 7,
  211.   I386_BND0R_REGNUM,
  212.   I386_BND3R_REGNUM = I386_BND0R_REGNUM + 3,
  213.   I386_BNDCFGU_REGNUM,
  214.   I386_BNDSTATUS_REGNUM,
  215.   I386_K0_REGNUM,                /* %k0 */
  216.   I386_K7_REGNUM = I386_K0_REGNUM + 7,
  217.   I386_ZMM0H_REGNUM,                /* %zmm0h */
  218.   I386_ZMM7H_REGNUM = I386_ZMM0H_REGNUM + 7
  219. };

  220. /* Register numbers of RECORD_REGMAP.  */

  221. enum record_i386_regnum
  222. {
  223.   X86_RECORD_REAX_REGNUM,
  224.   X86_RECORD_RECX_REGNUM,
  225.   X86_RECORD_REDX_REGNUM,
  226.   X86_RECORD_REBX_REGNUM,
  227.   X86_RECORD_RESP_REGNUM,
  228.   X86_RECORD_REBP_REGNUM,
  229.   X86_RECORD_RESI_REGNUM,
  230.   X86_RECORD_REDI_REGNUM,
  231.   X86_RECORD_R8_REGNUM,
  232.   X86_RECORD_R9_REGNUM,
  233.   X86_RECORD_R10_REGNUM,
  234.   X86_RECORD_R11_REGNUM,
  235.   X86_RECORD_R12_REGNUM,
  236.   X86_RECORD_R13_REGNUM,
  237.   X86_RECORD_R14_REGNUM,
  238.   X86_RECORD_R15_REGNUM,
  239.   X86_RECORD_REIP_REGNUM,
  240.   X86_RECORD_EFLAGS_REGNUM,
  241.   X86_RECORD_CS_REGNUM,
  242.   X86_RECORD_SS_REGNUM,
  243.   X86_RECORD_DS_REGNUM,
  244.   X86_RECORD_ES_REGNUM,
  245.   X86_RECORD_FS_REGNUM,
  246.   X86_RECORD_GS_REGNUM,
  247. };

  248. #define I386_NUM_GREGS        16
  249. #define I386_NUM_XREGS  9

  250. #define I386_SSE_NUM_REGS        (I386_MXCSR_REGNUM + 1)
  251. #define I386_AVX_NUM_REGS        (I386_YMM7H_REGNUM + 1)
  252. #define I386_MPX_NUM_REGS        (I386_BNDSTATUS_REGNUM + 1)
  253. #define I386_AVX512_NUM_REGS        (I386_ZMM7H_REGNUM + 1)

  254. /* Size of the largest register.  */
  255. #define I386_MAX_REGISTER_SIZE        64

  256. /* Types for i386-specific registers.  */
  257. extern struct type *i387_ext_type (struct gdbarch *gdbarch);

  258. /* Checks of different pseudo-registers.  */
  259. extern int i386_byte_regnum_p (struct gdbarch *gdbarch, int regnum);
  260. extern int i386_word_regnum_p (struct gdbarch *gdbarch, int regnum);
  261. extern int i386_dword_regnum_p (struct gdbarch *gdbarch, int regnum);
  262. extern int i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum);
  263. extern int i386_xmm_avx512_regnum_p (struct gdbarch * gdbarch, int regnum);
  264. extern int i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum);
  265. extern int i386_ymm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum);
  266. extern int i386_bnd_regnum_p (struct gdbarch *gdbarch, int regnum);
  267. extern int i386_k_regnum_p (struct gdbarch *gdbarch, int regnum);
  268. extern int i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum);
  269. extern int i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum);

  270. extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch,
  271.                                               int regnum);
  272. extern struct type *i386_pseudo_register_type (struct gdbarch *gdbarch,
  273.                                                int regnum);

  274. extern void i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
  275.                                                   struct regcache *regcache,
  276.                                                   int regnum,
  277.                                                   struct value *result);

  278. extern void i386_pseudo_register_write (struct gdbarch *gdbarch,
  279.                                         struct regcache *regcache,
  280.                                         int regnum, const gdb_byte *buf);

  281. /* Segment selectors.  */
  282. #define I386_SEL_RPL        0x0003  /* Requester's Privilege Level mask.  */
  283. #define I386_SEL_UPL        0x0003        /* User Privilige Level.  */
  284. #define I386_SEL_KPL        0x0000        /* Kernel Privilige Level.  */

  285. /* The length of the longest i386 instruction (according to
  286.    include/asm-i386/kprobes.h in Linux 2.6.  */
  287. #define I386_MAX_INSN_LEN (16)

  288. /* Functions exported from i386-tdep.c.  */
  289. extern CORE_ADDR i386_pe_skip_trampoline_code (struct frame_info *frame,
  290.                                                CORE_ADDR pc, char *name);
  291. extern CORE_ADDR i386_skip_main_prologue (struct gdbarch *gdbarch,
  292.                                           CORE_ADDR pc);

  293. /* Return whether the THIS_FRAME corresponds to a sigtramp routine.  */
  294. extern int i386_sigtramp_p (struct frame_info *this_frame);

  295. /* Return non-zero if REGNUM is a member of the specified group.  */
  296. extern int i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
  297.                                      struct reggroup *group);

  298. /* Supply register REGNUM from the general-purpose register set REGSET
  299.    to register cache REGCACHE.  If REGNUM is -1, do this for all
  300.    registers in REGSET.  */
  301. extern void i386_supply_gregset (const struct regset *regset,
  302.                                  struct regcache *regcache, int regnum,
  303.                                  const void *gregs, size_t len);

  304. /* General-purpose register set. */
  305. extern const struct regset i386_gregset;

  306. /* Floating-point register set. */
  307. extern const struct regset i386_fpregset;

  308. /* Default iterator over core file register note sections.  */
  309. extern void
  310.   i386_iterate_over_regset_sections (struct gdbarch *gdbarch,
  311.                                      iterate_over_regset_sections_cb *cb,
  312.                                      void *cb_data,
  313.                                      const struct regcache *regcache);

  314. extern struct displaced_step_closure *i386_displaced_step_copy_insn
  315.   (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to,
  316.    struct regcache *regs);
  317. extern void i386_displaced_step_fixup (struct gdbarch *gdbarch,
  318.                                        struct displaced_step_closure *closure,
  319.                                        CORE_ADDR from, CORE_ADDR to,
  320.                                        struct regcache *regs);

  321. /* Initialize a basic ELF architecture variant.  */
  322. extern void i386_elf_init_abi (struct gdbarch_info, struct gdbarch *);

  323. /* Initialize a SVR4 architecture variant.  */
  324. extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *);

  325. extern int i386_process_record (struct gdbarch *gdbarch,
  326.                                 struct regcache *regcache, CORE_ADDR addr);



  327. /* Functions and variables exported from i386bsd-tdep.c.  */

  328. extern void i386bsd_init_abi (struct gdbarch_info, struct gdbarch *);
  329. extern CORE_ADDR i386fbsd_sigtramp_start_addr;
  330. extern CORE_ADDR i386fbsd_sigtramp_end_addr;
  331. extern CORE_ADDR i386obsd_sigtramp_start_addr;
  332. extern CORE_ADDR i386obsd_sigtramp_end_addr;
  333. extern int i386fbsd4_sc_reg_offset[];
  334. extern int i386fbsd_sc_reg_offset[];
  335. extern int i386nbsd_sc_reg_offset[];
  336. extern int i386obsd_sc_reg_offset[];
  337. extern int i386bsd_sc_reg_offset[];

  338. /* SystemTap related functions.  */

  339. extern int i386_stap_is_single_operand (struct gdbarch *gdbarch,
  340.                                         const char *s);

  341. extern int i386_stap_parse_special_token (struct gdbarch *gdbarch,
  342.                                           struct stap_parse_info *p);

  343. #endif /* i386-tdep.h */