]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: change default initialization for register numbers on x86
authorChristina Schimpe <christina.schimpe@intel.com>
Mon, 28 Jul 2025 14:00:45 +0000 (07:00 -0700)
committerChristina Schimpe <christina.schimpe@intel.com>
Thu, 7 Aug 2025 12:06:43 +0000 (12:06 +0000)
As defined by the enums amd64_regnum and i386_regnum the register
numbering starts at 0.
Defaults for register numbers are currently set to 0 which seems to
be the wrong default.  Set them to -1 instead.  Configure the right
register number if we find out it's supported in i386_gdbarch_init.

Similarly we don't have to set the num_*regname* variables to 0 in
i386_gdbarch_init, as it's already assigned to 0 by default.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/i386-tdep.c
gdb/i386-tdep.h

index f97c98e6a40ecba246771af59e7ea5525ae7288b..21a5a28986fca944402e1ff94711e570377c3d2c 100644 (file)
@@ -8977,41 +8977,12 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->num_core_regs = I386_NUM_GREGS + I387_NUM_REGS;
   tdep->register_names = i386_register_names;
 
-  /* No upper YMM registers.  */
-  tdep->ymmh_register_names = NULL;
-  tdep->ymm0h_regnum = -1;
-
-  /* No upper ZMM registers.  */
-  tdep->zmmh_register_names = NULL;
-  tdep->zmm0h_regnum = -1;
-
-  /* No high XMM registers.  */
-  tdep->xmm_avx512_register_names = NULL;
-  tdep->xmm16_regnum = -1;
-
-  /* No upper YMM16-31 registers.  */
-  tdep->ymm16h_register_names = NULL;
-  tdep->ymm16h_regnum = -1;
-
   tdep->num_byte_regs = 8;
   tdep->num_word_regs = 8;
   tdep->num_dword_regs = 0;
   tdep->num_mmx_regs = 8;
   tdep->num_ymm_regs = 0;
 
-  /* No AVX512 registers.  */
-  tdep->k0_regnum = -1;
-  tdep->num_zmm_regs = 0;
-  tdep->num_ymm_avx512_regs = 0;
-  tdep->num_xmm_avx512_regs = 0;
-
-  /* No PKEYS registers  */
-  tdep->pkru_regnum = -1;
-  tdep->num_pkeys_regs = 0;
-
-  /* No segment base registers.  */
-  tdep->fsbase_regnum = -1;
-
   tdesc_arch_data_up tdesc_data = tdesc_data_alloc ();
 
   set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction);
index e849b336e122b34632e739d07f72a61dd06b7573..e4895b1d932ec641a6fa32d996817e67f7c6847d 100644 (file)
@@ -69,56 +69,57 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
   size_t sizeof_fpregset = 0;
 
   /* Register number for %st(0).  The register numbers for the other
-     registers follow from this one.  Set this to -1 to indicate the
-     absence of an FPU.  */
-  int st0_regnum = 0;
+     registers follow from this one.  Set this to a value >= 0 if FPU is
+     present.  */
+  int st0_regnum = -1;
 
   /* Number of MMX registers.  */
   int num_mmx_regs = 0;
 
-  /* Register number for %mm0.  Set this to -1 to indicate the absence
-     of MMX support.  */
-  int mm0_regnum = 0;
+  /* Register number for %mm0.  Set this to a value >= 0 if MMX is
+     supported.  */
+  int mm0_regnum = -1;
 
   /* Number of pseudo YMM registers.  */
   int num_ymm_regs = 0;
 
-  /* Register number for %ymm0.  Set this to -1 to indicate the absence
-     of pseudo YMM register support.  */
-  int ymm0_regnum = 0;
+  /* Register number for %ymm0.  Set this to a value >= 0 if pseudo YMM
+     registers are supported.  */
+  int ymm0_regnum = -1;
 
   /* Number of AVX512 OpMask registers (K-registers)  */
   int num_k_regs = 0;
 
-  /* Register number for %k0.  Set this to -1 to indicate the absence
-     of AVX512 OpMask register support.  */
-  int k0_regnum = 0;
+  /* Register number for %k0.  Set this to a value >= 0 if AVX512 OpMask
+     is supported.  */
+  int k0_regnum = -1;
 
   /* Number of pseudo ZMM registers ($zmm0-$zmm31).  */
   int num_zmm_regs = 0;
 
-  /* Register number for %zmm0.  Set this to -1 to indicate the absence
-     of pseudo ZMM register support.  */
-  int zmm0_regnum = 0;
+  /* Register number for %zmm0.  Set this to a value >= 0 if pseudo ZMM
+     registers are supported.  */
+  int zmm0_regnum = -1;
 
   /* Number of byte registers.  */
   int num_byte_regs = 0;
 
-  /* Register pseudo number for %al.  */
-  int al_regnum = 0;
+  /* Register pseudo number for %al.  If supported, set this to a
+     value >= 0.  */
+  int al_regnum = -1;
 
   /* Number of pseudo word registers.  */
   int num_word_regs = 0;
 
-  /* Register number for %ax.  */
-  int ax_regnum = 0;
+  /* Register number for %ax.  If supported, set this to a value >= 0.  */
+  int ax_regnum = -1;
 
   /* Number of pseudo dword registers.  */
   int num_dword_regs = 0;
 
-  /* Register number for %eax.  Set this to -1 to indicate the absence
-     of pseudo dword register support.  */
-  int eax_regnum = 0;
+  /* Register number for %eax.  Set this to a value >= 0 if pseudo dword
+     registers are supported.  */
+  int eax_regnum = -1;
 
   /* Number of core registers.  */
   int num_core_regs = 0;
@@ -129,14 +130,16 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
   /* Number of SSE registers added in AVX512.  */
   int num_xmm_avx512_regs = 0;
 
-  /* Register number of XMM16, the first XMM register added in AVX512.  */
-  int xmm16_regnum = 0;
+  /* Register number of XMM16, the first XMM register added in AVX512.
+     Set this to a value >= 0 if XMM registers are supported.  */
+  int xmm16_regnum = -1;
 
   /* Number of YMM registers added in AVX512.  */
   int num_ymm_avx512_regs = 0;
 
-  /* Register number of YMM16, the first YMM register added in AVX512.  */
-  int ymm16_regnum = 0;
+  /* Register number of YMM16, the first YMM register added in AVX512.
+     Set this to a value >= 0 if YMM registers are supported.  */
+  int ymm16_regnum = -1;
 
   /* Bits of the extended control register 0 (the XFEATURE_ENABLED_MASK
      register), excluding the x87 bit, which are supported by this GDB.  */
@@ -152,23 +155,23 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
   /* Register names.  */
   const char * const *register_names = nullptr;
 
-  /* Register number for %ymm0h.  Set this to -1 to indicate the absence
-     of upper YMM register support.  */
-  int ymm0h_regnum = 0;
+  /* Register number for %ymm0h.  Set this to a value >= 0 if they are
+     supported.  */
+  int ymm0h_regnum = -1;
 
   /* Upper YMM register names.  Only used for tdesc_numbered_register.  */
   const char * const *ymmh_register_names = nullptr;
 
-  /* Register number for %ymm16h.  Set this to -1 to indicate the absence
-  of support for YMM16-31.  */
-  int ymm16h_regnum = 0;
+  /* Register number for %ymm16h.  Set this to a value >= 0 if they are
+     supported.  */
+  int ymm16h_regnum = -1;
 
   /* YMM16-31 register names.  Only used for tdesc_numbered_register.  */
   const char * const *ymm16h_register_names = nullptr;
 
-  /* Register number for %zmm0h.  Set this to -1 to indicate the absence
-     of ZMM_HI256 register support.  */
-  int zmm0h_regnum = 0;
+  /* Register number for %zmm0h.  Set this to a value >= 0 if ZMM_HI256
+     registers are supported.  */
+  int zmm0h_regnum = -1;
 
   /* OpMask register names.  */
   const char * const *k_register_names = nullptr;
@@ -185,15 +188,16 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
   /* Number of PKEYS registers.  */
   int num_pkeys_regs = 0;
 
-  /* Register number for PKRU register.  */
-  int pkru_regnum = 0;
+  /* Register number for PKRU register.  If supported, set this to a value
+     >= 0.  */
+  int pkru_regnum = -1;
 
   /* PKEYS register names.  */
   const char * const *pkeys_register_names = nullptr;
 
-  /* Register number for %fsbase.  Set this to -1 to indicate the
-     absence of segment base registers.  */
-  int fsbase_regnum = 0;
+  /* Register number for %fsbase.  If supported, set this to a value
+     >= 0.  */
+  int fsbase_regnum = -1;
 
   /* Target description.  */
   const struct target_desc *tdesc = nullptr;