Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] Support for x86 segments as address classes
@ 2015-11-03 13:43 Richard Henderson
  2015-11-03 13:43 ` [PATCH 2/3] Use register cache for x86_64 ps_get_thread_area Richard Henderson
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Richard Henderson @ 2015-11-03 13:43 UTC (permalink / raw)
  To: gdb-patches

The following gets 90% of the way there, but I'm stuck --
address_to_pointer and pointer_to_address do not appear to
have access to a regcache.  And not just in the one level
of the caller, but significantly farther back in the call
stack too.

Which begs the question of whether I've simply missed
something in how to get hold of the current regcache?


r~


Richard Henderson (3):
  Add amd64 registers fs_base and gs_base
  Use register cache for x86_64 ps_get_thread_area
  Segment support for x86_64, part 1

 gdb/amd64-linux-nat.c                      | 107 ++++++++--------
 gdb/amd64-linux-tdep.c                     |   5 +
 gdb/amd64-linux-tdep.h                     |   2 +-
 gdb/amd64-tdep.c                           |  68 ++++++++++
 gdb/amd64-tdep.h                           |   6 +-
 gdb/features/i386/64bit-seg.xml            |  12 ++
 gdb/features/i386/amd64-avx-linux.c        |  36 +++---
 gdb/features/i386/amd64-avx-linux.xml      |   1 +
 gdb/features/i386/amd64-avx512-linux.c     | 192 +++++++++++++++--------------
 gdb/features/i386/amd64-avx512-linux.xml   |   1 +
 gdb/features/i386/amd64-linux.c            |   4 +
 gdb/features/i386/amd64-linux.xml          |   1 +
 gdb/features/i386/amd64-mpx-linux.c        |  48 ++++----
 gdb/features/i386/amd64-mpx-linux.xml      |   1 +
 gdb/features/i386/x32-avx-linux.c          |  36 +++---
 gdb/features/i386/x32-avx-linux.xml        |   1 +
 gdb/features/i386/x32-avx512-linux.c       | 192 +++++++++++++++--------------
 gdb/features/i386/x32-avx512-linux.xml     |   1 +
 gdb/features/i386/x32-linux.c              |   4 +
 gdb/features/i386/x32-linux.xml            |   1 +
 gdb/regformats/i386/amd64-avx-linux.dat    |   2 +
 gdb/regformats/i386/amd64-avx512-linux.dat |   2 +
 gdb/regformats/i386/amd64-linux.dat        |   2 +
 gdb/regformats/i386/amd64-mpx-linux.dat    |   2 +
 gdb/regformats/i386/x32-avx-linux.dat      |   2 +
 gdb/regformats/i386/x32-avx512-linux.dat   |   2 +
 gdb/regformats/i386/x32-linux.dat          |   2 +
 27 files changed, 438 insertions(+), 295 deletions(-)
 create mode 100644 gdb/features/i386/64bit-seg.xml

-- 
2.4.3


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/3] Use register cache for x86_64 ps_get_thread_area
  2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
@ 2015-11-03 13:43 ` Richard Henderson
  2015-11-03 13:44 ` [PATCH 3/3] Segment support for x86_64, part 1 Richard Henderson
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2015-11-03 13:43 UTC (permalink / raw)
  To: gdb-patches

	* amd64-linux-nat.c (ps_get_thread_area): Use regcache to
	fetch FS_BASE contents.
---
 gdb/amd64-linux-nat.c | 71 +++++++++++++++------------------------------------
 1 file changed, 21 insertions(+), 50 deletions(-)

diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 0a2cf45..b7211d3e 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -283,10 +283,11 @@ ps_err_e
 ps_get_thread_area (const struct ps_prochandle *ph,
                     lwpid_t lwpid, int idx, void **base)
 {
+  ps_err_e result;
+
   if (gdbarch_bfd_arch_info (target_gdbarch ())->bits_per_word == 32)
     {
       unsigned int base_addr;
-      ps_err_e result;
 
       result = x86_linux_get_thread_area (lwpid, (void *) (long) idx,
 					  &base_addr);
@@ -296,63 +297,33 @@ ps_get_thread_area (const struct ps_prochandle *ph,
 	     a "long" and a "void *" are the same.  */
 	  (*base) = (void *) (long) base_addr;
 	}
-      return result;
     }
   else
     {
-      /* This definition comes from prctl.h, but some kernels may not
-         have it.  */
-#ifndef PTRACE_ARCH_PRCTL
-#define PTRACE_ARCH_PRCTL      30
-#endif
+      struct cleanup *old_chain;
+      struct regcache *regcache;
+      enum amd64_regnum gdb_regnum;
+
       /* FIXME: ezannoni-2003-07-09 see comment above about include
 	 file order.  We could be getting bogus values for these two.  */
       gdb_assert (FS < ELF_NGREG);
       gdb_assert (GS < ELF_NGREG);
-      switch (idx)
-	{
-	case FS:
-#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
-	    {
-	      /* PTRACE_ARCH_PRCTL is obsolete since 2.6.25, where the
-		 fs_base and gs_base fields of user_regs_struct can be
-		 used directly.  */
-	      unsigned long fs;
-	      errno = 0;
-	      fs = ptrace (PTRACE_PEEKUSER, lwpid,
-			   offsetof (struct user_regs_struct, fs_base), 0);
-	      if (errno == 0)
-		{
-		  *base = (void *) fs;
-		  return PS_OK;
-		}
-	    }
-#endif
-	  if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0)
-	    return PS_OK;
-	  break;
-	case GS:
-#ifdef HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE
-	    {
-	      unsigned long gs;
-	      errno = 0;
-	      gs = ptrace (PTRACE_PEEKUSER, lwpid,
-			   offsetof (struct user_regs_struct, gs_base), 0);
-	      if (errno == 0)
-		{
-		  *base = (void *) gs;
-		  return PS_OK;
-		}
-	    }
-#endif
-	  if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0)
-	    return PS_OK;
-	  break;
-	default:                   /* Should not happen.  */
-	  return PS_BADADDR;
-	}
+      if (idx == FS)
+	gdb_regnum = AMD64_FSBASE_REGNUM;
+      else if (idx == GS)
+	gdb_regnum = AMD64_GSBASE_REGNUM;
+      else
+	return PS_BADADDR;
+
+      old_chain = save_inferior_ptid ();
+      inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
+      regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+      result = (regcache_raw_read (regcache, gdb_regnum, (gdb_byte *) base)
+		== REG_VALID ? PS_OK : PS_ERR);
+      do_cleanups (old_chain);
     }
-  return PS_ERR;               /* ptrace failed.  */
+
+  return result;
 }
 \f
 
-- 
2.4.3


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] Add amd64 registers fs_base and gs_base
  2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
  2015-11-03 13:43 ` [PATCH 2/3] Use register cache for x86_64 ps_get_thread_area Richard Henderson
  2015-11-03 13:44 ` [PATCH 3/3] Segment support for x86_64, part 1 Richard Henderson
@ 2015-11-03 13:44 ` Richard Henderson
  2015-11-05 11:21 ` [PATCH 0/3] Support for x86 segments as address classes Pedro Alves
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2015-11-03 13:44 UTC (permalink / raw)
  To: gdb-patches

	* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Read
	seg bases from ARCH_PRCTL if they're not present in struct user.
	(amd64_linux_store_inferior_registers): Likewise write them.
	* amd64-linux-tdep.c (amd64_linux_gregset_reg_offset): Add offsets
	for seg bases if they're present in struct user.
	* amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Set to
	AMD64_NUM_REGS.
	* amd64-tdep.c (amd64_init_abi): Init org.gnu.gdb.i386.seg.
	* amd64-tdep.h (AMD64_FSBASE_REGNUM, AMD64_GSBASE_REGNUM): New.
	(AMD64_NUM_REGS): Update.

	* features/i386/64bit-seg.xml: New file.
	* features/i386/amd64-avx-linux.xml: Include it.
	* features/i386/amd64-avx512-linux.xml: Likewise.
	* features/i386/amd64-linux.xml: Likewise.
	* features/i386/amd64-mpx-linux.xml: Likewise.
	* features/i386/x32-avx-linux.xml: Likewise.
	* features/i386/x32-avx512-linux.xml: Likewise.
	* features/i386/x32-linux.xml: Likewise.

	* features/i386/amd64-avx-linux.c: Regenerate.
	* features/i386/amd64-avx512-linux.c: Likewise.
	* features/i386/amd64-linux.c: Likewise.
	* features/i386/amd64-mpx-linux.c: Likewise.
	* features/i386/x32-avx-linux.c: Likewise.
	* features/i386/x32-avx512-linux.c: Likewise.
	* features/i386/x32-linux.c: Likewise.

	* regformats/i386/amd64-avx-linux.dat: Regenerate.
	* regformats/i386/amd64-avx512-linux.dat: Likewise.
	* regformats/i386/amd64-linux.dat: Likewise.
	* regformats/i386/amd64-mpx-linux.dat: Likewise.
	* regformats/i386/x32-avx-linux.dat: Likewise.
	* regformats/i386/x32-avx512-linux.dat: Likewise.
	* regformats/i386/x32-linux.dat: Likewise.
---
 gdb/amd64-linux-nat.c                      |  36 ++++++
 gdb/amd64-linux-tdep.c                     |   5 +
 gdb/amd64-linux-tdep.h                     |   2 +-
 gdb/amd64-tdep.c                           |  12 ++
 gdb/amd64-tdep.h                           |   6 +-
 gdb/features/i386/64bit-seg.xml            |  12 ++
 gdb/features/i386/amd64-avx-linux.c        |  36 +++---
 gdb/features/i386/amd64-avx-linux.xml      |   1 +
 gdb/features/i386/amd64-avx512-linux.c     | 192 +++++++++++++++--------------
 gdb/features/i386/amd64-avx512-linux.xml   |   1 +
 gdb/features/i386/amd64-linux.c            |   4 +
 gdb/features/i386/amd64-linux.xml          |   1 +
 gdb/features/i386/amd64-mpx-linux.c        |  48 ++++----
 gdb/features/i386/amd64-mpx-linux.xml      |   1 +
 gdb/features/i386/x32-avx-linux.c          |  36 +++---
 gdb/features/i386/x32-avx-linux.xml        |   1 +
 gdb/features/i386/x32-avx512-linux.c       | 192 +++++++++++++++--------------
 gdb/features/i386/x32-avx512-linux.xml     |   1 +
 gdb/features/i386/x32-linux.c              |   4 +
 gdb/features/i386/x32-linux.xml            |   1 +
 gdb/regformats/i386/amd64-avx-linux.dat    |   2 +
 gdb/regformats/i386/amd64-avx512-linux.dat |   2 +
 gdb/regformats/i386/amd64-linux.dat        |   2 +
 gdb/regformats/i386/amd64-mpx-linux.dat    |   2 +
 gdb/regformats/i386/x32-avx-linux.dat      |   2 +
 gdb/regformats/i386/x32-avx512-linux.dat   |   2 +
 gdb/regformats/i386/x32-linux.dat          |   2 +
 27 files changed, 361 insertions(+), 245 deletions(-)
 create mode 100644 gdb/features/i386/64bit-seg.xml

diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 397f664..0a2cf45 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -170,6 +170,21 @@ amd64_linux_fetch_inferior_registers (struct target_ops *ops,
 
 	  amd64_supply_fxsave (regcache, -1, &fpregs);
 	}
+
+#ifndef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
+      {
+	/* PTRACE_ARCH_PRCTL is obsolete since 2.6.25, where the
+	   fs_base and gs_base fields of user_regs_struct can be
+	   used directly.  */
+	unsigned long base;
+	if ((regnum == -1 || regnum == AMD64_FSBASE_REGNUM)
+	    && ptrace (PTRACE_ARCH_PRCTL, tid, &base, ARCH_GET_FS) == 0)
+	  regcache_raw_supply (regcache, AMD64_FSBASE_REGNUM, &base);
+	if ((regnum == -1 || regnum == AMD64_GSBASE_REGNUM)
+	    && ptrace (PTRACE_ARCH_PRCTL, tid, &base, ARCH_GET_GS) == 0)
+	  regcache_raw_supply (regcache, AMD64_GSBASE_REGNUM, &base);
+      }
+#endif
     }
 }
 
@@ -236,6 +251,27 @@ amd64_linux_store_inferior_registers (struct target_ops *ops,
 	  if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0)
 	    perror_with_name (_("Couldn't write floating point status"));
 	}
+
+#ifndef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
+      {
+	/* PTRACE_ARCH_PRCTL is obsolete since 2.6.25, where the
+	   fs_base and gs_base fields of user_regs_struct can be
+	   used directly.  */
+	unsigned long base;
+	if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM)
+	  {
+	    regcache_raw_collect (regcache, AMD64_FSBASE_REGNUM, &base);
+	    if (ptrace (PTRACE_ARCH_PRCTL, tid, &base, ARCH_SET_FS) < 0)
+	      perror_with_name (_("Couldn't write fs_base"));
+	  }
+	if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM)
+	  {
+	    regcache_raw_collect (regcache, AMD64_GSBASE_REGNUM, &base);
+	    if (ptrace (PTRACE_ARCH_PRCTL, tid, &base, ARCH_SET_GS) < 0)
+	      perror_with_name (_("Couldn't write gs_base"));
+	  }
+      }
+#endif
     }
 }
 \f
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 021dca6..575b937 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -102,6 +102,11 @@ int amd64_linux_gregset_reg_offset[] =
   -1, -1, -1, -1, -1, -1, -1, -1,
   -1, -1, -1, -1, -1, -1, -1, -1,
   -1, -1, -1, -1, -1, -1, -1, -1,
+#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
+  21 * 8, 22 * 8,		/* fs_base, gs_base */
+#else
+  -1, -1,
+#endif
   15 * 8			      /* "orig_rax" */
 };
 \f
diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h
index a850fe1..63f41b5 100644
--- a/gdb/amd64-linux-tdep.h
+++ b/gdb/amd64-linux-tdep.h
@@ -26,7 +26,7 @@
 /* Register number for the "orig_rax" register.  If this register
    contains a value >= 0 it is interpreted as the system call number
    that the kernel is supposed to restart.  */
-#define AMD64_LINUX_ORIG_RAX_REGNUM (AMD64_ZMM31H_REGNUM + 1)
+#define AMD64_LINUX_ORIG_RAX_REGNUM (AMD64_NUM_REGS)
 
 /* Total number of registers for GNU/Linux.  */
 #define AMD64_LINUX_NUM_REGS (AMD64_LINUX_ORIG_RAX_REGNUM + 1)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 6096ce9..6867a06 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2943,6 +2943,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 								    NULL };
   static const char *const stap_register_indirection_suffixes[] = { ")",
 								    NULL };
+  const struct tdesc_feature *feature;
 
   /* AMD64 generally uses `fxsave' instead of `fsave' for saving its
      floating-point registers.  */
@@ -2987,6 +2988,17 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
       tdep->bnd0r_regnum = AMD64_BND0R_REGNUM;
     }
 
+  feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.seg");
+  if (feature != NULL)
+    {
+      struct tdesc_arch_data *tdesc_data
+	= (struct tdesc_arch_data *) info.tdep_info;
+      tdesc_numbered_register (feature, tdesc_data,
+                               AMD64_FSBASE_REGNUM, "fs_base");
+      tdesc_numbered_register (feature, tdesc_data,
+                               AMD64_GSBASE_REGNUM, "gs_base");
+    }
+
   tdep->num_byte_regs = 20;
   tdep->num_word_regs = 16;
   tdep->num_dword_regs = 16;
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 704225e..92b74df 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -76,13 +76,15 @@ enum amd64_regnum
   AMD64_K0_REGNUM,
   AMD64_K7_REGNUM = AMD64_K0_REGNUM + 7,
   AMD64_ZMM0H_REGNUM,
-  AMD64_ZMM31H_REGNUM = AMD64_ZMM0H_REGNUM + 31
+  AMD64_ZMM31H_REGNUM = AMD64_ZMM0H_REGNUM + 31,
+  AMD64_FSBASE_REGNUM,
+  AMD64_GSBASE_REGNUM
 };
 
 /* Number of general purpose registers.  */
 #define AMD64_NUM_GREGS		24
 
-#define AMD64_NUM_REGS		(AMD64_ZMM31H_REGNUM + 1)
+#define AMD64_NUM_REGS		(AMD64_GSBASE_REGNUM + 1)
 
 extern struct target_desc *tdesc_amd64;
 
diff --git a/gdb/features/i386/64bit-seg.xml b/gdb/features/i386/64bit-seg.xml
new file mode 100644
index 0000000..7af63ee
--- /dev/null
+++ b/gdb/features/i386/64bit-seg.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.i386.seg">
+  <reg name="fs_base" bitsize="64" type="data_ptr"/>
+  <reg name="gs_base" bitsize="64" type="data_ptr"/>
+</feature>
diff --git a/gdb/features/i386/amd64-avx-linux.c b/gdb/features/i386/amd64-avx-linux.c
index ec419be..01e80a5 100644
--- a/gdb/features/i386/amd64-avx-linux.c
+++ b/gdb/features/i386/amd64-avx-linux.c
@@ -151,23 +151,27 @@ initialize_tdesc_amd64_avx_linux (void)
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   tdesc_create_reg (feature, "orig_rax", 57, 1, NULL, 64, "int");
 
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.seg");
+  tdesc_create_reg (feature, "fs_base", 58, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "gs_base", 59, 1, NULL, 64, "data_ptr");
+
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
-  tdesc_create_reg (feature, "ymm0h", 58, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm1h", 59, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm2h", 60, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm3h", 61, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm4h", 62, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm5h", 63, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm6h", 64, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm7h", 65, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm8h", 66, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm9h", 67, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm10h", 68, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm11h", 69, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm12h", 70, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm13h", 71, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm14h", 72, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm15h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm0h", 60, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm1h", 61, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm2h", 62, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm3h", 63, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm4h", 64, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm5h", 65, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm6h", 66, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm7h", 67, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm8h", 68, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm9h", 69, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm10h", 70, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm11h", 71, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm12h", 72, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm13h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm14h", 74, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm15h", 75, 1, NULL, 128, "uint128");
 
   tdesc_amd64_avx_linux = result;
 }
diff --git a/gdb/features/i386/amd64-avx-linux.xml b/gdb/features/i386/amd64-avx-linux.xml
index 35be33f..5acfe53 100644
--- a/gdb/features/i386/amd64-avx-linux.xml
+++ b/gdb/features/i386/amd64-avx-linux.xml
@@ -14,5 +14,6 @@
   <xi:include href="64bit-core.xml"/>
   <xi:include href="64bit-sse.xml"/>
   <xi:include href="64bit-linux.xml"/>
+  <xi:include href="64bit-seg.xml"/>
   <xi:include href="64bit-avx.xml"/>
 </target>
diff --git a/gdb/features/i386/amd64-avx512-linux.c b/gdb/features/i386/amd64-avx512-linux.c
index 61a547f..f3a56b0 100644
--- a/gdb/features/i386/amd64-avx512-linux.c
+++ b/gdb/features/i386/amd64-avx512-linux.c
@@ -151,23 +151,27 @@ initialize_tdesc_amd64_avx512_linux (void)
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   tdesc_create_reg (feature, "orig_rax", 57, 1, NULL, 64, "int");
 
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.seg");
+  tdesc_create_reg (feature, "fs_base", 58, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "gs_base", 59, 1, NULL, 64, "data_ptr");
+
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
-  tdesc_create_reg (feature, "ymm0h", 58, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm1h", 59, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm2h", 60, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm3h", 61, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm4h", 62, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm5h", 63, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm6h", 64, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm7h", 65, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm8h", 66, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm9h", 67, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm10h", 68, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm11h", 69, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm12h", 70, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm13h", 71, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm14h", 72, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm15h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm0h", 60, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm1h", 61, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm2h", 62, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm3h", 63, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm4h", 64, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm5h", 65, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm6h", 66, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm7h", 67, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm8h", 68, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm9h", 69, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm10h", 70, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm11h", 71, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm12h", 72, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm13h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm14h", 74, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm15h", 75, 1, NULL, 128, "uint128");
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
   type = tdesc_create_struct (feature, "br128");
@@ -200,12 +204,12 @@ initialize_tdesc_amd64_avx512_linux (void)
   field_type = tdesc_named_type (feature, "_bndcfgu");
   tdesc_add_field (type, "config", field_type);
 
-  tdesc_create_reg (feature, "bnd0raw", 74, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd1raw", 75, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd2raw", 76, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd3raw", 77, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bndcfgu", 78, 1, NULL, 64, "cfgu");
-  tdesc_create_reg (feature, "bndstatus", 79, 1, NULL, 64, "status");
+  tdesc_create_reg (feature, "bnd0raw", 76, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd1raw", 77, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd2raw", 78, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd3raw", 79, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bndcfgu", 80, 1, NULL, 64, "cfgu");
+  tdesc_create_reg (feature, "bndstatus", 81, 1, NULL, 64, "status");
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
   field_type = tdesc_named_type (feature, "ieee_single");
@@ -245,78 +249,78 @@ initialize_tdesc_amd64_avx512_linux (void)
   field_type = tdesc_named_type (feature, "uint128");
   tdesc_create_vector (feature, "v2ui128", field_type, 2);
 
-  tdesc_create_reg (feature, "xmm16", 80, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm17", 81, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm18", 82, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm19", 83, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm20", 84, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm21", 85, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm22", 86, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm23", 87, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm24", 88, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm25", 89, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm26", 90, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm27", 91, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm28", 92, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm29", 93, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm30", 94, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm31", 95, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "ymm16h", 96, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm17h", 97, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm18h", 98, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm19h", 99, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm20h", 100, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm21h", 101, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm22h", 102, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm23h", 103, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm24h", 104, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm25h", 105, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm26h", 106, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm27h", 107, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm28h", 108, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm29h", 109, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm30h", 110, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm31h", 111, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "k0", 112, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k1", 113, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k2", 114, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k3", 115, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k4", 116, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k5", 117, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k6", 118, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k7", 119, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "zmm0h", 120, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm1h", 121, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm2h", 122, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm3h", 123, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm4h", 124, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm5h", 125, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm6h", 126, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm7h", 127, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm8h", 128, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm9h", 129, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm10h", 130, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm11h", 131, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm12h", 132, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm13h", 133, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm14h", 134, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm15h", 135, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm16h", 136, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm17h", 137, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm18h", 138, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm19h", 139, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm20h", 140, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm21h", 141, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm22h", 142, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm23h", 143, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm24h", 144, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm25h", 145, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm26h", 146, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm27h", 147, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm28h", 148, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm29h", 149, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm30h", 150, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm31h", 151, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "xmm16", 82, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm17", 83, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm18", 84, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm19", 85, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm20", 86, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm21", 87, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm22", 88, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm23", 89, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm24", 90, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm25", 91, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm26", 92, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm27", 93, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm28", 94, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm29", 95, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm30", 96, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm31", 97, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "ymm16h", 98, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm17h", 99, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm18h", 100, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm19h", 101, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm20h", 102, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm21h", 103, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm22h", 104, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm23h", 105, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm24h", 106, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm25h", 107, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm26h", 108, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm27h", 109, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm28h", 110, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm29h", 111, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm30h", 112, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm31h", 113, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "k0", 114, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k1", 115, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k2", 116, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k3", 117, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k4", 118, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k5", 119, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k6", 120, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k7", 121, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "zmm0h", 122, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm1h", 123, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm2h", 124, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm3h", 125, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm4h", 126, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm5h", 127, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm6h", 128, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm7h", 129, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm8h", 130, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm9h", 131, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm10h", 132, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm11h", 133, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm12h", 134, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm13h", 135, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm14h", 136, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm15h", 137, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm16h", 138, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm17h", 139, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm18h", 140, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm19h", 141, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm20h", 142, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm21h", 143, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm22h", 144, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm23h", 145, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm24h", 146, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm25h", 147, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm26h", 148, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm27h", 149, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm28h", 150, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm29h", 151, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm30h", 152, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm31h", 153, 1, NULL, 256, "v2ui128");
 
   tdesc_amd64_avx512_linux = result;
 }
diff --git a/gdb/features/i386/amd64-avx512-linux.xml b/gdb/features/i386/amd64-avx512-linux.xml
index a1878a4..c228388 100644
--- a/gdb/features/i386/amd64-avx512-linux.xml
+++ b/gdb/features/i386/amd64-avx512-linux.xml
@@ -14,6 +14,7 @@
   <xi:include href="64bit-core.xml"/>
   <xi:include href="64bit-sse.xml"/>
   <xi:include href="64bit-linux.xml"/>
+  <xi:include href="64bit-seg.xml"/>
   <xi:include href="64bit-avx.xml"/>
   <xi:include href="64bit-mpx.xml"/>
   <xi:include href="64bit-avx512.xml"/>
diff --git a/gdb/features/i386/amd64-linux.c b/gdb/features/i386/amd64-linux.c
index 8cbf4bf..53b20f2 100644
--- a/gdb/features/i386/amd64-linux.c
+++ b/gdb/features/i386/amd64-linux.c
@@ -151,5 +151,9 @@ initialize_tdesc_amd64_linux (void)
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   tdesc_create_reg (feature, "orig_rax", 57, 1, NULL, 64, "int");
 
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.seg");
+  tdesc_create_reg (feature, "fs_base", 58, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "gs_base", 59, 1, NULL, 64, "data_ptr");
+
   tdesc_amd64_linux = result;
 }
diff --git a/gdb/features/i386/amd64-linux.xml b/gdb/features/i386/amd64-linux.xml
index e4f5545..5d0b13a 100644
--- a/gdb/features/i386/amd64-linux.xml
+++ b/gdb/features/i386/amd64-linux.xml
@@ -14,4 +14,5 @@
   <xi:include href="64bit-core.xml"/>
   <xi:include href="64bit-sse.xml"/>
   <xi:include href="64bit-linux.xml"/>
+  <xi:include href="64bit-seg.xml"/>
 </target>
diff --git a/gdb/features/i386/amd64-mpx-linux.c b/gdb/features/i386/amd64-mpx-linux.c
index 86a1774..4855e0d 100644
--- a/gdb/features/i386/amd64-mpx-linux.c
+++ b/gdb/features/i386/amd64-mpx-linux.c
@@ -151,23 +151,27 @@ initialize_tdesc_amd64_mpx_linux (void)
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   tdesc_create_reg (feature, "orig_rax", 57, 1, NULL, 64, "int");
 
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.seg");
+  tdesc_create_reg (feature, "fs_base", 58, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "gs_base", 59, 1, NULL, 64, "data_ptr");
+
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
-  tdesc_create_reg (feature, "ymm0h", 58, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm1h", 59, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm2h", 60, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm3h", 61, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm4h", 62, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm5h", 63, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm6h", 64, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm7h", 65, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm8h", 66, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm9h", 67, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm10h", 68, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm11h", 69, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm12h", 70, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm13h", 71, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm14h", 72, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm15h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm0h", 60, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm1h", 61, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm2h", 62, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm3h", 63, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm4h", 64, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm5h", 65, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm6h", 66, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm7h", 67, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm8h", 68, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm9h", 69, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm10h", 70, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm11h", 71, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm12h", 72, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm13h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm14h", 74, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm15h", 75, 1, NULL, 128, "uint128");
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
   type = tdesc_create_struct (feature, "br128");
@@ -200,12 +204,12 @@ initialize_tdesc_amd64_mpx_linux (void)
   field_type = tdesc_named_type (feature, "_bndcfgu");
   tdesc_add_field (type, "config", field_type);
 
-  tdesc_create_reg (feature, "bnd0raw", 74, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd1raw", 75, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd2raw", 76, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd3raw", 77, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bndcfgu", 78, 1, NULL, 64, "cfgu");
-  tdesc_create_reg (feature, "bndstatus", 79, 1, NULL, 64, "status");
+  tdesc_create_reg (feature, "bnd0raw", 76, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd1raw", 77, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd2raw", 78, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd3raw", 79, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bndcfgu", 80, 1, NULL, 64, "cfgu");
+  tdesc_create_reg (feature, "bndstatus", 81, 1, NULL, 64, "status");
 
   tdesc_amd64_mpx_linux = result;
 }
diff --git a/gdb/features/i386/amd64-mpx-linux.xml b/gdb/features/i386/amd64-mpx-linux.xml
index 6ed4d1d..bd4552f 100644
--- a/gdb/features/i386/amd64-mpx-linux.xml
+++ b/gdb/features/i386/amd64-mpx-linux.xml
@@ -14,6 +14,7 @@
   <xi:include href="64bit-core.xml"/>
   <xi:include href="64bit-sse.xml"/>
   <xi:include href="64bit-linux.xml"/>
+  <xi:include href="64bit-seg.xml"/>
   <xi:include href="64bit-avx.xml"/>
   <xi:include href="64bit-mpx.xml"/>
 </target>
diff --git a/gdb/features/i386/x32-avx-linux.c b/gdb/features/i386/x32-avx-linux.c
index 1f39610..e58af55 100644
--- a/gdb/features/i386/x32-avx-linux.c
+++ b/gdb/features/i386/x32-avx-linux.c
@@ -151,23 +151,27 @@ initialize_tdesc_x32_avx_linux (void)
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   tdesc_create_reg (feature, "orig_rax", 57, 1, NULL, 64, "int");
 
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.seg");
+  tdesc_create_reg (feature, "fs_base", 58, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "gs_base", 59, 1, NULL, 64, "data_ptr");
+
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
-  tdesc_create_reg (feature, "ymm0h", 58, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm1h", 59, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm2h", 60, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm3h", 61, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm4h", 62, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm5h", 63, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm6h", 64, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm7h", 65, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm8h", 66, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm9h", 67, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm10h", 68, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm11h", 69, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm12h", 70, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm13h", 71, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm14h", 72, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm15h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm0h", 60, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm1h", 61, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm2h", 62, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm3h", 63, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm4h", 64, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm5h", 65, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm6h", 66, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm7h", 67, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm8h", 68, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm9h", 69, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm10h", 70, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm11h", 71, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm12h", 72, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm13h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm14h", 74, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm15h", 75, 1, NULL, 128, "uint128");
 
   tdesc_x32_avx_linux = result;
 }
diff --git a/gdb/features/i386/x32-avx-linux.xml b/gdb/features/i386/x32-avx-linux.xml
index 51e6a20..5c2e46f 100644
--- a/gdb/features/i386/x32-avx-linux.xml
+++ b/gdb/features/i386/x32-avx-linux.xml
@@ -14,5 +14,6 @@
   <xi:include href="x32-core.xml"/>
   <xi:include href="64bit-sse.xml"/>
   <xi:include href="64bit-linux.xml"/>
+  <xi:include href="64bit-seg.xml"/>
   <xi:include href="64bit-avx.xml"/>
 </target>
diff --git a/gdb/features/i386/x32-avx512-linux.c b/gdb/features/i386/x32-avx512-linux.c
index 0f835d4..a8036c1 100644
--- a/gdb/features/i386/x32-avx512-linux.c
+++ b/gdb/features/i386/x32-avx512-linux.c
@@ -151,23 +151,27 @@ initialize_tdesc_x32_avx512_linux (void)
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   tdesc_create_reg (feature, "orig_rax", 57, 1, NULL, 64, "int");
 
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.seg");
+  tdesc_create_reg (feature, "fs_base", 58, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "gs_base", 59, 1, NULL, 64, "data_ptr");
+
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
-  tdesc_create_reg (feature, "ymm0h", 58, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm1h", 59, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm2h", 60, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm3h", 61, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm4h", 62, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm5h", 63, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm6h", 64, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm7h", 65, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm8h", 66, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm9h", 67, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm10h", 68, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm11h", 69, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm12h", 70, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm13h", 71, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm14h", 72, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm15h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm0h", 60, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm1h", 61, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm2h", 62, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm3h", 63, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm4h", 64, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm5h", 65, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm6h", 66, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm7h", 67, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm8h", 68, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm9h", 69, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm10h", 70, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm11h", 71, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm12h", 72, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm13h", 73, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm14h", 74, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm15h", 75, 1, NULL, 128, "uint128");
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
   type = tdesc_create_struct (feature, "br128");
@@ -200,12 +204,12 @@ initialize_tdesc_x32_avx512_linux (void)
   field_type = tdesc_named_type (feature, "_bndcfgu");
   tdesc_add_field (type, "config", field_type);
 
-  tdesc_create_reg (feature, "bnd0raw", 74, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd1raw", 75, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd2raw", 76, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bnd3raw", 77, 1, NULL, 128, "br128");
-  tdesc_create_reg (feature, "bndcfgu", 78, 1, NULL, 64, "cfgu");
-  tdesc_create_reg (feature, "bndstatus", 79, 1, NULL, 64, "status");
+  tdesc_create_reg (feature, "bnd0raw", 76, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd1raw", 77, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd2raw", 78, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bnd3raw", 79, 1, NULL, 128, "br128");
+  tdesc_create_reg (feature, "bndcfgu", 80, 1, NULL, 64, "cfgu");
+  tdesc_create_reg (feature, "bndstatus", 81, 1, NULL, 64, "status");
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
   field_type = tdesc_named_type (feature, "ieee_single");
@@ -245,78 +249,78 @@ initialize_tdesc_x32_avx512_linux (void)
   field_type = tdesc_named_type (feature, "uint128");
   tdesc_create_vector (feature, "v2ui128", field_type, 2);
 
-  tdesc_create_reg (feature, "xmm16", 80, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm17", 81, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm18", 82, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm19", 83, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm20", 84, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm21", 85, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm22", 86, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm23", 87, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm24", 88, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm25", 89, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm26", 90, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm27", 91, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm28", 92, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm29", 93, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm30", 94, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "xmm31", 95, 1, NULL, 128, "vec128");
-  tdesc_create_reg (feature, "ymm16h", 96, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm17h", 97, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm18h", 98, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm19h", 99, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm20h", 100, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm21h", 101, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm22h", 102, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm23h", 103, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm24h", 104, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm25h", 105, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm26h", 106, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm27h", 107, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm28h", 108, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm29h", 109, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm30h", 110, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "ymm31h", 111, 1, NULL, 128, "uint128");
-  tdesc_create_reg (feature, "k0", 112, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k1", 113, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k2", 114, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k3", 115, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k4", 116, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k5", 117, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k6", 118, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "k7", 119, 1, NULL, 64, "uint64");
-  tdesc_create_reg (feature, "zmm0h", 120, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm1h", 121, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm2h", 122, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm3h", 123, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm4h", 124, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm5h", 125, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm6h", 126, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm7h", 127, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm8h", 128, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm9h", 129, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm10h", 130, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm11h", 131, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm12h", 132, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm13h", 133, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm14h", 134, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm15h", 135, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm16h", 136, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm17h", 137, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm18h", 138, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm19h", 139, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm20h", 140, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm21h", 141, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm22h", 142, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm23h", 143, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm24h", 144, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm25h", 145, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm26h", 146, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm27h", 147, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm28h", 148, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm29h", 149, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm30h", 150, 1, NULL, 256, "v2ui128");
-  tdesc_create_reg (feature, "zmm31h", 151, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "xmm16", 82, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm17", 83, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm18", 84, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm19", 85, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm20", 86, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm21", 87, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm22", 88, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm23", 89, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm24", 90, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm25", 91, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm26", 92, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm27", 93, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm28", 94, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm29", 95, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm30", 96, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "xmm31", 97, 1, NULL, 128, "vec128");
+  tdesc_create_reg (feature, "ymm16h", 98, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm17h", 99, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm18h", 100, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm19h", 101, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm20h", 102, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm21h", 103, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm22h", 104, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm23h", 105, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm24h", 106, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm25h", 107, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm26h", 108, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm27h", 109, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm28h", 110, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm29h", 111, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm30h", 112, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "ymm31h", 113, 1, NULL, 128, "uint128");
+  tdesc_create_reg (feature, "k0", 114, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k1", 115, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k2", 116, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k3", 117, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k4", 118, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k5", 119, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k6", 120, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "k7", 121, 1, NULL, 64, "uint64");
+  tdesc_create_reg (feature, "zmm0h", 122, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm1h", 123, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm2h", 124, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm3h", 125, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm4h", 126, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm5h", 127, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm6h", 128, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm7h", 129, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm8h", 130, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm9h", 131, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm10h", 132, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm11h", 133, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm12h", 134, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm13h", 135, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm14h", 136, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm15h", 137, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm16h", 138, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm17h", 139, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm18h", 140, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm19h", 141, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm20h", 142, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm21h", 143, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm22h", 144, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm23h", 145, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm24h", 146, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm25h", 147, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm26h", 148, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm27h", 149, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm28h", 150, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm29h", 151, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm30h", 152, 1, NULL, 256, "v2ui128");
+  tdesc_create_reg (feature, "zmm31h", 153, 1, NULL, 256, "v2ui128");
 
   tdesc_x32_avx512_linux = result;
 }
diff --git a/gdb/features/i386/x32-avx512-linux.xml b/gdb/features/i386/x32-avx512-linux.xml
index bdc7b2f..f1d95d6 100644
--- a/gdb/features/i386/x32-avx512-linux.xml
+++ b/gdb/features/i386/x32-avx512-linux.xml
@@ -14,6 +14,7 @@
   <xi:include href="x32-core.xml"/>
   <xi:include href="64bit-sse.xml"/>
   <xi:include href="64bit-linux.xml"/>
+  <xi:include href="64bit-seg.xml"/>
   <xi:include href="64bit-avx.xml"/>
   <xi:include href="64bit-mpx.xml"/>
   <xi:include href="64bit-avx512.xml"/>
diff --git a/gdb/features/i386/x32-linux.c b/gdb/features/i386/x32-linux.c
index 387436f..cb43ebb 100644
--- a/gdb/features/i386/x32-linux.c
+++ b/gdb/features/i386/x32-linux.c
@@ -151,5 +151,9 @@ initialize_tdesc_x32_linux (void)
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   tdesc_create_reg (feature, "orig_rax", 57, 1, NULL, 64, "int");
 
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.seg");
+  tdesc_create_reg (feature, "fs_base", 58, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "gs_base", 59, 1, NULL, 64, "data_ptr");
+
   tdesc_x32_linux = result;
 }
diff --git a/gdb/features/i386/x32-linux.xml b/gdb/features/i386/x32-linux.xml
index feb1571..e7a86e6 100644
--- a/gdb/features/i386/x32-linux.xml
+++ b/gdb/features/i386/x32-linux.xml
@@ -14,4 +14,5 @@
   <xi:include href="x32-core.xml"/>
   <xi:include href="64bit-sse.xml"/>
   <xi:include href="64bit-linux.xml"/>
+  <xi:include href="64bit-seg.xml"/>
 </target>
diff --git a/gdb/regformats/i386/amd64-avx-linux.dat b/gdb/regformats/i386/amd64-avx-linux.dat
index d8199da..7780b3b 100644
--- a/gdb/regformats/i386/amd64-avx-linux.dat
+++ b/gdb/regformats/i386/amd64-avx-linux.dat
@@ -61,6 +61,8 @@ expedite:rbp,rsp,rip
 128:xmm15
 32:mxcsr
 64:orig_rax
+64:fs_base
+64:gs_base
 128:ymm0h
 128:ymm1h
 128:ymm2h
diff --git a/gdb/regformats/i386/amd64-avx512-linux.dat b/gdb/regformats/i386/amd64-avx512-linux.dat
index dfc41e2..f1658d3 100644
--- a/gdb/regformats/i386/amd64-avx512-linux.dat
+++ b/gdb/regformats/i386/amd64-avx512-linux.dat
@@ -61,6 +61,8 @@ expedite:rbp,rsp,rip
 128:xmm15
 32:mxcsr
 64:orig_rax
+64:fs_base
+64:gs_base
 128:ymm0h
 128:ymm1h
 128:ymm2h
diff --git a/gdb/regformats/i386/amd64-linux.dat b/gdb/regformats/i386/amd64-linux.dat
index 6914cc4..cd16a15 100644
--- a/gdb/regformats/i386/amd64-linux.dat
+++ b/gdb/regformats/i386/amd64-linux.dat
@@ -61,3 +61,5 @@ expedite:rbp,rsp,rip
 128:xmm15
 32:mxcsr
 64:orig_rax
+64:fs_base
+64:gs_base
diff --git a/gdb/regformats/i386/amd64-mpx-linux.dat b/gdb/regformats/i386/amd64-mpx-linux.dat
index 7a05cfe..32bcce1 100644
--- a/gdb/regformats/i386/amd64-mpx-linux.dat
+++ b/gdb/regformats/i386/amd64-mpx-linux.dat
@@ -61,6 +61,8 @@ expedite:rbp,rsp,rip
 128:xmm15
 32:mxcsr
 64:orig_rax
+64:fs_base
+64:gs_base
 128:ymm0h
 128:ymm1h
 128:ymm2h
diff --git a/gdb/regformats/i386/x32-avx-linux.dat b/gdb/regformats/i386/x32-avx-linux.dat
index a2b8d02..eb0e3953 100644
--- a/gdb/regformats/i386/x32-avx-linux.dat
+++ b/gdb/regformats/i386/x32-avx-linux.dat
@@ -61,6 +61,8 @@ expedite:rbp,rsp,rip
 128:xmm15
 32:mxcsr
 64:orig_rax
+64:fs_base
+64:gs_base
 128:ymm0h
 128:ymm1h
 128:ymm2h
diff --git a/gdb/regformats/i386/x32-avx512-linux.dat b/gdb/regformats/i386/x32-avx512-linux.dat
index 0f5b2ce..0b7f73a 100644
--- a/gdb/regformats/i386/x32-avx512-linux.dat
+++ b/gdb/regformats/i386/x32-avx512-linux.dat
@@ -61,6 +61,8 @@ expedite:rbp,rsp,rip
 128:xmm15
 32:mxcsr
 64:orig_rax
+64:fs_base
+64:gs_base
 128:ymm0h
 128:ymm1h
 128:ymm2h
diff --git a/gdb/regformats/i386/x32-linux.dat b/gdb/regformats/i386/x32-linux.dat
index d976a25..eee378f 100644
--- a/gdb/regformats/i386/x32-linux.dat
+++ b/gdb/regformats/i386/x32-linux.dat
@@ -61,3 +61,5 @@ expedite:rbp,rsp,rip
 128:xmm15
 32:mxcsr
 64:orig_rax
+64:fs_base
+64:gs_base
-- 
2.4.3


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/3] Segment support for x86_64, part 1
  2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
  2015-11-03 13:43 ` [PATCH 2/3] Use register cache for x86_64 ps_get_thread_area Richard Henderson
@ 2015-11-03 13:44 ` Richard Henderson
  2015-11-03 13:44 ` [PATCH 1/3] Add amd64 registers fs_base and gs_base Richard Henderson
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2015-11-03 13:44 UTC (permalink / raw)
  To: gdb-patches

	* amd64-tdep.c (amd64_address_class_type_flags): New.
	(amd64_address_class_type_flags_to_name): New.
	(amd64_address_class_name_to_type_flags): New.
	(amd64_init_abi): Register them.
---
 gdb/amd64-tdep.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 6867a06..3f12796 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2890,7 +2890,55 @@ const struct regset amd64_fpregset =
     NULL, amd64_supply_fpregset, amd64_collect_fpregset
   };
 \f
+/* Address classes.  */
 
+static int
+amd64_address_class_type_flags (int byte_size, int dwarf2_addr_class)
+{
+  switch (dwarf2_addr_class)
+    {
+    case 1: /* __seg_fs */
+      return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
+    case 2: /* __seg_gs */
+      return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2;
+    default:
+      return 0;
+    }
+}
+
+static const char *
+amd64_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+{
+  if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
+    return "__seg_fs";
+  if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
+    return "__seg_gs";
+  return NULL;
+}
+
+static int
+amd64_address_class_name_to_type_flags (struct gdbarch *gdbarch,
+				        const char *name,
+				        int *type_flags_ptr)
+{
+  if (strcmp (name, "__seg_fs") == 0)
+    {
+      *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
+      return 1;
+    }
+  if (strcmp (name, "__seg_gs") == 0)
+    {
+      *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2;
+      return 1;
+    }
+  return 0;
+}
+
+/* ??? We ought to fill in address_to_pointer and pointer_to_address,
+   except that these hooks do not have access to the thread, or a
+   regcache for the thread.  */
+
+\f
 /* Figure out where the longjmp will land.  Slurp the jmp_buf out of
    %rdi.  We expect its value to be a pointer to the jmp_buf structure
    from which we extract the address that we will land at.  This
@@ -3093,6 +3141,14 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_insn_is_call (gdbarch, amd64_insn_is_call);
   set_gdbarch_insn_is_ret (gdbarch, amd64_insn_is_ret);
   set_gdbarch_insn_is_jump (gdbarch, amd64_insn_is_jump);
+
+  /* Address handling.  */
+  set_gdbarch_address_class_type_flags
+    (gdbarch, amd64_address_class_type_flags);
+  set_gdbarch_address_class_type_flags_to_name
+    (gdbarch, amd64_address_class_type_flags_to_name);
+  set_gdbarch_address_class_name_to_type_flags
+    (gdbarch, amd64_address_class_name_to_type_flags);
 }
 \f
 
-- 
2.4.3


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Support for x86 segments as address classes
  2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
                   ` (2 preceding siblings ...)
  2015-11-03 13:44 ` [PATCH 1/3] Add amd64 registers fs_base and gs_base Richard Henderson
@ 2015-11-05 11:21 ` Pedro Alves
  2015-11-05 14:15   ` Richard Henderson
  2015-11-05 14:18 ` [PATCH 4/3] Segment support for x86_64, part 2 Richard Henderson
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2015-11-05 11:21 UTC (permalink / raw)
  To: Richard Henderson, gdb-patches

On 11/03/2015 01:43 PM, Richard Henderson wrote:
> The following gets 90% of the way there, but I'm stuck --
> address_to_pointer and pointer_to_address do not appear to
> have access to a regcache.  And not just in the one level
> of the caller, but significantly farther back in the call
> stack too.

The first two patches look generally good to me.  Though
you'll need to update the manual and NEWS as well to document
the new target feature.  (Also, I know this is a WIP, but
note that in gdb we strive to have the rationale for changes
in the git commit logs.)

> 
> Which begs the question of whether I've simply missed
> something in how to get hold of the current regcache?

get_current_frame / get_current_regcache ?  If you can pass it down
through a couple layers, it's of course better.

Though I'm not sufficiently familiar with the address class
mechanisms be to sure I'm not pointing you in the
wrong direction.  Ulrich, can you help?

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Support for x86 segments as address classes
  2015-11-05 11:21 ` [PATCH 0/3] Support for x86 segments as address classes Pedro Alves
@ 2015-11-05 14:15   ` Richard Henderson
  2015-11-18 18:18     ` Ulrich Weigand
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Henderson @ 2015-11-05 14:15 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 11/05/2015 12:21 PM, Pedro Alves wrote:
> On 11/03/2015 01:43 PM, Richard Henderson wrote:
>> Which begs the question of whether I've simply missed
>> something in how to get hold of the current regcache?
>
> get_current_frame / get_current_regcache ?  If you can pass it down
> through a couple layers, it's of course better.

Duh, get_current_regcache, of course.  Thanks.

Which makes for a relatively easy patch to finish the support.

However, IMO the results aren't ideal.  Consider:

int test(void)
{
   int __seg_fs *f = (int __seg_fs *)16;
   int __seg_gs *g = (int __seg_gs *)16;
   return *f + *g;
}

int main()
{
   test();
   return 0;
}

Now, this really isn't a proper executable testcase, because I haven't set up 
gs_base, but since libc.so set up fs_base for the thread pointer, it's good 
enough to step into test() and examine some variables.

Breakpoint 2, test () at z.c:10
10	  return *f + *g;
(gdb) ptype f
type = int * @__seg_fs
(gdb) ptype g
type = int * @__seg_gs
(gdb) info loc
f = 0x7ffff7fd9710
g = 0x10

It seems to me that the "real" value of both f and g are 0x10.  Instead, we 
display the converted value, displaying f with a surprising value.

It seems to me that it would be better to do the conversion when we want to 
dereference, such as "print *f", but not otherwise.  However, I'm not really 
sure how that would interact with the other users of address classes throughout 
gdb.


r~


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/3] Segment support for x86_64, part 2
  2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
                   ` (3 preceding siblings ...)
  2015-11-05 11:21 ` [PATCH 0/3] Support for x86 segments as address classes Pedro Alves
@ 2015-11-05 14:18 ` Richard Henderson
  2015-11-27 14:34 ` [PATCH 0/3] Support for x86 segments as address classes Gary Benson
  2016-04-19 14:23 ` Tedeschi, Walfred
  6 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2015-11-05 14:18 UTC (permalink / raw)
  To: gdb-patches

	* amd64-tdep.c (amd64_address_to_pointer): New.
	(amd64_pointer_to_address): New.
	(amd64_init_abi): Register them.
---
 gdb/amd64-tdep.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 60 insertions(+), 3 deletions(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 3f12796..b327692 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2934,9 +2934,64 @@ amd64_address_class_name_to_type_flags (struct gdbarch *gdbarch,
   return 0;
 }
 
-/* ??? We ought to fill in address_to_pointer and pointer_to_address,
-   except that these hooks do not have access to the thread, or a
-   regcache for the thread.  */
+static void
+amd64_address_to_pointer (struct gdbarch *gdbarch, struct type *type,
+			  gdb_byte *buf, CORE_ADDR addr)
+{
+  int regnum = -1;
+
+  switch (TYPE_ADDRESS_CLASS_ALL (type))
+    {
+    case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1:
+      regnum = AMD64_FSBASE_REGNUM;
+      break;
+    case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2:
+      regnum = AMD64_GSBASE_REGNUM;
+      break;
+    }
+  if (regnum >= 0)
+    {
+      struct regcache *regcache = get_current_regcache ();
+      ULONGEST base;
+
+      if (regcache_raw_read_unsigned (regcache, regnum, &base) == REG_VALID)
+	addr -= base;
+      /* ??? else error, but we have no way to signal that here.  */
+    }
+
+  store_unsigned_integer (buf, TYPE_LENGTH (type), BFD_ENDIAN_LITTLE, addr);
+}
+
+static CORE_ADDR
+amd64_pointer_to_address (struct gdbarch *gdbarch, struct type *type,
+			  const gdb_byte *buf)
+{
+  ULONGEST addr = extract_unsigned_integer (buf, TYPE_LENGTH (type),
+					    BFD_ENDIAN_LITTLE);
+  int regnum = -1;
+
+  switch (TYPE_ADDRESS_CLASS_ALL (type))
+    {
+    case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1:
+      regnum = AMD64_FSBASE_REGNUM;
+      break;
+    case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2:
+      regnum = AMD64_GSBASE_REGNUM;
+      break;
+    }
+  if (regnum >= 0)
+    {
+      struct regcache *regcache = get_current_regcache ();
+      ULONGEST base;
+
+      if (regcache_raw_read_unsigned (regcache, regnum, &base) == REG_VALID)
+	addr += base;
+      /* ??? else error, but we have no way to signal that here.  */
+    }
+
+  return addr;
+}
+
 
 \f
 /* Figure out where the longjmp will land.  Slurp the jmp_buf out of
@@ -3149,6 +3204,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
     (gdbarch, amd64_address_class_type_flags_to_name);
   set_gdbarch_address_class_name_to_type_flags
     (gdbarch, amd64_address_class_name_to_type_flags);
+  set_gdbarch_address_to_pointer (gdbarch, amd64_address_to_pointer);
+  set_gdbarch_pointer_to_address (gdbarch, amd64_pointer_to_address);
 }
 \f
 
-- 
2.4.3


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Support for x86 segments as address classes
  2015-11-05 14:15   ` Richard Henderson
@ 2015-11-18 18:18     ` Ulrich Weigand
  0 siblings, 0 replies; 12+ messages in thread
From: Ulrich Weigand @ 2015-11-18 18:18 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Pedro Alves, gdb-patches

Pedro Alves wrote:

> get_current_frame / get_current_regcache ?  If you can pass it down
> through a couple layers, it's of course better.
> 
> Though I'm not sufficiently familiar with the address class
> mechanisms be to sure I'm not pointing you in the
> wrong direction.  Ulrich, can you help?

Sorry for the late reply, I must haved missed this earlier ...

I'm a bit sceptical about using get_current_regcache in the
gdbarch_address_to_pointer routines.  Those routines are called
from the generic unpack_long / pack_long routines, which in
turn are called from all over the source base.

It is at least not immediately obvious to me that all those
call sites will have an appropriate "current" regcache set.
(It is probably the case most of the time, though ...)

I had a similar issue on the SPU, where I'm using those
routines to encode the SPU ID into the GDB CORE_ADDR.
For a while, I was attempting to get the SPU ID to use
from the "current" regcache as well, but then decided on
another approach: create a separate gdbarch structure for
each SPU ID in use, and take the SPU ID from gdbarch->tdep
in gdbarch_address_to_pointer.

This worked because I was able to already identify the
appropriate SPU ID whenever creating an gdbarch (from
the objfile, or for the current thread).  This method
likely will not work for the x86 case.


Richard Henderson wrote:

> Breakpoint 2, test () at z.c:10
> 10	  return *f + *g;
> (gdb) ptype f
> type = int * @__seg_fs
> (gdb) ptype g
> type = int * @__seg_gs
> (gdb) info loc
> f = 0x7ffff7fd9710
> g = 0x10
> 
> It seems to me that the "real" value of both f and g are 0x10.  Instead, we 
> display the converted value, displaying f with a surprising value.

Yes, that's another problem.  GDB currently always does a pointer-to-address
conversion, both if it then wants to use the address for accessing memory,
and when it simply wants to *print* the pointer value.  In the latter case,
the address is printed via paddress.

Again, I worked around this issue on the SPU using a hack: paddress always
truncates the output to the size of an address on the platform, which I
defined a 32 on the SPU.  The extra bits to encode the SPU ID within a
GDB address are placed in the high 32 bits, which means a sequence of
pointer-to-address conversion followed by paddress actually prints the
original *pointer* value.

To clean this up, it seems GDB code should be clearer in when to use
*GDB address* values (e.g. to access memory), and when to use *target
pointer* values (e.g. for printing).  This probably means auditing a
lot of code ...
 
> It seems to me that it would be better to do the conversion when we want to 
> dereference, such as "print *f", but not otherwise.  However, I'm not really 
> sure how that would interact with the other users of address classes throughout 
> gdb.

That might a workaround for the x86 case.  I'd still encode address classes
into the types, but leave pointer-to-address / address-to-pointer conversion
as no-ops, and instead modify e.g. value_ind (pointer indirection).  There
is even already a callback to support type-specific value_ind implementations.

However, I'm not completely sure this will cover all relevant cases where
you really want an address.   What about "x/x f", for example?  Perhaps
the correct place to hook is value_as_address?  This already handles the
gdbarch_integer_to_address callback today ...

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Support for x86 segments as address classes
  2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
                   ` (4 preceding siblings ...)
  2015-11-05 14:18 ` [PATCH 4/3] Segment support for x86_64, part 2 Richard Henderson
@ 2015-11-27 14:34 ` Gary Benson
  2016-04-19 14:23 ` Tedeschi, Walfred
  6 siblings, 0 replies; 12+ messages in thread
From: Gary Benson @ 2015-11-27 14:34 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gdb-patches

Hi Richard,

Richard Henderson wrote:
> The following gets 90% of the way there, but I'm stuck --
> address_to_pointer and pointer_to_address do not appear to
> have access to a regcache.  And not just in the one level
> of the caller, but significantly farther back in the call
> stack too.
> 
> Which begs the question of whether I've simply missed
> something in how to get hold of the current regcache?

I don't know the answer to your questions, but thanks for
doing this; I can write better libpthread Infinity notes
for glibc with this.  (I tried adding this support myself
a month or so back but got stuck way earlier than you!)

Cheers,
Gary

-- 
http://gbenson.net/


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 0/3] Support for x86 segments as address classes
  2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
                   ` (5 preceding siblings ...)
  2015-11-27 14:34 ` [PATCH 0/3] Support for x86 segments as address classes Gary Benson
@ 2016-04-19 14:23 ` Tedeschi, Walfred
  2016-04-19 14:44   ` Richard Henderson
  6 siblings, 1 reply; 12+ messages in thread
From: Tedeschi, Walfred @ 2016-04-19 14:23 UTC (permalink / raw)
  To: Richard Henderson, gdb-patches



-----Original Message-----
From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Richard Henderson
Sent: Tuesday, November 03, 2015 2:43 PM
To: gdb-patches@gcc.gnu.org
Subject: [PATCH 0/3] Support for x86 segments as address classes

The following gets 90% of the way there, but I'm stuck -- address_to_pointer and pointer_to_address do not appear to have access to a regcache.  And not just in the one level of the caller, but significantly farther back in the call stack too.

Which begs the question of whether I've simply missed something in how to get hold of the current regcache?


r~


Richard Henderson (3):
  Add amd64 registers fs_base and gs_base
  Use register cache for x86_64 ps_get_thread_area
  Segment support for x86_64, part 1

 gdb/amd64-linux-nat.c                      | 107 ++++++++--------
 gdb/amd64-linux-tdep.c                     |   5 +
 gdb/amd64-linux-tdep.h                     |   2 +-
 gdb/amd64-tdep.c                           |  68 ++++++++++
 gdb/amd64-tdep.h                           |   6 +-
 gdb/features/i386/64bit-seg.xml            |  12 ++
 gdb/features/i386/amd64-avx-linux.c        |  36 +++---
 gdb/features/i386/amd64-avx-linux.xml      |   1 +
 gdb/features/i386/amd64-avx512-linux.c     | 192 +++++++++++++++--------------
 gdb/features/i386/amd64-avx512-linux.xml   |   1 +
 gdb/features/i386/amd64-linux.c            |   4 +
 gdb/features/i386/amd64-linux.xml          |   1 +
 gdb/features/i386/amd64-mpx-linux.c        |  48 ++++----
 gdb/features/i386/amd64-mpx-linux.xml      |   1 +
 gdb/features/i386/x32-avx-linux.c          |  36 +++---
 gdb/features/i386/x32-avx-linux.xml        |   1 +
 gdb/features/i386/x32-avx512-linux.c       | 192 +++++++++++++++--------------
 gdb/features/i386/x32-avx512-linux.xml     |   1 +
 gdb/features/i386/x32-linux.c              |   4 +
 gdb/features/i386/x32-linux.xml            |   1 +
 gdb/regformats/i386/amd64-avx-linux.dat    |   2 +
 gdb/regformats/i386/amd64-avx512-linux.dat |   2 +
 gdb/regformats/i386/amd64-linux.dat        |   2 +
 gdb/regformats/i386/amd64-mpx-linux.dat    |   2 +
 gdb/regformats/i386/x32-avx-linux.dat      |   2 +
 gdb/regformats/i386/x32-avx512-linux.dat   |   2 +
 gdb/regformats/i386/x32-linux.dat          |   2 +
 27 files changed, 438 insertions(+), 295 deletions(-)  create mode 100644 gdb/features/i386/64bit-seg.xml

--
2.4.3

Richard,

I was about to prepare also a patch about the same topic.
Intention is to make fs_base and gs_base available for the user.

Have you gave up this patch, or have you found some road blocker?

Thanks and regard,
-Fred

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Support for x86 segments as address classes
  2016-04-19 14:23 ` Tedeschi, Walfred
@ 2016-04-19 14:44   ` Richard Henderson
  2016-04-19 14:47     ` Walfred Tedeschi
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Henderson @ 2016-04-19 14:44 UTC (permalink / raw)
  To: Tedeschi, Walfred, gdb-patches

On 04/19/2016 07:13 AM, Tedeschi, Walfred wrote:
> I was about to prepare also a patch about the same topic.
> Intention is to make fs_base and gs_base available for the user.
>
> Have you gave up this patch, or have you found some road blocker?

I ran out of time at first, and then forgot about this patch set across the 
Christmas break.  If you'd like to pick it up, please do.


r~


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Support for x86 segments as address classes
  2016-04-19 14:44   ` Richard Henderson
@ 2016-04-19 14:47     ` Walfred Tedeschi
  0 siblings, 0 replies; 12+ messages in thread
From: Walfred Tedeschi @ 2016-04-19 14:47 UTC (permalink / raw)
  To: Richard Henderson, gdb-patches

Am 4/19/2016 um 4:43 PM schrieb Richard Henderson:
> On 04/19/2016 07:13 AM, Tedeschi, Walfred wrote:
>> I was about to prepare also a patch about the same topic.
>> Intention is to make fs_base and gs_base available for the user.
>>
>> Have you gave up this patch, or have you found some road blocker?
>
> I ran out of time at first, and then forgot about this patch set across
> the Christmas break.  If you'd like to pick it up, please do.
>
>
> r~
>
Richard,

I will do so and add you as co-author, ok?
In any case i go up to have the fs_base and gs_base available for the 
user, by now.

Thanks for the prompt answer!

Best regards,
-Fred
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-04-19 14:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
2015-11-03 13:43 ` [PATCH 2/3] Use register cache for x86_64 ps_get_thread_area Richard Henderson
2015-11-03 13:44 ` [PATCH 3/3] Segment support for x86_64, part 1 Richard Henderson
2015-11-03 13:44 ` [PATCH 1/3] Add amd64 registers fs_base and gs_base Richard Henderson
2015-11-05 11:21 ` [PATCH 0/3] Support for x86 segments as address classes Pedro Alves
2015-11-05 14:15   ` Richard Henderson
2015-11-18 18:18     ` Ulrich Weigand
2015-11-05 14:18 ` [PATCH 4/3] Segment support for x86_64, part 2 Richard Henderson
2015-11-27 14:34 ` [PATCH 0/3] Support for x86 segments as address classes Gary Benson
2016-04-19 14:23 ` Tedeschi, Walfred
2016-04-19 14:44   ` Richard Henderson
2016-04-19 14:47     ` Walfred Tedeschi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox