Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162101760
D14148.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
252 KB
Referenced Files
None
Subscribers
None
D14148.diff
View Options
Index: head/devel/gdb/Makefile
===================================================================
--- head/devel/gdb/Makefile
+++ head/devel/gdb/Makefile
@@ -2,8 +2,7 @@
# $FreeBSD$
PORTNAME= gdb
-PORTVERSION= 8.0.1
-PORTREVISION= 2
+PORTVERSION= 8.1
CATEGORIES= devel
MASTER_SITES= GNU
@@ -39,26 +38,16 @@
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-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 \
- ${FILESDIR}/commit-0335ac6d12 \
- ${FILESDIR}/commit-12c4bd7f53 \
- ${FILESDIR}/commit-6d5be5d6b8 \
- ${FILESDIR}/commit-a80a647180 \
- ${FILESDIR}/commit-544c67cda1 \
- ${FILESDIR}/commit-a181c0bf74
+EXTRA_PATCHES= ${FILESDIR}/commit-d2176225dc \
+ ${FILESDIR}/commit-b999e2038d \
+ ${FILESDIR}/commit-262f62f57d \
+ ${FILESDIR}/commit-92fce24de2 \
+ ${FILESDIR}/commit-2d97a5d9d3 \
+ ${FILESDIR}/commit-906b4aac4c \
+ ${FILESDIR}/commit-f169cfdc08 \
+ ${FILESDIR}/commit-12279366d7 \
+ ${FILESDIR}/commit-386a867618 \
+ ${FILESDIR}/commit-7efba073e2
LIB_DEPENDS+= libexpat.so:textproc/expat2
VER= ${PORTVERSION:S/.//g}
Index: head/devel/gdb/distinfo
===================================================================
--- head/devel/gdb/distinfo
+++ head/devel/gdb/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1505207991
-SHA256 (gdb-8.0.1.tar.xz) = 3dbd5f93e36ba2815ad0efab030dcd0c7b211d7b353a40a53f4c02d7d56295e3
-SIZE (gdb-8.0.1.tar.xz) = 19583920
+TIMESTAMP = 1517392551
+SHA256 (gdb-8.1.tar.xz) = af61a0263858e69c5dce51eab26662ff3d2ad9aa68da9583e8143b5426be4b34
+SIZE (gdb-8.1.tar.xz) = 20095080
Index: head/devel/gdb/files/commit-0335ac6d12
===================================================================
--- head/devel/gdb/files/commit-0335ac6d12
+++ head/devel/gdb/files/commit-0335ac6d12
@@ -1,24 +0,0 @@
-commit 0335ac6d12906bfb4b48410d8a7229c21c727cf2
-Author: John Baldwin <jhb@FreeBSD.org>
-Date: Tue Aug 15 08:04:23 2017 -0700
-
- Fix compile on big-endian platforms in siginfo_t converter.
-
- gdb/ChangeLog:
-
- * fbsd-nat.c (fbsd_convert_siginfo): Fix compile on big-endian
- platforms.
-
-diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
-index c89343a24f..6ba6a01a70 100644
---- gdb/fbsd-nat.c
-+++ gdb/fbsd-nat.c
-@@ -314,7 +314,7 @@ fbsd_convert_siginfo (siginfo_t *si)
- 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;
-+ si32.si_value.sival_ptr = (uintptr_t) si->si_value.sival_ptr;
- else
- si32.si_value.sival_int = si->si_value.sival_int;
- #else
Index: head/devel/gdb/files/commit-0aa37b654c
===================================================================
--- head/devel/gdb/files/commit-0aa37b654c
+++ head/devel/gdb/files/commit-0aa37b654c
@@ -1,90 +0,0 @@
-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;
Index: head/devel/gdb/files/commit-0b9305edf1
===================================================================
--- head/devel/gdb/files/commit-0b9305edf1
+++ head/devel/gdb/files/commit-0b9305edf1
@@ -1,30 +0,0 @@
-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". */
Index: head/devel/gdb/files/commit-12279366d7
===================================================================
--- head/devel/gdb/files/commit-12279366d7
+++ head/devel/gdb/files/commit-12279366d7
@@ -0,0 +1,121 @@
+commit 12279366d71627bfbdd74d1a6675dca825d8feca
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Sat Mar 3 21:25:33 2018 -0800
+
+ Implement "to_stopped_by_hw_breakpoint" for x86 debug registers.
+
+ Report that a thread is stopped by a hardware breakpoint if a non-data
+ watchpoint is set in DR6. This change should be a no-op since a target
+ still needs to implement the "to_supports_stopped_by_hw_breakpoint"
+ method before this function is used.
+
+ gdb/ChangeLog:
+
+ * nat/x86-dregs.c (x86_dr_stopped_by_hw_breakpoint): New function.
+ * nat/x86-dregs.h (x86_dr_stopped_by_hw_breakpoint): New
+ prototype.
+ * x86-nat.c (x86_stopped_by_hw_breakpoint): New function.
+ (x86_use_watchpoints): Set "stopped_by_hw_breakpoint" target
+ method.
+
+diff --git gdb/nat/x86-dregs.c gdb/nat/x86-dregs.c
+index c816473628..f11a708e27 100644
+--- gdb/nat/x86-dregs.c
++++ gdb/nat/x86-dregs.c
+@@ -649,3 +649,48 @@ x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state)
+ CORE_ADDR addr = 0;
+ return x86_dr_stopped_data_address (state, &addr);
+ }
++
++/* Return non-zero if the inferior has some hardware breakpoint that
++ triggered. Otherwise return zero. */
++
++int
++x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state)
++{
++ CORE_ADDR addr = 0;
++ int i;
++ int rc = 0;
++ /* The current thread's DR_STATUS. We always need to read this to
++ check whether some watchpoint caused the trap. */
++ unsigned status;
++ /* We need DR_CONTROL as well, but only iff DR_STATUS indicates a
++ breakpoint trap. Only fetch it when necessary, to avoid an
++ unnecessary extra syscall when no watchpoint triggered. */
++ int control_p = 0;
++ unsigned control = 0;
++
++ /* As above, always read the current thread's debug registers rather
++ than trusting dr_mirror. */
++ status = x86_dr_low_get_status ();
++
++ ALL_DEBUG_ADDRESS_REGISTERS (i)
++ {
++ if (!X86_DR_WATCH_HIT (status, i))
++ continue;
++
++ if (!control_p)
++ {
++ control = x86_dr_low_get_control ();
++ control_p = 1;
++ }
++
++ if (X86_DR_GET_RW_LEN (control, i) == 0)
++ {
++ addr = x86_dr_low_get_addr (i);
++ rc = 1;
++ if (show_debug_regs)
++ x86_show_dr (state, "watchpoint_hit", addr, -1, hw_execute);
++ }
++ }
++
++ return rc;
++}
+diff --git gdb/nat/x86-dregs.h gdb/nat/x86-dregs.h
+index dd6242eda9..e86e83aea0 100644
+--- gdb/nat/x86-dregs.h
++++ gdb/nat/x86-dregs.h
+@@ -128,4 +128,8 @@ extern int x86_dr_stopped_data_address (struct x86_debug_reg_state *state,
+ Otherwise return false. */
+ extern int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state);
+
++/* Return true if the inferior has some hardware breakpoint that
++ triggered. Otherwise return false. */
++extern int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state);
++
+ #endif /* X86_DREGS_H */
+diff --git gdb/x86-nat.c gdb/x86-nat.c
+index b126c47c94..bec51373a6 100644
+--- gdb/x86-nat.c
++++ gdb/x86-nat.c
+@@ -260,6 +260,18 @@ x86_can_use_hw_breakpoint (struct target_ops *self,
+ return 1;
+ }
+
++/* Return non-zero if the inferior has some breakpoint that triggered.
++ Otherwise return zero. */
++
++static int
++x86_stopped_by_hw_breakpoint (struct target_ops *ops)
++{
++ struct x86_debug_reg_state *state
++ = x86_debug_reg_state (ptid_get_pid (inferior_ptid));
++
++ return x86_dr_stopped_by_hw_breakpoint (state);
++}
++
+ static void
+ add_show_debug_regs_command (void)
+ {
+@@ -297,6 +309,11 @@ x86_use_watchpoints (struct target_ops *t)
+ t->to_remove_watchpoint = x86_remove_watchpoint;
+ t->to_insert_hw_breakpoint = x86_insert_hw_breakpoint;
+ t->to_remove_hw_breakpoint = x86_remove_hw_breakpoint;
++
++ /* A target must provide an implementation of the
++ "to_supports_stopped_by_hw_breakpoint" target method before this
++ callback will be used. */
++ t->to_stopped_by_hw_breakpoint = x86_stopped_by_hw_breakpoint;
+ }
+
+ void
Index: head/devel/gdb/files/commit-12c4bd7f53
===================================================================
--- head/devel/gdb/files/commit-12c4bd7f53
+++ head/devel/gdb/files/commit-12c4bd7f53
@@ -1,45 +0,0 @@
-commit 12c4bd7f53e9cefcf7c3a7f8cbf9e552526cb963
-Author: John Baldwin <jhb@FreeBSD.org>
-Date: Thu Oct 5 09:50:01 2017 -0700
-
- Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types.
-
- FreeBSD recently added two additional ELF auxiliary vectors. FreeBSD's
- AT_HWCAP uses a different number compared to AT_HWCAP on Linux as the
- numerical value was already in use for a different vector on FreeBSD.
-
- include/ChangeLog:
-
- * elf/common.h (AT_FREEBSD_EHDRFLAGS, AT_FREEBSD_HWCAP): Define.
-
- gdb/ChangeLog:
-
- * fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_EHDRFLAGS and
- AT_HWCAP.
-
-diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
-index 727e28a645..fa4cd912ef 100644
---- gdb/fbsd-tdep.c
-+++ gdb/fbsd-tdep.c
-@@ -392,6 +392,8 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
- TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC);
- TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX);
- TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX);
-+ TAG (EHDRFLAGS, _("ELF header e_flags"), AUXV_FORMAT_HEX);
-+ TAG (HWCAP, _("Machine-dependent CPU capability hints"), AUXV_FORMAT_HEX);
- default:
- default_print_auxv_entry (gdbarch, file, type, val);
- return;
-diff --git include/elf/common.h include/elf/common.h
-index d08731cca1..f89ab32889 100644
---- include/elf/common.h
-+++ include/elf/common.h
-@@ -1144,6 +1144,8 @@
- #define AT_FREEBSD_PAGESIZESLEN 21 /* Number of pagesizes. */
- #define AT_FREEBSD_TIMEKEEP 22 /* Pointer to timehands. */
- #define AT_FREEBSD_STACKPROT 23 /* Initial stack protection. */
-+#define AT_FREEBSD_EHDRFLAGS 24 /* e_flags field from ELF header. */
-+#define AT_FREEBSD_HWCAP 25 /* CPU feature flags. */
-
- #define AT_SUN_UID 2000 /* Effective user ID. */
- #define AT_SUN_RUID 2001 /* Real user ID. */
Index: head/devel/gdb/files/commit-262f62f57d
===================================================================
--- head/devel/gdb/files/commit-262f62f57d
+++ head/devel/gdb/files/commit-262f62f57d
@@ -0,0 +1,43 @@
+commit 262f62f57d987269152412a55c458a03adc6ddd6
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Tue Jan 9 13:35:17 2018 -0800
+
+ Use gdb::unique_xmalloc_ptr<> instead of a deleter that invokes free().
+
+ Since xfree() always wraps free(), it is safe to use the xfree deleter
+ for buffers allocated by library routines such as kinfo_getvmmap() that
+ must be released via free().
+
+ gdb/ChangeLog:
+
+ * fbsd-nat.c (struct free_deleter): Remove.
+ (fbsd_find_memory_regions): Use gdb::unique_xmalloc_ptr<>.
+
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index d0aaf89145..81f8e27a2d 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -81,14 +81,6 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid)
+ }
+
+ #ifdef HAVE_KINFO_GETVMMAP
+-/* Deleter for std::unique_ptr that invokes free. */
+-
+-template <typename T>
+-struct free_deleter
+-{
+- void operator() (T *ptr) const { free (ptr); }
+-};
+-
+ /* Iterate over all the memory regions in the current inferior,
+ calling FUNC for each memory region. OBFD is passed as the last
+ argument to FUNC. */
+@@ -102,7 +94,7 @@ fbsd_find_memory_regions (struct target_ops *self,
+ uint64_t size;
+ int i, nitems;
+
+- std::unique_ptr<struct kinfo_vmentry, free_deleter<struct kinfo_vmentry>>
++ gdb::unique_xmalloc_ptr<struct kinfo_vmentry>
+ vmentl (kinfo_getvmmap (pid, &nitems));
+ if (vmentl == NULL)
+ perror_with_name (_("Couldn't fetch VM map entries."));
Index: head/devel/gdb/files/commit-2af9fc4432
===================================================================
--- head/devel/gdb/files/commit-2af9fc4432
+++ head/devel/gdb/files/commit-2af9fc4432
@@ -1,35 +0,0 @@
-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". */
Index: head/devel/gdb/files/commit-2d97a5d9d3
===================================================================
--- head/devel/gdb/files/commit-2d97a5d9d3
+++ head/devel/gdb/files/commit-2d97a5d9d3
@@ -0,0 +1,169 @@
+commit 2d97a5d9d33aea87c3bd02fd1fa417f5d4e1fa05
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Tue Jan 9 13:35:17 2018 -0800
+
+ Document support for 'info proc' on FreeBSD.
+
+ Since the 'info proc' support on FreeBSD does not use /proc, reword
+ the documentation for 'info proc' to not assume /proc. This includes
+ renaming the node to 'Process Information' and suggesting that
+ additional process information can be queried via different
+ OS-specific interfaces. This is also cleans up the description of
+ 'info proc' support for core files a bit as /proc is not used for core
+ file support on any current platform.
+
+ gdb/ChangeLog:
+
+ * NEWS: Document that 'info proc' now works on FreeBSD.
+
+ gdb/doc/ChangeLog:
+
+ * gdb.texinfo (pwd): Update cross-reference for Process Information
+ node and remove explicit /proc reference.
+ (Native): Rename subsection from SVR4 Process Information to
+ Process Information.
+ (Process Information): Reword introduction to be less /proc
+ centric. Document support for "info proc" on FreeBSD.
+
+diff --git gdb/NEWS gdb/NEWS
+index 2f834c6ff4..f69173a245 100644
+--- gdb/NEWS
++++ gdb/NEWS
+@@ -3,6 +3,9 @@
+
+ *** Changes since GDB 8.1
+
++* 'info proc' now works on running processes on FreeBSD systems and core
++ files created on FreeBSD systems.
++
+ *** Changes in GDB 8.1
+
+ * GDB now supports dynamically creating arbitrary register groups specified
+diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo
+index 8bdafb0ba4..096c82cc82 100644
+--- gdb/doc/gdb.texinfo
++++ gdb/doc/gdb.texinfo
+@@ -2523,9 +2523,9 @@ Print the @value{GDBN} working directory.
+
+ It is generally impossible to find the current working directory of
+ the process being debugged (since a program can change its directory
+-during its run). If you work on a system where @value{GDBN} is
+-configured with the @file{/proc} support, you can use the @code{info
+-proc} command (@pxref{SVR4 Process Information}) to find out the
++during its run). If you work on a system where @value{GDBN} supports
++the @code {info proc} command (@pxref{Process Information}), you can
++use the @code{info proc} command to find out the
+ current working directory of the debuggee.
+
+ @node Input/Output
+@@ -21712,7 +21712,7 @@ configurations.
+
+ @menu
+ * BSD libkvm Interface:: Debugging BSD kernel memory images
+-* SVR4 Process Information:: SVR4 process information
++* Process Information:: Process information
+ * DJGPP Native:: Features specific to the DJGPP port
+ * Cygwin Native:: Features specific to the Cygwin port
+ * Hurd Native:: Features specific to @sc{gnu} Hurd
+@@ -21759,24 +21759,32 @@ Set current context from proc address. This command isn't available on
+ modern FreeBSD systems.
+ @end table
+
+-@node SVR4 Process Information
+-@subsection SVR4 Process Information
++@node Process Information
++@subsection Process Information
+ @cindex /proc
+ @cindex examine process image
+ @cindex process info via @file{/proc}
+
+-Many versions of SVR4 and compatible systems provide a facility called
+-@samp{/proc} that can be used to examine the image of a running
+-process using file-system subroutines.
++Some operating systems provide interfaces to fetch additional
++information about running processes beyond memory and per-thread
++register state. If @value{GDBN} is configured for an operating system
++with a supported interface, the command @code{info proc} is available
++to report information about the process running your program, or about
++any process running on your system.
+
+-If @value{GDBN} is configured for an operating system with this
+-facility, the command @code{info proc} is available to report
+-information about the process running your program, or about any
+-process running on your system. This includes, as of this writing,
+-@sc{gnu}/Linux and Solaris, for example.
++One supported interface is a facility called @samp{/proc} that can be
++used to examine the image of a running process using file-system
++subroutines. This facility is supported on @sc{gnu}/Linux and Solaris
++systems.
+
+-This command may also work on core files that were created on a system
+-that has the @samp{/proc} facility.
++On FreeBSD systems, system control nodes are used to query process
++information.
++
++In addition, some systems may provide additional process information
++in core files. Note that a core file may include a subset of the
++information available from a live process. Process information is
++currently avaiable from cores created on @sc{gnu}/Linux and FreeBSD
++systems.
+
+ @table @code
+ @kindex info proc
+@@ -21800,36 +21808,40 @@ a process ID rather than a thread ID).
+ @item info proc cmdline
+ @cindex info proc cmdline
+ Show the original command line of the process. This command is
+-specific to @sc{gnu}/Linux.
++supported on @sc{gnu}/Linux and FreeBSD.
+
+ @item info proc cwd
+ @cindex info proc cwd
+ Show the current working directory of the process. This command is
+-specific to @sc{gnu}/Linux.
++supported on @sc{gnu}/Linux and FreeBSD.
+
+ @item info proc exe
+ @cindex info proc exe
+-Show the name of executable of the process. This command is specific
+-to @sc{gnu}/Linux.
++Show the name of executable of the process. This command is supported
++on @sc{gnu}/Linux and FreeBSD.
+
+ @item info proc mappings
+ @cindex memory address space mappings
+-Report the memory address space ranges accessible in the program, with
+-information on whether the process has read, write, or execute access
+-rights to each range. On @sc{gnu}/Linux systems, each memory range
+-includes the object file which is mapped to that range, instead of the
+-memory access rights to that range.
++Report the memory address space ranges accessible in the program. On
++Solaris and FreeBSD systems, each memory range includes information on
++whether the process has read, write, or execute access rights to each
++range. On @sc{gnu}/Linux and FreeBSD systems, each memory range
++includes the object file which is mapped to that range.
+
+ @item info proc stat
+ @itemx info proc status
+ @cindex process detailed status information
+-These subcommands are specific to @sc{gnu}/Linux systems. They show
+-the process-related information, including the user ID and group ID;
+-how many threads are there in the process; its virtual memory usage;
+-the signals that are pending, blocked, and ignored; its TTY; its
+-consumption of system and user time; its stack size; its @samp{nice}
+-value; etc. For more information, see the @samp{proc} man page
+-(type @kbd{man 5 proc} from your shell prompt).
++Show additional process-related information, including the user ID and
++group ID; virtual memory usage; the signals that are pending, blocked,
++and ignored; its TTY; its consumption of system and user time; its
++stack size; its @samp{nice} value; etc. These commands are supported
++on @sc{gnu}/Linux and FreeBSD.
++
++For @sc{gnu}/Linux systems, see the @samp{proc} man page for more
++information (type @kbd{man 5 proc} from your shell prompt).
++
++For FreeBSD systems, @code{info proc stat} is an alias for @code{info
++proc status}.
+
+ @item info proc all
+ Show all the information about the process described under all of the
Index: head/devel/gdb/files/commit-382b69bbb7
===================================================================
--- head/devel/gdb/files/commit-382b69bbb7
+++ head/devel/gdb/files/commit-382b69bbb7
@@ -1,220 +0,0 @@
-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,
Index: head/devel/gdb/files/commit-386a867618
===================================================================
--- head/devel/gdb/files/commit-386a867618
+++ head/devel/gdb/files/commit-386a867618
@@ -0,0 +1,115 @@
+commit 386a86761838df16c1459275d465ed21a1c35d9f
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Sat Mar 3 21:25:33 2018 -0800
+
+ Add a new debug knob for the FreeBSD native target.
+
+ For now this just logs information about the state of the current LWP
+ for each STOPPED event in fbsd_wait().
+
+ gdb/ChangeLog:
+
+ * NEWS (Changes since GDB 8.1): Add "set/show debug fbsd-nat".
+ * fbsd-nat.c (debug_fbsd_nat): New variable.
+ (show_fbsd_nat_debug): New function.
+ (fbsd_wait): Log LWP info if "debug_fbsd_nat" is enabled.
+ (_initialize_fbsd_nat): Add "fbsd-nat" debug boolean command.
+
+ gdb/doc/ChangeLog:
+
+ * gdb.texinfo (Debugging Output): Document "set/show debug
+ fbsd-nat".
+
+diff --git gdb/NEWS gdb/NEWS
+index 1767cef920..867e268a2a 100644
+--- gdb/NEWS
++++ gdb/NEWS
+@@ -6,6 +6,12 @@
+ * 'info proc' now works on running processes on FreeBSD systems and core
+ files created on FreeBSD systems.
+
++* New commands
++
++set debug fbsd-nat
++show debug fbsd-nat
++ Control display of debugging info regarding the FreeBSD native target.
++
+ *** Changes in GDB 8.1
+
+ * GDB now supports dynamically creating arbitrary register groups specified
+diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo
+index ee7adc8df2..74e0fdb4a4 100644
+--- gdb/doc/gdb.texinfo
++++ gdb/doc/gdb.texinfo
+@@ -24554,6 +24554,11 @@ Displays the current state of displaying debugging info about
+ Turns on or off debugging messages from the FreeBSD LWP debug support.
+ @item show debug fbsd-lwp
+ Show the current state of FreeBSD LWP debugging messages.
++@item set debug fbsd-nat
++@cindex FreeBSD native target debug messages
++Turns on or off debugging messages from the FreeBSD native target.
++@item show debug fbsd-nat
++Show the current state of FreeBSD native target debugging messages.
+ @item set debug frame
+ @cindex frame debugging info
+ Turns on or off display of @value{GDBN} frame debugging info. The
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 3a216abf18..2516ac5552 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -765,6 +765,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object,
+
+ #ifdef PT_LWPINFO
+ static int debug_fbsd_lwp;
++static int debug_fbsd_nat;
+
+ static void (*super_resume) (struct target_ops *,
+ ptid_t,
+@@ -782,6 +783,14 @@ show_fbsd_lwp_debug (struct ui_file *file, int from_tty,
+ fprintf_filtered (file, _("Debugging of FreeBSD lwp module is %s.\n"), value);
+ }
+
++static void
++show_fbsd_nat_debug (struct ui_file *file, int from_tty,
++ struct cmd_list_element *c, const char *value)
++{
++ fprintf_filtered (file, _("Debugging of FreeBSD native target is %s.\n"),
++ value);
++}
++
+ /*
+ FreeBSD's first thread support was via a "reentrant" version of libc
+ (libc_r) that first shipped in 2.2.7. This library multiplexed all
+@@ -1212,6 +1221,18 @@ fbsd_wait (struct target_ops *ops,
+
+ wptid = ptid_build (pid, pl.pl_lwpid, 0);
+
++ if (debug_fbsd_nat)
++ {
++ fprintf_unfiltered (gdb_stdlog,
++ "FNAT: stop for LWP %u event %d flags %#x\n",
++ pl.pl_lwpid, pl.pl_event, pl.pl_flags);
++ if (pl.pl_flags & PL_FLAG_SI)
++ fprintf_unfiltered (gdb_stdlog,
++ "FNAT: si_signo %u si_code %u\n",
++ pl.pl_siginfo.si_signo,
++ pl.pl_siginfo.si_code);
++ }
++
+ #ifdef PT_LWP_EVENTS
+ if (pl.pl_flags & PL_FLAG_EXITED)
+ {
+@@ -1569,5 +1590,13 @@ Enables printf debugging output."),
+ NULL,
+ &show_fbsd_lwp_debug,
+ &setdebuglist, &showdebuglist);
++ add_setshow_boolean_cmd ("fbsd-nat", class_maintenance,
++ &debug_fbsd_nat, _("\
++Set debugging of FreeBSD native target."), _("\
++Show debugging of FreeBSD native target."), _("\
++Enables printf debugging output."),
++ NULL,
++ &show_fbsd_nat_debug,
++ &setdebuglist, &showdebuglist);
+ #endif
+ }
Index: head/devel/gdb/files/commit-3c3ae77e68
===================================================================
--- head/devel/gdb/files/commit-3c3ae77e68
+++ head/devel/gdb/files/commit-3c3ae77e68
@@ -1,156 +0,0 @@
-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;
-
Index: head/devel/gdb/files/commit-45eba0ab7d
===================================================================
--- head/devel/gdb/files/commit-45eba0ab7d
+++ head/devel/gdb/files/commit-45eba0ab7d
@@ -1,45 +0,0 @@
-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));
Index: head/devel/gdb/files/commit-48aeef91c2
===================================================================
--- head/devel/gdb/files/commit-48aeef91c2
+++ head/devel/gdb/files/commit-48aeef91c2
@@ -1,805 +0,0 @@
-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
Index: head/devel/gdb/files/commit-4b654465bf
===================================================================
--- head/devel/gdb/files/commit-4b654465bf
+++ head/devel/gdb/files/commit-4b654465bf
@@ -1,118 +0,0 @@
-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);
Index: head/devel/gdb/files/commit-544c67cda1
===================================================================
--- head/devel/gdb/files/commit-544c67cda1
+++ head/devel/gdb/files/commit-544c67cda1
@@ -1,159 +0,0 @@
-commit 544c67cda1686c1b204cb96c0d7885b08d37b8d6
-Author: John Baldwin <jhb@FreeBSD.org>
-Date: Fri Oct 6 11:41:45 2017 -0700
-
- Account for padding in FreeBSD/mipsn32 NT_PRSTATUS notes.
-
- Add a new ELF backend method to grok FreeBSD NT_PRSTATUS core dump
- notes. Define a method for MIPS N32 to override the default
- elfcore_grok_freebsd_prstatus that accounts for additional padding
- between pr_pid and pr_reg that is not present in other 32-bit FreeBSD
- platforms.
-
- * elf-bfd.h (struct elf_backend_data): Add
- `elf_backend_grok_freebsd_prstatus'.
- * elf.c (elfcore_grok_freebsd_note): Call
- `elf_backend_grok_freebsd_prstatus' to handle NT_PRSTATUS if
- present.
- * elfn32-mips.c (elf_n32_mips_grok_freebsd_prstatus): New
- function.
- (elf_backend_grok_freebsd_prstatus): Define.
- * elfxx-target.h (elf_backend_grok_freebsd_prstatus): Define.
- (elfNN_bed): Initialize `elf_backend_grok_freebsd_prstatus'.
-
-diff --git bfd/elf-bfd.h bfd/elf-bfd.h
-index fd08748ae2..399e298a8d 100644
---- bfd/elf-bfd.h
-+++ bfd/elf-bfd.h
-@@ -1270,6 +1270,11 @@ struct elf_backend_data
- bfd_boolean (*elf_backend_grok_psinfo)
- (bfd *, Elf_Internal_Note *);
-
-+ /* This function, if defined, is called when a "FreeBSD" NT_PRSTATUS
-+ note is found in a core file. */
-+ bfd_boolean (*elf_backend_grok_freebsd_prstatus)
-+ (bfd *, Elf_Internal_Note *);
-+
- /* This function, if defined, is called to write a note to a corefile. */
- char *(*elf_backend_write_core_note)
- (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
-diff --git bfd/elf.c bfd/elf.c
-index 02deceaf4c..c6de70d6b5 100644
---- bfd/elf.c
-+++ bfd/elf.c
-@@ -9981,9 +9981,14 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
- static bfd_boolean
- elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
- {
-+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
-+
- switch (note->type)
- {
- case NT_PRSTATUS:
-+ if (bed->elf_backend_grok_freebsd_prstatus)
-+ if ((*bed->elf_backend_grok_freebsd_prstatus) (abfd, note))
-+ return TRUE;
- return elfcore_grok_freebsd_prstatus (abfd, note);
-
- case NT_FPREGSET:
-diff --git bfd/elfn32-mips.c bfd/elfn32-mips.c
-index dce7ba1c7a..fdae18365e 100644
---- bfd/elfn32-mips.c
-+++ bfd/elfn32-mips.c
-@@ -80,6 +80,8 @@ static bfd_boolean elf32_mips_grok_prstatus
- (bfd *, Elf_Internal_Note *);
- static bfd_boolean elf32_mips_grok_psinfo
- (bfd *, Elf_Internal_Note *);
-+static bfd_boolean elf_n32_mips_grok_freebsd_prstatus
-+ (bfd *, Elf_Internal_Note *);
- static irix_compat_t elf_n32_mips_irix_compat
- (bfd *);
-
-@@ -3578,6 +3580,56 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
-
- return TRUE;
- }
-+
-+static bfd_boolean
-+elf_n32_mips_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
-+{
-+ size_t offset;
-+ size_t size;
-+ size_t min_size;
-+
-+ /* Compute offset of pr_getregsz, skipping over pr_statussz.
-+ Also compute minimum size of this note. */
-+ offset = 4 + 4;
-+ min_size = offset + 4 * 2 + 4 + 4 + 4;
-+
-+ if (note->descsz < min_size)
-+ return FALSE;
-+
-+ /* Check for version 1 in pr_version. */
-+ if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1)
-+ return FALSE;
-+
-+ /* Extract size of pr_reg from pr_gregsetsz. */
-+ /* Skip over pr_gregsetsz and pr_fpregsetsz. */
-+ size = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
-+ offset += 4 * 2;
-+
-+ /* Skip over pr_osreldate. */
-+ offset += 4;
-+
-+ /* Read signal from pr_cursig. */
-+ if (elf_tdata (abfd)->core->signal == 0)
-+ elf_tdata (abfd)->core->signal
-+ = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
-+ offset += 4;
-+
-+ /* Read TID from pr_pid. */
-+ elf_tdata (abfd)->core->lwpid
-+ = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
-+ offset += 4;
-+
-+ /* Padding before pr_reg. */
-+ offset += 4;
-+
-+ /* Make sure that there is enough data remaining in the note. */
-+ if (note->descsz - offset < size)
-+ return FALSE;
-+
-+ /* Make a ".reg/999" section and a ".reg" section. */
-+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
-+ size, note->descpos + offset);
-+}
-
- /* Depending on the target vector we generate some version of Irix
- executables or "normal" MIPS ELF ABI executables. */
-@@ -3684,6 +3736,8 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
- _bfd_mips_elf_copy_indirect_symbol
- #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
- #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
-+#define elf_backend_grok_freebsd_prstatus \
-+ elf_n32_mips_grok_freebsd_prstatus
- #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
-
- #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
-diff --git bfd/elfxx-target.h bfd/elfxx-target.h
-index 551883fa09..6efca84e4e 100644
---- bfd/elfxx-target.h
-+++ bfd/elfxx-target.h
-@@ -597,6 +597,9 @@
- #ifndef elf_backend_grok_psinfo
- #define elf_backend_grok_psinfo NULL
- #endif
-+#ifndef elf_backend_grok_freebsd_prstatus
-+#define elf_backend_grok_freebsd_prstatus NULL
-+#endif
- #ifndef elf_backend_write_core_note
- #define elf_backend_write_core_note NULL
- #endif
-@@ -820,6 +823,7 @@ static struct elf_backend_data elfNN_bed =
- elf_backend_sort_relocs_p,
- elf_backend_grok_prstatus,
- elf_backend_grok_psinfo,
-+ elf_backend_grok_freebsd_prstatus,
- elf_backend_write_core_note,
- elf_backend_lookup_section_flags_hook,
- elf_backend_reloc_type_class,
Index: head/devel/gdb/files/commit-6d5be5d6b8
===================================================================
--- head/devel/gdb/files/commit-6d5be5d6b8
+++ head/devel/gdb/files/commit-6d5be5d6b8
@@ -1,24 +0,0 @@
-commit 6d5be5d6b8b4412e65bc037472aa2e727c25ccf5
-Author: John Baldwin <jhb@FreeBSD.org>
-Date: Thu Oct 5 09:50:01 2017 -0700
-
- Handle the NT_ARM_VFP core dump note on FreeBSD.
-
- bfd/ChangeLog:
-
- * elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_VFP.
-
-diff --git bfd/elf.c bfd/elf.c
-index fd7f773730..02deceaf4c 100644
---- bfd/elf.c
-+++ bfd/elf.c
-@@ -10022,6 +10022,9 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
- return elfcore_make_note_pseudosection (abfd, ".note.freebsdcore.lwpinfo",
- note);
-
-+ case NT_ARM_VFP:
-+ return elfcore_grok_arm_vfp (abfd, note);
-+
- default:
- return TRUE;
- }
Index: head/devel/gdb/files/commit-6e5eab33ab
===================================================================
--- head/devel/gdb/files/commit-6e5eab33ab
+++ head/devel/gdb/files/commit-6e5eab33ab
@@ -1,120 +0,0 @@
-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);
Index: head/devel/gdb/files/commit-762c974a09
===================================================================
--- head/devel/gdb/files/commit-762c974a09
+++ head/devel/gdb/files/commit-762c974a09
@@ -1,167 +0,0 @@
-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);
-+}
Index: head/devel/gdb/files/commit-7efba073e2
===================================================================
--- head/devel/gdb/files/commit-7efba073e2
+++ head/devel/gdb/files/commit-7efba073e2
@@ -0,0 +1,184 @@
+commit 7efba073e2b83803a47fd89e701fe60b98f2debc
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Sat Mar 3 21:25:33 2018 -0800
+
+ Use signal information to determine SIGTRAP type for FreeBSD.
+
+ Use the signal code from siginfo_t to distinguish SIGTRAP events due
+ to trace traps (TRAP_TRACE) and software breakpoints (TRAP_BRKPT).
+ For software breakpoints, adjust the PC when the event is reported as
+ part of the API when supplying "stopped_by_sw_breakpoint". Currently
+ FreeBSD only supports hardware watchpoints and breakpoints on x86
+ which are reported as trace traps. Signal information is not used on
+ MIPS and sparc64 kernels which do not reliably report TRAP_BRKPT for
+ software breakpoints.
+
+ gdb/ChangeLog:
+
+ * fbsd-nat.c: Include "inf-ptrace.h".
+ (USE_SIGTRAP_SIGINFO): Conditionally define.
+ [USE_SIGTRAP_SIGINFO] (fbsd_handle_debug_trap): New function.
+ (fbsd_wait) [USE_SIGTRAP_SIGINFO]: Call "fbsd_handle_debug_trap".
+ [USE_SIGTRAP_SIGINFO] (fbsd_stopped_by_sw_breakpoint): New
+ function.
+ [USE_SIGTRAP_SIGINFO] (fbsd_supports_stopped_by_sw_breakpoint):
+ Likewise.
+ [USE_SIGTRAP_SIGINFO] (fbsd_supports_stopped_by_hw_breakpoint):
+ Likewise.
+ (fbsd_nat_add_target) [USE_SIGTRAP_SIGINFO]: Set
+ "stopped_by_sw_breakpoint", "supports_stopped_by_sw_breakpoint",
+ "supports_stopped_by_hw_breakpoint" target methods.
+
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 2516ac5552..bea7f42c7e 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -26,6 +26,7 @@
+ #include "gdbcmd.h"
+ #include "gdbthread.h"
+ #include "gdb_wait.h"
++#include "inf-ptrace.h"
+ #include <sys/types.h>
+ #include <sys/procfs.h>
+ #include <sys/ptrace.h>
+@@ -45,6 +46,14 @@
+
+ #include <list>
+
++#ifdef TRAP_BRKPT
++/* MIPS does not set si_code for SIGTRAP. sparc64 reports
++ non-standard values in si_code for SIGTRAP. */
++# if !defined(__mips__) && !defined(__sparc64__)
++# define USE_SIGTRAP_SIGINFO
++# endif
++#endif
++
+ /* Return the name of a file that can be opened to get the symbols for
+ the child process identified by PID. */
+
+@@ -1187,6 +1196,56 @@ fbsd_resume (struct target_ops *ops,
+ super_resume (ops, ptid, step, signo);
+ }
+
++#ifdef USE_SIGTRAP_SIGINFO
++/* Handle breakpoint and trace traps reported via SIGTRAP. If the
++ trap was a breakpoint or trace trap that should be reported to the
++ core, return true. */
++
++static bool
++fbsd_handle_debug_trap (struct target_ops *ops, ptid_t ptid,
++ const struct ptrace_lwpinfo &pl)
++{
++
++ /* Ignore traps without valid siginfo or for signals other than
++ SIGTRAP. */
++ if (! (pl.pl_flags & PL_FLAG_SI) || pl.pl_siginfo.si_signo != SIGTRAP)
++ return false;
++
++ /* Trace traps are either a single step or a hardware watchpoint or
++ breakpoint. */
++ if (pl.pl_siginfo.si_code == TRAP_TRACE)
++ {
++ if (debug_fbsd_nat)
++ fprintf_unfiltered (gdb_stdlog,
++ "FNAT: trace trap for LWP %ld\n", ptid.lwp ());
++ return true;
++ }
++
++ if (pl.pl_siginfo.si_code == TRAP_BRKPT)
++ {
++ /* Fixup PC for the software breakpoint. */
++ struct regcache *regcache = get_thread_regcache (ptid);
++ struct gdbarch *gdbarch = regcache->arch ();
++ int decr_pc = gdbarch_decr_pc_after_break (gdbarch);
++
++ if (debug_fbsd_nat)
++ fprintf_unfiltered (gdb_stdlog,
++ "FNAT: sw breakpoint trap for LWP %ld\n",
++ ptid.lwp ());
++ if (decr_pc != 0)
++ {
++ CORE_ADDR pc;
++
++ pc = regcache_read_pc (regcache);
++ regcache_write_pc (regcache, pc - decr_pc);
++ }
++ return true;
++ }
++
++ return false;
++}
++#endif
++
+ /* Wait for the child specified by PTID to do something. Return the
+ process ID of the child, or MINUS_ONE_PTID in case of error; store
+ the status in *OURSTATUS. */
+@@ -1372,6 +1431,11 @@ fbsd_wait (struct target_ops *ops,
+ }
+ #endif
+
++#ifdef USE_SIGTRAP_SIGINFO
++ if (fbsd_handle_debug_trap (ops, wptid, pl))
++ return wptid;
++#endif
++
+ /* Note that PL_FLAG_SCE is set for any event reported while
+ a thread is executing a system call in the kernel. In
+ particular, signals that interrupt a sleep in a system
+@@ -1410,6 +1474,42 @@ fbsd_wait (struct target_ops *ops,
+ }
+ }
+
++#ifdef USE_SIGTRAP_SIGINFO
++/* Implement the "to_stopped_by_sw_breakpoint" target_ops method. */
++
++static int
++fbsd_stopped_by_sw_breakpoint (struct target_ops *ops)
++{
++ struct ptrace_lwpinfo pl;
++
++ if (ptrace (PT_LWPINFO, get_ptrace_pid (inferior_ptid), (caddr_t) &pl,
++ sizeof pl) == -1)
++ return 0;
++
++ return ((pl.pl_flags & PL_FLAG_SI)
++ && pl.pl_siginfo.si_signo == SIGTRAP
++ && pl.pl_siginfo.si_code == TRAP_BRKPT);
++}
++
++/* Implement the "to_supports_stopped_by_sw_breakpoint" target_ops
++ method. */
++
++static int
++fbsd_supports_stopped_by_sw_breakpoint (struct target_ops *ops)
++{
++ return 1;
++}
++
++/* Implement the "to_supports_stopped_by_hw_breakpoint" target_ops
++ method. */
++
++static int
++fbsd_supports_stopped_by_hw_breakpoint (struct target_ops *ops)
++{
++ return ops->to_stopped_by_hw_breakpoint != NULL;
++}
++#endif
++
+ #ifdef TDP_RFPPWAIT
+ /* Target hook for follow_fork. On entry and at return inferior_ptid is
+ the ptid of the followed inferior. */
+@@ -1560,6 +1660,13 @@ fbsd_nat_add_target (struct target_ops *t)
+ t->to_wait = fbsd_wait;
+ t->to_post_startup_inferior = fbsd_post_startup_inferior;
+ t->to_post_attach = fbsd_post_attach;
++#ifdef USE_SIGTRAP_SIGINFO
++ t->to_stopped_by_sw_breakpoint = fbsd_stopped_by_sw_breakpoint;
++ t->to_supports_stopped_by_sw_breakpoint
++ = fbsd_supports_stopped_by_sw_breakpoint;
++ t->to_supports_stopped_by_hw_breakpoint
++ = fbsd_supports_stopped_by_hw_breakpoint;
++#endif
+ #ifdef TDP_RFPPWAIT
+ t->to_follow_fork = fbsd_follow_fork;
+ t->to_insert_fork_catchpoint = fbsd_insert_fork_catchpoint;
Index: head/devel/gdb/files/commit-906b4aac4c
===================================================================
--- head/devel/gdb/files/commit-906b4aac4c
+++ head/devel/gdb/files/commit-906b4aac4c
@@ -0,0 +1,29 @@
+commit 906b4aac4c1d3cdb2b1ea7105133cfbe25e04e14
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Fri Jan 12 12:05:50 2018 -0800
+
+ Use the correct value for the offset of 'kve_protection'.
+
+ I had forgotten to convert the decimal output of 'ptype /o' to hex
+ (but still used a 0x prefix) for the KVE_PROTECTION constant defining
+ the offset of the 'kve_protection' field in the 'kinfo_vmentry'
+ structure. This resulted in garbage permissions for entries in 'info
+ proc mappings' for FreeBSD core dumps.
+
+ gdb/ChangeLog:
+
+ * fbsd-tdep.c (KVE_PROTECTION): Correct value.
+
+diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
+index 8aa0243d54..e49a9aff09 100644
+--- gdb/fbsd-tdep.c
++++ gdb/fbsd-tdep.c
+@@ -62,7 +62,7 @@
+ #define KVE_END 0x10
+ #define KVE_OFFSET 0x18
+ #define KVE_FLAGS 0x2c
+-#define KVE_PROTECTION 0x56
++#define KVE_PROTECTION 0x38
+ #define KVE_PATH 0x88
+
+ /* Flags in the 'kve_protection' field in struct kinfo_vmentry. These
Index: head/devel/gdb/files/commit-929edea98d
===================================================================
--- head/devel/gdb/files/commit-929edea98d
+++ head/devel/gdb/files/commit-929edea98d
@@ -1,211 +0,0 @@
-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);
Index: head/devel/gdb/files/commit-92fce24de2
===================================================================
--- head/devel/gdb/files/commit-92fce24de2
+++ head/devel/gdb/files/commit-92fce24de2
@@ -0,0 +1,548 @@
+commit 92fce24de299a8b9a9a1c0c6b98e0e9c1656f99c
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Tue Jan 9 13:35:17 2018 -0800
+
+ Support 'info proc' for native FreeBSD processes.
+
+ - Command line arguments are fetched via the kern.proc.args.<pid>
+ sysctl.
+ - The 'cwd' and 'exe' values are obtained from the per-process
+ file descriptor table returned by kinfo_getfile() from libutil.
+ - 'mappings' is implemented by walking the array of VM map entries
+ returned by kinfo_getvmmap() from libutil.
+ - 'status' output is generated by outputting fields from the structure
+ returned by the kern.proc.pid.<pid> sysctl.
+ - 'stat' is aliased to 'status'.
+
+ gdb/ChangeLog:
+
+ * configure.ac: Check for kinfo_getfile in libutil.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+ * fbsd-nat.c: Include "fbsd-tdep.h".
+ (fbsd_fetch_cmdline): New.
+ (fbsd_fetch_kinfo_proc): Move earlier and change to return a bool
+ rather than calling error.
+ (fbsd_info_proc): New.
+ (fbsd_thread_name): Report error if fbsd_fetch_kinfo_proc fails.
+ (fbsd_wait): Report warning if fbsd_fetch_kinfo_proc fails.
+ (fbsd_nat_add_target): Set "to_info_proc" to "fbsd_info_proc".
+
+diff --git gdb/config.in gdb/config.in
+index 1d11a97080..ad2cc1754e 100644
+--- gdb/config.in
++++ gdb/config.in
+@@ -219,6 +219,9 @@
+ /* Define to 1 if you have the <inttypes.h> header file. */
+ #undef HAVE_INTTYPES_H
+
++/* Define to 1 if your system has the kinfo_getfile function. */
++#undef HAVE_KINFO_GETFILE
++
+ /* Define to 1 if your system has the kinfo_getvmmap function. */
+ #undef HAVE_KINFO_GETVMMAP
+
+diff --git gdb/configure gdb/configure
+index db610f32fc..68b9aad02d 100755
+--- gdb/configure
++++ gdb/configure
+@@ -7927,6 +7927,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
+ fi
+
+
++# fbsd-nat.c can also use kinfo_getfile.
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kinfo_getfile" >&5
++$as_echo_n "checking for library containing kinfo_getfile... " >&6; }
++if test "${ac_cv_search_kinfo_getfile+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ ac_func_search_save_LIBS=$LIBS
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++/* Override any GCC internal prototype to avoid an error.
++ Use char because int might match the return type of a GCC
++ builtin and then its argument prototype would still apply. */
++#ifdef __cplusplus
++extern "C"
++#endif
++char kinfo_getfile ();
++int
++main ()
++{
++return kinfo_getfile ();
++ ;
++ return 0;
++}
++_ACEOF
++for ac_lib in '' util util-freebsd; do
++ if test -z "$ac_lib"; then
++ ac_res="none required"
++ else
++ ac_res=-l$ac_lib
++ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
++ fi
++ if ac_fn_c_try_link "$LINENO"; then :
++ ac_cv_search_kinfo_getfile=$ac_res
++fi
++rm -f core conftest.err conftest.$ac_objext \
++ conftest$ac_exeext
++ if test "${ac_cv_search_kinfo_getfile+set}" = set; then :
++ break
++fi
++done
++if test "${ac_cv_search_kinfo_getfile+set}" = set; then :
++
++else
++ ac_cv_search_kinfo_getfile=no
++fi
++rm conftest.$ac_ext
++LIBS=$ac_func_search_save_LIBS
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kinfo_getfile" >&5
++$as_echo "$ac_cv_search_kinfo_getfile" >&6; }
++ac_res=$ac_cv_search_kinfo_getfile
++if test "$ac_res" != no; then :
++ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
++
++$as_echo "#define HAVE_KINFO_GETFILE 1" >>confdefs.h
++
++fi
++
++
+
+ if test "X$prefix" = "XNONE"; then
+ acl_final_prefix="$ac_default_prefix"
+diff --git gdb/configure.ac gdb/configure.ac
+index 3db44ae758..551afc727e 100644
+--- gdb/configure.ac
++++ gdb/configure.ac
+@@ -523,6 +523,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd,
+ [AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
+ [Define to 1 if your system has the kinfo_getvmmap function. ])])
+
++# fbsd-nat.c can also use kinfo_getfile.
++AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd,
++ [AC_DEFINE(HAVE_KINFO_GETFILE, 1,
++ [Define to 1 if your system has the kinfo_getfile function. ])])
++
+ AM_ICONV
+
+ # GDB may fork/exec the iconv program to get the list of supported character
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index 81f8e27a2d..b352418813 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -32,14 +32,16 @@
+ #include <sys/signal.h>
+ #include <sys/sysctl.h>
+ #include <sys/user.h>
+-#ifdef HAVE_KINFO_GETVMMAP
++#if defined(HAVE_KINFO_GETFILE) || defined(HAVE_KINFO_GETVMMAP)
+ #include <libutil.h>
+-#else
++#endif
++#if !defined(HAVE_KINFO_GETVMMAP)
+ #include "filestuff.h"
+ #endif
+
+ #include "elf-bfd.h"
+ #include "fbsd-nat.h"
++#include "fbsd-tdep.h"
+
+ #include <list>
+
+@@ -205,6 +207,331 @@ fbsd_find_memory_regions (struct target_ops *self,
+ }
+ #endif
+
++/* Fetch the command line for a running process. */
++
++static gdb::unique_xmalloc_ptr<char>
++fbsd_fetch_cmdline (pid_t pid)
++{
++ size_t len;
++ int mib[4];
++
++ len = 0;
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC;
++ mib[2] = KERN_PROC_ARGS;
++ mib[3] = pid;
++ if (sysctl (mib, 4, NULL, &len, NULL, 0) == -1)
++ return nullptr;
++
++ if (len == 0)
++ return nullptr;
++
++ gdb::unique_xmalloc_ptr<char> cmdline ((char *) xmalloc (len));
++ if (sysctl (mib, 4, cmdline.get (), &len, NULL, 0) == -1)
++ return nullptr;
++
++ return cmdline;
++}
++
++/* Fetch the external variant of the kernel's internal process
++ structure for the process PID into KP. */
++
++static bool
++fbsd_fetch_kinfo_proc (pid_t pid, struct kinfo_proc *kp)
++{
++ size_t len;
++ int mib[4];
++
++ len = sizeof *kp;
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC;
++ mib[2] = KERN_PROC_PID;
++ mib[3] = pid;
++ return (sysctl (mib, 4, kp, &len, NULL, 0) == 0);
++}
++
++/* Implement the "to_info_proc target_ops" method. */
++
++static void
++fbsd_info_proc (struct target_ops *ops, const char *args,
++ enum info_proc_what what)
++{
++#ifdef HAVE_KINFO_GETFILE
++ gdb::unique_xmalloc_ptr<struct kinfo_file> fdtbl;
++ int nfd = 0;
++#endif
++ struct kinfo_proc kp;
++ char *tmp;
++ pid_t pid;
++ bool do_cmdline = false;
++ bool do_cwd = false;
++ bool do_exe = false;
++#ifdef HAVE_KINFO_GETVMMAP
++ bool do_mappings = false;
++#endif
++ bool do_status = false;
++
++ switch (what)
++ {
++ case IP_MINIMAL:
++ do_cmdline = true;
++ do_cwd = true;
++ do_exe = true;
++ break;
++#ifdef HAVE_KINFO_GETVMMAP
++ case IP_MAPPINGS:
++ do_mappings = true;
++ break;
++#endif
++ case IP_STATUS:
++ case IP_STAT:
++ do_status = true;
++ break;
++ case IP_CMDLINE:
++ do_cmdline = true;
++ break;
++ case IP_EXE:
++ do_exe = true;
++ break;
++ case IP_CWD:
++ do_cwd = true;
++ break;
++ case IP_ALL:
++ do_cmdline = true;
++ do_cwd = true;
++ do_exe = true;
++#ifdef HAVE_KINFO_GETVMMAP
++ do_mappings = true;
++#endif
++ do_status = true;
++ break;
++ default:
++ error (_("Not supported on this target."));
++ }
++
++ gdb_argv built_argv (args);
++ if (built_argv.count () == 0)
++ {
++ pid = ptid_get_pid (inferior_ptid);
++ if (pid == 0)
++ error (_("No current process: you must name one."));
++ }
++ else if (built_argv.count () == 1 && isdigit (built_argv[0][0]))
++ pid = strtol (built_argv[0], NULL, 10);
++ else
++ error (_("Invalid arguments."));
++
++ printf_filtered (_("process %d\n"), pid);
++#ifdef HAVE_KINFO_GETFILE
++ if (do_cwd || do_exe)
++ fdtbl.reset (kinfo_getfile (pid, &nfd));
++#endif
++
++ if (do_cmdline)
++ {
++ gdb::unique_xmalloc_ptr<char> cmdline = fbsd_fetch_cmdline (pid);
++ if (cmdline != nullptr)
++ printf_filtered ("cmdline = '%s'\n", cmdline.get ());
++ else
++ warning (_("unable to fetch command line"));
++ }
++ if (do_cwd)
++ {
++ const char *cwd = NULL;
++#ifdef HAVE_KINFO_GETFILE
++ struct kinfo_file *kf = fdtbl.get ();
++ for (int i = 0; i < nfd; i++, kf++)
++ {
++ if (kf->kf_type == KF_TYPE_VNODE && kf->kf_fd == KF_FD_TYPE_CWD)
++ {
++ cwd = kf->kf_path;
++ break;
++ }
++ }
++#endif
++ if (cwd != NULL)
++ printf_filtered ("cwd = '%s'\n", cwd);
++ else
++ warning (_("unable to fetch current working directory"));
++ }
++ if (do_exe)
++ {
++ const char *exe = NULL;
++#ifdef HAVE_KINFO_GETFILE
++ struct kinfo_file *kf = fdtbl.get ();
++ for (int i = 0; i < nfd; i++, kf++)
++ {
++ if (kf->kf_type == KF_TYPE_VNODE && kf->kf_fd == KF_FD_TYPE_TEXT)
++ {
++ exe = kf->kf_path;
++ break;
++ }
++ }
++#endif
++ if (exe == NULL)
++ exe = fbsd_pid_to_exec_file (ops, pid);
++ if (exe != NULL)
++ printf_filtered ("exe = '%s'\n", exe);
++ else
++ warning (_("unable to fetch executable path name"));
++ }
++#ifdef HAVE_KINFO_GETVMMAP
++ if (do_mappings)
++ {
++ int nvment;
++ gdb::unique_xmalloc_ptr<struct kinfo_vmentry>
++ vmentl (kinfo_getvmmap (pid, &nvment));
++
++ if (vmentl != nullptr)
++ {
++ printf_filtered (_("Mapped address spaces:\n\n"));
++#ifdef __LP64__
++ printf_filtered (" %18s %18s %10s %10s %9s %s\n",
++ "Start Addr",
++ " End Addr",
++ " Size", " Offset", "Flags ", "File");
++#else
++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
++ "Start Addr",
++ " End Addr",
++ " Size", " Offset", "Flags ", "File");
++#endif
++
++ struct kinfo_vmentry *kve = vmentl.get ();
++ for (int i = 0; i < nvment; i++, kve++)
++ {
++ ULONGEST start, end;
++
++ start = kve->kve_start;
++ end = kve->kve_end;
++#ifdef __LP64__
++ printf_filtered (" %18s %18s %10s %10s %9s %s\n",
++ hex_string (start),
++ hex_string (end),
++ hex_string (end - start),
++ hex_string (kve->kve_offset),
++ fbsd_vm_map_entry_flags (kve->kve_flags,
++ kve->kve_protection),
++ kve->kve_path);
++#else
++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
++ hex_string (start),
++ hex_string (end),
++ hex_string (end - start),
++ hex_string (kve->kve_offset),
++ fbsd_vm_map_entry_flags (kve->kve_flags,
++ kve->kve_protection),
++ kve->kve_path);
++#endif
++ }
++ }
++ else
++ warning (_("unable to fetch virtual memory map"));
++ }
++#endif
++ if (do_status)
++ {
++ if (!fbsd_fetch_kinfo_proc (pid, &kp))
++ warning (_("Failed to fetch process information"));
++ else
++ {
++ const char *state;
++ int pgtok;
++
++ printf_filtered ("Name: %s\n", kp.ki_comm);
++ switch (kp.ki_stat)
++ {
++ case SIDL:
++ state = "I (idle)";
++ break;
++ case SRUN:
++ state = "R (running)";
++ break;
++ case SSTOP:
++ state = "T (stopped)";
++ break;
++ case SZOMB:
++ state = "Z (zombie)";
++ break;
++ case SSLEEP:
++ state = "S (sleeping)";
++ break;
++ case SWAIT:
++ state = "W (interrupt wait)";
++ break;
++ case SLOCK:
++ state = "L (blocked on lock)";
++ break;
++ default:
++ state = "? (unknown)";
++ break;
++ }
++ printf_filtered ("State: %s\n", state);
++ printf_filtered ("Parent process: %d\n", kp.ki_ppid);
++ printf_filtered ("Process group: %d\n", kp.ki_pgid);
++ printf_filtered ("Session id: %d\n", kp.ki_sid);
++ printf_filtered ("TTY: %ju\n", (uintmax_t) kp.ki_tdev);
++ printf_filtered ("TTY owner process group: %d\n", kp.ki_tpgid);
++ printf_filtered ("User IDs (real, effective, saved): %d %d %d\n",
++ kp.ki_ruid, kp.ki_uid, kp.ki_svuid);
++ printf_filtered ("Group IDs (real, effective, saved): %d %d %d\n",
++ kp.ki_rgid, kp.ki_groups[0], kp.ki_svgid);
++ printf_filtered ("Groups: ");
++ for (int i = 0; i < kp.ki_ngroups; i++)
++ printf_filtered ("%d ", kp.ki_groups[i]);
++ printf_filtered ("\n");
++ printf_filtered ("Minor faults (no memory page): %ld\n",
++ kp.ki_rusage.ru_minflt);
++ printf_filtered ("Minor faults, children: %ld\n",
++ kp.ki_rusage_ch.ru_minflt);
++ printf_filtered ("Major faults (memory page faults): %ld\n",
++ kp.ki_rusage.ru_majflt);
++ printf_filtered ("Major faults, children: %ld\n",
++ kp.ki_rusage_ch.ru_majflt);
++ printf_filtered ("utime: %jd.%06ld\n",
++ (intmax_t) kp.ki_rusage.ru_utime.tv_sec,
++ kp.ki_rusage.ru_utime.tv_usec);
++ printf_filtered ("stime: %jd.%06ld\n",
++ (intmax_t) kp.ki_rusage.ru_stime.tv_sec,
++ kp.ki_rusage.ru_stime.tv_usec);
++ printf_filtered ("utime, children: %jd.%06ld\n",
++ (intmax_t) kp.ki_rusage_ch.ru_utime.tv_sec,
++ kp.ki_rusage_ch.ru_utime.tv_usec);
++ printf_filtered ("stime, children: %jd.%06ld\n",
++ (intmax_t) kp.ki_rusage_ch.ru_stime.tv_sec,
++ kp.ki_rusage_ch.ru_stime.tv_usec);
++ printf_filtered ("'nice' value: %d\n", kp.ki_nice);
++ printf_filtered ("Start time: %jd.%06ld\n", kp.ki_start.tv_sec,
++ kp.ki_start.tv_usec);
++ pgtok = getpagesize () / 1024;
++ printf_filtered ("Virtual memory size: %ju kB\n",
++ (uintmax_t) kp.ki_size / 1024);
++ printf_filtered ("Data size: %ju kB\n",
++ (uintmax_t) kp.ki_dsize * pgtok);
++ printf_filtered ("Stack size: %ju kB\n",
++ (uintmax_t) kp.ki_ssize * pgtok);
++ printf_filtered ("Text size: %ju kB\n",
++ (uintmax_t) kp.ki_tsize * pgtok);
++ printf_filtered ("Resident set size: %ju kB\n",
++ (uintmax_t) kp.ki_rssize * pgtok);
++ printf_filtered ("Maximum RSS: %ju kB\n",
++ (uintmax_t) kp.ki_rusage.ru_maxrss);
++ printf_filtered ("Pending Signals: ");
++ for (int i = 0; i < _SIG_WORDS; i++)
++ printf_filtered ("%08x ", kp.ki_siglist.__bits[i]);
++ printf_filtered ("\n");
++ printf_filtered ("Ignored Signals: ");
++ for (int i = 0; i < _SIG_WORDS; i++)
++ printf_filtered ("%08x ", kp.ki_sigignore.__bits[i]);
++ printf_filtered ("\n");
++ printf_filtered ("Caught Signals: ");
++ for (int i = 0; i < _SIG_WORDS; i++)
++ printf_filtered ("%08x ", kp.ki_sigcatch.__bits[i]);
++ printf_filtered ("\n");
++ }
++ }
++}
++
+ #ifdef KERN_PROC_AUXV
+ static enum target_xfer_status (*super_xfer_partial) (struct target_ops *ops,
+ enum target_object object,
+@@ -455,26 +782,6 @@ show_fbsd_lwp_debug (struct ui_file *file, int from_tty,
+ fprintf_filtered (file, _("Debugging of FreeBSD lwp module is %s.\n"), value);
+ }
+
+-#if defined(TDP_RFPPWAIT) || defined(HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME)
+-/* Fetch the external variant of the kernel's internal process
+- structure for the process PID into KP. */
+-
+-static void
+-fbsd_fetch_kinfo_proc (pid_t pid, struct kinfo_proc *kp)
+-{
+- size_t len;
+- int mib[4];
+-
+- len = sizeof *kp;
+- mib[0] = CTL_KERN;
+- mib[1] = KERN_PROC;
+- mib[2] = KERN_PROC_PID;
+- mib[3] = pid;
+- if (sysctl (mib, 4, kp, &len, NULL, 0) == -1)
+- perror_with_name (("sysctl"));
+-}
+-#endif
+-
+ /*
+ FreeBSD's first thread support was via a "reentrant" version of libc
+ (libc_r) that first shipped in 2.2.7. This library multiplexed all
+@@ -560,7 +867,8 @@ fbsd_thread_name (struct target_ops *self, struct thread_info *thr)
+ /* Note that ptrace_lwpinfo returns the process command in pl_tdname
+ if a name has not been set explicitly. Return a NULL name in
+ that case. */
+- fbsd_fetch_kinfo_proc (pid, &kp);
++ if (!fbsd_fetch_kinfo_proc (pid, &kp))
++ perror_with_name (_("Failed to fetch process information"));
+ if (ptrace (PT_LWPINFO, lwp, (caddr_t) &pl, sizeof pl) == -1)
+ perror_with_name (("ptrace"));
+ if (strcmp (kp.ki_comm, pl.pl_tdname) == 0)
+@@ -970,9 +1278,13 @@ fbsd_wait (struct target_ops *ops,
+ #ifndef PTRACE_VFORK
+ /* For vfork, the child process will have the P_PPWAIT
+ flag set. */
+- fbsd_fetch_kinfo_proc (child, &kp);
+- if (kp.ki_flag & P_PPWAIT)
+- ourstatus->kind = TARGET_WAITKIND_VFORKED;
++ if (fbsd_fetch_kinfo_proc (child, &kp))
++ {
++ if (kp.ki_flag & P_PPWAIT)
++ ourstatus->kind = TARGET_WAITKIND_VFORKED;
++ }
++ else
++ warning (_("Failed to fetch process information"));
+ #endif
+ ourstatus->value.related_pid = child_ptid;
+
+@@ -1176,6 +1488,7 @@ fbsd_nat_add_target (struct target_ops *t)
+ {
+ t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+ t->to_find_memory_regions = fbsd_find_memory_regions;
++ t->to_info_proc = fbsd_info_proc;
+ #ifdef KERN_PROC_AUXV
+ super_xfer_partial = t->to_xfer_partial;
+ t->to_xfer_partial = fbsd_xfer_partial;
Index: head/devel/gdb/files/commit-a181c0bf74
===================================================================
--- head/devel/gdb/files/commit-a181c0bf74
+++ head/devel/gdb/files/commit-a181c0bf74
@@ -1,79 +0,0 @@
-commit a181c0bf74
-Author: John Baldwin <jhb@FreeBSD.org>
-Date: Mon Oct 9 09:54:42 2017 -0700
-
- Use gdbarch_long_bit to determine layout of FreeBSD siginfo_t.
-
- FreeBSD architectures are either ILP32 or LP64 resulting in two
- different layouts for siginfo_t. Previously, the 'bits_per_word'
- member of bfd_arch_info was used to determine the layout to use for a
- given FreeBSD architecture. However, mipsn32 architectures inherit
- from a 64-bit mips architecture where bits_per_word is 64. As a
- result, $_siginfo was not properly extracted from FreeBSD/mipsn32 core
- dumps. Fix this by using gdbarch_long_bit instead of 'bits_per_word'
- to determine if a FreeBSD architecture is ILP32 or LP64.
-
- gdb/ChangeLog:
-
- * fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit.
- (fbsd_convert_siginfo): Likewise.
- * fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise.
-
-diff --git gdb/ChangeLog gdb/ChangeLog
-index 7c8c6e4fe5..b04da8bd44 100644
---- gdb/ChangeLog
-+++ gdb/ChangeLog
-@@ -1,3 +1,9 @@
-+2017-10-09 John Baldwin <jhb@FreeBSD.org>
-+
-+ * fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit.
-+ (fbsd_convert_siginfo): Likewise.
-+ * fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise.
-+
- 2017-10-09 Simon Marchi <simon.marchi@polymtl.ca>
-
- * configure.ac (try_guile_versions): Remove guile-2.2.
-diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
-index 5ad0dda5b4..265175a769 100644
---- gdb/fbsd-nat.c
-+++ gdb/fbsd-nat.c
-@@ -279,7 +279,7 @@ fbsd_siginfo_size ()
- 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)
-+ if (gdbarch_long_bit (gdbarch) == 32)
- return sizeof (struct siginfo32);
- #endif
- return sizeof (siginfo_t);
-@@ -296,7 +296,7 @@ fbsd_convert_siginfo (siginfo_t *si)
- 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)
-+ if (gdbarch_long_bit (gdbarch) != 32)
- return;
-
- struct siginfo32 si32;
-diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
-index fa4cd912ef..fa70f7c20b 100644
---- gdb/fbsd-tdep.c
-+++ gdb/fbsd-tdep.c
-@@ -143,7 +143,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
- {
- size_t siginfo_size;
-
-- if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
-+ if (gdbarch_long_bit (gdbarch) == 32)
- siginfo_size = SIZE32_SIGINFO_T;
- else
- siginfo_size = SIZE64_SIGINFO_T;
-@@ -168,7 +168,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
- len = siginfo_size - offset;
-
- ULONGEST siginfo_offset;
-- if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
-+ if (gdbarch_long_bit (gdbarch) == 32)
- siginfo_offset = LWPINFO_OFFSET + LWPINFO32_PL_SIGINFO;
- else
- siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO;
Index: head/devel/gdb/files/commit-a80a647180
===================================================================
--- head/devel/gdb/files/commit-a80a647180
+++ head/devel/gdb/files/commit-a80a647180
@@ -1,53 +0,0 @@
-commit a80a647180bf92692e0f01efe7b323afe7d317c9
-Author: John Baldwin <jhb@FreeBSD.org>
-Date: Thu Oct 5 09:50:01 2017 -0700
-
- Add a signal frame unwinder for FreeBSD/mipsn32.
-
- The N32 signal frame uses an identical layout to N64, so reuse the N64
- handler. The N32 signal trampoline does use one different instruction
- relative to N64, so a separate tramp_frame is required.
-
- gdb/ChangeLog:
-
- * mips-fbsd-tdep.c (MIPS_INST_ADDIU_A0_SP_N32): Define.
- (mipsn32_fbsd_sigframe): Define.
- (mips_fbsd_init_abi): Install mipsn32_fbsd_sigframe unwinder
- for FreeBSD/mipsn32.
-
-diff --git gdb/mips-fbsd-tdep.c gdb/mips-fbsd-tdep.c
-index 05545e37d8..b1578d0cbb 100644
---- gdb/mips-fbsd-tdep.c
-+++ gdb/mips-fbsd-tdep.c
-@@ -426,6 +426,23 @@ mips64_fbsd_sigframe_init (const struct tramp_frame *self,
- trad_frame_set_id (cache, frame_id_build (sp, func));
- }
-
-+#define MIPS_INST_ADDIU_A0_SP_N32 (0x27a40000 \
-+ + N64_SIGFRAME_UCONTEXT_OFFSET)
-+
-+static const struct tramp_frame mipsn32_fbsd_sigframe =
-+{
-+ SIGTRAMP_FRAME,
-+ MIPS_INSN32_SIZE,
-+ {
-+ { MIPS_INST_ADDIU_A0_SP_N32, -1 }, /* addiu a0, sp, SIGF_UC */
-+ { MIPS_INST_LI_V0_SIGRETURN, -1 }, /* li v0, SYS_sigreturn */
-+ { MIPS_INST_SYSCALL, -1 }, /* syscall */
-+ { MIPS_INST_BREAK, -1 }, /* break */
-+ { TRAMP_SENTINEL_INSN, -1 }
-+ },
-+ mips64_fbsd_sigframe_init
-+};
-+
- #define MIPS_INST_DADDIU_A0_SP_N64 (0x67a40000 \
- + N64_SIGFRAME_UCONTEXT_OFFSET)
-
-@@ -519,6 +536,7 @@ mips_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
- tramp_frame_prepend_unwinder (gdbarch, &mips_fbsd_sigframe);
- break;
- case MIPS_ABI_N32:
-+ tramp_frame_prepend_unwinder (gdbarch, &mipsn32_fbsd_sigframe);
- break;
- case MIPS_ABI_N64:
- tramp_frame_prepend_unwinder (gdbarch, &mips64_fbsd_sigframe);
Index: head/devel/gdb/files/commit-b30ff123fb
===================================================================
--- head/devel/gdb/files/commit-b30ff123fb
+++ head/devel/gdb/files/commit-b30ff123fb
@@ -1,40 +0,0 @@
-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
Index: head/devel/gdb/files/commit-b5430a3ced
===================================================================
--- head/devel/gdb/files/commit-b5430a3ced
+++ head/devel/gdb/files/commit-b5430a3ced
@@ -1,117 +0,0 @@
-commit b5430a3ced5fe5ba484bd9b3215b9ae19ced0160
-Author: John Baldwin <jhb@FreeBSD.org>
-Date: Thu Jun 1 09:40:46 2017 -0700
-
- Use the ELF class to determine the word size for FreeBSD core notes.
-
- FreeBSD ELF cores contain data structures with that have two different
- layouts: one for ILP32 platforms and a second for LP64 platforms.
- Previously, the code used 'bits_per_word' from 'arch_info', but this
- field is not a reliable indicator of the format for FreeBSD MIPS cores
- in particular.
-
- I had originally posted this patch back in November because process
- cores for FreeBSD MIPS contained an e_flags value of 0 in the header
- which resulted in a bfd_arch which always had 'bits_per_word' set to
- 32. This permitted reading o32 cores, but not n64 cores. The feedback
- I received then was to try to change n64 cores to use a different
- default bfd_arch that had a 64-bit 'bits_per_word' when e_flags was zero.
- I submitted a patch to that effect but it was never approved. Instead,
- I changed FreeBSD's kernel and gcore commands to preserve the e_flags
- field from an executable when generating process cores. With a proper
- e_flags field in process cores, n64 cores now use a 64-bit bfd_arch and
- now work fine. However, the change to include e_flags in the process
- cores had the unintended side effect of breaking handling of o32
- process cores. Specifically, FreeBSD MIPS builds o32 with a default
- MIPS architecture of 'mips3', thus FreeBSD process cores with a non-zero
- e_flags match the 'mips3' bfd_arch which has 64 'bits_per_word'.
-
- From this, it seems that 'bits_per_word' for FreeBSD MIPS is not likely
- to ever be completely correct. However, FreeBSD core dumps do
- reliably set the ELF class to ELFCLASS32 for cores using ILP32 and
- ELFCLASS64 for cores using LP64. As such, I think my original patch of
- using the ELF class instead of 'bits_per_word' is probably the simplest
- and most reliable approach for detecting the note structure layout.
-
- bfd/ChangeLog:
-
- * elf.c (elfcore_grok_freebsd_psinfo): Use ELF header class to
- determine structure sizes.
- (elfcore_grok_freebsd_prstatus): Likewise.
-
-diff --git bfd/elf.c bfd/elf.c
-index 863bd61c5f..34d39c547b 100644
---- bfd/elf.c
-+++ bfd/elf.c
-@@ -9814,14 +9814,14 @@ elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note)
- {
- size_t offset;
-
-- switch (abfd->arch_info->bits_per_word)
-+ switch (elf_elfheader (abfd)->e_ident[EI_CLASS])
- {
-- case 32:
-+ case ELFCLASS32:
- if (note->descsz < 108)
- return FALSE;
- break;
-
-- case 64:
-+ case ELFCLASS64:
- if (note->descsz < 120)
- return FALSE;
- break;
-@@ -9836,7 +9836,7 @@ elfcore_grok_freebsd_psinfo (bfd *abfd, Elf_Internal_Note *note)
- offset = 4;
-
- /* Skip over pr_psinfosz. */
-- if (abfd->arch_info->bits_per_word == 32)
-+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS32)
- offset += 4;
- else
- {
-@@ -9879,13 +9879,13 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
- offset = 4;
-
- /* Skip over pr_statussz. */
-- switch (abfd->arch_info->bits_per_word)
-+ switch (elf_elfheader (abfd)->e_ident[EI_CLASS])
- {
-- case 32:
-+ case ELFCLASS32:
- offset += 4;
- break;
-
-- case 64:
-+ case ELFCLASS64:
- offset += 4; /* Padding before pr_statussz. */
- offset += 8;
- break;
-@@ -9895,13 +9895,16 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
- }
-
- /* Extract size of pr_reg from pr_gregsetsz. */
-- if (abfd->arch_info->bits_per_word == 32)
-+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS32)
- size = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
- else
- size = bfd_h_get_64 (abfd, (bfd_byte *) note->descdata + offset);
-
- /* Skip over pr_gregsetsz and pr_fpregsetsz. */
-- offset += (abfd->arch_info->bits_per_word / 8) * 2;
-+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS32)
-+ offset += 4 * 2;
-+ else
-+ offset += 8 * 2;
-
- /* Skip over pr_osreldate. */
- offset += 4;
-@@ -9918,7 +9921,7 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
- offset += 4;
-
- /* Padding before pr_reg. */
-- if (abfd->arch_info->bits_per_word == 64)
-+ if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64)
- offset += 4;
-
- /* Make a ".reg/999" section and a ".reg" section. */
Index: head/devel/gdb/files/commit-b999e2038d
===================================================================
--- head/devel/gdb/files/commit-b999e2038d
+++ head/devel/gdb/files/commit-b999e2038d
@@ -0,0 +1,32 @@
+commit b999e2038dbc54e2c8b1c390f8b8fe50d0f1d10a
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Tue Jan 9 13:35:17 2018 -0800
+
+ Don't return stale data from fbsd_pid_to_exec_file for kernel processes.
+
+ For processes without an associated executable (such as kernel processes),
+ the kern.proc.pathname.<pid> system control node returns a length of zero
+ without modifying the user's buffer. Detect this case and return NULL
+ rather than the previous contents of the static buffer 'buf'.
+
+ gdb/ChangeLog:
+
+ * fbsd-nat.c (fbsd_pid_to_exec_file) [KERN_PROC_PATHNAME]: Return
+ NULL for an empty pathname.
+
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index ec4eed9abe..d0aaf89145 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -63,7 +63,10 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid)
+ mib[3] = pid;
+ buflen = sizeof buf;
+ if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0)
+- return buf;
++ /* The kern.proc.pathname.<pid> sysctl returns a length of zero
++ for processes without an associated executable such as kernel
++ processes. */
++ return buflen == 0 ? NULL : buf;
+ #endif
+
+ xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
Index: head/devel/gdb/files/commit-d2176225dc
===================================================================
--- head/devel/gdb/files/commit-d2176225dc
+++ head/devel/gdb/files/commit-d2176225dc
@@ -0,0 +1,725 @@
+commit d2176225dc982c22640215a0e611e997e8eeb030
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Tue Jan 9 13:35:17 2018 -0800
+
+ Support 'info proc' for FreeBSD process core dumps.
+
+ - Command line arguments are obtained from the pr_psargs[] array
+ saved in the NT_PRPSINFO note.
+ - The 'cwd' and 'exe' values are obtained from the per-process file
+ descriptor table stored in the NT_PROCSTAT_FILES core note.
+ - 'mappings' is implemented by walking the array of VM map entries
+ stored in the NT_PROCSTAT_VMMAP core note.
+ - 'status' output is generated by outputting fields from
+ the first structure stored in the NT_PROCSTAT_PROC core note.
+ - 'stat' is aliased to 'status'.
+
+ gdb/ChangeLog:
+
+ * fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
+ (KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
+ (KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
+ (KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
+ (KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
+ (KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
+ (KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
+ (KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
+ (kinfo_proc_layout_32, kinfo_proc_layout_i386)
+ (kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
+ (fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
+ (fbsd_core_fetch_timeval, fbsd_print_sigset)
+ (fbsd_core_info_proc_status, fbsd_core_info_proc): New.
+ (fbsd_init_abi): Install gdbarch "core_info_proc" method.
+ * fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
+
+diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c
+index ce17c672d9..8aa0243d54 100644
+--- gdb/fbsd-tdep.c
++++ gdb/fbsd-tdep.c
+@@ -52,6 +52,228 @@
+ #define SIZE64_SIGINFO_T 80
+ #define SIZE32_SIGINFO_T 64
+
++/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_VMMAP core
++ dump notes. See <sys/user.h> for the definition of struct
++ kinfo_vmentry. This data structure should have the same layout on
++ all architectures. */
++
++#define KVE_STRUCTSIZE 0x0
++#define KVE_START 0x8
++#define KVE_END 0x10
++#define KVE_OFFSET 0x18
++#define KVE_FLAGS 0x2c
++#define KVE_PROTECTION 0x56
++#define KVE_PATH 0x88
++
++/* Flags in the 'kve_protection' field in struct kinfo_vmentry. These
++ match the KVME_PROT_* constants in <sys/user.h>. */
++
++#define KINFO_VME_PROT_READ 0x00000001
++#define KINFO_VME_PROT_WRITE 0x00000002
++#define KINFO_VME_PROT_EXEC 0x00000004
++
++/* Flags in the 'kve_flags' field in struct kinfo_vmentry. These
++ match the KVME_FLAG_* constants in <sys/user.h>. */
++
++#define KINFO_VME_FLAG_COW 0x00000001
++#define KINFO_VME_FLAG_NEEDS_COPY 0x00000002
++#define KINFO_VME_FLAG_NOCOREDUMP 0x00000004
++#define KINFO_VME_FLAG_SUPER 0x00000008
++#define KINFO_VME_FLAG_GROWS_UP 0x00000010
++#define KINFO_VME_FLAG_GROWS_DOWN 0x00000020
++
++/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_FILES core
++ dump notes. See <sys/user.h> for the definition of struct
++ kinfo_file. This data structure should have the same layout on all
++ architectures. */
++
++#define KF_STRUCTSIZE 0x0
++#define KF_TYPE 0x4
++#define KF_FD 0x8
++#define KF_PATH 0x170
++
++/* Constants for the 'kf_type' field in struct kinfo_file. These
++ match the KF_TYPE_* constants in <sys/user.h>. */
++
++#define KINFO_FILE_TYPE_VNODE 1
++
++/* Special values for the 'kf_fd' field in struct kinfo_file. These
++ match the KF_FD_TYPE_* constants in <sys/user.h>. */
++
++#define KINFO_FILE_FD_TYPE_CWD -1
++#define KINFO_FILE_FD_TYPE_TEXT -5
++
++/* Number of 32-bit words in a signal set. This matches _SIG_WORDS in
++ <sys/_sigset.h> and is the same value on all architectures. */
++
++#define SIG_WORDS 4
++
++/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_PROC core
++ dump notes. See <sys/user.h> for the definition of struct
++ kinfo_proc. This data structure has different layouts on different
++ architectures mostly due to ILP32 vs LP64. However, FreeBSD/i386
++ uses a 32-bit time_t while all other architectures use a 64-bit
++ time_t.
++
++ The core dump note actually contains one kinfo_proc structure for
++ each thread, but all of the process-wide data can be obtained from
++ the first structure. One result of this note's format is that some
++ of the process-wide status available in the native target method
++ from the kern.proc.pid.<pid> sysctl such as ki_stat and ki_siglist
++ is not available from a core dump. Instead, the per-thread data
++ structures contain the value of these fields for individual
++ threads. */
++
++struct kinfo_proc_layout
++{
++ /* Offsets of struct kinfo_proc members. */
++ int ki_layout;
++ int ki_pid;
++ int ki_ppid;
++ int ki_pgid;
++ int ki_tpgid;
++ int ki_sid;
++ int ki_tdev_freebsd11;
++ int ki_sigignore;
++ int ki_sigcatch;
++ int ki_uid;
++ int ki_ruid;
++ int ki_svuid;
++ int ki_rgid;
++ int ki_svgid;
++ int ki_ngroups;
++ int ki_groups;
++ int ki_size;
++ int ki_rssize;
++ int ki_tsize;
++ int ki_dsize;
++ int ki_ssize;
++ int ki_start;
++ int ki_nice;
++ int ki_comm;
++ int ki_tdev;
++ int ki_rusage;
++ int ki_rusage_ch;
++
++ /* Offsets of struct rusage members. */
++ int ru_utime;
++ int ru_stime;
++ int ru_maxrss;
++ int ru_minflt;
++ int ru_majflt;
++};
++
++const struct kinfo_proc_layout kinfo_proc_layout_32 =
++ {
++ .ki_layout = 0x4,
++ .ki_pid = 0x28,
++ .ki_ppid = 0x2c,
++ .ki_pgid = 0x30,
++ .ki_tpgid = 0x34,
++ .ki_sid = 0x38,
++ .ki_tdev_freebsd11 = 0x44,
++ .ki_sigignore = 0x68,
++ .ki_sigcatch = 0x78,
++ .ki_uid = 0x88,
++ .ki_ruid = 0x8c,
++ .ki_svuid = 0x90,
++ .ki_rgid = 0x94,
++ .ki_svgid = 0x98,
++ .ki_ngroups = 0x9c,
++ .ki_groups = 0xa0,
++ .ki_size = 0xe0,
++ .ki_rssize = 0xe4,
++ .ki_tsize = 0xec,
++ .ki_dsize = 0xf0,
++ .ki_ssize = 0xf4,
++ .ki_start = 0x118,
++ .ki_nice = 0x145,
++ .ki_comm = 0x17f,
++ .ki_tdev = 0x1f0,
++ .ki_rusage = 0x220,
++ .ki_rusage_ch = 0x278,
++
++ .ru_utime = 0x0,
++ .ru_stime = 0x10,
++ .ru_maxrss = 0x20,
++ .ru_minflt = 0x30,
++ .ru_majflt = 0x34,
++ };
++
++const struct kinfo_proc_layout kinfo_proc_layout_i386 =
++ {
++ .ki_layout = 0x4,
++ .ki_pid = 0x28,
++ .ki_ppid = 0x2c,
++ .ki_pgid = 0x30,
++ .ki_tpgid = 0x34,
++ .ki_sid = 0x38,
++ .ki_tdev_freebsd11 = 0x44,
++ .ki_sigignore = 0x68,
++ .ki_sigcatch = 0x78,
++ .ki_uid = 0x88,
++ .ki_ruid = 0x8c,
++ .ki_svuid = 0x90,
++ .ki_rgid = 0x94,
++ .ki_svgid = 0x98,
++ .ki_ngroups = 0x9c,
++ .ki_groups = 0xa0,
++ .ki_size = 0xe0,
++ .ki_rssize = 0xe4,
++ .ki_tsize = 0xec,
++ .ki_dsize = 0xf0,
++ .ki_ssize = 0xf4,
++ .ki_start = 0x118,
++ .ki_nice = 0x135,
++ .ki_comm = 0x16f,
++ .ki_tdev = 0x1e0,
++ .ki_rusage = 0x210,
++ .ki_rusage_ch = 0x258,
++
++ .ru_utime = 0x0,
++ .ru_stime = 0x8,
++ .ru_maxrss = 0x10,
++ .ru_minflt = 0x20,
++ .ru_majflt = 0x24,
++ };
++
++const struct kinfo_proc_layout kinfo_proc_layout_64 =
++ {
++ .ki_layout = 0x4,
++ .ki_pid = 0x48,
++ .ki_ppid = 0x4c,
++ .ki_pgid = 0x50,
++ .ki_tpgid = 0x54,
++ .ki_sid = 0x58,
++ .ki_tdev_freebsd11 = 0x64,
++ .ki_sigignore = 0x88,
++ .ki_sigcatch = 0x98,
++ .ki_uid = 0xa8,
++ .ki_ruid = 0xac,
++ .ki_svuid = 0xb0,
++ .ki_rgid = 0xb4,
++ .ki_svgid = 0xb8,
++ .ki_ngroups = 0xbc,
++ .ki_groups = 0xc0,
++ .ki_size = 0x100,
++ .ki_rssize = 0x108,
++ .ki_tsize = 0x118,
++ .ki_dsize = 0x120,
++ .ki_ssize = 0x128,
++ .ki_start = 0x150,
++ .ki_nice = 0x185,
++ .ki_comm = 0x1bf,
++ .ki_tdev = 0x230,
++ .ki_rusage = 0x260,
++ .ki_rusage_ch = 0x2f0,
++
++ .ru_utime = 0x0,
++ .ru_stime = 0x10,
++ .ru_maxrss = 0x20,
++ .ru_minflt = 0x40,
++ .ru_majflt = 0x48,
++ };
++
+ static struct gdbarch_data *fbsd_gdbarch_data_handle;
+
+ struct fbsd_gdbarch_data
+@@ -367,6 +589,433 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
+ return note_data;
+ }
+
++/* Helper function to generate mappings flags for a single VM map
++ entry in 'info proc mappings'. */
++
++const char *
++fbsd_vm_map_entry_flags (int kve_flags, int kve_protection)
++{
++ static char vm_flags[9];
++
++ vm_flags[0] = (kve_protection & KINFO_VME_PROT_READ) ? 'r' : '-';
++ vm_flags[1] = (kve_protection & KINFO_VME_PROT_WRITE) ? 'w' : '-';
++ vm_flags[2] = (kve_protection & KINFO_VME_PROT_EXEC) ? 'x' : '-';
++ vm_flags[3] = ' ';
++ vm_flags[4] = (kve_flags & KINFO_VME_FLAG_COW) ? 'C' : '-';
++ vm_flags[5] = (kve_flags & KINFO_VME_FLAG_NEEDS_COPY) ? 'N' : '-';
++ vm_flags[6] = (kve_flags & KINFO_VME_FLAG_SUPER) ? 'S' : '-';
++ vm_flags[7] = (kve_flags & KINFO_VME_FLAG_GROWS_UP) ? 'U'
++ : (kve_flags & KINFO_VME_FLAG_GROWS_DOWN) ? 'D' : '-';
++ vm_flags[8] = '\0';
++
++ return vm_flags;
++}
++
++/* Implement "info proc mappings" for a corefile. */
++
++static void
++fbsd_core_info_proc_mappings (struct gdbarch *gdbarch)
++{
++ asection *section;
++ unsigned char *descdata, *descend;
++ size_t note_size;
++
++ section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.vmmap");
++ if (section == NULL)
++ {
++ warning (_("unable to find mappings in core file"));
++ return;
++ }
++
++ note_size = bfd_get_section_size (section);
++ if (note_size < 4)
++ error (_("malformed core note - too short for header"));
++
++ gdb::def_vector<unsigned char> contents (note_size);
++ if (!bfd_get_section_contents (core_bfd, section, contents.data (),
++ 0, note_size))
++ error (_("could not get core note contents"));
++
++ descdata = contents.data ();
++ descend = descdata + note_size;
++
++ /* Skip over the structure size. */
++ descdata += 4;
++
++ printf_filtered (_("Mapped address spaces:\n\n"));
++ if (gdbarch_addr_bit (gdbarch) == 64)
++ {
++ printf_filtered (" %18s %18s %10s %10s %9s %s\n",
++ "Start Addr",
++ " End Addr",
++ " Size", " Offset", "Flags ", "File");
++ }
++ else
++ {
++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
++ "Start Addr",
++ " End Addr",
++ " Size", " Offset", "Flags ", "File");
++ }
++
++ while (descdata + KVE_PATH < descend)
++ {
++ ULONGEST start, end, offset, flags, prot, structsize;
++
++ structsize = bfd_get_32 (core_bfd, descdata + KVE_STRUCTSIZE);
++ if (structsize < KVE_PATH)
++ error (_("malformed core note - vmmap entry too small"));
++
++ start = bfd_get_64 (core_bfd, descdata + KVE_START);
++ end = bfd_get_64 (core_bfd, descdata + KVE_END);
++ offset = bfd_get_64 (core_bfd, descdata + KVE_OFFSET);
++ flags = bfd_get_32 (core_bfd, descdata + KVE_FLAGS);
++ prot = bfd_get_32 (core_bfd, descdata + KVE_PROTECTION);
++ if (gdbarch_addr_bit (gdbarch) == 64)
++ {
++ printf_filtered (" %18s %18s %10s %10s %9s %s\n",
++ paddress (gdbarch, start),
++ paddress (gdbarch, end),
++ hex_string (end - start),
++ hex_string (offset),
++ fbsd_vm_map_entry_flags (flags, prot),
++ descdata + KVE_PATH);
++ }
++ else
++ {
++ printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
++ paddress (gdbarch, start),
++ paddress (gdbarch, end),
++ hex_string (end - start),
++ hex_string (offset),
++ fbsd_vm_map_entry_flags (flags, prot),
++ descdata + KVE_PATH);
++ }
++
++ descdata += structsize;
++ }
++}
++
++/* Fetch the pathname of a vnode for a single file descriptor from the
++ file table core note. */
++
++static gdb::unique_xmalloc_ptr<char>
++fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd)
++{
++ asection *section;
++ unsigned char *descdata, *descend;
++ size_t note_size;
++
++ section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files");
++ if (section == NULL)
++ return nullptr;
++
++ note_size = bfd_get_section_size (section);
++ if (note_size < 4)
++ error (_("malformed core note - too short for header"));
++
++ gdb::def_vector<unsigned char> contents (note_size);
++ if (!bfd_get_section_contents (core_bfd, section, contents.data (),
++ 0, note_size))
++ error (_("could not get core note contents"));
++
++ descdata = contents.data ();
++ descend = descdata + note_size;
++
++ /* Skip over the structure size. */
++ descdata += 4;
++
++ while (descdata + KVE_PATH < descend)
++ {
++ ULONGEST structsize;
++
++ structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE);
++ if (structsize < KVE_PATH)
++ error (_("malformed core note - vmmap entry too small"));
++
++ if (bfd_get_32 (core_bfd, descdata + KF_TYPE) == KINFO_FILE_TYPE_VNODE
++ && bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd)
++ {
++ char *path = (char *) descdata + KF_PATH;
++ return gdb::unique_xmalloc_ptr<char> (xstrdup (path));
++ }
++
++ descdata += structsize;
++ }
++ return nullptr;
++}
++
++/* Helper function to read a struct timeval. */
++
++static void
++fbsd_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data,
++ LONGEST &sec, ULONGEST &usec)
++{
++ if (gdbarch_addr_bit (gdbarch) == 64)
++ {
++ sec = bfd_get_signed_64 (core_bfd, data);
++ usec = bfd_get_64 (core_bfd, data + 8);
++ }
++ else if (bfd_get_arch (core_bfd) == bfd_arch_i386)
++ {
++ sec = bfd_get_signed_32 (core_bfd, data);
++ usec = bfd_get_32 (core_bfd, data + 4);
++ }
++ else
++ {
++ sec = bfd_get_signed_64 (core_bfd, data);
++ usec = bfd_get_32 (core_bfd, data + 8);
++ }
++}
++
++/* Print out the contents of a signal set. */
++
++static void
++fbsd_print_sigset (const char *descr, unsigned char *sigset)
++{
++ printf_filtered ("%s: ", descr);
++ for (int i = 0; i < SIG_WORDS; i++)
++ printf_filtered ("%08x ",
++ (unsigned int) bfd_get_32 (core_bfd, sigset + i * 4));
++ printf_filtered ("\n");
++}
++
++/* Implement "info proc status" for a corefile. */
++
++static void
++fbsd_core_info_proc_status (struct gdbarch *gdbarch)
++{
++ const struct kinfo_proc_layout *kp;
++ asection *section;
++ const char *state;
++ unsigned char *descdata;
++ int addr_bit, long_bit;
++ size_t note_size;
++ ULONGEST value;
++ LONGEST sec;
++
++ section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.proc");
++ if (section == NULL)
++ {
++ warning (_("unable to find process info in core file"));
++ return;
++ }
++
++ addr_bit = gdbarch_addr_bit (gdbarch);
++ if (addr_bit == 64)
++ kp = &kinfo_proc_layout_64;
++ else if (bfd_get_arch (core_bfd) == bfd_arch_i386)
++ kp = &kinfo_proc_layout_i386;
++ else
++ kp = &kinfo_proc_layout_32;
++ long_bit = gdbarch_long_bit (gdbarch);
++
++ /*
++ * Ensure that the note is large enough for all of the fields fetched
++ * by this function. In particular, the note must contain the 32-bit
++ * structure size, then it must be long enough to access the last
++ * field used (ki_rusage_ch.ru_majflt) which is the size of a long.
++ */
++ note_size = bfd_get_section_size (section);
++ if (note_size < (4 + kp->ki_rusage_ch + kp->ru_majflt
++ + long_bit / TARGET_CHAR_BIT))
++ error (_("malformed core note - too short"));
++
++ gdb::def_vector<unsigned char> contents (note_size);
++ if (!bfd_get_section_contents (core_bfd, section, contents.data (),
++ 0, note_size))
++ error (_("could not get core note contents"));
++
++ descdata = contents.data ();
++
++ /* Skip over the structure size. */
++ descdata += 4;
++
++ /* Verify 'ki_layout' is 0. */
++ if (bfd_get_32 (core_bfd, descdata + kp->ki_layout) != 0)
++ {
++ warning (_("unsupported process information in core file"));
++ return;
++ }
++
++ printf_filtered ("Name: %.19s\n", descdata + kp->ki_comm);
++ printf_filtered ("Process ID: %s\n",
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pid)));
++ printf_filtered ("Parent process: %s\n",
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ppid)));
++ printf_filtered ("Process group: %s\n",
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pgid)));
++ printf_filtered ("Session id: %s\n",
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_sid)));
++
++ /* FreeBSD 12.0 and later store a 64-bit dev_t at 'ki_tdev'. Older
++ kernels store a 32-bit dev_t at 'ki_tdev_freebsd11'. In older
++ kernels the 64-bit 'ki_tdev' field is in a reserved section of
++ the structure that is cleared to zero. Assume that a zero value
++ in ki_tdev indicates a core dump from an older kernel and use the
++ value in 'ki_tdev_freebsd11' instead. */
++ value = bfd_get_64 (core_bfd, descdata + kp->ki_tdev);
++ if (value == 0)
++ value = bfd_get_32 (core_bfd, descdata + kp->ki_tdev_freebsd11);
++ printf_filtered ("TTY: %s\n", pulongest (value));
++ printf_filtered ("TTY owner process group: %s\n",
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_tpgid)));
++ printf_filtered ("User IDs (real, effective, saved): %s %s %s\n",
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ruid)),
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_uid)),
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svuid)));
++ printf_filtered ("Group IDs (real, effective, saved): %s %s %s\n",
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_rgid)),
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_groups)),
++ pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svgid)));
++ printf_filtered ("Groups: ");
++ uint16_t ngroups = bfd_get_16 (core_bfd, descdata + kp->ki_ngroups);
++ for (int i = 0; i < ngroups; i++)
++ printf_filtered ("%s ",
++ pulongest (bfd_get_32 (core_bfd,
++ descdata + kp->ki_groups + i * 4)));
++ printf_filtered ("\n");
++ value = bfd_get (long_bit, core_bfd,
++ descdata + kp->ki_rusage + kp->ru_minflt);
++ printf_filtered ("Minor faults (no memory page): %s\n", pulongest (value));
++ value = bfd_get (long_bit, core_bfd,
++ descdata + kp->ki_rusage_ch + kp->ru_minflt);
++ printf_filtered ("Minor faults, children: %s\n", pulongest (value));
++ value = bfd_get (long_bit, core_bfd,
++ descdata + kp->ki_rusage + kp->ru_majflt);
++ printf_filtered ("Major faults (memory page faults): %s\n",
++ pulongest (value));
++ value = bfd_get (long_bit, core_bfd,
++ descdata + kp->ki_rusage_ch + kp->ru_majflt);
++ printf_filtered ("Major faults, children: %s\n", pulongest (value));
++ fbsd_core_fetch_timeval (gdbarch,
++ descdata + kp->ki_rusage + kp->ru_utime,
++ sec, value);
++ printf_filtered ("utime: %s.%06d\n", plongest (sec), (int) value);
++ fbsd_core_fetch_timeval (gdbarch,
++ descdata + kp->ki_rusage + kp->ru_stime,
++ sec, value);
++ printf_filtered ("stime: %s.%06d\n", plongest (sec), (int) value);
++ fbsd_core_fetch_timeval (gdbarch,
++ descdata + kp->ki_rusage_ch + kp->ru_utime,
++ sec, value);
++ printf_filtered ("utime, children: %s.%06d\n", plongest (sec), (int) value);
++ fbsd_core_fetch_timeval (gdbarch,
++ descdata + kp->ki_rusage_ch + kp->ru_stime,
++ sec, value);
++ printf_filtered ("stime, children: %s.%06d\n", plongest (sec), (int) value);
++ printf_filtered ("'nice' value: %d\n",
++ bfd_get_signed_8 (core_bfd, descdata + kp->ki_nice));
++ fbsd_core_fetch_timeval (gdbarch, descdata + kp->ki_start, sec, value);
++ printf_filtered ("Start time: %s.%06d\n", plongest (sec), (int) value);
++ printf_filtered ("Virtual memory size: %s kB\n",
++ pulongest (bfd_get (addr_bit, core_bfd,
++ descdata + kp->ki_size) / 1024));
++ printf_filtered ("Data size: %s pages\n",
++ pulongest (bfd_get (addr_bit, core_bfd,
++ descdata + kp->ki_dsize)));
++ printf_filtered ("Stack size: %s pages\n",
++ pulongest (bfd_get (addr_bit, core_bfd,
++ descdata + kp->ki_ssize)));
++ printf_filtered ("Text size: %s pages\n",
++ pulongest (bfd_get (addr_bit, core_bfd,
++ descdata + kp->ki_tsize)));
++ printf_filtered ("Resident set size: %s pages\n",
++ pulongest (bfd_get (addr_bit, core_bfd,
++ descdata + kp->ki_rssize)));
++ printf_filtered ("Maximum RSS: %s pages\n",
++ pulongest (bfd_get (long_bit, core_bfd,
++ descdata + kp->ki_rusage
++ + kp->ru_maxrss)));
++ fbsd_print_sigset ("Ignored Signals", descdata + kp->ki_sigignore);
++ fbsd_print_sigset ("Caught Signals", descdata + kp->ki_sigcatch);
++}
++
++/* Implement the "core_info_proc" gdbarch method. */
++
++static void
++fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args,
++ enum info_proc_what what)
++{
++ bool do_cmdline = false;
++ bool do_cwd = false;
++ bool do_exe = false;
++ bool do_mappings = false;
++ bool do_status = false;
++ int pid;
++
++ switch (what)
++ {
++ case IP_MINIMAL:
++ do_cmdline = true;
++ do_cwd = true;
++ do_exe = true;
++ break;
++ case IP_MAPPINGS:
++ do_mappings = true;
++ break;
++ case IP_STATUS:
++ case IP_STAT:
++ do_status = true;
++ break;
++ case IP_CMDLINE:
++ do_cmdline = true;
++ break;
++ case IP_EXE:
++ do_exe = true;
++ break;
++ case IP_CWD:
++ do_cwd = true;
++ break;
++ case IP_ALL:
++ do_cmdline = true;
++ do_cwd = true;
++ do_exe = true;
++ do_mappings = true;
++ do_status = true;
++ break;
++ default:
++ return;
++ }
++
++ pid = bfd_core_file_pid (core_bfd);
++ if (pid != 0)
++ printf_filtered (_("process %d\n"), pid);
++
++ if (do_cmdline)
++ {
++ const char *cmdline;
++
++ cmdline = bfd_core_file_failing_command (core_bfd);
++ if (cmdline)
++ printf_filtered ("cmdline = '%s'\n", cmdline);
++ else
++ warning (_("Command line unavailable"));
++ }
++ if (do_cwd)
++ {
++ gdb::unique_xmalloc_ptr<char> cwd =
++ fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_CWD);
++ if (cwd)
++ printf_filtered ("cwd = '%s'\n", cwd.get ());
++ else
++ warning (_("unable to read current working directory"));
++ }
++ if (do_exe)
++ {
++ gdb::unique_xmalloc_ptr<char> exe =
++ fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_TEXT);
++ if (exe)
++ printf_filtered ("exe = '%s'\n", exe.get ());
++ else
++ warning (_("unable to read executable path name"));
++ }
++ if (do_mappings)
++ fbsd_core_info_proc_mappings (gdbarch);
++ if (do_status)
++ fbsd_core_info_proc_status (gdbarch);
++}
++
+ /* Print descriptions of FreeBSD-specific AUXV entries to FILE. */
+
+ static void
+@@ -519,6 +1168,7 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ 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_core_info_proc (gdbarch, fbsd_core_info_proc);
+ set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry);
+ set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type);
+
+diff --git gdb/fbsd-tdep.h gdb/fbsd-tdep.h
+index 9769903dec..0b293e5a25 100644
+--- gdb/fbsd-tdep.h
++++ gdb/fbsd-tdep.h
+@@ -22,4 +22,11 @@
+
+ extern void fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
+
++/* Helper function to generate mappings flags for a single VM map
++ entry in 'info proc mappings'. The KVE_FLAGS and KVE_PROTECTION
++ parameters should contain the values of the corresponding fields in
++ a 'struct kinfo_vmentry'. */
++
++extern const char *fbsd_vm_map_entry_flags (int kve_flags, int kve_protection);
++
+ #endif /* fbsd-tdep.h */
Index: head/devel/gdb/files/commit-e6f3b9c319
===================================================================
--- head/devel/gdb/files/commit-e6f3b9c319
+++ head/devel/gdb/files/commit-e6f3b9c319
@@ -1,25 +0,0 @@
-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;
- }
Index: head/devel/gdb/files/commit-f169cfdc08
===================================================================
--- head/devel/gdb/files/commit-f169cfdc08
+++ head/devel/gdb/files/commit-f169cfdc08
@@ -0,0 +1,84 @@
+commit f169cfdc08761a3d9fcd587ad8661102672403ec
+Author: John Baldwin <jhb@FreeBSD.org>
+Date: Tue Oct 24 21:06:00 2017 -0700
+
+ Workaround a FreeBSD ptrace() bug with clearing thread events.
+
+ When multiple threads within a process wish to report STOPPED events
+ from wait(), the kernel picks one thread event as the thread event to
+ report. The chosen thread event is retrieved via PT_LWPINFO by
+ passing the process ID as the request pid. If multiple events are
+ pending, then the subsequent wait() after resuming a process will
+ report another STOPPED event after resuming the process to handle the
+ next thread event and so on.
+
+ A single thread event is cleared as a side effect of resuming the
+ process with PT_CONTINUE, PT_STEP, etc. In older kernels, however,
+ the request pid was used to select which thread's event was cleared
+ rather than always clearing the event that was just reported. To
+ avoid clearing the event of the wrong LWP, always pass the process ID
+ instead of an LWP ID to PT_CONTINUE or PT_SYSCALL.
+
+ In the case of stepping, the process ID cannot be used with PT_STEP
+ since it would step the thread that reported an event which may not be
+ the thread indicated by PTID. For stepping, use PT_SETSTEP to enable
+ stepping on the desired thread before resuming the process via
+ PT_CONTINUE instead of using PT_STEP.
+
+ This manifested as a failure in the
+ gdb.threads/continue-pending-status.exp test. Specifically, if thread
+ 2 reported a breakpoint and the test thus switched to thread 3 before
+ continuing, thread 3's event (if any) was discarded and thread 2's
+ breakpoint remained pending and was reported a second time as a
+ duplicate event. As a result, the PC was decremented twice for the
+ same breakpoint resulting in an illegal instruction fault on x86.
+
+ gdb/ChangeLog:
+
+ * fbsd-nat.c (fbsd_resume): Use PT_SETSTEP for stepping and a
+ wildcard process pid for super_resume for kernels with a
+ specific bug.
+
+diff --git gdb/fbsd-nat.c gdb/fbsd-nat.c
+index b352418813..3a216abf18 100644
+--- gdb/fbsd-nat.c
++++ gdb/fbsd-nat.c
+@@ -1143,6 +1143,38 @@ fbsd_resume (struct target_ops *ops,
+ }
+ ptid = inferior_ptid;
+ }
++
++#if __FreeBSD_version < 1200052
++ /* When multiple threads within a process wish to report STOPPED
++ events from wait(), the kernel picks one thread event as the
++ thread event to report. The chosen thread event is retrieved via
++ PT_LWPINFO by passing the process ID as the request pid. If
++ multiple events are pending, then the subsequent wait() after
++ resuming a process will report another STOPPED event after
++ resuming the process to handle the next thread event and so on.
++
++ A single thread event is cleared as a side effect of resuming the
++ process with PT_CONTINUE, PT_STEP, etc. In older kernels,
++ however, the request pid was used to select which thread's event
++ was cleared rather than always clearing the event that was just
++ reported. To avoid clearing the event of the wrong LWP, always
++ pass the process ID instead of an LWP ID to PT_CONTINUE or
++ PT_SYSCALL.
++
++ In the case of stepping, the process ID cannot be used with
++ PT_STEP since it would step the thread that reported an event
++ which may not be the thread indicated by PTID. For stepping, use
++ PT_SETSTEP to enable stepping on the desired thread before
++ resuming the process via PT_CONTINUE instead of using
++ PT_STEP. */
++ if (step)
++ {
++ if (ptrace (PT_SETSTEP, get_ptrace_pid (ptid), NULL, 0) == -1)
++ perror_with_name (("ptrace"));
++ step = 0;
++ }
++ ptid = ptid_t (ptid.pid ());
++#endif
+ super_resume (ops, ptid, step, signo);
+ }
+
Index: head/devel/gdb/files/extrapatch-kgdb
===================================================================
--- head/devel/gdb/files/extrapatch-kgdb
+++ head/devel/gdb/files/extrapatch-kgdb
@@ -1,8 +1,8 @@
diff --git gdb/Makefile.in gdb/Makefile.in
-index cf59ae7143..0dd72d35d1 100644
+index 17b71c6e7c..282522187b 100644
--- gdb/Makefile.in
+++ gdb/Makefile.in
-@@ -227,7 +227,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import
+@@ -230,7 +230,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import
# Generated headers in the gnulib directory. These must be listed
# so that they are generated before other files are compiled.
@@ -12,15 +12,15 @@
#
# CLI sub directory definitons
-@@ -745,6 +746,7 @@ TARGET_OBS = @TARGET_OBS@
+@@ -629,6 +630,7 @@ TARGET_OBS = @TARGET_OBS@
# All target-dependent objects files that require 64-bit CORE_ADDR
# (used with --enable-targets=all --enable-64-bit-bfd).
ALL_64_TARGET_OBS = \
+ aarch64-fbsd-kern.o \
aarch64-fbsd-tdep.o \
- aarch64-insn.o \
aarch64-linux-tdep.o \
-@@ -759,6 +761,7 @@ ALL_64_TARGET_OBS = \
+ aarch64-newlib-tdep.o \
+@@ -642,6 +644,7 @@ ALL_64_TARGET_OBS = \
amd64-darwin-tdep.o \
amd64-dicos-tdep.o \
amd64-fbsd-tdep.o \
@@ -28,7 +28,7 @@
amd64-linux-tdep.o \
amd64-nbsd-tdep.o \
amd64-obsd-tdep.o \
-@@ -770,6 +773,7 @@ ALL_64_TARGET_OBS = \
+@@ -656,6 +659,7 @@ ALL_64_TARGET_OBS = \
ia64-vms-tdep.o \
mips64-obsd-tdep.o \
sparc64-fbsd-tdep.o \
@@ -36,17 +36,16 @@
sparc64-linux-tdep.o \
sparc64-nbsd-tdep.o \
sparc64-obsd-tdep.o \
-@@ -797,6 +801,9 @@ ALL_TARGET_OBS = \
+@@ -684,6 +688,8 @@ ALL_TARGET_OBS = \
cris-linux-tdep.o \
cris-tdep.o \
dicos-tdep.o \
+ fbsd-kld.o \
+ fbsd-kthr.o \
-+ fbsd-kvm.o \
fbsd-tdep.o \
frv-linux-tdep.o \
frv-tdep.o \
-@@ -813,6 +820,7 @@ ALL_TARGET_OBS = \
+@@ -700,6 +706,7 @@ ALL_TARGET_OBS = \
i386-darwin-tdep.o \
i386-dicos-tdep.o \
i386-fbsd-tdep.o \
@@ -54,7 +53,7 @@
i386-gnu-tdep.o \
i386-go32-tdep.o \
i386-linux-tdep.o \
-@@ -837,6 +845,7 @@ ALL_TARGET_OBS = \
+@@ -724,6 +731,7 @@ ALL_TARGET_OBS = \
mep-tdep.o \
microblaze-linux-tdep.o \
microblaze-tdep.o \
@@ -62,7 +61,7 @@
mips-fbsd-tdep.o \
mips-linux-tdep.o \
mips-nbsd-tdep.o \
-@@ -854,6 +863,7 @@ ALL_TARGET_OBS = \
+@@ -741,6 +749,7 @@ ALL_TARGET_OBS = \
nto-tdep.o \
obsd-tdep.o \
ppc-fbsd-tdep.o \
@@ -70,7 +69,7 @@
ppc-linux-tdep.o \
ppc-nbsd-tdep.o \
ppc-obsd-tdep.o \
-@@ -1871,7 +1881,7 @@ generated_files = \
+@@ -1610,7 +1619,7 @@ generated_files = \
# Flags needed to compile Python code
PYTHON_CFLAGS = @PYTHON_CFLAGS@
@@ -79,7 +78,7 @@
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
# Rule for compiling .c files in the top-level gdb directory.
-@@ -2210,6 +2220,12 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
+@@ -1920,6 +1929,12 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
@@ -92,7 +91,7 @@
# Convenience rule to handle recursion.
$(LIBGNU) $(GNULIB_H): all-lib
all-lib: $(GNULIB_BUILDDIR)/Makefile
-@@ -2254,7 +2270,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
+@@ -1964,7 +1979,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp init.l-tmp version.c-tmp
rm -f init.c version.c observer.h observer.inc
@@ -101,7 +100,7 @@
rm -f gdb[0-9]$(EXEEXT)
rm -f test-cp-name-parser$(EXEEXT)
rm -f xml-builtin.c stamp-xml
-@@ -2461,6 +2477,7 @@ MAKEOVERRIDES =
+@@ -2178,6 +2193,7 @@ MAKEOVERRIDES =
ALLDEPFILES = \
aarch64-fbsd-nat.c \
@@ -109,7 +108,7 @@
aarch64-fbsd-tdep.c \
aarch64-linux-nat.c \
aarch64-linux-tdep.c \
-@@ -2478,6 +2495,7 @@ ALLDEPFILES = \
+@@ -2195,6 +2211,7 @@ ALLDEPFILES = \
amd64-bsd-nat.c \
amd64-darwin-tdep.c \
amd64-dicos-tdep.c \
@@ -117,8 +116,8 @@
amd64-fbsd-nat.c \
amd64-fbsd-tdep.c \
amd64-linux-nat.c \
-@@ -2513,6 +2531,9 @@ ALLDEPFILES = \
- dcache.c \
+@@ -2228,6 +2245,9 @@ ALLDEPFILES = \
+ darwin-nat.c \
dicos-tdep.c \
exec.c \
+ fbsd-kld.c \
@@ -127,7 +126,7 @@
fbsd-nat.c \
fbsd-tdep.c \
fork-child.c \
-@@ -2534,6 +2555,7 @@ ALLDEPFILES = \
+@@ -2249,6 +2269,7 @@ ALLDEPFILES = \
i386-darwin-nat.c \
i386-darwin-tdep.c \
i386-dicos-tdep.c \
@@ -135,7 +134,7 @@
i386-fbsd-nat.c \
i386-fbsd-tdep.c \
i386-gnu-nat.c \
-@@ -2575,6 +2597,7 @@ ALLDEPFILES = \
+@@ -2290,6 +2311,7 @@ ALLDEPFILES = \
mingw-hdep.c \
mips-fbsd-nat.c \
mips-fbsd-tdep.c \
@@ -143,7 +142,7 @@
mips-linux-nat.c \
mips-linux-tdep.c \
mips-nbsd-nat.c \
-@@ -2592,6 +2615,7 @@ ALLDEPFILES = \
+@@ -2307,6 +2329,7 @@ ALLDEPFILES = \
obsd-nat.c \
obsd-tdep.c \
posix-hdep.c \
@@ -151,7 +150,7 @@
ppc-fbsd-nat.c \
ppc-fbsd-tdep.c \
ppc-linux-nat.c \
-@@ -2636,6 +2660,7 @@ ALLDEPFILES = \
+@@ -2351,6 +2374,7 @@ ALLDEPFILES = \
sparc-sol2-nat.c \
sparc-sol2-tdep.c \
sparc-tdep.c \
@@ -159,30 +158,17 @@
sparc64-fbsd-nat.c \
sparc64-fbsd-tdep.c \
sparc64-linux-nat.c \
-@@ -2667,6 +2692,12 @@ ALLDEPFILES = \
- xtensa-linux-tdep.c \
- xtensa-tdep.c \
- xtensa-xtregs.c \
-+ kgdb/kld.c \
-+ kgdb/kthr.c \
-+ kgdb/trgt.c \
-+ kgdb/trgt_amd64.c \
-+ kgdb/trgt_i386.c \
-+ kgdb/trgt_sparc64.c \
- common/mingw-strerror.c \
- common/posix-strerror.c
+@@ -2638,7 +2662,7 @@ endif
-@@ -2928,7 +2959,7 @@ endif
-
# A list of all the objects we might care about in this build, for
# dependency tracking.
-all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \
+all_object_files = kgdb-main.o gdb.o $(LIBGDB_OBS) gdbtk-main.o \
test-cp-name-parser.o
- # Ensure that generated files are created early. Use order-only
+ # All the .deps files to include.
diff --git gdb/config.in gdb/config.in
-index 3f8a72326b..bb1e8c23bf 100644
+index 1d11a97080..50a5a5b322 100644
--- gdb/config.in
+++ gdb/config.in
@@ -222,6 +222,9 @@
@@ -195,21 +181,11 @@
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
-diff --git gdb/config/mips/fbsd.mh gdb/config/mips/fbsd.mh
-index f433347a20..5470795612 100644
---- gdb/config/mips/fbsd.mh
-+++ gdb/config/mips/fbsd.mh
-@@ -1,3 +1,5 @@
- # Host: FreeBSD/mips
- NATDEPFILES= fork-child.o inf-ptrace.o fbsd-nat.o mips-fbsd-nat.o
- HAVE_NATIVE_GCORE_HOST = 1
-+
-+LOADLIBES= -lkvm
diff --git gdb/configure gdb/configure
-index e14886b67d..5682ce42d6 100755
+index 84a0790c0d..f4c323d4ab 100755
--- gdb/configure
+++ gdb/configure
-@@ -7968,6 +7968,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
+@@ -7927,6 +7927,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
fi
@@ -277,10 +253,10 @@
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
diff --git gdb/configure.ac gdb/configure.ac
-index 50f6f592ba..89cdc9cc8e 100644
+index d4133ea71e..bac85c53e0 100644
--- gdb/configure.ac
+++ gdb/configure.ac
-@@ -530,6 +530,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd,
+@@ -523,6 +523,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd,
[AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
[Define to 1 if your system has the kinfo_getvmmap function. ])])
@@ -292,71 +268,88 @@
AM_ICONV
# GDB may fork/exec the iconv program to get the list of supported character
+diff --git gdb/configure.nat gdb/configure.nat
+index 8e14892722..ada205f34d 100644
+--- gdb/configure.nat
++++ gdb/configure.nat
+@@ -62,7 +62,8 @@ case ${gdb_host} in
+ LOADLIBES='-ldl $(RDYNAMIC)'
+ ;;
+ fbsd*)
+- NATDEPFILES='fork-child.o fork-inferior.o inf-ptrace.o fbsd-nat.o'
++ NATDEPFILES='fork-child.o fork-inferior.o inf-ptrace.o fbsd-nat.o \
++ fbsd-kvm.o'
+ HAVE_NATIVE_GCORE_HOST=1
+ LOADLIBES='-lkvm'
+ ;;
diff --git gdb/configure.tgt gdb/configure.tgt
-index f72a0dbbc1..2d73300961 100644
+index fb8014a8e8..1a86608840 100644
--- gdb/configure.tgt
+++ gdb/configure.tgt
-@@ -203,7 +203,13 @@ i[34567]86-*-dicos*)
+@@ -92,7 +92,7 @@ esac
+
+ case "${targ}" in
+ *-*-freebsd* | *-*-kfreebsd*-gnu)
+- os_obs="fbsd-tdep.o solib-svr4.o";;
++ os_obs="fbsd-tdep.o solib-svr4.o fbsd-kld.o fbsd-kthr.o";;
+ *-*-netbsd* | *-*-knetbsd*-gnu)
+ os_obs="nbsd-tdep.o solib-svr4.o";;
+ *-*-openbsd*)
+@@ -249,7 +249,11 @@ i[34567]86-*-dicos*)
+ ;;
i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
# Target: FreeBSD/i386
- gdb_target_obs="i386-tdep.o i387-tdep.o i386-bsd-tdep.o i386-fbsd-tdep.o \
-- fbsd-tdep.o solib-svr4.o"
-+ fbsd-tdep.o solib-svr4.o \
-+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o"
+- gdb_target_obs="i386-bsd-tdep.o i386-fbsd-tdep.o "
++ gdb_target_obs="i386-bsd-tdep.o i386-fbsd-tdep.o i386fbsd-kern.o"
+ if test "x$enable_64_bit_bfd" = "xyes"; then
+ # Target: FreeBSD amd64
-+ gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o amd64fbsd-kern.o \
-+ ${gdb_target_obs}"
++ gdb_target_obs="amd64fbsd-tdep.o amd64fbsd-kern.o ${gdb_target_obs}"
+ fi
;;
i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
# Target: NetBSD/i386
-@@ -377,7 +383,8 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
+@@ -408,7 +412,7 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
;;
mips*-*-freebsd*)
# Target: MIPS running FreeBSD
-- gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o"
-+ gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o \
-+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o mipsfbsd-kern.o"
+- gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o"
++ gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o mipsfbsd-kern.o"
gdb_sim=../sim/mips/libsim.a
;;
mips64*-*-openbsd*)
-@@ -436,7 +443,8 @@ powerpc*-*-freebsd*)
+@@ -472,7 +476,7 @@ or1k-*-* | or1knd-*-*)
+ powerpc*-*-freebsd*)
# Target: FreeBSD/powerpc
gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
- ppc-fbsd-tdep.o fbsd-tdep.o solib-svr4.o \
-- ravenscar-thread.o ppc-ravenscar-thread.o"
-+ ravenscar-thread.o ppc-ravenscar-thread.o \
-+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o ppcfbsd-kern.o"
+- ppc-fbsd-tdep.o \
++ ppc-fbsd-tdep.o ppcfbsd-kern.o \
+ ravenscar-thread.o ppc-ravenscar-thread.o"
;;
- powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
-@@ -560,7 +568,8 @@ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
+@@ -594,6 +598,7 @@ sparc64-*-linux*)
+ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
# Target: FreeBSD/sparc64
gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64-fbsd-tdep.o \
- fbsd-tdep.o solib-svr4.o \
-- ravenscar-thread.o sparc-ravenscar-thread.o"
-+ ravenscar-thread.o sparc-ravenscar-thread.o \
-+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o sparc64fbsd-kern.o"
++ sparc64fbsd-kern.o \
+ ravenscar-thread.o sparc-ravenscar-thread.o"
;;
sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
- # Target: NetBSD/sparc
-@@ -691,7 +700,9 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
+@@ -716,8 +721,8 @@ x86_64-*-linux*)
+ ;;
+ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
# Target: FreeBSD/amd64
- gdb_target_obs="amd64-tdep.o amd64-fbsd-tdep.o i386-tdep.o \
- i387-tdep.o i386-bsd-tdep.o i386-fbsd-tdep.o \
-- fbsd-tdep.o solib-svr4.o"
-+ fbsd-tdep.o solib-svr4.o \
-+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o amd64fbsd-kern.o \
-+ i386fbsd-kern.o"
+- gdb_target_obs="amd64-fbsd-tdep.o ${i386_tobjs} \
+- i386-bsd-tdep.o i386-fbsd-tdep.o"
++ gdb_target_obs="amd64-fbsd-tdep.o amd64fbsd-kern.o ${i386_tobjs} \
++ i386-bsd-tdep.o i386-fbsd-tdep.o i386fbsd-kern.o"
;;
x86_64-*-mingw* | x86_64-*-cygwin*)
# Target: MingW/amd64
diff --git gdb/defs.h gdb/defs.h
-index a0b586f401..44d3d112ed 100644
+index 4fb2129b30..0cb0bad5c5 100644
--- gdb/defs.h
+++ gdb/defs.h
-@@ -590,6 +590,7 @@ enum gdb_osabi
+@@ -516,6 +516,7 @@ enum gdb_osabi
GDB_OSABI_SOLARIS,
GDB_OSABI_LINUX,
GDB_OSABI_FREEBSD,
@@ -364,8 +357,20 @@
GDB_OSABI_NETBSD,
GDB_OSABI_OPENBSD,
GDB_OSABI_WINCE,
+diff --git gdb/gnulib/configure gdb/gnulib/configure
+index 37efd06b67..a23fc0a81c 100644
+--- gdb/gnulib/configure
++++ gdb/gnulib/configure
+@@ -16790,6 +16790,7 @@ else
+ case "$host_os" in
+ # Guess all is fine on glibc systems.
+ *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
++ freebsd*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_gettimeofday_clobber="guessing yes" ;;
+ esac
diff --git gdb/osabi.c gdb/osabi.c
-index 84fa9c0273..5c49e22657 100644
+index 129164f51e..4eacc074a3 100644
--- gdb/osabi.c
+++ gdb/osabi.c
@@ -65,6 +65,7 @@ static const struct osabi_names gdb_osabi_names[] =
@@ -377,40 +382,43 @@
{ "OpenBSD", NULL },
{ "WindowsCE", NULL },
diff --git gdb/regcache.c gdb/regcache.c
-index 37bc2f0046..9da3aaa514 100644
+index fb6a904dec..f9b7105b8f 100644
--- gdb/regcache.c
+++ gdb/regcache.c
-@@ -1105,6 +1105,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
- }
+@@ -1079,6 +1079,23 @@ regcache::raw_supply_zeroed (int regnum)
+ m_register_status[regnum] = REG_VALID;
}
+void
-+regcache_raw_supply_unsigned (struct regcache *regcache, int regnum,
-+ ULONGEST val)
++regcache::raw_supply_unsigned (int regnum, ULONGEST val)
+{
-+ gdb_byte *buf;
++ enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch);
++ gdb_byte *regbuf;
++ size_t regsize;
+
-+ gdb_assert (regcache != NULL);
-+ gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
-+ buf = (gdb_byte *)alloca (regcache->descr->sizeof_register[regnum]);
-+ store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
-+ gdbarch_byte_order (regcache->descr->gdbarch), val);
-+ regcache_raw_supply (regcache, regnum, buf);
++ assert_regnum (regnum);
++ gdb_assert (!m_readonly_p);
++
++ regbuf = register_buffer (regnum);
++ regsize = m_descr->sizeof_register[regnum];
++
++ store_unsigned_integer (regbuf, regsize, byte_order, val);
++ m_register_status[regnum] = REG_VALID;
+}
+
/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
void
diff --git gdb/regcache.h gdb/regcache.h
-index 1d60fa7616..9b8a4723a3 100644
+index 9e3da8c3fc..5c65a9be1e 100644
--- gdb/regcache.h
+++ gdb/regcache.h
-@@ -149,6 +149,8 @@ extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
+@@ -294,6 +294,8 @@ public:
+ void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
+ bool is_signed);
- extern void regcache_raw_supply (struct regcache *regcache,
- int regnum, const void *buf);
-+extern void regcache_raw_supply_unsigned (struct regcache *regcache,
-+ int regnum, ULONGEST val);
- extern void regcache_raw_collect (const struct regcache *regcache,
- int regnum, void *buf);
++ void raw_supply_unsigned (int regnum, ULONGEST val);
++
+ void raw_supply_zeroed (int regnum);
+ enum register_status get_register_status (int regnum) const;
Index: head/devel/gdb/files/kgdb/amd64fbsd-kern.c
===================================================================
--- head/devel/gdb/files/kgdb/amd64fbsd-kern.c
+++ head/devel/gdb/files/kgdb/amd64fbsd-kern.c
@@ -27,24 +27,23 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
-#ifdef __amd64__
-#include <machine/pcb.h>
-#include <machine/frame.h>
-#endif
-#include <string.h>
-
-#include <defs.h>
-#include <frame-unwind.h>
+#include "defs.h"
+#include "frame-unwind.h"
#include "gdbcore.h"
#include "osabi.h"
-#include <regcache.h>
+#include "regcache.h"
#include "solib.h"
#include "stack.h"
#include "symtab.h"
#include "trad-frame.h"
-#include <amd64-tdep.h>
+#include "amd64-tdep.h"
+#include "x86-xstate.h"
+#ifdef __amd64__
+#include <machine/pcb.h>
+#include <machine/frame.h>
+#endif
+
#include "kgdb.h"
static const int amd64fbsd_pcb_offset[] = {
@@ -88,11 +87,11 @@
if (target_read_memory(pcb_addr + amd64fbsd_pcb_offset[i], buf,
sizeof buf) != 0)
continue;
- regcache_raw_supply(regcache, i, buf);
+ regcache->raw_supply(i, buf);
}
- regcache_raw_supply_unsigned(regcache, AMD64_CS_REGNUM, CODE_SEL);
- regcache_raw_supply_unsigned(regcache, AMD64_SS_REGNUM, DATA_SEL);
+ regcache->raw_supply_unsigned(AMD64_CS_REGNUM, CODE_SEL);
+ regcache->raw_supply_unsigned(AMD64_SS_REGNUM, DATA_SEL);
}
static const int amd64fbsd_trapframe_offset[] = {
@@ -204,6 +203,7 @@
find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL);
return (name && ((strcmp (name, "calltrap") == 0)
+ || (strcmp (name, "fast_syscall_common") == 0)
|| (strcmp (name, "fork_trampoline") == 0)
|| (strcmp (name, "mchk_calltrap") == 0)
|| (strcmp (name, "nmi_calltrap") == 0)
@@ -223,7 +223,8 @@
amd64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
{
- amd64_init_abi(info, gdbarch);
+ amd64_init_abi(info, gdbarch,
+ amd64_target_description (X86_XSTATE_SSE_MASK));
frame_unwind_prepend_unwinder(gdbarch, &amd64fbsd_trapframe_unwind);
@@ -232,8 +233,6 @@
fbsd_vmcore_set_supply_pcb(gdbarch, amd64fbsd_supply_pcb);
fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb);
}
-
-void _initialize_amd64_kgdb_tdep(void);
void
_initialize_amd64_kgdb_tdep(void)
Index: head/devel/gdb/files/kgdb/fbsd-kld.c
===================================================================
--- head/devel/gdb/files/kgdb/fbsd-kld.c
+++ head/devel/gdb/files/kgdb/fbsd-kld.c
@@ -27,25 +27,22 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <fcntl.h>
-#include <libgen.h>
-
-#include <defs.h>
-#include <command.h>
-#include <completer.h>
-#include <environ.h>
-#include <exec.h>
-#include <frame-unwind.h>
-#include <inferior.h>
-#include <objfiles.h>
-#include <gdbcore.h>
-#include <language.h>
+#include "defs.h"
+#include "command.h"
+#include "completer.h"
+#include "environ.h"
+#include "exec.h"
+#include "frame-unwind.h"
+#include "inferior.h"
+#include "objfiles.h"
+#include "gdbcore.h"
+#include "language.h"
#include "solib.h"
-#include <solist.h>
+#include "solist.h"
#include "kgdb.h"
-struct lm_info {
+struct lm_info_kld : public lm_info_base {
CORE_ADDR base_address;
};
@@ -199,7 +196,7 @@
* Try to find this kld in the kernel linker's list of linker files.
*/
static int
-find_kld_address (char *arg, CORE_ADDR *address)
+find_kld_address (const char *arg, CORE_ADDR *address)
{
struct kld_info *info;
CORE_ADDR kld;
@@ -314,7 +311,7 @@
}
static void
-kgdb_add_kld_cmd (char *arg, int from_tty)
+kgdb_add_kld_cmd (const char *arg, int from_tty)
{
char path[PATH_MAX];
CORE_ADDR base_addr;
@@ -349,26 +346,30 @@
static void
kld_relocate_section_addresses (struct so_list *so, struct target_section *sec)
{
- static CORE_ADDR curr_addr;
+ lm_info_kld *li = (lm_info_kld *) so->lm_info;
+ static CORE_ADDR curr_addr;
- if (sec == so->sections)
- curr_addr = so->lm_info->base_address;
+ if (sec == so->sections)
+ curr_addr = li->base_address;
- adjust_section_address(sec, &curr_addr);
+ adjust_section_address(sec, &curr_addr);
}
static void
kld_free_so (struct so_list *so)
{
+ lm_info_kld *li = (lm_info_kld *) so->lm_info;
- xfree(so->lm_info);
+ delete li;
}
static void
kld_clear_so (struct so_list *so)
{
- if (so->lm_info != NULL)
- so->lm_info->base_address = 0;
+ lm_info_kld *li = (lm_info_kld *) so->lm_info;
+
+ if (li != NULL)
+ li->base_address = 0;
}
static void
@@ -460,9 +461,11 @@
newobj = XCNEW (struct so_list);
- newobj->lm_info = XNEW (struct lm_info);
- newobj->lm_info->base_address = 0;
+ lm_info_kld *li = new lm_info_kld;
+ li->base_address = 0;
+ newobj->lm_info = li;
+
/* Read the base filename and store it in so_original_name. */
target_read_string(read_pointer(kld + info->off_filename),
&path, sizeof(newobj->so_original_name), &error);
@@ -504,9 +507,8 @@
sizeof(newobj->so_name));
/* Read this kld's base address. */
- newobj->lm_info->base_address = read_pointer(kld +
- info->off_address);
- if (newobj->lm_info->base_address == 0) {
+ li->base_address = read_pointer(kld + info->off_address);
+ if (li->base_address == 0) {
warning(
"kld_current_sos: Invalid address for kld \"%s\"",
newobj->so_original_name);
@@ -523,7 +525,7 @@
}
static int
-kld_open_symbol_file_object (void *from_ttyp)
+kld_open_symbol_file_object (int from_tty)
{
return (0);
@@ -553,8 +555,6 @@
*temp_pathname = xstrdup(path);
return (fd);
}
-
-void _initialize_kld_target(void);
void
_initialize_kld_target(void)
Index: head/devel/gdb/files/kgdb/fbsd-kvm.c
===================================================================
--- head/devel/gdb/files/kgdb/fbsd-kvm.c
+++ head/devel/gdb/files/kgdb/fbsd-kvm.c
@@ -27,35 +27,25 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <sys/user.h>
-#include <err.h>
-#include <fcntl.h>
-#include <kvm.h>
-
-#include <defs.h>
-#include <readline/readline.h>
-#include <readline/tilde.h>
-#include <command.h>
+#include "defs.h"
+#include "command.h"
#include "elf-bfd.h"
-#include <exec.h>
#include "filenames.h"
-#include <frame-unwind.h>
-#include <gdb.h>
-#include <gdbcore.h>
-#include <gdbthread.h>
+#include "gdbcore.h"
+#include "gdbthread.h"
#include "gdb_obstack.h"
-#include <inferior.h>
-#include <language.h>
+#include "inferior.h"
#include "objfiles.h"
#include "osabi.h"
-#include <regcache.h>
-#include <solib.h>
-#include <target.h>
-#include <ui-out.h>
+#include "solib.h"
+#include "target.h"
+#include "value.h"
+#include "readline/tilde.h"
+#include <sys/user.h>
+#include <fcntl.h>
+#include <kvm.h>
+
#include "kgdb.h"
static CORE_ADDR stoppcbs;
@@ -503,20 +493,18 @@
}
static void
-kgdb_switch_to_thread(int tid)
+kgdb_switch_to_thread(const char *arg, int tid)
{
- char buf[16];
- int thread_id;
+ struct thread_info *tp;
- thread_id = ptid_to_global_thread_id(fbsd_vmcore_ptid(tid));
- if (thread_id == 0)
- error ("invalid tid");
- snprintf(buf, sizeof(buf), "%d", thread_id);
- gdb_thread_select(current_uiout, buf, NULL);
+ tp = find_thread_ptid (fbsd_vmcore_ptid (tid));
+ if (tp == NULL)
+ error ("invalid tid");
+ thread_select (arg, tp);
}
static void
-kgdb_set_proc_cmd (char *arg, int from_tty)
+kgdb_set_proc_cmd (const char *arg, int from_tty)
{
CORE_ADDR addr;
struct kthr *thr;
@@ -538,11 +526,11 @@
if (thr == NULL)
error("invalid proc address");
}
- kgdb_switch_to_thread(thr->tid);
+ kgdb_switch_to_thread(arg, thr->tid);
}
static void
-kgdb_set_tid_cmd (char *arg, int from_tty)
+kgdb_set_tid_cmd (const char *arg, int from_tty)
{
CORE_ADDR addr;
struct kthr *thr;
@@ -558,7 +546,7 @@
error("invalid thread address");
addr = thr->tid;
}
- kgdb_switch_to_thread(addr);
+ kgdb_switch_to_thread(arg, addr);
}
static int
@@ -567,8 +555,6 @@
return 1;
}
-
-void _initialize_kgdb_target(void);
void
_initialize_kgdb_target(void)
Index: head/devel/gdb/files/kgdb/i386fbsd-kern.c
===================================================================
--- head/devel/gdb/files/kgdb/i386fbsd-kern.c
+++ head/devel/gdb/files/kgdb/i386fbsd-kern.c
@@ -27,27 +27,25 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/param.h>
-#include <sys/proc.h>
+#include "defs.h"
+#include "frame-unwind.h"
+#include "gdbcore.h"
+#include "inferior.h"
+#include "osabi.h"
+#include "regcache.h"
+#include "progspace.h"
+#include "solib.h"
+#include "trad-frame.h"
+#include "i386-tdep.h"
+
#ifdef __i386__
+#include <sys/proc.h>
#include <machine/pcb.h>
#include <machine/frame.h>
#include <machine/segments.h>
#include <machine/tss.h>
#endif
-#include <string.h>
-#include <defs.h>
-#include <frame-unwind.h>
-#include "gdbcore.h"
-#include <inferior.h>
-#include "osabi.h"
-#include <regcache.h>
-#include "progspace.h"
-#include "solib.h"
-#include "trad-frame.h"
-#include <i386-tdep.h>
-
#include "kgdb.h"
struct i386fbsd_info {
@@ -135,14 +133,14 @@
if (target_read_memory(pcb_addr + i386fbsd_pcb_offset[i], buf, sizeof buf)
!= 0)
continue;
- regcache_raw_supply(regcache, i, buf);
+ regcache->raw_supply(i, buf);
}
- regcache_raw_supply_unsigned(regcache, I386_CS_REGNUM, CODE_SEL);
- regcache_raw_supply_unsigned(regcache, I386_DS_REGNUM, DATA_SEL);
- regcache_raw_supply_unsigned(regcache, I386_ES_REGNUM, DATA_SEL);
- regcache_raw_supply_unsigned(regcache, I386_FS_REGNUM, PRIV_SEL);
- regcache_raw_supply_unsigned(regcache, I386_GS_REGNUM, DATA_SEL);
- regcache_raw_supply_unsigned(regcache, I386_SS_REGNUM, DATA_SEL);
+ regcache->raw_supply_unsigned(I386_CS_REGNUM, CODE_SEL);
+ regcache->raw_supply_unsigned(I386_DS_REGNUM, DATA_SEL);
+ regcache->raw_supply_unsigned(I386_ES_REGNUM, DATA_SEL);
+ regcache->raw_supply_unsigned(I386_FS_REGNUM, PRIV_SEL);
+ regcache->raw_supply_unsigned(I386_GS_REGNUM, DATA_SEL);
+ regcache->raw_supply_unsigned(I386_SS_REGNUM, DATA_SEL);
}
#ifdef __i386__
@@ -461,8 +459,6 @@
fbsd_vmcore_set_supply_pcb(gdbarch, i386fbsd_supply_pcb);
fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb);
}
-
-void _initialize_i386_kgdb_tdep(void);
void
_initialize_i386_kgdb_tdep(void)
Index: head/devel/gdb/files/kgdb/kgdb-main.c
===================================================================
--- head/devel/gdb/files/kgdb/kgdb-main.c
+++ head/devel/gdb/files/kgdb/kgdb-main.c
@@ -379,6 +379,10 @@
add_arg(&args, "-iex");
add_arg(&args, "set prompt (kgdb) ");
+ /* Change osabi to assume a FreeBSD kernel. */
+ add_arg(&args, "-iex");
+ add_arg(&args, "set osabi FreeBSD/kernel");
+
/* Open the vmcore if requested. */
if (vmcore != NULL) {
add_arg(&args, "-ex");
Index: head/devel/gdb/files/kgdb/mipsfbsd-kern.c
===================================================================
--- head/devel/gdb/files/kgdb/mipsfbsd-kern.c
+++ head/devel/gdb/files/kgdb/mipsfbsd-kern.c
@@ -30,25 +30,20 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/trgt_mips.c 249878 2013-04-25 04:53:01Z imp $");
-#include <sys/types.h>
+#include "defs.h"
+#include "frame-unwind.h"
+#include "osabi.h"
+#include "regcache.h"
+#include "solib.h"
+#include "trad-frame.h"
+#include "mips-tdep.h"
+
#ifdef __mips__
#include <machine/asm.h>
#include <machine/pcb.h>
#include <machine/frame.h>
#endif
-#include <string.h>
-#include <defs.h>
-#include <frame-unwind.h>
-//#include <target.h>
-//#include <gdbthread.h>
-//#include <inferior.h>
-#include "osabi.h"
-#include <regcache.h>
-#include "solib.h"
-#include "trad-frame.h"
-#include <mips-tdep.h>
-
#include "kgdb.h"
/* Size of struct trapframe in registers. */
@@ -92,7 +87,7 @@
static void
mipsfbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
size_t regsize = mips_isa_regsize (gdbarch);
gdb_byte buf[regsize * (FBSD_PCB_REG_PC + 1)];
@@ -102,35 +97,35 @@
sizeof(buf)) != 0)
return;
- regcache_raw_supply_unsigned (regcache, MIPS_ZERO_REGNUM, 0);
- regcache_raw_supply (regcache, MIPS_S2_REGNUM - 2,
- buf + (regsize * FBSD_PCB_REG_S0));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM - 1,
- buf + (regsize * FBSD_PCB_REG_S1));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM,
- buf + (regsize * FBSD_PCB_REG_S2));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM + 1,
- buf + (regsize * FBSD_PCB_REG_S3));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM + 2,
- buf + (regsize * FBSD_PCB_REG_S4));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM + 3,
- buf + (regsize * FBSD_PCB_REG_S5));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM + 4,
- buf + (regsize * FBSD_PCB_REG_S6));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM + 5,
- buf + (regsize * FBSD_PCB_REG_S7));
- regcache_raw_supply (regcache, MIPS_SP_REGNUM,
- buf + (regsize * FBSD_PCB_REG_SP));
- regcache_raw_supply (regcache, MIPS_S2_REGNUM + 6,
- buf + (regsize * FBSD_PCB_REG_S8));
- regcache_raw_supply (regcache, MIPS_RA_REGNUM,
- buf + (regsize * FBSD_PCB_REG_RA));
- regcache_raw_supply (regcache, MIPS_PS_REGNUM,
- buf + (regsize * FBSD_PCB_REG_SR));
- regcache_raw_supply (regcache, MIPS_GP_REGNUM,
- buf + (regsize * FBSD_PCB_REG_GP));
- regcache_raw_supply (regcache, MIPS_EMBED_PC_REGNUM,
- buf + (regsize * FBSD_PCB_REG_PC));
+ regcache->raw_supply_unsigned (MIPS_ZERO_REGNUM, 0);
+ regcache->raw_supply (MIPS_S2_REGNUM - 2,
+ buf + (regsize * FBSD_PCB_REG_S0));
+ regcache->raw_supply (MIPS_S2_REGNUM - 1,
+ buf + (regsize * FBSD_PCB_REG_S1));
+ regcache->raw_supply (MIPS_S2_REGNUM,
+ buf + (regsize * FBSD_PCB_REG_S2));
+ regcache->raw_supply (MIPS_S2_REGNUM + 1,
+ buf + (regsize * FBSD_PCB_REG_S3));
+ regcache->raw_supply (MIPS_S2_REGNUM + 2,
+ buf + (regsize * FBSD_PCB_REG_S4));
+ regcache->raw_supply (MIPS_S2_REGNUM + 3,
+ buf + (regsize * FBSD_PCB_REG_S5));
+ regcache->raw_supply (MIPS_S2_REGNUM + 4,
+ buf + (regsize * FBSD_PCB_REG_S6));
+ regcache->raw_supply (MIPS_S2_REGNUM + 5,
+ buf + (regsize * FBSD_PCB_REG_S7));
+ regcache->raw_supply (MIPS_SP_REGNUM,
+ buf + (regsize * FBSD_PCB_REG_SP));
+ regcache->raw_supply (MIPS_S2_REGNUM + 6,
+ buf + (regsize * FBSD_PCB_REG_S8));
+ regcache->raw_supply (MIPS_RA_REGNUM,
+ buf + (regsize * FBSD_PCB_REG_RA));
+ regcache->raw_supply (MIPS_PS_REGNUM,
+ buf + (regsize * FBSD_PCB_REG_SR));
+ regcache->raw_supply (MIPS_GP_REGNUM,
+ buf + (regsize * FBSD_PCB_REG_GP));
+ regcache->raw_supply (MIPS_EMBED_PC_REGNUM,
+ buf + (regsize * FBSD_PCB_REG_PC));
}
static struct trad_frame_cache *
@@ -291,8 +286,6 @@
fbsd_vmcore_set_supply_pcb (gdbarch, mipsfbsd_supply_pcb);
fbsd_vmcore_set_cpu_pcb_addr (gdbarch, kgdb_trgt_stop_pcb);
}
-
-void _initialize_mips_kgdb_tdep (void);
void
_initialize_mips_kgdb_tdep (void)
Index: head/devel/gdb/files/kgdb/ppcfbsd-kern.c
===================================================================
--- head/devel/gdb/files/kgdb/ppcfbsd-kern.c
+++ head/devel/gdb/files/kgdb/ppcfbsd-kern.c
@@ -27,25 +27,22 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
-#ifdef __powerpc__
-#include <machine/pcb.h>
-#include <machine/frame.h>
-#endif
-#include <string.h>
-
-#include <defs.h>
-#include <frame-unwind.h>
+#include "defs.h"
+#include "frame-unwind.h"
#include "gdbcore.h"
#include "osabi.h"
#include "regcache.h"
#include "solib.h"
#include "symtab.h"
#include "trad-frame.h"
-
-#include <ppc-tdep.h>
+#include "ppc-tdep.h"
#include "ppc64-tdep.h"
+#ifdef __powerpc__
+#include <machine/pcb.h>
+#include <machine/frame.h>
+#endif
+
#include "kgdb.h"
#ifdef __powerpc__
@@ -56,7 +53,7 @@
struct gdbarch_tdep *tdep;
int i;
- tdep = gdbarch_tdep (target_gdbarch());
+ tdep = gdbarch_tdep (regcache->arch ());
if (target_read_memory(pcb_addr, (gdb_byte *)&pcb, sizeof(pcb)) != 0)
memset(&pcb, 0, sizeof(pcb));
@@ -65,20 +62,20 @@
* r14-r31 are saved in the pcb
*/
for (i = 14; i <= 31; i++) {
- regcache_raw_supply(regcache, tdep->ppc_gp0_regnum + i,
+ regcache->raw_supply(tdep->ppc_gp0_regnum + i,
(char *)&pcb.pcb_context[i]);
}
/* r1 is saved in the sp field */
- regcache_raw_supply(regcache, tdep->ppc_gp0_regnum + 1,
+ regcache->raw_supply(tdep->ppc_gp0_regnum + 1,
(char *)&pcb.pcb_sp);
if (tdep->wordsize == 8)
/* r2 is saved in the toc field */
- regcache_raw_supply(regcache, tdep->ppc_gp0_regnum + 2,
+ regcache->raw_supply(tdep->ppc_gp0_regnum + 2,
(char *)&pcb.pcb_toc);
- regcache_raw_supply(regcache, tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr);
- regcache_raw_supply(regcache, tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr);
+ regcache->raw_supply(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr);
+ regcache->raw_supply(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr);
}
#endif
@@ -231,8 +228,6 @@
ppc64_elf_make_msymbol_special);
}
}
-
-void _initialize_ppc_kgdb_tdep(void);
void
_initialize_ppc_kgdb_tdep(void)
Index: head/devel/gdb/files/kgdb/sparc64fbsd-kern.c
===================================================================
--- head/devel/gdb/files/kgdb/sparc64fbsd-kern.c
+++ head/devel/gdb/files/kgdb/sparc64fbsd-kern.c
@@ -27,25 +27,22 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
-#ifdef __sparc64__
-#include <machine/asm.h>
-#include <machine/pcb.h>
-#include <machine/frame.h>
-#endif
-#include <string.h>
-
-#include <defs.h>
+#include "defs.h"
#include "gdbcore.h"
#include "osabi.h"
#include "regcache.h"
-#include <target.h>
-#include <frame-unwind.h>
+#include "target.h"
+#include "frame-unwind.h"
#include "solib.h"
#include "trad-frame.h"
+#include "sparc-tdep.h"
+#include "sparc64-tdep.h"
-#include <sparc-tdep.h>
-#include <sparc64-tdep.h>
+#ifdef __sparc64__
+#include <machine/asm.h>
+#include <machine/pcb.h>
+#include <machine/frame.h>
+#endif
#include "kgdb.h"
@@ -304,8 +301,6 @@
fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb);
#endif
}
-
-void _initialize_sparc64_kgdb_tdep(void);
void
_initialize_sparc64_kgdb_tdep(void)
Index: head/devel/gdb/files/patch-aarch64-fbsd
===================================================================
--- head/devel/gdb/files/patch-aarch64-fbsd
+++ head/devel/gdb/files/patch-aarch64-fbsd
@@ -1,468 +0,0 @@
---- gdb/Makefile.in.orig 2017-09-14 09:28:17 UTC
-+++ gdb/Makefile.in
-@@ -745,6 +745,7 @@ TARGET_OBS = @TARGET_OBS@
- # All target-dependent objects files that require 64-bit CORE_ADDR
- # (used with --enable-targets=all --enable-64-bit-bfd).
- ALL_64_TARGET_OBS = \
-+ aarch64-fbsd-tdep.o \
- aarch64-insn.o \
- aarch64-linux-tdep.o \
- aarch64-newlib-tdep.o \
-@@ -2458,6 +2459,8 @@ force_update:
- MAKEOVERRIDES =
-
- ALLDEPFILES = \
-+ aarch64-fbsd-nat.c \
-+ aarch64-fbsd-tdep.c \
- aarch64-linux-nat.c \
- aarch64-linux-tdep.c \
- aarch64-newlib-tdep.c \
-diff --git gdb/aarch64-fbsd-nat.c gdb/aarch64-fbsd-nat.c
-new file mode 100644
-index 0000000000..f7855b9c0b
---- /dev/null
-+++ gdb/aarch64-fbsd-nat.c
-@@ -0,0 +1,133 @@
-+/* Native-dependent code for FreeBSD/aarch64.
-+
-+ Copyright (C) 2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "defs.h"
-+#include "target.h"
-+
-+#include <sys/types.h>
-+#include <sys/ptrace.h>
-+#include <machine/reg.h>
-+
-+#include "fbsd-nat.h"
-+#include "aarch64-tdep.h"
-+#include "aarch64-fbsd-tdep.h"
-+#include "inf-ptrace.h"
-+
-+/* Determine if PT_GETREGS fetches REGNUM. */
-+
-+static bool
-+getregs_supplies (struct gdbarch *gdbarch, int regnum)
-+{
-+ return (regnum >= AARCH64_X0_REGNUM && regnum <= AARCH64_CPSR_REGNUM);
-+}
-+
-+/* Determine if PT_GETFPREGS fetches REGNUM. */
-+
-+static bool
-+getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
-+{
-+ return (regnum >= AARCH64_V0_REGNUM && regnum <= AARCH64_FPCR_REGNUM);
-+}
-+
-+/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
-+ for all registers. */
-+
-+static void
-+aarch64_fbsd_fetch_inferior_registers (struct target_ops *ops,
-+ struct regcache *regcache, int regnum)
-+{
-+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
-+
-+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
-+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
-+ {
-+ struct reg regs;
-+
-+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
-+ perror_with_name (_("Couldn't get registers"));
-+
-+ regcache_supply_regset (&aarch64_fbsd_gregset, regcache, regnum, ®s,
-+ sizeof (regs));
-+ }
-+
-+ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
-+ {
-+ struct fpreg fpregs;
-+
-+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
-+ perror_with_name (_("Couldn't get floating point status"));
-+
-+ regcache_supply_regset (&aarch64_fbsd_fpregset, regcache, regnum, &fpregs,
-+ sizeof (fpregs));
-+ }
-+}
-+
-+/* Store register REGNUM back into the inferior. If REGNUM is -1, do
-+ this for all registers. */
-+
-+static void
-+aarch64_fbsd_store_inferior_registers (struct target_ops *ops,
-+ struct regcache *regcache, int regnum)
-+{
-+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
-+
-+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
-+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
-+ {
-+ struct reg regs;
-+
-+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
-+ perror_with_name (_("Couldn't get registers"));
-+
-+ regcache_collect_regset (&aarch64_fbsd_gregset, regcache, regnum, ®s,
-+ sizeof (regs));
-+
-+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
-+ perror_with_name (_("Couldn't write registers"));
-+ }
-+
-+ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
-+ {
-+ struct fpreg fpregs;
-+
-+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
-+ perror_with_name (_("Couldn't get floating point status"));
-+
-+ regcache_collect_regset (&aarch64_fbsd_fpregset, regcache, regnum, &fpregs,
-+ sizeof (fpregs));
-+
-+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
-+ perror_with_name (_("Couldn't write floating point status"));
-+ }
-+}
-+
-+
-+/* Provide a prototype to silence -Wmissing-prototypes. */
-+void _initialize_aarch64_fbsd_nat (void);
-+
-+void
-+_initialize_aarch64_fbsd_nat (void)
-+{
-+ struct target_ops *t;
-+
-+ t = inf_ptrace_target ();
-+ t->to_fetch_registers = aarch64_fbsd_fetch_inferior_registers;
-+ t->to_store_registers = aarch64_fbsd_store_inferior_registers;
-+ fbsd_nat_add_target (t);
-+}
-diff --git gdb/aarch64-fbsd-tdep.c gdb/aarch64-fbsd-tdep.c
-new file mode 100644
-index 0000000000..f8ce627282
---- /dev/null
-+++ gdb/aarch64-fbsd-tdep.c
-@@ -0,0 +1,208 @@
-+/* Target-dependent code for FreeBSD/aarch64.
-+
-+ Copyright (C) 2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "defs.h"
-+
-+#include "gdbarch.h"
-+#include "fbsd-tdep.h"
-+#include "aarch64-tdep.h"
-+#include "aarch64-fbsd-tdep.h"
-+#include "osabi.h"
-+#include "solib-svr4.h"
-+#include "target.h"
-+#include "tramp-frame.h"
-+#include "trad-frame.h"
-+
-+/* In a signal frame, sp points to a 'struct sigframe' which is
-+ defined as:
-+
-+ struct sigframe {
-+ siginfo_t sf_si;
-+ ucontext_t sf_uc;
-+ };
-+
-+ ucontext_t is defined as:
-+
-+ struct __ucontext {
-+ sigset_t uc_sigmask;
-+ mcontext_t uc_mcontext;
-+ ...
-+ };
-+
-+ The mcontext_t contains the general purpose register set followed
-+ by the floating point register set. The floating point register
-+ set is only valid if the _MC_FP_VALID flag is set in mc_flags. */
-+
-+#define AARCH64_MCONTEXT_REG_SIZE 8
-+#define AARCH64_MCONTEXT_FPREG_SIZE 16
-+#define AARCH64_SIGFRAME_UCONTEXT_OFFSET 80
-+#define AARCH64_UCONTEXT_MCONTEXT_OFFSET 16
-+#define AARCH64_MCONTEXT_FPREGS_OFFSET 272
-+#define AARCH64_MCONTEXT_FLAGS_OFFSET 800
-+#define AARCH64_MCONTEXT_FLAG_FP_VALID 0x1
-+
-+/* Implement the "init" method of struct tramp_frame. */
-+
-+static void
-+aarch64_fbsd_sigframe_init (const struct tramp_frame *self,
-+ struct frame_info *this_frame,
-+ struct trad_frame_cache *this_cache,
-+ CORE_ADDR func)
-+{
-+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
-+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-+ CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
-+ CORE_ADDR mcontext_addr =
-+ sp
-+ + AARCH64_SIGFRAME_UCONTEXT_OFFSET
-+ + AARCH64_UCONTEXT_MCONTEXT_OFFSET;
-+ gdb_byte buf[4];
-+ int i;
-+
-+ for (i = 0; i < 30; i++)
-+ {
-+ trad_frame_set_reg_addr (this_cache,
-+ AARCH64_X0_REGNUM + i,
-+ mcontext_addr + i * AARCH64_MCONTEXT_REG_SIZE);
-+ }
-+ trad_frame_set_reg_addr (this_cache, AARCH64_LR_REGNUM,
-+ mcontext_addr + 30 * AARCH64_MCONTEXT_REG_SIZE);
-+ trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM,
-+ mcontext_addr + 31 * AARCH64_MCONTEXT_REG_SIZE);
-+ trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM,
-+ mcontext_addr + 32 * AARCH64_MCONTEXT_REG_SIZE);
-+ trad_frame_set_reg_addr (this_cache, AARCH64_CPSR_REGNUM,
-+ mcontext_addr + 33 * AARCH64_MCONTEXT_REG_SIZE);
-+
-+ if (target_read_memory (mcontext_addr + AARCH64_MCONTEXT_FLAGS_OFFSET, buf,
-+ 4) == 0
-+ && (extract_unsigned_integer (buf, 4, byte_order)
-+ & AARCH64_MCONTEXT_FLAG_FP_VALID))
-+ {
-+ for (i = 0; i < 32; i++)
-+ {
-+ trad_frame_set_reg_addr (this_cache, AARCH64_V0_REGNUM + i,
-+ mcontext_addr
-+ + AARCH64_MCONTEXT_FPREGS_OFFSET
-+ + i * AARCH64_MCONTEXT_FPREG_SIZE);
-+ }
-+ trad_frame_set_reg_addr (this_cache, AARCH64_FPSR_REGNUM,
-+ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET
-+ + 32 * AARCH64_MCONTEXT_FPREG_SIZE);
-+ trad_frame_set_reg_addr (this_cache, AARCH64_FPCR_REGNUM,
-+ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET
-+ + 32 * AARCH64_MCONTEXT_FPREG_SIZE + 4);
-+ }
-+
-+ trad_frame_set_id (this_cache, frame_id_build (sp, func));
-+}
-+
-+static const struct tramp_frame aarch64_fbsd_sigframe =
-+{
-+ SIGTRAMP_FRAME,
-+ 4,
-+ {
-+ {0x910003e0, -1}, /* mov x0, sp */
-+ {0x91014000, -1}, /* add x0, x0, #SF_UC */
-+ {0xd2803428, -1}, /* mov x8, #SYS_sigreturn */
-+ {0xd4000001, -1}, /* svc 0x0 */
-+ {TRAMP_SENTINEL_INSN, -1}
-+ },
-+ aarch64_fbsd_sigframe_init
-+};
-+
-+/* Register maps. */
-+
-+static const struct regcache_map_entry aarch64_fbsd_gregmap[] =
-+ {
-+ { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */
-+ { 1, AARCH64_LR_REGNUM, 8 },
-+ { 1, AARCH64_SP_REGNUM, 8 },
-+ { 1, AARCH64_PC_REGNUM, 8 },
-+ { 1, AARCH64_CPSR_REGNUM, 4 },
-+ { 0 }
-+ };
-+
-+static const struct regcache_map_entry aarch64_fbsd_fpregmap[] =
-+ {
-+ { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */
-+ { 1, AARCH64_FPSR_REGNUM, 4 },
-+ { 1, AARCH64_FPCR_REGNUM, 4 },
-+ { 0 }
-+ };
-+
-+/* Register set definitions. */
-+
-+const struct regset aarch64_fbsd_gregset =
-+ {
-+ aarch64_fbsd_gregmap,
-+ regcache_supply_regset, regcache_collect_regset
-+ };
-+
-+const struct regset aarch64_fbsd_fpregset =
-+ {
-+ aarch64_fbsd_fpregmap,
-+ regcache_supply_regset, regcache_collect_regset
-+ };
-+
-+/* Implement the "regset_from_core_section" gdbarch method. */
-+
-+static void
-+aarch64_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
-+ iterate_over_regset_sections_cb *cb,
-+ void *cb_data,
-+ const struct regcache *regcache)
-+{
-+ cb (".reg", AARCH64_FBSD_SIZEOF_GREGSET, &aarch64_fbsd_gregset,
-+ NULL, cb_data);
-+ cb (".reg2", AARCH64_FBSD_SIZEOF_FPREGSET, &aarch64_fbsd_fpregset,
-+ NULL, cb_data);
-+}
-+
-+/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */
-+
-+static void
-+aarch64_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
-+{
-+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-+
-+ /* Generic FreeBSD support. */
-+ fbsd_init_abi (info, gdbarch);
-+
-+ set_solib_svr4_fetch_link_map_offsets (gdbarch,
-+ svr4_lp64_fetch_link_map_offsets);
-+
-+ tramp_frame_prepend_unwinder (gdbarch, &aarch64_fbsd_sigframe);
-+
-+ /* Enable longjmp. */
-+ tdep->jb_pc = 13;
-+
-+ set_gdbarch_iterate_over_regset_sections
-+ (gdbarch, aarch64_fbsd_iterate_over_regset_sections);
-+}
-+
-+/* Provide a prototype to silence -Wmissing-prototypes. */
-+extern initialize_file_ftype _initialize_aarch64_fbsd_tdep;
-+
-+void
-+_initialize_aarch64_fbsd_tdep (void)
-+{
-+ gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_FREEBSD,
-+ aarch64_fbsd_init_abi);
-+}
-diff --git gdb/aarch64-fbsd-tdep.h gdb/aarch64-fbsd-tdep.h
-new file mode 100644
-index 0000000000..0f66dd3925
---- /dev/null
-+++ gdb/aarch64-fbsd-tdep.h
-@@ -0,0 +1,33 @@
-+/* FreeBSD/aarch64 target support, prototypes.
-+
-+ Copyright (C) 2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "regset.h"
-+
-+/* The general-purpose regset consists of 30 X registers, plus LR, SP,
-+ ELR, and SPSR registers. SPSR is 32 bits but the structure is
-+ passed to 64 bit alignment. */
-+#define AARCH64_FBSD_SIZEOF_GREGSET (34 * X_REGISTER_SIZE)
-+
-+/* The fp regset consists of 32 V registers, plus FPSR and FPCR which
-+ are 4 bytes wide each, and the whole structure is padded to 128 bit
-+ alignment. */
-+#define AARCH64_FBSD_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
-+
-+extern const struct regset aarch64_fbsd_gregset;
-+extern const struct regset aarch64_fbsd_fpregset;
-diff --git gdb/config/aarch64/fbsd.mh gdb/config/aarch64/fbsd.mh
-new file mode 100644
-index 0000000000..4171987bc9
---- /dev/null
-+++ gdb/config/aarch64/fbsd.mh
-@@ -0,0 +1,23 @@
-+# Host: Freebsd/aarch64
-+#
-+# Copyright (C) 2017 Free Software Foundation, Inc.
-+#
-+# This file is part of GDB.
-+#
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
-+
-+NATDEPFILES= inf-ptrace.o fork-child.o aarch64-fbsd-nat.o fbsd-nat.o
-+HAVE_NATIVE_GCORE_HOST = 1
-+
-+LOADLIBES= -lkvm
-diff --git gdb/configure.host gdb/configure.host
-index d74fd04934..304675f137 100644
---- gdb/configure.host
-+++ gdb/configure.host
-@@ -84,6 +84,7 @@ case "${host}" in
- *-*-darwin*) gdb_host=darwin ;;
-
- aarch64*-*-linux*) gdb_host=linux ;;
-+aarch64*-*-freebsd*) gdb_host=fbsd ;;
-
- alpha*-*-linux*) gdb_host=alpha-linux ;;
- alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
-diff --git gdb/configure.tgt gdb/configure.tgt
-index fdcb7b1d69..f72a0dbbc1 100644
---- gdb/configure.tgt
-+++ gdb/configure.tgt
-@@ -44,6 +44,11 @@ aarch64*-*-elf | aarch64*-*-rtems*)
- gdb_target_obs="aarch64-tdep.o aarch64-newlib-tdep.o aarch64-insn.o"
- ;;
-
-+aarch64*-*-freebsd*)
-+ # Target: FreeBSD/aarch64
-+ gdb_target_obs="aarch64-tdep.o aarch64-fbsd-tdep.o aarch64-insn.o"
-+ ;;
-+
- aarch64*-*-linux*)
- # Target: AArch64 linux
- gdb_target_obs="aarch64-tdep.o aarch64-linux-tdep.o aarch64-insn.o \
Index: head/devel/gdb/files/patch-armfbsd
===================================================================
--- head/devel/gdb/files/patch-armfbsd
+++ head/devel/gdb/files/patch-armfbsd
@@ -1,512 +0,0 @@
-diff --git gdb/arm-fbsd-nat.c gdb/arm-fbsd-nat.c
-new file mode 100644
-index 0000000000..b1c5c360f8
---- /dev/null
-+++ gdb/arm-fbsd-nat.c
-@@ -0,0 +1,151 @@
-+/* Native-dependent code for FreeBSD/arm.
-+
-+ Copyright (C) 2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "defs.h"
-+#include "target.h"
-+
-+#include <sys/types.h>
-+#include <sys/ptrace.h>
-+#include <machine/reg.h>
-+
-+#include "fbsd-nat.h"
-+#include "arm-tdep.h"
-+#include "arm-fbsd-tdep.h"
-+#include "inf-ptrace.h"
-+
-+/* Determine if PT_GETREGS fetches REGNUM. */
-+
-+static bool
-+getregs_supplies (struct gdbarch *gdbarch, int regnum)
-+{
-+ return ((regnum >= ARM_A1_REGNUM && regnum <= ARM_PC_REGNUM)
-+ || regnum == ARM_PS_REGNUM);
-+}
-+
-+#ifdef PT_GETVFPREGS
-+/* Determine if PT_GETVFPREGS fetches REGNUM. */
-+
-+static bool
-+getvfpregs_supplies (struct gdbarch *gdbarch, int regnum)
-+{
-+ return ((regnum >= ARM_D0_REGNUM && regnum <= ARM_D31_REGNUM)
-+ || regnum == ARM_FPSCR_REGNUM);
-+}
-+#endif
-+
-+/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
-+ for all registers. */
-+
-+static void
-+arm_fbsd_fetch_inferior_registers (struct target_ops *ops,
-+ struct regcache *regcache, int regnum)
-+{
-+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
-+
-+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
-+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
-+ {
-+ struct reg regs;
-+
-+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
-+ perror_with_name (_("Couldn't get registers"));
-+
-+ regcache_supply_regset (&arm_fbsd_gregset, regcache, regnum, ®s,
-+ sizeof (regs));
-+ }
-+
-+#ifdef PT_GETVFPREGS
-+ if (regnum == -1 || getvfpregs_supplies (gdbarch, regnum))
-+ {
-+ struct vfpreg vfpregs;
-+
-+ if (ptrace (PT_GETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1)
-+ perror_with_name (_("Couldn't get floating point status"));
-+
-+ regcache_supply_regset (&arm_fbsd_vfpregset, regcache, regnum, &vfpregs,
-+ sizeof (vfpregs));
-+ }
-+#endif
-+}
-+
-+/* Store register REGNUM back into the inferior. If REGNUM is -1, do
-+ this for all registers. */
-+
-+static void
-+arm_fbsd_store_inferior_registers (struct target_ops *ops,
-+ struct regcache *regcache, int regnum)
-+{
-+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
-+
-+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
-+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
-+ {
-+ struct reg regs;
-+
-+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
-+ perror_with_name (_("Couldn't get registers"));
-+
-+ regcache_collect_regset (&arm_fbsd_gregset, regcache, regnum, ®s,
-+ sizeof (regs));
-+
-+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
-+ perror_with_name (_("Couldn't write registers"));
-+ }
-+
-+#ifdef PT_GETVFPREGS
-+ if (regnum == -1 || getvfpregs_supplies (gdbarch, regnum))
-+ {
-+ struct vfpreg vfpregs;
-+
-+ if (ptrace (PT_GETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1)
-+ perror_with_name (_("Couldn't get floating point status"));
-+
-+ regcache_collect_regset (&arm_fbsd_vfpregset, regcache, regnum, &vfpregs,
-+ sizeof (vfpregs));
-+
-+ if (ptrace (PT_SETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1)
-+ perror_with_name (_("Couldn't write floating point status"));
-+ }
-+#endif
-+}
-+
-+/* Implement the to_read_description method. */
-+
-+static const struct target_desc *
-+arm_fbsd_read_description (struct target_ops *ops)
-+{
-+ const struct target_desc *desc;
-+
-+ desc = arm_fbsd_read_description_auxv (ops);
-+ if (desc == NULL)
-+ desc = ops->beneath->to_read_description (ops->beneath);
-+ return desc;
-+}
-+
-+void
-+_initialize_arm_fbsd_nat (void)
-+{
-+ struct target_ops *t;
-+
-+ t = inf_ptrace_target ();
-+ t->to_fetch_registers = arm_fbsd_fetch_inferior_registers;
-+ t->to_store_registers = arm_fbsd_store_inferior_registers;
-+ t->to_read_description = arm_fbsd_read_description;
-+ fbsd_nat_add_target (t);
-+}
-diff --git gdb/arm-fbsd-tdep.c gdb/arm-fbsd-tdep.c
-new file mode 100644
-index 0000000000..02697b3de8
---- /dev/null
-+++ gdb/arm-fbsd-tdep.c
-@@ -0,0 +1,260 @@
-+/* Target-dependent code for FreeBSD/arm.
-+
-+ Copyright (C) 2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "defs.h"
-+
-+#include "elf/common.h"
-+#include "arm-tdep.h"
-+#include "arm-fbsd-tdep.h"
-+#include "auxv.h"
-+#include "fbsd-tdep.h"
-+#include "osabi.h"
-+#include "solib-svr4.h"
-+#include "target.h"
-+#include "trad-frame.h"
-+#include "tramp-frame.h"
-+
-+/* In a signal frame, sp points to a 'struct sigframe' which is
-+ defined as:
-+
-+ struct sigframe {
-+ siginfo_t sf_si;
-+ ucontext_t sf_uc;
-+ mcontext_vfp_t sf_vfp;
-+ };
-+
-+ ucontext_t is defined as:
-+
-+ struct __ucontext {
-+ sigset_t uc_sigmask;
-+ mcontext_t uc_mcontext;
-+ ...
-+ };
-+
-+ mcontext_t is defined as:
-+
-+ struct {
-+ unsigned int __gregs[17];
-+ size_t mc_vfp_size;
-+ void *mc_vfp_ptr;
-+ ...
-+ };
-+
-+ mcontext_vfp_t is defined as:
-+
-+ struct {
-+ uint64_t mcv_reg[32];
-+ uint32_t mcv_fpscr;
-+ };
-+
-+ If the VFP state is valid, then mc_vfp_ptr will point to sf_vfp in
-+ the sigframe, otherwise it is NULL. There is no non-VFP floating
-+ point register state saved in the signal frame. */
-+
-+#define ARM_MCONTEXT_REG_SIZE 4
-+#define ARM_MCONTEXT_VFP_REG_SIZE 8
-+#define ARM_SIGFRAME_UCONTEXT_OFFSET 64
-+#define ARM_UCONTEXT_MCONTEXT_OFFSET 16
-+#define ARM_MCONTEXT_VFP_PTR_OFFSET 72
-+
-+/* Implement the "init" method of struct tramp_frame. */
-+
-+static void
-+arm_fbsd_sigframe_init (const struct tramp_frame *self,
-+ struct frame_info *this_frame,
-+ struct trad_frame_cache *this_cache,
-+ CORE_ADDR func)
-+{
-+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
-+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-+ CORE_ADDR sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
-+ CORE_ADDR mcontext_addr =
-+ sp
-+ + ARM_SIGFRAME_UCONTEXT_OFFSET
-+ + ARM_UCONTEXT_MCONTEXT_OFFSET;
-+ CORE_ADDR mcontext_vfp_addr;
-+ gdb_byte buf[4];
-+ int i;
-+
-+ for (i = 0; i < 16; i++)
-+ {
-+ trad_frame_set_reg_addr (this_cache,
-+ ARM_A1_REGNUM + i,
-+ mcontext_addr + i * ARM_MCONTEXT_REG_SIZE);
-+ }
-+ trad_frame_set_reg_addr (this_cache, ARM_PS_REGNUM,
-+ mcontext_addr + 16 * ARM_MCONTEXT_REG_SIZE);
-+
-+ mcontext_vfp_addr = 0;
-+ if (target_read_memory (mcontext_addr + ARM_MCONTEXT_VFP_PTR_OFFSET, buf,
-+ 4) == 0)
-+ mcontext_vfp_addr = extract_unsigned_integer (buf, 4, byte_order);
-+ if (mcontext_vfp_addr != 0)
-+ {
-+ for (i = 0; i < 32; i++)
-+ {
-+ trad_frame_set_reg_addr (this_cache, ARM_D0_REGNUM + i,
-+ mcontext_vfp_addr
-+ + i * ARM_MCONTEXT_VFP_REG_SIZE);
-+ }
-+ trad_frame_set_reg_addr (this_cache, ARM_FPSCR_REGNUM,
-+ mcontext_vfp_addr
-+ + 32 * ARM_MCONTEXT_VFP_REG_SIZE);
-+ }
-+
-+ trad_frame_set_id (this_cache, frame_id_build (sp, func));
-+}
-+
-+static const struct tramp_frame arm_fbsd_sigframe =
-+{
-+ SIGTRAMP_FRAME,
-+ 4,
-+ {
-+ {0xe1a0000d, -1}, /* mov r0, sp */
-+ {0xe2800040, -1}, /* add r0, r0, #SIGF_UC */
-+ {0xe59f700c, -1}, /* ldr r7, [pc, #12] */
-+ {0xef0001a1, -1}, /* swi SYS_sigreturn */
-+ {TRAMP_SENTINEL_INSN, -1}
-+ },
-+ arm_fbsd_sigframe_init
-+};
-+
-+/* Register maps. */
-+
-+static const struct regcache_map_entry arm_fbsd_gregmap[] =
-+ {
-+ { 13, ARM_A1_REGNUM, 4 }, /* r0 ... r12 */
-+ { 1, ARM_SP_REGNUM, 4 },
-+ { 1, ARM_LR_REGNUM, 4 },
-+ { 1, ARM_PC_REGNUM, 4 },
-+ { 1, ARM_PS_REGNUM, 4 },
-+ { 0 }
-+ };
-+
-+static const struct regcache_map_entry arm_fbsd_vfpregmap[] =
-+ {
-+ { 32, ARM_D0_REGNUM, 8 }, /* d0 ... d31 */
-+ { 1, ARM_FPSCR_REGNUM, 4 },
-+ { 0 }
-+ };
-+
-+/* Register set definitions. */
-+
-+const struct regset arm_fbsd_gregset =
-+ {
-+ arm_fbsd_gregmap,
-+ regcache_supply_regset, regcache_collect_regset
-+ };
-+
-+const struct regset arm_fbsd_vfpregset =
-+ {
-+ arm_fbsd_vfpregmap,
-+ regcache_supply_regset, regcache_collect_regset
-+ };
-+
-+/* Implement the "regset_from_core_section" gdbarch method. */
-+
-+static void
-+arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
-+ iterate_over_regset_sections_cb *cb,
-+ void *cb_data,
-+ const struct regcache *regcache)
-+{
-+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-+
-+ cb (".reg", ARM_FBSD_SIZEOF_GREGSET, &arm_fbsd_gregset, NULL, cb_data);
-+
-+ /* While FreeBSD/arm cores do contain a NT_FPREGSET / ".reg2"
-+ register set, it is not populated with register values by the
-+ kernel but just contains all zeroes. */
-+ if (tdep->vfp_register_count > 0)
-+ cb (".reg-arm-vfp", ARM_FBSD_SIZEOF_VFPREGSET, &arm_fbsd_vfpregset,
-+ "VFP floating-point", cb_data);
-+}
-+
-+/* Lookup a target description from a target's AT_HWCAP auxiliary
-+ vector. */
-+
-+const struct target_desc *
-+arm_fbsd_read_description_auxv (struct target_ops *target)
-+{
-+ CORE_ADDR arm_hwcap = 0;
-+
-+ if (target_auxv_search (target, AT_FREEBSD_HWCAP, &arm_hwcap) != 1)
-+ return NULL;
-+
-+ if (arm_hwcap & HWCAP_VFP)
-+ {
-+ if (arm_hwcap & HWCAP_NEON)
-+ return tdesc_arm_with_neon;
-+ else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32))
-+ == (HWCAP_VFPv3 | HWCAP_VFPD32))
-+ return tdesc_arm_with_vfpv3;
-+ else
-+ return tdesc_arm_with_vfpv2;
-+ }
-+
-+ return NULL;
-+}
-+
-+/* Implement the "core_read_description" gdbarch method. */
-+
-+static const struct target_desc *
-+arm_fbsd_core_read_description (struct gdbarch *gdbarch,
-+ struct target_ops *target,
-+ bfd *abfd)
-+{
-+ return arm_fbsd_read_description_auxv (target);
-+}
-+
-+/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */
-+
-+static void
-+arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
-+{
-+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-+
-+ /* Generic FreeBSD support. */
-+ fbsd_init_abi (info, gdbarch);
-+
-+ if (tdep->fp_model == ARM_FLOAT_AUTO)
-+ tdep->fp_model = ARM_FLOAT_SOFT_VFP;
-+
-+ tramp_frame_prepend_unwinder (gdbarch, &arm_fbsd_sigframe);
-+
-+ set_solib_svr4_fetch_link_map_offsets
-+ (gdbarch, svr4_ilp32_fetch_link_map_offsets);
-+
-+ tdep->jb_pc = 24;
-+ tdep->jb_elt_size = 4;
-+
-+ set_gdbarch_iterate_over_regset_sections
-+ (gdbarch, arm_fbsd_iterate_over_regset_sections);
-+ set_gdbarch_core_read_description (gdbarch, arm_fbsd_core_read_description);
-+
-+ /* Single stepping. */
-+ set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
-+}
-+
-+void
-+_initialize_arm_fbsd_tdep (void)
-+{
-+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_FREEBSD,
-+ arm_fbsd_init_abi);
-+}
-diff --git gdb/arm-fbsd-tdep.h gdb/arm-fbsd-tdep.h
-new file mode 100644
-index 0000000000..8717b804af
---- /dev/null
-+++ gdb/arm-fbsd-tdep.h
-@@ -0,0 +1,40 @@
-+/* FreeBSD/arm target support, prototypes.
-+
-+ Copyright (C) 2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "regset.h"
-+
-+/* The general-purpose regset consists of 13 R registers, plus SP, LR,
-+ PC, and CPSR registers. */
-+#define ARM_FBSD_SIZEOF_GREGSET (17 * 4)
-+
-+/* The VFP regset consists of 32 D registers plus FPSCR, and the whole
-+ structure is padded to 64-bit alignment. */
-+#define ARM_FBSD_SIZEOF_VFPREGSET (33 * 8)
-+
-+extern const struct regset arm_fbsd_gregset;
-+extern const struct regset arm_fbsd_vfpregset;
-+
-+/* Flags passed in AT_HWCAP. */
-+#define HWCAP_VFP 0x00000040
-+#define HWCAP_NEON 0x00001000
-+#define HWCAP_VFPv3 0x00002000
-+#define HWCAP_VFPD32 0x00080000
-+
-+extern const struct target_desc *
-+arm_fbsd_read_description_auxv (struct target_ops *target);
---- /dev/null
-+++ gdb/config/arm/fbsd.mh
-@@ -0,0 +1,3 @@
-+# Host: FreeBSD/arm
-+NATDEPFILES= arm-fbsd-nat.o fbsd-nat.o fork-child.o inf-ptrace.o
-+HAVE_NATIVE_GCORE_HOST = 1
-diff --git gdb/configure.tgt gdb/configure.tgt
-index 122a72608f..06957c111d 100644
---- gdb/configure.tgt
-+++ gdb/configure.tgt
-@@ -110,6 +110,11 @@ arm*-*-linux*)
- solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
- build_gdbserver=yes
- ;;
-+arm*-*-freebsd*)
-+ # Target: FreeBSD/arm
-+ gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-fbsd-tdep.o \
-+ fbsd-tdep.o solib-svr4.o"
-+ ;;
- arm*-*-netbsd* | arm*-*-knetbsd*-gnu)
- # Target: NetBSD/arm
- gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-nbsd-tdep.o \
-diff --git gdb/Makefile.in gdb/Makefile.in
-index 9454e3a62f..c9bd60a2d8 100644
---- gdb/Makefile.in
-+++ gdb/Makefile.in
-@@ -794,6 +794,7 @@ ALL_TARGET_OBS = \
- arc-tdep.o \
- arm.o \
- arm-bsd-tdep.o \
-+ arm-fbsd-tdep.o \
- arm-get-next-pcs.o \
- arm-linux.o \
- arm-linux-tdep.o \
-@@ -2537,6 +2538,8 @@ ALLDEPFILES = \
- arc-tdep.c \
- arm.c \
- arm-bsd-tdep.c \
-+ arm-fbsd-nat.c \
-+ arm-fbsd-tdep.c \
- arm-get-next-pcs.c \
- arm-linux.c \
- arm-linux-nat.c \
Index: head/devel/gdb/files/patch-gdb_configure
===================================================================
--- head/devel/gdb/files/patch-gdb_configure
+++ head/devel/gdb/files/patch-gdb_configure
@@ -1,6 +1,6 @@
--- gdb/configure.orig 2017-09-14 09:28:17 UTC
+++ gdb/configure
-@@ -15103,12 +15103,10 @@ if test "${ERROR_ON_WARNING}" = yes ; then
+@@ -15292,13 +15292,10 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
@@ -10,9 +10,10 @@
--Wno-unused -Wunused-value -Wunused-function \
--Wno-switch -Wno-char-subscripts \
--Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \
---Wno-sign-compare -Wno-narrowing"
+--Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized \
+--Wno-mismatched-tags"
+-Wno-unused -Wno-switch -Wno-char-subscripts \
+-Wempty-body -Wno-sign-compare -Wno-narrowing -Wno-mismatched-tags"
- # Enable -Wno-format by default when using gcc on mingw since many
- # GCC versions complain about %I64.
+ case "${host}" in
+ *-*-mingw32*)
Index: head/devel/gdb/files/patch-gdb_configure.host
===================================================================
--- head/devel/gdb/files/patch-gdb_configure.host
+++ head/devel/gdb/files/patch-gdb_configure.host
@@ -1,10 +0,0 @@
---- gdb/configure.host.orig 2017-09-14 09:28:17 UTC
-+++ gdb/configure.host
-@@ -90,6 +90,7 @@ alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
- gdb_host=nbsd ;;
- alpha*-*-openbsd*) gdb_host=nbsd ;;
-
-+arm*-*-freebsd*) gdb_host=fbsd ;;
- arm*-*-linux*) gdb_host=linux ;;
- arm*-*-netbsdelf* | arm*-*-knetbsd*-gnu)
- gdb_host=nbsdelf ;;
Index: head/devel/gdb/files/patch-nowarning
===================================================================
--- head/devel/gdb/files/patch-nowarning
+++ head/devel/gdb/files/patch-nowarning
@@ -1,65 +0,0 @@
---- gdb/arm-tdep.c.orig 2016-07-08 15:42:17 UTC
-+++ gdb/arm-tdep.c
-@@ -9880,7 +9880,7 @@
- && !INSN_RECORDED(arm_insn_r))
- {
- /* Handle MLA(S) and MUL(S). */
-- if (0 <= insn_op1 && 3 >= insn_op1)
-+ if (3 >= insn_op1)
- {
- record_buf[0] = bits (arm_insn_r->arm_insn, 12, 15);
- record_buf[1] = ARM_PS_REGNUM;
---- gdb/cris-tdep.c.orig 2016-07-08 15:45:26.575379589 +0200
-+++ gdb/cris-tdep.c 2016-07-08 15:47:07.849372792 +0200
-@@ -1441,7 +1441,7 @@
- /* Indeterminate/obsolete. */
- return 0;
- case cris_ver_v0_3:
-- return (version >= 0 && version <= 3);
-+ return (version <= 3);
- case cris_ver_v3p:
- return (version >= 3);
- case cris_ver_v8:
-@@ -1449,7 +1449,7 @@
- case cris_ver_v8p:
- return (version >= 8);
- case cris_ver_v0_10:
-- return (version >= 0 && version <= 10);
-+ return (version <= 10);
- case cris_ver_v3_10:
- return (version >= 3 && version <= 10);
- case cris_ver_v8_10:
---- gdb/main.c.orig 2016-08-03 17:55:42.243017327 +0200
-+++ gdb/main.c 2016-08-03 17:56:04.478015630 +0200
-@@ -226,7 +226,7 @@
- {
- /* Append the part of SYSTEM_GDBINIT that follows GDB_DATADIR
- to gdb_datadir. */
-- char *tmp_sys_gdbinit = xstrdup (SYSTEM_GDBINIT + datadir_len);
-+ char *tmp_sys_gdbinit = xstrdup (&(SYSTEM_GDBINIT[datadir_len]));
- char *p;
-
- for (p = tmp_sys_gdbinit; IS_DIR_SEPARATOR (*p); ++p)
---- gdb/dtrace-probe.c.orig 2016-08-03 17:57:18.454010903 +0200
-+++ gdb/dtrace-probe.c 2016-08-03 17:58:01.001007519 +0200
-@@ -421,7 +421,8 @@
- arg.type_str = xstrdup (p);
-
- /* Use strtab_size as a sentinel. */
-- while (*p++ != '\0' && p - strtab < strtab_size);
-+ while (*p++ != '\0' && p - strtab < strtab_size)
-+ ;
-
- /* Try to parse a type expression from the type string. If
- this does not work then we set the type to `long
---- libiberty/stack-limit.c.orig 2016-08-05 14:12:21.942893014 +0200
-+++ libiberty/stack-limit.c 2016-08-05 14:12:58.794890125 +0200
-@@ -51,7 +51,7 @@
- struct rlimit rlim;
- if (getrlimit (RLIMIT_STACK, &rlim) == 0
- && rlim.rlim_cur != RLIM_INFINITY
-- && rlim.rlim_cur < pref
-+ && rlim.rlim_cur < (rlim_t)pref
- && (rlim.rlim_max == RLIM_INFINITY || rlim.rlim_cur < rlim.rlim_max))
- {
- rlim.rlim_cur = pref;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 10, 6:53 PM (1 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34937923
Default Alt Text
D14148.diff (252 KB)
Attached To
Mode
D14148: devel/gdb: Upgrade to gdb 8.1
Attached
Detach File
Event Timeline
Log In to Comment