aboutsummaryrefslogtreecommitdiffstats
path: root/devel
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2017-08-05 04:16:33 +0800
committerjhb <jhb@FreeBSD.org>2017-08-05 04:16:33 +0800
commit5be7e1145fc75e057604eb5bf5687bbc523b44c0 (patch)
treeefa578222876378822d63d97ee10987874f1febf /devel
parent0114cc7a4f12eb79264592843481482e90ddb780 (diff)
downloadfreebsd-ports-gnome-5be7e1145fc75e057604eb5bf5687bbc523b44c0.tar.gz
freebsd-ports-gnome-5be7e1145fc75e057604eb5bf5687bbc523b44c0.tar.zst
freebsd-ports-gnome-5be7e1145fc75e057604eb5bf5687bbc523b44c0.zip
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
Diffstat (limited to 'devel')
-rw-r--r--devel/gdb/Makefile16
-rw-r--r--devel/gdb/files/commit-0aa37b654c90
-rw-r--r--devel/gdb/files/commit-0b9305edf130
-rw-r--r--devel/gdb/files/commit-2af9fc443235
-rw-r--r--devel/gdb/files/commit-382b69bbb7220
-rw-r--r--devel/gdb/files/commit-3c3ae77e68156
-rw-r--r--devel/gdb/files/commit-45eba0ab7d45
-rw-r--r--devel/gdb/files/commit-48aeef91c2805
-rw-r--r--devel/gdb/files/commit-4b654465bf118
-rw-r--r--devel/gdb/files/commit-6e5eab33ab120
-rw-r--r--devel/gdb/files/commit-762c974a09167
-rw-r--r--devel/gdb/files/commit-929edea98d211
-rw-r--r--devel/gdb/files/commit-b30ff123fb40
-rw-r--r--devel/gdb/files/commit-e6f3b9c31925
-rw-r--r--devel/gdb/files/patch-gdb-corelow.c11
15 files changed, 2088 insertions, 1 deletions
diff --git a/devel/gdb/Makefile b/devel/gdb/Makefile
index 30fc905583d1..cc8be132a4e1 100644
--- a/devel/gdb/Makefile
+++ b/devel/gdb/Makefile
@@ -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 sometimes
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}
diff --git a/devel/gdb/files/commit-0aa37b654c b/devel/gdb/files/commit-0aa37b654c
new file mode 100644
index 000000000000..ee6db77f7d1c
--- /dev/null
+++ b/devel/gdb/files/commit-0aa37b654c
@@ -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;
diff --git a/devel/gdb/files/commit-0b9305edf1 b/devel/gdb/files/commit-0b9305edf1
new file mode 100644
index 000000000000..b64636180b8b
--- /dev/null
+++ b/devel/gdb/files/commit-0b9305edf1
@@ -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". */
diff --git a/devel/gdb/files/commit-2af9fc4432 b/devel/gdb/files/commit-2af9fc4432
new file mode 100644
index 000000000000..9e48d8577dbd
--- /dev/null
+++ b/devel/gdb/files/commit-2af9fc4432
@@ -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". */
diff --git a/devel/gdb/files/commit-382b69bbb7 b/devel/gdb/files/commit-382b69bbb7
new file mode 100644
index 000000000000..1b56fada59c7
--- /dev/null
+++ b/devel/gdb/files/commit-382b69bbb7
@@ -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,
diff --git a/devel/gdb/files/commit-3c3ae77e68 b/devel/gdb/files/commit-3c3ae77e68
new file mode 100644
index 000000000000..bd232d7031a6
--- /dev/null
+++ b/devel/gdb/files/commit-3c3ae77e68
@@ -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;
+
diff --git a/devel/gdb/files/commit-45eba0ab7d b/devel/gdb/files/commit-45eba0ab7d
new file mode 100644
index 000000000000..30fdedc176bf
--- /dev/null
+++ b/devel/gdb/files/commit-45eba0ab7d
@@ -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));
diff --git a/devel/gdb/files/commit-48aeef91c2 b/devel/gdb/files/commit-48aeef91c2
new file mode 100644
index 000000000000..2558d9ace3b6
--- /dev/null
+++ b/devel/gdb/files/commit-48aeef91c2
@@ -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");
+- tdesc_create_reg (feature, "xmm27", 90, 1, NULL, 128, "vec128");
+- tdesc_create_reg (feature, "xmm28", 91, 1, NULL, 128, "vec128");
+- tdesc_create_reg (feature, "xmm29", 92, 1, NULL, 128, "vec128");
+- tdesc_create_reg (feature, "xmm30", 93, 1, NULL, 128, "vec128");
+- tdesc_create_reg (feature, "xmm31", 94, 1, NULL, 128, "vec128");
+- tdesc_create_reg (feature, "ymm16h", 95, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm17h", 96, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm18h", 97, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm19h", 98, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm20h", 99, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm21h", 100, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm22h", 101, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm23h", 102, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm24h", 103, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm25h", 104, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm26h", 105, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm27h", 106, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm28h", 107, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm29h", 108, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm30h", 109, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "ymm31h", 110, 1, NULL, 128, "uint128");
+- tdesc_create_reg (feature, "k0", 111, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "k1", 112, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "k2", 113, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "k3", 114, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "k4", 115, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "k5", 116, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "k6", 117, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "k7", 118, 1, NULL, 64, "uint64");
+- tdesc_create_reg (feature, "zmm0h", 119, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm1h", 120, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm2h", 121, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm3h", 122, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm4h", 123, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm5h", 124, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm6h", 125, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm7h", 126, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm8h", 127, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm9h", 128, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm10h", 129, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm11h", 130, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm12h", 131, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm13h", 132, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm14h", 133, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm15h", 134, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm16h", 135, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm17h", 136, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm18h", 137, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm19h", 138, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm20h", 139, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm21h", 140, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm22h", 141, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm23h", 142, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm24h", 143, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm25h", 144, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm26h", 145, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm27h", 146, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm28h", 147, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm29h", 148, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm30h", 149, 1, NULL, 256, "v2ui128");
+- tdesc_create_reg (feature, "zmm31h", 150, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "xmm16", 81, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm17", 82, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm18", 83, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm19", 84, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm20", 85, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm21", 86, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm22", 87, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm23", 88, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm24", 89, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm25", 90, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm26", 91, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm27", 92, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm28", 93, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm29", 94, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm30", 95, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "xmm31", 96, 1, NULL, 128, "vec128");
++ tdesc_create_reg (feature, "ymm16h", 97, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm17h", 98, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm18h", 99, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm19h", 100, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm20h", 101, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm21h", 102, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm22h", 103, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm23h", 104, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm24h", 105, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm25h", 106, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm26h", 107, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm27h", 108, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm28h", 109, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm29h", 110, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm30h", 111, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "ymm31h", 112, 1, NULL, 128, "uint128");
++ tdesc_create_reg (feature, "k0", 113, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "k1", 114, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "k2", 115, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "k3", 116, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "k4", 117, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "k5", 118, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "k6", 119, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "k7", 120, 1, NULL, 64, "uint64");
++ tdesc_create_reg (feature, "zmm0h", 121, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm1h", 122, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm2h", 123, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm3h", 124, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm4h", 125, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm5h", 126, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm6h", 127, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm7h", 128, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm8h", 129, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm9h", 130, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm10h", 131, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm11h", 132, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm12h", 133, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm13h", 134, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm14h", 135, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm15h", 136, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm16h", 137, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm17h", 138, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm18h", 139, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm19h", 140, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm20h", 141, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm21h", 142, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm22h", 143, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm23h", 144, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm24h", 145, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm25h", 146, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm26h", 147, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm27h", 148, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm28h", 149, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm29h", 150, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm30h", 151, 1, NULL, 256, "v2ui128");
++ tdesc_create_reg (feature, "zmm31h", 152, 1, NULL, 256, "v2ui128");
+
+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys");
+- tdesc_create_reg (feature, "pkru", 151, 1, NULL, 32, "uint32");
++ tdesc_create_reg (feature, "pkru", 153, 1, NULL, 32, "uint32");
+
+ tdesc_amd64_avx_mpx_avx512_pku = result;
+ }
+diff --git gdb/features/i386/amd64-avx-mpx-avx512-pku.xml gdb/features/i386/amd64-avx-mpx-avx512-pku.xml
+index e769108873..d8203e3400 100644
+--- gdb/features/i386/amd64-avx-mpx-avx512-pku.xml
++++ gdb/features/i386/amd64-avx-mpx-avx512-pku.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-mpx.xml"/>
+ <xi:include href="64bit-avx512.xml"/>
+diff --git gdb/features/i386/amd64-avx-mpx.c gdb/features/i386/amd64-avx-mpx.c
+index ab56f42f13..0c5161fe8d 100644
+--- gdb/features/i386/amd64-avx-mpx.c
++++ gdb/features/i386/amd64-avx-mpx.c
+@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx_mpx (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 (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");
+
+ tdesc_amd64_avx_mpx = result;
+ }
+diff --git gdb/features/i386/amd64-avx-mpx.xml gdb/features/i386/amd64-avx-mpx.xml
+index 0001dc8413..001cc58fa6 100644
+--- gdb/features/i386/amd64-avx-mpx.xml
++++ gdb/features/i386/amd64-avx-mpx.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-mpx.xml"/>
+ </target>
+diff --git gdb/features/i386/amd64-avx.c gdb/features/i386/amd64-avx.c
+index 42bd69ab97..61d3ff56a4 100644
+--- gdb/features/i386/amd64-avx.c
++++ gdb/features/i386/amd64-avx.c
+@@ -146,23 +146,27 @@ initialize_tdesc_amd64_avx (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");
+
+ tdesc_amd64_avx = result;
+ }
+diff --git gdb/features/i386/amd64-avx.xml gdb/features/i386/amd64-avx.xml
+index d3b63b8132..a0fec551d9 100644
+--- gdb/features/i386/amd64-avx.xml
++++ gdb/features/i386/amd64-avx.xml
+@@ -12,5 +12,6 @@
+ <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"/>
+ </target>
+diff --git gdb/features/i386/amd64-mpx.c gdb/features/i386/amd64-mpx.c
+index 41f0e7834b..026fdb8625 100644
+--- gdb/features/i386/amd64-mpx.c
++++ gdb/features/i386/amd64-mpx.c
+@@ -146,6 +146,10 @@ initialize_tdesc_amd64_mpx (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.mpx");
+ type = tdesc_create_struct (feature, "br128");
+ field_type = tdesc_named_type (feature, "uint64");
+@@ -177,12 +181,12 @@ initialize_tdesc_amd64_mpx (void)
+ field_type = tdesc_named_type (feature, "_bndcfgu");
+ tdesc_add_field (type, "config", field_type);
+
+- tdesc_create_reg (feature, "bnd0raw", 57, 1, NULL, 128, "br128");
+- tdesc_create_reg (feature, "bnd1raw", 58, 1, NULL, 128, "br128");
+- tdesc_create_reg (feature, "bnd2raw", 59, 1, NULL, 128, "br128");
+- tdesc_create_reg (feature, "bnd3raw", 60, 1, NULL, 128, "br128");
+- tdesc_create_reg (feature, "bndcfgu", 61, 1, NULL, 64, "cfgu");
+- tdesc_create_reg (feature, "bndstatus", 62, 1, NULL, 64, "status");
++ tdesc_create_reg (feature, "bnd0raw", 59, 1, NULL, 128, "br128");
++ tdesc_create_reg (feature, "bnd1raw", 60, 1, NULL, 128, "br128");
++ tdesc_create_reg (feature, "bnd2raw", 61, 1, NULL, 128, "br128");
++ tdesc_create_reg (feature, "bnd3raw", 62, 1, NULL, 128, "br128");
++ tdesc_create_reg (feature, "bndcfgu", 63, 1, NULL, 64, "cfgu");
++ tdesc_create_reg (feature, "bndstatus", 64, 1, NULL, 64, "status");
+
+ tdesc_amd64_mpx = result;
+ }
+diff --git gdb/features/i386/amd64-mpx.xml gdb/features/i386/amd64-mpx.xml
+index 7692006e9c..7e0253d661 100644
+--- gdb/features/i386/amd64-mpx.xml
++++ gdb/features/i386/amd64-mpx.xml
+@@ -12,5 +12,6 @@
+ <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-mpx.xml"/>
+ </target>
+diff --git gdb/features/i386/amd64.c gdb/features/i386/amd64.c
+index b875a9b322..31ab6ccfba 100644
+--- gdb/features/i386/amd64.c
++++ gdb/features/i386/amd64.c
+@@ -146,5 +146,9 @@ initialize_tdesc_amd64 (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");
++
+ tdesc_amd64 = result;
+ }
+diff --git gdb/features/i386/amd64.xml gdb/features/i386/amd64.xml
+index d11c07e234..1962a2af37 100644
+--- gdb/features/i386/amd64.xml
++++ gdb/features/i386/amd64.xml
+@@ -12,4 +12,5 @@
+ <architecture>i386:x86-64</architecture>
+ <xi:include href="64bit-core.xml"/>
+ <xi:include href="64bit-sse.xml"/>
++ <xi:include href="64bit-segments.xml"/>
+ </target>
+diff --git gdb/regformats/i386/amd64-avx-avx512.dat gdb/regformats/i386/amd64-avx-avx512.dat
+index b7938e6919..1fbe4733f5 100644
+--- gdb/regformats/i386/amd64-avx-avx512.dat
++++ gdb/regformats/i386/amd64-avx-avx512.dat
+@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip
+ 128:xmm14
+ 128:xmm15
+ 32:mxcsr
++64:fs_base
++64:gs_base
+ 128:ymm0h
+ 128:ymm1h
+ 128:ymm2h
+diff --git gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat
+index b3340d3276..23c3a4062e 100644
+--- gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat
++++ gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat
+@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip
+ 128:xmm14
+ 128:xmm15
+ 32:mxcsr
++64:fs_base
++64:gs_base
+ 128:ymm0h
+ 128:ymm1h
+ 128:ymm2h
+diff --git gdb/regformats/i386/amd64-avx-mpx.dat gdb/regformats/i386/amd64-avx-mpx.dat
+index d985641b01..655775b0f9 100644
+--- gdb/regformats/i386/amd64-avx-mpx.dat
++++ gdb/regformats/i386/amd64-avx-mpx.dat
+@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip
+ 128:xmm14
+ 128:xmm15
+ 32:mxcsr
++64:fs_base
++64:gs_base
+ 128:ymm0h
+ 128:ymm1h
+ 128:ymm2h
+diff --git gdb/regformats/i386/amd64-avx.dat gdb/regformats/i386/amd64-avx.dat
+index 223233667a..8b9d81e743 100644
+--- gdb/regformats/i386/amd64-avx.dat
++++ gdb/regformats/i386/amd64-avx.dat
+@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip
+ 128:xmm14
+ 128:xmm15
+ 32:mxcsr
++64:fs_base
++64:gs_base
+ 128:ymm0h
+ 128:ymm1h
+ 128:ymm2h
+diff --git gdb/regformats/i386/amd64-mpx.dat gdb/regformats/i386/amd64-mpx.dat
+index 43b87769c2..d5e60babd8 100644
+--- gdb/regformats/i386/amd64-mpx.dat
++++ gdb/regformats/i386/amd64-mpx.dat
+@@ -60,6 +60,8 @@ expedite:rbp,rsp,rip
+ 128:xmm14
+ 128:xmm15
+ 32:mxcsr
++64:fs_base
++64:gs_base
+ 128:bnd0raw
+ 128:bnd1raw
+ 128:bnd2raw
+diff --git gdb/regformats/i386/amd64.dat gdb/regformats/i386/amd64.dat
+index 0ff917019d..66f26ad094 100644
+--- gdb/regformats/i386/amd64.dat
++++ gdb/regformats/i386/amd64.dat
+@@ -60,3 +60,5 @@ expedite:rbp,rsp,rip
+ 128:xmm14
+ 128:xmm15
+ 32:mxcsr
++64:fs_base
++64:gs_base
diff --git a/devel/gdb/files/commit-4b654465bf b/devel/gdb/files/commit-4b654465bf
new file mode 100644
index 000000000000..70d0f5b9bfc7
--- /dev/null
+++ b/devel/gdb/files/commit-4b654465bf
@@ -0,0 +1,118 @@
+commit 4b654465bfc3034c969d2d942c14b2cedfd3e3b6
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Wed Jun 28 12:50:56 2017 -0700
+
+ Read signal information from FreeBSD core dumps.
+
+ FreeBSD recently added a new ELF core note which dumps the entire LWP
+ info structure (the same structure returned by the ptrace PT_LWPINFO
+ operation) for each thread. The plan is for this note to eventually
+ supplant the older "thrmisc" ELF core note as it contains more
+ information and it permits new information to be exported via both
+ ptrace() and core dumps using the same structure.
+
+ For signal information, the implementation is similar to the native
+ implementation for FreeBSD processes. The PL_FLAG_SI flag must be
+ checked to determine if the embedded siginfo_t structure is valid, and
+ if so it is transferred into the caller's buffer.
+
+ gdb/ChangeLog:
+
+ * fbsd-tdep.c (LWPINFO_OFFSET, LWPINFO_PL_FLAGS)
+ (LWPINFO64_PL_SIGINFO, LWPINFO32_PL_SIGINFO, PL_FLAG_SI)
+ (SIZE64_SIGINFO_T, SIZE32_SIGINFO_T, fbsd_core_xfer_siginfo): New.
+ (fbsd_init_abi): Install gdbarch "core_xfer_siginfo" method.
+
+diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
+index 32df104208..6f30197a83 100644
+--- gdb/fbsd-tdep.c
++++ gdb/fbsd-tdep.c
+@@ -30,6 +30,28 @@
+ #include "fbsd-tdep.h"
+
+
++/* FreeBSD kernels 12.0 and later include a copy of the
++ 'ptrace_lwpinfo' structure returned by the PT_LWPINFO ptrace
++ operation in an ELF core note (NT_FREEBSD_PTLWPINFO) for each LWP.
++ The constants below define the offset of field members and flags in
++ this structure used by methods in this file. Note that the
++ 'ptrace_lwpinfo' struct in the note is preceded by a 4 byte integer
++ containing the size of the structure. */
++
++#define LWPINFO_OFFSET 0x4
++
++/* Offsets in ptrace_lwpinfo. */
++#define LWPINFO_PL_FLAGS 0x8
++#define LWPINFO64_PL_SIGINFO 0x30
++#define LWPINFO32_PL_SIGINFO 0x2c
++
++/* Flags in pl_flags. */
++#define PL_FLAG_SI 0x20 /* siginfo is valid */
++
++/* Sizes of siginfo_t. */
++#define SIZE64_SIGINFO_T 80
++#define SIZE32_SIGINFO_T 64
++
+ static struct gdbarch_data *fbsd_gdbarch_data_handle;
+
+ struct fbsd_gdbarch_data
+@@ -113,6 +135,51 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
+ return NULL;
+ }
+
++/* Implement the "core_xfer_siginfo" gdbarch method. */
++
++static LONGEST
++fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
++ ULONGEST offset, ULONGEST len)
++{
++ size_t siginfo_size;
++
++ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
++ siginfo_size = SIZE32_SIGINFO_T;
++ else
++ siginfo_size = SIZE64_SIGINFO_T;
++ if (offset > siginfo_size)
++ return -1;
++
++ thread_section_name section_name (".note.freebsdcore.lwpinfo", inferior_ptid);
++ asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
++ if (section == NULL)
++ return -1;
++
++ gdb_byte buf[4];
++ if (!bfd_get_section_contents (core_bfd, section, buf,
++ LWPINFO_OFFSET + LWPINFO_PL_FLAGS, 4))
++ return -1;
++
++ int pl_flags = extract_signed_integer (buf, 4, gdbarch_byte_order (gdbarch));
++ if (!(pl_flags & PL_FLAG_SI))
++ return -1;
++
++ if (offset + len > siginfo_size)
++ len = siginfo_size - offset;
++
++ ULONGEST siginfo_offset;
++ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
++ siginfo_offset = LWPINFO_OFFSET + LWPINFO32_PL_SIGINFO;
++ else
++ siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO;
++
++ if (!bfd_get_section_contents (core_bfd, section, readbuf,
++ siginfo_offset + offset, len))
++ return -1;
++
++ return len;
++}
++
+ static int
+ find_signalled_thread (struct thread_info *info, void *data)
+ {
+@@ -447,6 +514,7 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+ set_gdbarch_core_pid_to_str (gdbarch, fbsd_core_pid_to_str);
+ set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name);
++ set_gdbarch_core_xfer_siginfo (gdbarch, fbsd_core_xfer_siginfo);
+ set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes);
+ set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry);
+ set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type);
diff --git a/devel/gdb/files/commit-6e5eab33ab b/devel/gdb/files/commit-6e5eab33ab
new file mode 100644
index 000000000000..9b45c3e9e3c8
--- /dev/null
+++ b/devel/gdb/files/commit-6e5eab33ab
@@ -0,0 +1,120 @@
+commit 6e5eab33abe09041b29e0ce484f684ad0ffe80a5
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Wed Jun 28 10:41:57 2017 -0700
+
+ Move the thread_section_name class to gdbcore.h.
+
+ This allows it to be used outside of corelow.c.
+
+diff --git gdb/corelow.c gdb/corelow.c
+index 0aff02d4db..578c910bb5 100644
+--- gdb/corelow.c
++++ gdb/corelow.c
+@@ -485,51 +485,6 @@ 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.
+diff --git gdb/gdbcore.h gdb/gdbcore.h
+index e3eed0395d..87f3dcd64d 100644
+--- gdb/gdbcore.h
++++ gdb/gdbcore.h
+@@ -226,6 +226,51 @@ struct core_fns
+
+ };
+
++/* 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;
++};
++
+ /* NOTE: cagney/2004-04-05: Replaced by "regset.h" and
+ regset_from_core_section(). */
+ extern void deprecated_add_core_fns (struct core_fns *cf);
diff --git a/devel/gdb/files/commit-762c974a09 b/devel/gdb/files/commit-762c974a09
new file mode 100644
index 000000000000..f7173b42aa1e
--- /dev/null
+++ b/devel/gdb/files/commit-762c974a09
@@ -0,0 +1,167 @@
+commit 762c974a09746bda8a5d64ed3ee887adeae742b9
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Wed Jun 28 08:14:06 2017 -0700
+
+ Implement the "get_siginfo_type" gdbarch method for FreeBSD architectures.
+
+ As with Linux architectures, cache the created type in the gdbarch when it
+ is first created. Currently FreeBSD uses an identical siginfo type on
+ all architectures, so there is no support for architecture-specific fields.
+
+ gdb/ChangeLog:
+
+ * fbsd-tdep.c (fbsd_gdbarch_data_handle, struct fbsd_gdbarch_data)
+ (init_fbsd_gdbarch_data, get_fbsd_gdbarch_data)
+ (fbsd_get_siginfo_type): New.
+ (fbsd_init_abi): Install gdbarch "get_siginfo_type" method.
+ (_initialize_fbsd_tdep): New.
+
+diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
+index b834ce38b4..24a3c20dd6 100644
+--- gdb/fbsd-tdep.c
++++ gdb/fbsd-tdep.c
+@@ -30,6 +30,26 @@
+ #include "fbsd-tdep.h"
+
+
++static struct gdbarch_data *fbsd_gdbarch_data_handle;
++
++struct fbsd_gdbarch_data
++ {
++ struct type *siginfo_type;
++ };
++
++static void *
++init_fbsd_gdbarch_data (struct gdbarch *gdbarch)
++{
++ return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct fbsd_gdbarch_data);
++}
++
++static struct fbsd_gdbarch_data *
++get_fbsd_gdbarch_data (struct gdbarch *gdbarch)
++{
++ return ((struct fbsd_gdbarch_data *)
++ gdbarch_data (gdbarch, fbsd_gdbarch_data_handle));
++}
++
+ /* This is how we want PTIDs from core files to be printed. */
+
+ static const char *
+@@ -314,6 +334,97 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
+ fprint_auxv_entry (file, name, description, format, type, val);
+ }
+
++/* Implement the "get_siginfo_type" gdbarch method. */
++
++static struct type *
++fbsd_get_siginfo_type (struct gdbarch *gdbarch)
++{
++ struct fbsd_gdbarch_data *fbsd_gdbarch_data;
++ struct type *int_type, *int32_type, *uint32_type, *long_type, *void_ptr_type;
++ struct type *uid_type, *pid_type;
++ struct type *sigval_type, *reason_type;
++ struct type *siginfo_type;
++ struct type *type;
++
++ fbsd_gdbarch_data = get_fbsd_gdbarch_data (gdbarch);
++ if (fbsd_gdbarch_data->siginfo_type != NULL)
++ return fbsd_gdbarch_data->siginfo_type;
++
++ int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
++ 0, "int");
++ int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t");
++ uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t");
++ long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
++ 0, "long");
++ void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
++
++ /* union sigval */
++ sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
++ TYPE_NAME (sigval_type) = xstrdup ("sigval");
++ append_composite_type_field (sigval_type, "sival_int", int_type);
++ append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
++
++ /* __pid_t */
++ pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
++ TYPE_LENGTH (int32_type), "__pid_t");
++ TYPE_TARGET_TYPE (pid_type) = int32_type;
++ TYPE_TARGET_STUB (pid_type) = 1;
++
++ /* __uid_t */
++ uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
++ TYPE_LENGTH (uint32_type), "__uid_t");
++ TYPE_TARGET_TYPE (uid_type) = uint32_type;
++ TYPE_TARGET_STUB (uid_type) = 1;
++
++ /* _reason */
++ reason_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
++
++ /* _fault */
++ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
++ append_composite_type_field (type, "si_trapno", int_type);
++ append_composite_type_field (reason_type, "_fault", type);
++
++ /* _timer */
++ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
++ append_composite_type_field (type, "si_timerid", int_type);
++ append_composite_type_field (type, "si_overrun", int_type);
++ append_composite_type_field (reason_type, "_timer", type);
++
++ /* _mesgq */
++ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
++ append_composite_type_field (type, "si_mqd", int_type);
++ append_composite_type_field (reason_type, "_mesgq", type);
++
++ /* _poll */
++ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
++ append_composite_type_field (type, "si_band", long_type);
++ append_composite_type_field (reason_type, "_poll", type);
++
++ /* __spare__ */
++ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
++ append_composite_type_field (type, "__spare1__", long_type);
++ append_composite_type_field (type, "__spare2__",
++ init_vector_type (int_type, 7));
++ append_composite_type_field (reason_type, "__spare__", type);
++
++ /* struct siginfo */
++ siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
++ TYPE_NAME (siginfo_type) = xstrdup ("siginfo");
++ append_composite_type_field (siginfo_type, "si_signo", int_type);
++ append_composite_type_field (siginfo_type, "si_errno", int_type);
++ append_composite_type_field (siginfo_type, "si_code", int_type);
++ append_composite_type_field (siginfo_type, "si_pid", pid_type);
++ append_composite_type_field (siginfo_type, "si_uid", uid_type);
++ append_composite_type_field (siginfo_type, "si_status", int_type);
++ append_composite_type_field (siginfo_type, "si_addr", void_ptr_type);
++ append_composite_type_field (siginfo_type, "si_value", sigval_type);
++ append_composite_type_field (siginfo_type, "_reason", reason_type);
++
++ fbsd_gdbarch_data->siginfo_type = siginfo_type;
++
++ return siginfo_type;
++}
++
+ /* Implement the "get_syscall_number" gdbarch method. */
+
+ static LONGEST
+@@ -339,8 +450,19 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name);
+ set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes);
+ set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry);
++ set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type);
+
+ /* `catch syscall' */
+ set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml");
+ set_gdbarch_get_syscall_number (gdbarch, fbsd_get_syscall_number);
+ }
++
++/* Provide a prototype to silence -Wmissing-prototypes. */
++extern initialize_file_ftype _initialize_fbsd_tdep;
++
++void
++_initialize_fbsd_tdep (void)
++{
++ fbsd_gdbarch_data_handle =
++ gdbarch_data_register_post_init (init_fbsd_gdbarch_data);
++}
diff --git a/devel/gdb/files/commit-929edea98d b/devel/gdb/files/commit-929edea98d
new file mode 100644
index 000000000000..c03922569fb8
--- /dev/null
+++ b/devel/gdb/files/commit-929edea98d
@@ -0,0 +1,211 @@
+commit 929edea98d27cf9d72305c1584ee77627da7fa96
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Wed Jun 28 09:53:06 2017 -0700
+
+ Fetch signal information for native FreeBSD processes.
+
+ Use the `pl_siginfo' field in the `struct ptrace_lwpinfo' object returned
+ by the PT_LWPINFO ptrace() request to supply the current contents of
+ $_siginfo for each thread. Note that FreeBSD does not supply a way to
+ modify the signal information for a thread, so $_siginfo is read-only for
+ FreeBSD.
+
+ To handle 32-bit processes on a 64-bit host, define types for 32-bit
+ compatible siginfo_t and convert the 64-bit siginfo_t to the 32-bit
+ equivalent when supplying information for a 32-bit process.
+
+ gdb/ChangeLog:
+
+ * fbsd-nat.c [PT_LWPINFO && __LP64__] (union sigval32)
+ (struct siginfo32): New.
+ [PT_LWPINFO] (fbsd_siginfo_size, fbsd_convert_siginfo): New.
+ (fbsd_xfer_partial) [PT_LWPINFO]: Handle TARGET_OBJECT_SIGNAL_INFO
+ via ptrace(PT_LWPINFO).
+
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index ef5ad1ec92..85f56059bd 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -28,6 +28,7 @@
+ #include <sys/types.h>
+ #include <sys/procfs.h>
+ #include <sys/ptrace.h>
++#include <sys/signal.h>
+ #include <sys/sysctl.h>
+ #ifdef HAVE_KINFO_GETVMMAP
+ #include <sys/user.h>
+@@ -216,6 +217,135 @@ static enum target_xfer_status (*super_xfer_partial) (struct target_ops *ops,
+ ULONGEST len,
+ ULONGEST *xfered_len);
+
++#ifdef PT_LWPINFO
++/* Return the size of siginfo for the current inferior. */
++
++#ifdef __LP64__
++union sigval32 {
++ int sival_int;
++ uint32_t sival_ptr;
++};
++
++/* This structure matches the naming and layout of `siginfo_t' in
++ <sys/signal.h>. In particular, the `si_foo' macros defined in that
++ header can be used with both types to copy fields in the `_reason'
++ union. */
++
++struct siginfo32
++{
++ int si_signo;
++ int si_errno;
++ int si_code;
++ __pid_t si_pid;
++ __uid_t si_uid;
++ int si_status;
++ uint32_t si_addr;
++ union sigval32 si_value;
++ union
++ {
++ struct
++ {
++ int _trapno;
++ } _fault;
++ struct
++ {
++ int _timerid;
++ int _overrun;
++ } _timer;
++ struct
++ {
++ int _mqd;
++ } _mesgq;
++ struct
++ {
++ int32_t _band;
++ } _poll;
++ struct
++ {
++ int32_t __spare1__;
++ int __spare2__[7];
++ } __spare__;
++ } _reason;
++};
++#endif
++
++static size_t
++fbsd_siginfo_size ()
++{
++#ifdef __LP64__
++ struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
++
++ /* Is the inferior 32-bit? If so, use the 32-bit siginfo size. */
++ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
++ return sizeof (struct siginfo32);
++#endif
++ return sizeof (siginfo_t);
++}
++
++/* Convert a native 64-bit siginfo object to a 32-bit object. Note
++ that FreeBSD doesn't support writing to $_siginfo, so this only
++ needs to convert one way. */
++
++static void
++fbsd_convert_siginfo (siginfo_t *si)
++{
++#ifdef __LP64__
++ struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
++
++ /* Is the inferior 32-bit? If not, nothing to do. */
++ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word != 32)
++ return;
++
++ struct siginfo32 si32;
++
++ si32.si_signo = si->si_signo;
++ si32.si_errno = si->si_errno;
++ si32.si_code = si->si_code;
++ si32.si_pid = si->si_pid;
++ si32.si_uid = si->si_uid;
++ si32.si_status = si->si_status;
++ si32.si_addr = (uintptr_t) si->si_addr;
++
++ /* If sival_ptr is being used instead of sival_int on a big-endian
++ platform, then sival_int will be zero since it holds the upper
++ 32-bits of the pointer value. */
++#if _BYTE_ORDER == _BIG_ENDIAN
++ if (si->si_value.sival_int == 0)
++ si32->si_value.sival_ptr = (uintptr_t) si->si_value.sival_ptr;
++ else
++ si32.si_value.sival_int = si->si_value.sival_int;
++#else
++ si32.si_value.sival_int = si->si_value.sival_int;
++#endif
++
++ /* Always copy the spare fields and then possibly overwrite them for
++ signal-specific or code-specific fields. */
++ si32._reason.__spare__.__spare1__ = si->_reason.__spare__.__spare1__;
++ for (int i = 0; i < 7; i++)
++ si32._reason.__spare__.__spare2__[i] = si->_reason.__spare__.__spare2__[i];
++ switch (si->si_signo) {
++ case SIGILL:
++ case SIGFPE:
++ case SIGSEGV:
++ case SIGBUS:
++ si32.si_trapno = si->si_trapno;
++ break;
++ }
++ switch (si->si_code) {
++ case SI_TIMER:
++ si32.si_timerid = si->si_timerid;
++ si32.si_overrun = si->si_overrun;
++ break;
++ case SI_MESGQ:
++ si32.si_mqd = si->si_mqd;
++ break;
++ }
++
++ memcpy(si, &si32, sizeof (si32));
++#endif
++}
++#endif
++
+ /* Implement the "to_xfer_partial target_ops" method. */
+
+ static enum target_xfer_status
+@@ -228,6 +358,38 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object,
+
+ switch (object)
+ {
++#ifdef PT_LWPINFO
++ case TARGET_OBJECT_SIGNAL_INFO:
++ {
++ struct ptrace_lwpinfo pl;
++ size_t siginfo_size;
++
++ /* FreeBSD doesn't support writing to $_siginfo. */
++ if (writebuf != NULL)
++ return TARGET_XFER_E_IO;
++
++ if (inferior_ptid.lwp_p ())
++ pid = inferior_ptid.lwp ();
++
++ siginfo_size = fbsd_siginfo_size ();
++ if (offset > siginfo_size)
++ return TARGET_XFER_E_IO;
++
++ if (ptrace (PT_LWPINFO, pid, (PTRACE_TYPE_ARG3) &pl, sizeof (pl)) == -1)
++ return TARGET_XFER_E_IO;
++
++ if (!(pl.pl_flags & PL_FLAG_SI))
++ return TARGET_XFER_E_IO;
++
++ fbsd_convert_siginfo (&pl.pl_siginfo);
++ if (offset + len > siginfo_size)
++ len = siginfo_size - offset;
++
++ memcpy (readbuf, ((gdb_byte *) &pl.pl_siginfo) + offset, len);
++ *xfered_len = len;
++ return TARGET_XFER_OK;
++ }
++#endif
+ case TARGET_OBJECT_AUXV:
+ {
+ struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
diff --git a/devel/gdb/files/commit-b30ff123fb b/devel/gdb/files/commit-b30ff123fb
new file mode 100644
index 000000000000..4b32dcdfe0e7
--- /dev/null
+++ b/devel/gdb/files/commit-b30ff123fb
@@ -0,0 +1,40 @@
+commit b30ff123fbff63d6c8be1115320efd0158e49a7f
+Author: Yao Qi <yao.qi@linaro.org>
+Date: Thu Jun 22 13:41:27 2017 +0100
+
+ Regenerate two regformats/i386/.dat files
+
+ The self tests which compare pre-generated target descriptions and
+ dynamically created target descriptions fail, and it turns out that two
+ pre-generated target descriptions are wrong, so regenerate them.
+
+ gdb:
+
+ 2017-06-22 Yao Qi <yao.qi@linaro.org>
+
+ * regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat: Regenerated.
+ * regformats/i386/amd64-avx-mpx-avx512-pku.dat: Regenerated.
+
+diff --git gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat
+index 3ae6b0e472..9cd0fae820 100644
+--- gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat
++++ gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat
+@@ -157,3 +157,4 @@ expedite:rbp,rsp,rip
+ 256:zmm29h
+ 256:zmm30h
+ 256:zmm31h
++32:pkru
+diff --git gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat
+index 88185fd8c3..b3340d3276 100644
+--- gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat
++++ gdb/regformats/i386/amd64-avx-mpx-avx512-pku.dat
+@@ -60,9 +60,6 @@ expedite:rbp,rsp,rip
+ 128:xmm14
+ 128:xmm15
+ 32:mxcsr
+-64:orig_rax
+-64:fs_base
+-64:gs_base
+ 128:ymm0h
+ 128:ymm1h
+ 128:ymm2h
diff --git a/devel/gdb/files/commit-e6f3b9c319 b/devel/gdb/files/commit-e6f3b9c319
new file mode 100644
index 000000000000..1b7e4288f816
--- /dev/null
+++ b/devel/gdb/files/commit-e6f3b9c319
@@ -0,0 +1,25 @@
+commit e6f3b9c3194c0d89efffd6e5b59471950f979e5a
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Wed Jun 28 12:47:14 2017 -0700
+
+ Create pseudo sections for FreeBSD NT_PTLWPINFO core notes.
+
+ bfd/ChangeLog:
+
+ * elf.c (elfcore_grok_freebsd_note): Handle NT_FREEBSD_PTLWPINFO.
+
+diff --git bfd/elf.c bfd/elf.c
+index 063a6e4bb3..dcb06383d9 100644
+--- bfd/elf.c
++++ bfd/elf.c
+@@ -9980,6 +9980,10 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
+ else
+ return TRUE;
+
++ case NT_FREEBSD_PTLWPINFO:
++ return elfcore_make_note_pseudosection (abfd, ".note.freebsdcore.lwpinfo",
++ note);
++
+ default:
+ return TRUE;
+ }
diff --git a/devel/gdb/files/patch-gdb-corelow.c b/devel/gdb/files/patch-gdb-corelow.c
new file mode 100644
index 000000000000..b69a04cda824
--- /dev/null
+++ b/devel/gdb/files/patch-gdb-corelow.c
@@ -0,0 +1,11 @@
+--- gdb/corelow.c.orig 2017-07-29 11:06:52.922688000 -0700
++++ gdb/corelow.c 2017-07-29 11:07:23.883255000 -0700
+@@ -517,7 +517,7 @@ get_core_register_section (struct regcache *regcache,
+ bool variable_size_section = (regset != NULL
+ && regset->flags & REGSET_VARIABLE_SIZE);
+
+- thread_section_name section_name (name, regcache->ptid ());
++ thread_section_name section_name (name, regcache_get_ptid (regcache));
+
+ section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
+ if (! section)