Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Aug 2017 20:16:33 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r447377 - in head/devel/gdb: . files
Message-ID:  <201708042016.v74KGXhd014172@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb (src,doc committer)
Date: Fri Aug  4 20:16:33 2017
New Revision: 447377
URL: https://svnweb.freebsd.org/changeset/ports/447377

Log:
  Backport support for fs_base/gs_base and $_siginfo from GDB master.
  
  Bring in two patchsets committed to GDB master along with a few other commits
  those patchsets depend on.
  - Add support for examining $_siginfo.  When a thread has valid signal
    information, report the current information in a $_siginfo variable.
    For live processes the values are extracted via the PT_LWPINFO ptrace
    request.  The values are also extracted from process core dumps that
    include NT_LWPINFO notes (currently only present in FreeBSD 12-current).
  - Add support for the $fs_base and $gs_base registers on amd64.  This only
    works for live processes via the PT_{GET,SET}{FS,GS}BASE ptrace requests.
    FreeBSD currently does not store these values in core dumps, so they are
    not available from core dumps.
  
  Reviewed by:	luca.pizzamiglio@gmail.com (maintainer)
  Approved by:	az, imp
  Differential Revision:	https://reviews.freebsd.org/D11813

Added:
  head/devel/gdb/files/commit-0aa37b654c   (contents, props changed)
  head/devel/gdb/files/commit-0b9305edf1   (contents, props changed)
  head/devel/gdb/files/commit-2af9fc4432   (contents, props changed)
  head/devel/gdb/files/commit-382b69bbb7   (contents, props changed)
  head/devel/gdb/files/commit-3c3ae77e68   (contents, props changed)
  head/devel/gdb/files/commit-45eba0ab7d   (contents, props changed)
  head/devel/gdb/files/commit-48aeef91c2   (contents, props changed)
  head/devel/gdb/files/commit-4b654465bf   (contents, props changed)
  head/devel/gdb/files/commit-6e5eab33ab   (contents, props changed)
  head/devel/gdb/files/commit-762c974a09   (contents, props changed)
  head/devel/gdb/files/commit-929edea98d   (contents, props changed)
  head/devel/gdb/files/commit-b30ff123fb   (contents, props changed)
  head/devel/gdb/files/commit-e6f3b9c319   (contents, props changed)
  head/devel/gdb/files/patch-gdb-corelow.c   (contents, props changed)
Modified:
  head/devel/gdb/Makefile

Modified: head/devel/gdb/Makefile
==============================================================================
--- head/devel/gdb/Makefile	Fri Aug  4 20:14:00 2017	(r447376)
+++ head/devel/gdb/Makefile	Fri Aug  4 20:16:33 2017	(r447377)
@@ -3,6 +3,7 @@
 
 PORTNAME=	gdb
 PORTVERSION=	8.0
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	GNU
 
@@ -34,7 +35,20 @@ CFLAGS:=	${CFLAGS:C/ +$//}	# blanks at EOL creep in so
 CFLAGS+=	-DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable
 EXCLUDE=	dejagnu expect sim texinfo intl
 EXTRACT_AFTER_ARGS=	${EXCLUDE:S/^/--exclude /}
-EXTRA_PATCHES=	${FILESDIR}/commit-b5430a3ced
+EXTRA_PATCHES=	${FILESDIR}/commit-45eba0ab7d \
+		${FILESDIR}/commit-3c3ae77e68 \
+		${FILESDIR}/commit-b5430a3ced \
+		${FILESDIR}/commit-762c974a09 \
+		${FILESDIR}/commit-929edea98d \
+		${FILESDIR}/commit-6e5eab33ab \
+		${FILESDIR}/commit-382b69bbb7 \
+		${FILESDIR}/commit-2af9fc4432 \
+		${FILESDIR}/commit-0b9305edf1 \
+		${FILESDIR}/commit-e6f3b9c319 \
+		${FILESDIR}/commit-4b654465bf \
+		${FILESDIR}/commit-b30ff123fb \
+		${FILESDIR}/commit-48aeef91c2 \
+		${FILESDIR}/commit-0aa37b654c
 LIB_DEPENDS+=	libexpat.so:textproc/expat2
 
 VER=		${PORTVERSION:S/.//g}

Added: head/devel/gdb/files/commit-0aa37b654c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-0aa37b654c	Fri Aug  4 20:16:33 2017	(r447377)
@@ -0,0 +1,90 @@
+commit 0aa37b654c0f31e446ab47826f0bcbec15d0112f
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Mon Jun 26 18:18:19 2017 -0700
+
+    Support the fs_base and gs_base registers on FreeBSD/amd64 native processes.
+    
+    Use ptrace operations to fetch and store the fs_base and gs_base registers
+    for FreeBSD/amd64 processes.  Note that FreeBSD does not currently store the
+    value of these registers in core dumps, so these registers are only
+    available when inspecting a running process.
+    
+    gdb/ChangeLog:
+    
+            * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Use
+            PT_GETFSBASE and PT_GETGSBASE.
+            (amd64bsd_store_inferior_registers): Use PT_SETFSBASE and
+            PT_SETGSBASE.
+
+diff --git gdb/amd64-bsd-nat.c gdb/amd64-bsd-nat.c
+index ca61a3551b..41dee84269 100644
+--- gdb/amd64-bsd-nat.c
++++ gdb/amd64-bsd-nat.c
+@@ -57,6 +57,33 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
+ 	return;
+     }
+ 
++#ifdef PT_GETFSBASE
++  if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM)
++    {
++      register_t base;
++
++      if (ptrace (PT_GETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1)
++	perror_with_name (_("Couldn't get segment register fs_base"));
++
++      regcache_raw_supply (regcache, AMD64_FSBASE_REGNUM, &base);
++      if (regnum != -1)
++	return;
++    }
++#endif
++#ifdef PT_GETGSBASE
++  if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM)
++    {
++      register_t base;
++
++      if (ptrace (PT_GETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1)
++	perror_with_name (_("Couldn't get segment register gs_base"));
++
++      regcache_raw_supply (regcache, AMD64_GSBASE_REGNUM, &base);
++      if (regnum != -1)
++	return;
++    }
++#endif
++
+   if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
+     {
+       struct fpreg fpregs;
+@@ -108,6 +135,33 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
+ 	return;
+     }
+ 
++#ifdef PT_SETFSBASE
++  if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM)
++    {
++      register_t base;
++
++      regcache_raw_collect (regcache, AMD64_FSBASE_REGNUM, &base);
++
++      if (ptrace (PT_SETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1)
++	perror_with_name (_("Couldn't write segment register fs_base"));
++      if (regnum != -1)
++	return;
++    }
++#endif
++#ifdef PT_SETGSBASE
++  if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM)
++    {
++      register_t base;
++
++      regcache_raw_collect (regcache, AMD64_GSBASE_REGNUM, &base);
++
++      if (ptrace (PT_SETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1)
++	perror_with_name (_("Couldn't write segment register gs_base"));
++      if (regnum != -1)
++	return;
++    }
++#endif
++
+   if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
+     {
+       struct fpreg fpregs;

Added: head/devel/gdb/files/commit-0b9305edf1
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-0b9305edf1	Fri Aug  4 20:16:33 2017	(r447377)
@@ -0,0 +1,30 @@
+commit 0b9305edf1d0b15913643b132dad02d4ca4fbb43
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Wed Jun 28 11:41:41 2017 -0700
+
+    Recognize the recently-added FreeBSD core dump note for LWP info.
+    
+    This core dump note contains the same information returned by the
+    ptrace PT_LWPINFO operation for each LWP belonging to a process.
+    
+    binutils/ChangeLog:
+    
+            * readelf.c (get_freebsd_elfcore_note_type): Handle
+            NT_FREEBSD_PTLWPINFO.
+    
+    include/ChangeLog:
+    
+            * elf/common.h (NT_FREEBSD_PTLWPINFO): Define.
+
+diff --git include/elf/common.h include/elf/common.h
+index 2976c06067..3a144f03bc 100644
+--- include/elf/common.h
++++ include/elf/common.h
+@@ -641,6 +641,7 @@
+ #define	NT_FREEBSD_PROCSTAT_OSREL	14	/* Procstat osreldate data. */
+ #define	NT_FREEBSD_PROCSTAT_PSSTRINGS	15	/* Procstat ps_strings data. */
+ #define	NT_FREEBSD_PROCSTAT_AUXV	16	/* Procstat auxv data. */
++#define	NT_FREEBSD_PTLWPINFO	17	/* Thread ptrace miscellaneous info. */
+ 
+ /* Note segments for core files on NetBSD systems.  Note name
+    must start with "NetBSD-CORE".  */

Added: head/devel/gdb/files/commit-2af9fc4432
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-2af9fc4432	Fri Aug  4 20:16:33 2017	(r447377)
@@ -0,0 +1,35 @@
+commit 2af9fc4432bbda5ebd805bf5b56d81cd80d0cbf5
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Wed Jun 28 11:21:10 2017 -0700
+
+    Use the thread_section_name helper class in fbsd_core_thread_name.
+    
+    gdb/ChangeLog:
+    
+            * fbsd-tdep.c (fbsd_core_thread_name): Use thread_section_name.
+
+diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
+index 24a3c20dd6..32df104208 100644
+--- gdb/fbsd-tdep.c
++++ gdb/fbsd-tdep.c
+@@ -75,7 +75,6 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
+   static char buf[80];
+   struct bfd_section *section;
+   bfd_size_type size;
+-  char sectionstr[32];
+ 
+   if (ptid_get_lwp (thr->ptid) != 0)
+     {
+@@ -86,9 +85,9 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
+ 	 structure.  Rather than define the full structure here, just
+ 	 extract the null-terminated name from the start of the
+ 	 note.  */
+-      xsnprintf (sectionstr, sizeof sectionstr, ".thrmisc/%ld",
+-		ptid_get_lwp (thr->ptid));
+-      section = bfd_get_section_by_name (core_bfd, sectionstr);
++      thread_section_name section_name (".thrmisc", thr->ptid);
++
++      section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
+       if (section != NULL && bfd_section_size (core_bfd, section) > 0)
+ 	{
+ 	  /* Truncate the name if it is longer than "buf".  */

Added: head/devel/gdb/files/commit-382b69bbb7
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-382b69bbb7	Fri Aug  4 20:16:33 2017	(r447377)
@@ -0,0 +1,220 @@
+commit 382b69bbb7a4fec5213d2382fe70a68d7a46b3e7
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Wed Jun 28 11:11:20 2017 -0700
+
+    Add a new gdbarch method to fetch signal information from core files.
+    
+    Previously the core_xfer_partial method used core_get_siginfo to handle
+    TARGET_OBJECT_SIGNAL_INFO requests.  However, core_get_siginfo looked for
+    Linux-specific sections in the core file.  To support fetching siginfo
+    from cores on other systems, add a new gdbarch method (`core_xfer_siginfo`)
+    and move the body of the existing core_get_siginfo into a
+    linux_core_xfer_siginfo implementation of this method in linux-tdep.c.
+    
+    gdb/ChangeLog:
+    
+            * corelow.c (get_core_siginfo): Remove.
+            (core_xfer_partial): Use the gdbarch "core_xfer_siginfo" method
+            instead of get_core_siginfo.
+            * gdbarch.sh (core_xfer_siginfo): New gdbarch callback.
+            * gdbarch.h: Re-generate.
+            * gdbarch.c: Re-generate.
+            * linux-tdep.c (linux_core_xfer_siginfo): New.
+            (linux_init_abi): Install gdbarch "core_xfer_siginfo" method.
+
+diff --git gdb/corelow.c gdb/corelow.c
+index 578c910bb5..5dbabc79e6 100644
+--- gdb/corelow.c
++++ gdb/corelow.c
+@@ -668,25 +668,6 @@ add_to_spuid_list (bfd *abfd, asection *asect, void *list_p)
+   list->pos += 4;
+ }
+ 
+-/* Read siginfo data from the core, if possible.  Returns -1 on
+-   failure.  Otherwise, returns the number of bytes read.  ABFD is the
+-   core file's BFD; READBUF, OFFSET, and LEN are all as specified by
+-   the to_xfer_partial interface.  */
+-
+-static LONGEST
+-get_core_siginfo (bfd *abfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
+-{
+-  thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid);
+-  asection *section = bfd_get_section_by_name (abfd, section_name.c_str ());
+-  if (section == NULL)
+-    return -1;
+-
+-  if (!bfd_get_section_contents (abfd, section, readbuf, offset, len))
+-    return -1;
+-
+-  return len;
+-}
+-
+ static enum target_xfer_status
+ core_xfer_partial (struct target_ops *ops, enum target_object object,
+ 		   const char *annex, gdb_byte *readbuf,
+@@ -874,12 +855,20 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
+     case TARGET_OBJECT_SIGNAL_INFO:
+       if (readbuf)
+ 	{
+-	  LONGEST l = get_core_siginfo (core_bfd, readbuf, offset, len);
+-
+-	  if (l > 0)
++	  if (core_gdbarch
++	      && gdbarch_core_xfer_siginfo_p (core_gdbarch))
+ 	    {
+-	      *xfered_len = len;
+-	      return TARGET_XFER_OK;
++	      LONGEST l = gdbarch_core_xfer_siginfo  (core_gdbarch, readbuf,
++						      offset, len);
++
++	      if (l >= 0)
++		{
++		  *xfered_len = l;
++		  if (l == 0)
++		    return TARGET_XFER_EOF;
++		  else
++		    return TARGET_XFER_OK;
++		}
+ 	    }
+ 	}
+       return TARGET_XFER_E_IO;
+diff --git gdb/gdbarch.c gdb/gdbarch.c
+index e5efdfbb26..24521b5e23 100644
+--- gdb/gdbarch.c
++++ gdb/gdbarch.c
+@@ -287,6 +287,7 @@ struct gdbarch
+   gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix;
+   gdbarch_core_pid_to_str_ftype *core_pid_to_str;
+   gdbarch_core_thread_name_ftype *core_thread_name;
++  gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo;
+   const char * gcore_bfd_target;
+   int vtable_function_descriptors;
+   int vbit_in_delta;
+@@ -646,6 +647,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
+   /* Skip verify of core_xfer_shared_libraries_aix, has predicate.  */
+   /* Skip verify of core_pid_to_str, has predicate.  */
+   /* Skip verify of core_thread_name, has predicate.  */
++  /* Skip verify of core_xfer_siginfo, has predicate.  */
+   /* Skip verify of gcore_bfd_target, has predicate.  */
+   /* Skip verify of vtable_function_descriptors, invalid_p == 0 */
+   /* Skip verify of vbit_in_delta, invalid_p == 0 */
+@@ -884,6 +886,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
+                       "gdbarch_dump: core_xfer_shared_libraries_aix = <%s>\n",
+                       host_address_to_string (gdbarch->core_xfer_shared_libraries_aix));
+   fprintf_unfiltered (file,
++                      "gdbarch_dump: gdbarch_core_xfer_siginfo_p() = %d\n",
++                      gdbarch_core_xfer_siginfo_p (gdbarch));
++  fprintf_unfiltered (file,
++                      "gdbarch_dump: core_xfer_siginfo = <%s>\n",
++                      host_address_to_string (gdbarch->core_xfer_siginfo));
++  fprintf_unfiltered (file,
+                       "gdbarch_dump: decr_pc_after_break = %s\n",
+                       core_addr_to_string_nz (gdbarch->decr_pc_after_break));
+   fprintf_unfiltered (file,
+@@ -3797,6 +3805,30 @@ set_gdbarch_core_thread_name (struct gdbarch *gdbarch,
+ }
+ 
+ int
++gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch)
++{
++  gdb_assert (gdbarch != NULL);
++  return gdbarch->core_xfer_siginfo != NULL;
++}
++
++LONGEST
++gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
++{
++  gdb_assert (gdbarch != NULL);
++  gdb_assert (gdbarch->core_xfer_siginfo != NULL);
++  if (gdbarch_debug >= 2)
++    fprintf_unfiltered (gdb_stdlog, "gdbarch_core_xfer_siginfo called\n");
++  return gdbarch->core_xfer_siginfo (gdbarch,  readbuf, offset, len);
++}
++
++void
++set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch,
++                               gdbarch_core_xfer_siginfo_ftype core_xfer_siginfo)
++{
++  gdbarch->core_xfer_siginfo = core_xfer_siginfo;
++}
++
++int
+ gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch)
+ {
+   gdb_assert (gdbarch != NULL);
+diff --git gdb/gdbarch.h gdb/gdbarch.h
+index ab7561f851..1c95301f6f 100644
+--- gdb/gdbarch.h
++++ gdb/gdbarch.h
+@@ -933,6 +933,16 @@ typedef const char * (gdbarch_core_thread_name_ftype) (struct gdbarch *gdbarch,
+ extern const char * gdbarch_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr);
+ extern void set_gdbarch_core_thread_name (struct gdbarch *gdbarch, gdbarch_core_thread_name_ftype *core_thread_name);
+ 
++/* Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
++   from core file into buffer READBUF with length LEN.  Return the number
++   of bytes read (zero indicates EOF, a negative value indicates failure). */
++
++extern int gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch);
++
++typedef LONGEST (gdbarch_core_xfer_siginfo_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
++extern LONGEST gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
++extern void set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo);
++
+ /* BFD target to use when generating a core file. */
+ 
+ extern int gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch);
+diff --git gdb/gdbarch.sh gdb/gdbarch.sh
+index 22f5715037..3aab17f958 100755
+--- gdb/gdbarch.sh
++++ gdb/gdbarch.sh
+@@ -755,6 +755,11 @@ M;const char *;core_pid_to_str;ptid_t ptid;ptid
+ # How the core target extracts the name of a thread from a core file.
+ M;const char *;core_thread_name;struct thread_info *thr;thr
+ 
++# Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
++# from core file into buffer READBUF with length LEN.  Return the number
++# of bytes read (zero indicates EOF, a negative value indicates failure).
++M;LONGEST;core_xfer_siginfo;gdb_byte *readbuf, ULONGEST offset, ULONGEST len; readbuf, offset, len
++
+ # BFD target to use when generating a core file.
+ V;const char *;gcore_bfd_target;;;0;0;;;pstring (gdbarch->gcore_bfd_target)
+ 
+diff --git gdb/linux-tdep.c gdb/linux-tdep.c
+index 2792cbd4c8..5c7f8a0758 100644
+--- gdb/linux-tdep.c
++++ gdb/linux-tdep.c
+@@ -1127,6 +1127,26 @@ linux_core_info_proc (struct gdbarch *gdbarch, const char *args,
+     error (_("unable to handle request"));
+ }
+ 
++/* Read siginfo data from the core, if possible.  Returns -1 on
++   failure.  Otherwise, returns the number of bytes read.  READBUF,
++   OFFSET, and LEN are all as specified by the to_xfer_partial
++   interface.  */
++
++static LONGEST
++linux_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
++			 ULONGEST offset, ULONGEST len)
++{
++  thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid);
++  asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
++  if (section == NULL)
++    return -1;
++
++  if (!bfd_get_section_contents (core_bfd, section, readbuf, offset, len))
++    return -1;
++
++  return len;
++}
++
+ typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size,
+ 					    ULONGEST offset, ULONGEST inode,
+ 					    int read, int write,
+@@ -2516,6 +2536,7 @@ linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+   set_gdbarch_core_pid_to_str (gdbarch, linux_core_pid_to_str);
+   set_gdbarch_info_proc (gdbarch, linux_info_proc);
+   set_gdbarch_core_info_proc (gdbarch, linux_core_info_proc);
++  set_gdbarch_core_xfer_siginfo (gdbarch, linux_core_xfer_siginfo);
+   set_gdbarch_find_memory_regions (gdbarch, linux_find_memory_regions);
+   set_gdbarch_make_corefile_notes (gdbarch, linux_make_corefile_notes);
+   set_gdbarch_has_shared_address_space (gdbarch,

Added: head/devel/gdb/files/commit-3c3ae77e68
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-3c3ae77e68	Fri Aug  4 20:16:33 2017	(r447377)
@@ -0,0 +1,156 @@
+commit 3c3ae77e68a9032ef9f174bf6b1cc992b6a4cb35
+Author: Pedro Alves <palves@redhat.com>
+Date:   Thu May 4 15:14:37 2017 +0100
+
+    Fix get_core_register_section leak, introduce thread_section_name
+    
+    This plugs a leak introduced in the previous change to
+    get_core_register_section, which removed an xfree call that is
+    actually necessary because the 'section_name' local is static.
+    
+    From [1] it looks like the reason the variable was made static to
+    begin with, was just "laziness" to avoid having to think about freeing
+    it on every function return path:
+    
+     https://sourceware.org/ml/gdb-patches/2005-03/msg00237.html
+    
+    The easiest to fix that nowadays is to use a std::string.
+    
+    I don't see a need to xstrdup the section name in the single-threaded
+    case though, and also there's more than one place that computes a
+    multi-threaded section name in the same way.  So put the section name
+    computation in a wrapper class with state.
+    
+    gdb/ChangeLog:
+    2017-05-04  Pedro Alves  <palves@redhat.com>
+    
+            * corelow.c (thread_section_name): New class.
+            (get_core_register_section, get_core_siginfo): Use it.
+
+diff --git gdb/corelow.c gdb/corelow.c
+index 2266f2467a..0aff02d4db 100644
+--- gdb/corelow.c
++++ gdb/corelow.c
+@@ -485,6 +485,51 @@ core_detach (struct target_ops *ops, const char *args, int from_tty)
+     printf_filtered (_("No core file now.\n"));
+ }
+ 
++/* Build either a single-thread or multi-threaded section name for
++   PTID.
++
++   If ptid's lwp member is zero, we want to do the single-threaded
++   thing: look for a section named NAME (as passed to the
++   constructor).  If ptid's lwp member is non-zero, we'll want do the
++   multi-threaded thing: look for a section named "NAME/LWP", where
++   LWP is the shortest ASCII decimal representation of ptid's lwp
++   member.  */
++
++class thread_section_name
++{
++public:
++  /* NAME is the single-threaded section name.  If PTID represents an
++     LWP, then the build section name is "NAME/LWP", otherwise it's
++     just "NAME" unmodified.  */
++  thread_section_name (const char *name, ptid_t ptid)
++  {
++    if (ptid.lwp_p ())
++      {
++	m_storage = string_printf ("%s/%ld", name, ptid.lwp ());
++	m_section_name = m_storage.c_str ();
++      }
++    else
++      m_section_name = name;
++  }
++
++  /* Return the computed section name.  The result is valid as long as
++     this thread_section_name object is live.  */
++  const char *c_str () const
++  { return m_section_name; }
++
++  /* Disable copy.  */
++  thread_section_name (const thread_section_name &) = delete;
++  void operator= (const thread_section_name &) = delete;
++
++private:
++  /* Either a pointer into M_STORAGE, or a pointer to the name passed
++     as parameter to the constructor.  */
++  const char *m_section_name;
++  /* If we need to build a new section name, this is where we store
++     it.  */
++  std::string m_storage;
++};
++
+ /* Try to retrieve registers from a section in core_bfd, and supply
+    them to core_vec->core_read_registers, as the register set numbered
+    WHICH.
+@@ -511,21 +556,15 @@ get_core_register_section (struct regcache *regcache,
+ 			   const char *human_name,
+ 			   int required)
+ {
+-  static char *section_name;
+   struct bfd_section *section;
+   bfd_size_type size;
+   char *contents;
+   bool variable_size_section = (regset != NULL
+ 				&& regset->flags & REGSET_VARIABLE_SIZE);
+-  ptid_t ptid = regcache_get_ptid (regcache);
+ 
+-  if (ptid_get_lwp (ptid))
+-    section_name = xstrprintf ("%s/%ld", name,
+-			       ptid_get_lwp (ptid));
+-  else
+-    section_name = xstrdup (name);
++  thread_section_name section_name (name, regcache->ptid ());
+ 
+-  section = bfd_get_section_by_name (core_bfd, section_name);
++  section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
+   if (! section)
+     {
+       if (required)
+@@ -537,13 +576,14 @@ get_core_register_section (struct regcache *regcache,
+   size = bfd_section_size (core_bfd, section);
+   if (size < min_size)
+     {
+-      warning (_("Section `%s' in core file too small."), section_name);
++      warning (_("Section `%s' in core file too small."),
++	       section_name.c_str ());
+       return;
+     }
+   if (size != min_size && !variable_size_section)
+     {
+       warning (_("Unexpected size of section `%s' in core file."),
+-	       section_name);
++	       section_name.c_str ());
+     }
+ 
+   contents = (char *) alloca (size);
+@@ -551,7 +591,7 @@ get_core_register_section (struct regcache *regcache,
+ 				  (file_ptr) 0, size))
+     {
+       warning (_("Couldn't read %s registers from `%s' section in core file."),
+-	       human_name, name);
++	       human_name, section_name.c_str ());
+       return;
+     }
+ 
+@@ -681,18 +721,8 @@ add_to_spuid_list (bfd *abfd, asection *asect, void *list_p)
+ static LONGEST
+ get_core_siginfo (bfd *abfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
+ {
+-  asection *section;
+-  char *section_name;
+-  const char *name = ".note.linuxcore.siginfo";
+-
+-  if (ptid_get_lwp (inferior_ptid))
+-    section_name = xstrprintf ("%s/%ld", name,
+-			       ptid_get_lwp (inferior_ptid));
+-  else
+-    section_name = xstrdup (name);
+-
+-  section = bfd_get_section_by_name (abfd, section_name);
+-  xfree (section_name);
++  thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid);
++  asection *section = bfd_get_section_by_name (abfd, section_name.c_str ());
+   if (section == NULL)
+     return -1;
+ 

Added: head/devel/gdb/files/commit-45eba0ab7d
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-45eba0ab7d	Fri Aug  4 20:16:33 2017	(r447377)
@@ -0,0 +1,45 @@
+commit 45eba0ab7d26435121facb68847fbd0cd4a313c1
+Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
+Date:   Thu May 4 11:06:10 2017 +0200
+
+    Remove some superfluous code in corelow.c
+    
+    In corelow.c I stumbled upon an extra semicolon and an xfree of a NULL
+    pointer.  Remove them.
+    
+    gdb/ChangeLog:
+    
+            * corelow.c (sniff_core_bfd): Remove extra semicolon.
+            (get_core_register_section): Remove xfree of NULL pointer.
+
+diff --git gdb/corelow.c gdb/corelow.c
+index 3267c37843..2266f2467a 100644
+--- gdb/corelow.c
++++ gdb/corelow.c
+@@ -129,7 +129,7 @@ sniff_core_bfd (bfd *abfd)
+ {
+   struct core_fns *cf;
+   struct core_fns *yummy = NULL;
+-  int matches = 0;;
++  int matches = 0;
+ 
+   /* Don't sniff if we have support for register sets in
+      CORE_GDBARCH.  */
+@@ -511,7 +511,7 @@ get_core_register_section (struct regcache *regcache,
+ 			   const char *human_name,
+ 			   int required)
+ {
+-  static char *section_name = NULL;
++  static char *section_name;
+   struct bfd_section *section;
+   bfd_size_type size;
+   char *contents;
+@@ -519,8 +519,6 @@ get_core_register_section (struct regcache *regcache,
+ 				&& regset->flags & REGSET_VARIABLE_SIZE);
+   ptid_t ptid = regcache_get_ptid (regcache);
+ 
+-  xfree (section_name);
+-
+   if (ptid_get_lwp (ptid))
+     section_name = xstrprintf ("%s/%ld", name,
+ 			       ptid_get_lwp (ptid));

Added: head/devel/gdb/files/commit-48aeef91c2
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gdb/files/commit-48aeef91c2	Fri Aug  4 20:16:33 2017	(r447377)
@@ -0,0 +1,805 @@
+commit 48aeef91c248291dd03583798904612426b1f40a
+Author: John Baldwin <jhb@FreeBSD.org>
+Date:   Mon Jun 26 18:14:43 2017 -0700
+
+    Include the fs_base and gs_base registers in amd64 target descriptions.
+    
+    This permits these registers to be used with non-Linux targets.
+    
+    gdb/ChangeLog:
+    
+            * features/Makefile (amd64.dat, amd64-avx.dat, amd64-mpx.dat)
+            (amd64-avx-mpx.dat, amd64-avx-avx512.dat)
+            (amd64-avx-mpx-avx512-pku.dat): Add i386/64bit-segments.xml in
+            those rules.
+            * features/i386/amd64-avx-avx512.xml: Add 64bit-segments.xml.
+            * features/i386/amd64-avx-mpx-avx512-pku.xml: Add 64bit-segments.xml.
+            * features/i386/amd64-avx-mpx.xml: Add 64bit-segments.xml.
+            * features/i386/amd64-avx.xml: Add 64bit-segments.xml.
+            * features/i386/amd64-mpx.xml: Add 64bit-segments.xml.
+            * features/i386/amd64.xml: Add 64bit-segments.xml.
+            * features/i386/amd64-avx-avx512.c: Regenerated.
+            * features/i386/amd64-avx-mpx-avx512-pku.c: Regenerated.
+            * features/i386/amd64-avx-mpx.c: Regenerated.
+            * features/i386/amd64-avx.c: Regenerated.
+            * features/i386/amd64-mpx.c: Regenerated.
+            * features/i386/amd64.c: Regenerated.
+            * regformats/i386/amd64-avx-avx512.dat: Regenerated.
+            * regformats/i386/amd64-avx-mpx-avx512-pku.dat: Regenerated.
+            * regformats/i386/amd64-avx-mpx.dat: Regenerated.
+            * regformats/i386/amd64-avx.dat: Regenerated.
+            * regformats/i386/amd64-mpx.dat: Regenerated.
+            * regformats/i386/amd64.dat: Regenerated.
+
+diff --git gdb/features/Makefile gdb/features/Makefile
+index 3bc8b5ae85..75741acbe1 100644
+--- gdb/features/Makefile
++++ gdb/features/Makefile
+@@ -263,7 +263,8 @@ $(outdir)/arm/arm-with-iwmmxt.dat: arm/arm-core.xml arm/xscale-iwmmxt.xml
+ $(outdir)/i386/i386.dat: i386/32bit-core.xml i386/32bit-sse.xml
+ $(outdir)/i386/i386-linux.dat: i386/32bit-core.xml i386/32bit-sse.xml \
+ 			       i386/32bit-linux.xml
+-$(outdir)/i386/amd64.dat: i386/64bit-core.xml i386/64bit-sse.xml
++$(outdir)/i386/amd64.dat: i386/64bit-core.xml i386/64bit-sse.xml \
++			       i386/64bit-segments.xml
+ $(outdir)/i386/amd64-linux.dat: i386/64bit-core.xml i386/64bit-sse.xml \
+ 			       i386/64bit-linux.xml i386/64bit-segments.xml
+ $(outdir)/i386/i386-avx.dat: i386/32bit-core.xml i386/32bit-avx.xml
+@@ -289,7 +290,8 @@ $(outdir)/i386/i386-avx-mpx-avx512-pku-linux.dat: i386/32bit-core.xml \
+ 			       i386/32bit-pkeys.xml i386/32bit-linux.xml
+ $(outdir)/i386/i386-mmx.dat: i386/32bit-core.xml 
+ $(outdir)/i386/i386-mmx-linux.dat: i386/32bit-core.xml i386/32bit-linux.xml
+-$(outdir)/i386/amd64-avx.dat: i386/64bit-core.xml i386/64bit-avx.xml
++$(outdir)/i386/amd64-avx.dat: i386/64bit-core.xml i386/64bit-avx.xml \
++			       i386/64bit-segments.xml
+ $(outdir)/i386/amd64-avx-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \
+ 			       i386/64bit-linux.xml i386/64bit-segments.xml
+ $(outdir)/i386/amd64-mpx-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \
+@@ -297,16 +299,16 @@ $(outdir)/i386/amd64-mpx-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \
+ $(outdir)/i386/amd64-avx-mpx-linux.dat: i386/64bit-core.xml \
+ 			       i386/64bit-linux.xml i386/64bit-segments.xml i386/64bit-mpx.xml
+ $(outdir)/i386/amd64-mpx.dat: i386/64bit-core.xml i386/64bit-avx.xml \
+-			       i386/64bit-mpx.xml
++			       i386/64bit-segments.xml i386/64bit-mpx.xml
+ $(outdir)/i386/amd64-avx-mpx.dat: i386/64bit-core.xml \
+-			       i386/64bit-mpx.xml
++			       i386/64bit-segments.xml i386/64bit-mpx.xml
+ $(outdir)/i386/amd64-avx-avx512.dat: i386/64bit-core.xml i386/64bit-avx.xml \
+-			       i386/64bit-avx512.xml
++			       i386/64bit-avx512.xml i386/64bit-segments.xml
+ $(outdir)/i386/amd64-avx-avx512-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \
+ 			       i386/64bit-avx512.xml i386/64bit-linux.xml
+ $(outdir)/i386/amd64-avx-mpx-avx512-pku.dat: i386/64bit-core.xml \
+ 			       i386/64bit-avx.xml i386/64bit-mpx.xml i386/64bit-avx512.xml \
+-			       i386/64bit-pkeys.xml
++			       i386/64bit-pkeys.xml i386/64bit-segments.xml
+ $(outdir)/i386/amd64-avx-mpx-avx512-pku-linux.dat: i386/64bit-core.xml \
+ 			       i386/64bit-avx.xml i386/64bit-mpx.xml i386/64bit-avx512.xml \
+ 			       i386/64bit-linux.xml i386/64bit-segments.xml \
+diff --git gdb/features/i386/amd64-avx-avx512.c gdb/features/i386/amd64-avx-avx512.c
+index 8a185c108d..f1ebde1071 100644
+--- gdb/features/i386/amd64-avx-avx512.c
++++ gdb/features/i386/amd64-avx-avx512.c
+@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx_avx512 (void)
+   tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128");
+   tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr");
+ 
++  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments");
++  tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int");
++  tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int");
++
+   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
+-  tdesc_create_reg (feature, "ymm0h", 57, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm1h", 58, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm2h", 59, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm3h", 60, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm4h", 61, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm5h", 62, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm6h", 63, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm7h", 64, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm8h", 65, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm9h", 66, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm10h", 67, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm11h", 68, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm12h", 69, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm13h", 70, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm14h", 71, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm15h", 72, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm0h", 59, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm1h", 60, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm2h", 61, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm3h", 62, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm4h", 63, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm5h", 64, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm6h", 65, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm7h", 66, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm8h", 67, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm9h", 68, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm10h", 69, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm11h", 70, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm12h", 71, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm13h", 72, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm14h", 73, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm15h", 74, 1, NULL, 128, "uint128");
+ 
+   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
+   field_type = tdesc_named_type (feature, "ieee_single");
+@@ -202,78 +206,78 @@ initialize_tdesc_amd64_avx_avx512 (void)
+   field_type = tdesc_named_type (feature, "uint128");
+   tdesc_create_vector (feature, "v2ui128", field_type, 2);
+ 
+-  tdesc_create_reg (feature, "xmm16", 73, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm17", 74, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm18", 75, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm19", 76, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm20", 77, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm21", 78, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm22", 79, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm23", 80, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm24", 81, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm25", 82, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm26", 83, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm27", 84, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm28", 85, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm29", 86, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm30", 87, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm31", 88, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "ymm16h", 89, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm17h", 90, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm18h", 91, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm19h", 92, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm20h", 93, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm21h", 94, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm22h", 95, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm23h", 96, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm24h", 97, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm25h", 98, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm26h", 99, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm27h", 100, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm28h", 101, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm29h", 102, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm30h", 103, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm31h", 104, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "k0", 105, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "k1", 106, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "k2", 107, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "k3", 108, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "k4", 109, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "k5", 110, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "k6", 111, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "k7", 112, 1, NULL, 64, "uint64");
+-  tdesc_create_reg (feature, "zmm0h", 113, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm1h", 114, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm2h", 115, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm3h", 116, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm4h", 117, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm5h", 118, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm6h", 119, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm7h", 120, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm8h", 121, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm9h", 122, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm10h", 123, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm11h", 124, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm12h", 125, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm13h", 126, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm14h", 127, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm15h", 128, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm16h", 129, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm17h", 130, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm18h", 131, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm19h", 132, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm20h", 133, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm21h", 134, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm22h", 135, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm23h", 136, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm24h", 137, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm25h", 138, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm26h", 139, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm27h", 140, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm28h", 141, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm29h", 142, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm30h", 143, 1, NULL, 256, "v2ui128");
+-  tdesc_create_reg (feature, "zmm31h", 144, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "xmm16", 75, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm17", 76, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm18", 77, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm19", 78, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm20", 79, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm21", 80, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm22", 81, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm23", 82, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm24", 83, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm25", 84, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm26", 85, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm27", 86, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm28", 87, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm29", 88, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm30", 89, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "xmm31", 90, 1, NULL, 128, "vec128");
++  tdesc_create_reg (feature, "ymm16h", 91, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm17h", 92, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm18h", 93, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm19h", 94, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm20h", 95, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm21h", 96, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm22h", 97, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm23h", 98, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm24h", 99, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm25h", 100, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm26h", 101, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm27h", 102, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm28h", 103, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm29h", 104, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm30h", 105, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm31h", 106, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "k0", 107, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "k1", 108, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "k2", 109, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "k3", 110, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "k4", 111, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "k5", 112, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "k6", 113, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "k7", 114, 1, NULL, 64, "uint64");
++  tdesc_create_reg (feature, "zmm0h", 115, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm1h", 116, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm2h", 117, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm3h", 118, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm4h", 119, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm5h", 120, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm6h", 121, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm7h", 122, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm8h", 123, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm9h", 124, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm10h", 125, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm11h", 126, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm12h", 127, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm13h", 128, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm14h", 129, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm15h", 130, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm16h", 131, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm17h", 132, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm18h", 133, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm19h", 134, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm20h", 135, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm21h", 136, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm22h", 137, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm23h", 138, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm24h", 139, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm25h", 140, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm26h", 141, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm27h", 142, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm28h", 143, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm29h", 144, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm30h", 145, 1, NULL, 256, "v2ui128");
++  tdesc_create_reg (feature, "zmm31h", 146, 1, NULL, 256, "v2ui128");
+ 
+   tdesc_amd64_avx_avx512 = result;
+ }
+diff --git gdb/features/i386/amd64-avx-avx512.xml gdb/features/i386/amd64-avx-avx512.xml
+index a4587433c8..fdf8136f74 100644
+--- gdb/features/i386/amd64-avx-avx512.xml
++++ gdb/features/i386/amd64-avx-avx512.xml
+@@ -12,6 +12,7 @@
+   <architecture>i386:x86-64</architecture>
+   <xi:include href="64bit-core.xml"/>
+   <xi:include href="64bit-sse.xml"/>
++  <xi:include href="64bit-segments.xml"/>
+   <xi:include href="64bit-avx.xml"/>
+   <xi:include href="64bit-avx512.xml"/>
+ </target>
+diff --git gdb/features/i386/amd64-avx-mpx-avx512-pku.c gdb/features/i386/amd64-avx-mpx-avx512-pku.c
+index dfe7d7778a..f119e52f5d 100644
+--- gdb/features/i386/amd64-avx-mpx-avx512-pku.c
++++ gdb/features/i386/amd64-avx-mpx-avx512-pku.c
+@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx_mpx_avx512_pku (void)
+   tdesc_create_reg (feature, "xmm15", 55, 1, NULL, 128, "vec128");
+   tdesc_create_reg (feature, "mxcsr", 56, 1, "vector", 32, "i386_mxcsr");
+ 
++  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments");
++  tdesc_create_reg (feature, "fs_base", 57, 1, NULL, 64, "int");
++  tdesc_create_reg (feature, "gs_base", 58, 1, NULL, 64, "int");
++
+   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
+-  tdesc_create_reg (feature, "ymm0h", 57, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm1h", 58, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm2h", 59, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm3h", 60, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm4h", 61, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm5h", 62, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm6h", 63, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm7h", 64, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm8h", 65, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm9h", 66, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm10h", 67, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm11h", 68, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm12h", 69, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm13h", 70, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm14h", 71, 1, NULL, 128, "uint128");
+-  tdesc_create_reg (feature, "ymm15h", 72, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm0h", 59, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm1h", 60, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm2h", 61, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm3h", 62, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm4h", 63, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm5h", 64, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm6h", 65, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm7h", 66, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm8h", 67, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm9h", 68, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm10h", 69, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm11h", 70, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm12h", 71, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm13h", 72, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm14h", 73, 1, NULL, 128, "uint128");
++  tdesc_create_reg (feature, "ymm15h", 74, 1, NULL, 128, "uint128");
+ 
+   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
+   type = tdesc_create_struct (feature, "br128");
+@@ -195,12 +199,12 @@ initialize_tdesc_amd64_avx_mpx_avx512_pku (void)
+   field_type = tdesc_named_type (feature, "_bndcfgu");
+   tdesc_add_field (type, "config", field_type);
+ 
+-  tdesc_create_reg (feature, "bnd0raw", 73, 1, NULL, 128, "br128");
+-  tdesc_create_reg (feature, "bnd1raw", 74, 1, NULL, 128, "br128");
+-  tdesc_create_reg (feature, "bnd2raw", 75, 1, NULL, 128, "br128");
+-  tdesc_create_reg (feature, "bnd3raw", 76, 1, NULL, 128, "br128");
+-  tdesc_create_reg (feature, "bndcfgu", 77, 1, NULL, 64, "cfgu");
+-  tdesc_create_reg (feature, "bndstatus", 78, 1, NULL, 64, "status");
++  tdesc_create_reg (feature, "bnd0raw", 75, 1, NULL, 128, "br128");
++  tdesc_create_reg (feature, "bnd1raw", 76, 1, NULL, 128, "br128");
++  tdesc_create_reg (feature, "bnd2raw", 77, 1, NULL, 128, "br128");
++  tdesc_create_reg (feature, "bnd3raw", 78, 1, NULL, 128, "br128");
++  tdesc_create_reg (feature, "bndcfgu", 79, 1, NULL, 64, "cfgu");
++  tdesc_create_reg (feature, "bndstatus", 80, 1, NULL, 64, "status");
+ 
+   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
+   field_type = tdesc_named_type (feature, "ieee_single");
+@@ -240,81 +244,81 @@ initialize_tdesc_amd64_avx_mpx_avx512_pku (void)
+   field_type = tdesc_named_type (feature, "uint128");
+   tdesc_create_vector (feature, "v2ui128", field_type, 2);
+ 
+-  tdesc_create_reg (feature, "xmm16", 79, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm17", 80, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm18", 81, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm19", 82, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm20", 83, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm21", 84, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm22", 85, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm23", 86, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm24", 87, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm25", 88, 1, NULL, 128, "vec128");
+-  tdesc_create_reg (feature, "xmm26", 89, 1, NULL, 128, "vec128");

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708042016.v74KGXhd014172>