Wed Nov 29 03:35:16 2017 UTC ()
bring back all our foonbsd-{nat,tdep} files as foo-nbsd-{nat,tdep}. Account
for that in the config glue.


(christos)
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/amd64-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/arm-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/hppa-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/hppa-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/i386-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/i386-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/mips-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.h
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.h
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sh-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sh-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-tdep.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/vax-nbsd-tdep.c
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/alpha/nbsd.mh
diff -r1.5 -r1.6 src/external/gpl3/gdb/dist/gdb/config/arm/nbsdelf.mh
diff -r1.4 -r1.5 src/external/gpl3/gdb/dist/gdb/config/i386/nbsd64.mh
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/i386/nbsdelf.mh
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/m68k/nbsdelf.mh
diff -r1.5 -r1.6 src/external/gpl3/gdb/dist/gdb/config/mips/nbsd.mh
diff -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdb/config/pa/nbsd.mh
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/powerpc/nbsd.mh
diff -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdb/config/powerpc/ppc64-nbsd.mh
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/sh/nbsd.mh
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/sparc/nbsd64.mh
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/sparc/nbsdelf.mh
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/vax/nbsdelf.mh

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c 2017/11/28 18:18:04 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/alpha.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    Contributed by Wasabi Systems, Inc.
 
@@ -28,13 +28,19 @@
 #include "value.h"
 
 #include "alpha-tdep.h"
-#include "alpha-bsd-tdep.h"
+#include "alphabsd-tdep.h"
 #include "nbsd-tdep.h"
 #include "solib-svr4.h"
+#include "trad-frame.h"
+#include "frame-unwind.h"
+#include "tramp-frame.h"
 #include "target.h"
 
 /* Core file support.  */
 
+/* Even though NetBSD/alpha used ELF since day one, it used the
+   traditional a.out-style core dump format before NetBSD 1.6.  */
+
 /* Sizeof `struct reg' in <machine/reg.h>.  */
 #define ALPHANBSD_SIZEOF_GREGS	(32 * 8)
 
@@ -168,32 +174,96 @@
 
 /* Signal trampolines.  */
 
+static void
+alphanbsd_sigtramp_cache_init (const struct tramp_frame *,
+			       struct frame_info *,
+			       struct trad_frame_cache *,
+			       CORE_ADDR);
 /* Under NetBSD/alpha, signal handler invocations can be identified by the
    designated code sequence that is used to return from a signal handler.
    In particular, the return address of a signal handler points to the
-   following code sequence:
+   following code sequences: */
+static const struct tramp_frame alphanbsd_sigtramp_sc1 = {
+  SIGTRAMP_FRAME,
+  4,
+  {
+    { 0xa61e0000, 0xffffffff },		/* ldq a0, 0(sp) */
+    { 0x23de0010, 0xffffffff },		/* lda sp, 16(sp) */
+    { 0x201f0127, 0xffffffff },		/* lda v0, 295 */
+    { 0x00000083, 0xffffffff },		/* call_pal callsys */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  alphanbsd_sigtramp_cache_init
+};
 
-	ldq	a0, 0(sp)
-	lda	sp, 16(sp)
-	lda	v0, 295(zero)	# __sigreturn14
-	call_pal callsys
-
-   Each instruction has a unique encoding, so we simply attempt to match
-   the instruction the PC is pointing to with any of the above instructions.
-   If there is a hit, we know the offset to the start of the designated
-   sequence and can then check whether we really are executing in the
-   signal trampoline.  If not, -1 is returned, otherwise the offset from the
-   start of the return sequence is returned.  */
-static const gdb_byte sigtramp_retcode[] =
+/* The siginfo signal trampoline for NetBSD/alpha introduced in 2.0 */
+static const struct tramp_frame alphanbsd_sigtramp_si2 =
 {
-  0x00, 0x00, 0x1e, 0xa6,	/* ldq a0, 0(sp) */
-  0x10, 0x00, 0xde, 0x23,	/* lda sp, 16(sp) */
-  0x27, 0x01, 0x1f, 0x20,	/* lda v0, 295(zero) */
-  0x83, 0x00, 0x00, 0x00,	/* call_pal callsys */
+  SIGTRAMP_FRAME,
+  4,
+  {
+    { 0x221e0080, -1 },		/* lda	a0,128(sp) */
+    { 0x201f0134, -1 },		/* lda	v0,308 */
+    { 0x00000083, -1 },		/* callsys */
+    { 0x47e00410, -1 },		/* mov	v0,a0 */
+    { 0x201f0001, -1 },		/* lda	v0,1 */
+    { 0x00000083, -1 },		/* callsys */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  alphanbsd_sigtramp_cache_init
 };
-#define RETCODE_NWORDS		4
-#define RETCODE_SIZE		(RETCODE_NWORDS * 4)
+/* The siginfo signal trampoline for NetBSD/alpha introduced in 4.0 */
+static const struct tramp_frame alphanbsd_sigtramp_si4 =
+{
+  SIGTRAMP_FRAME,
+  4,
+  {
+    { 0x27ba0000, 0xffff0000 },
+    { 0x23bd0000, 0xffff0000 },	/* ldgp	gp,0(ra) */
+    { 0x221e0080, -1 },		/* lda	a0,128(sp) */
+    { 0x201f0134, -1 },		/* lda	v0,308 */
+    { 0x00000083, -1 },		/* callsys */
+    { 0x221fffff, -1 },		/* lda	a0,-1 */
+    { 0x201f0001, -1 },		/* lda	v0,1 */
+    { 0x00000083, -1 },		/* callsys */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  alphanbsd_sigtramp_cache_init
+};
 
+static void
+alphanbsd_sigtramp_cache_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);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  CORE_ADDR addr, sp;
+  int i;
+
+  sp = get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM);
+
+  if (self == &alphanbsd_sigtramp_sc1) {
+    addr = sp;
+  } else {
+    addr = sp + 128 + 56;
+  }
+ 
+  for (i = 0; i < 32; i++, addr += ALPHA_REGISTER_SIZE)
+    {
+      trad_frame_set_reg_addr (this_cache, i, addr);
+    }
+  trad_frame_set_reg_addr (this_cache, ALPHA_PC_REGNUM, addr);
+
+  /* Construct the frame ID using the function start.  */
+  trad_frame_set_id (this_cache, frame_id_build (sp, func));
+}
+
+#ifdef notyet
+#define RETCODE_NWORDS          4
+#define RETCODE_SIZE            (RETCODE_NWORDS * 4)
+
 static LONGEST
 alphanbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
@@ -242,6 +312,7 @@
     return 0;
   return get_frame_base (get_next_frame (frame));
 }
+#endif
 
 
 static void
@@ -259,32 +330,49 @@
   /* NetBSD/alpha does not provide single step support via ptrace(2); we
      must use software single-stepping.  */
   set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
-
   /* NetBSD/alpha has SVR4-style shared libraries.  */
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_lp64_fetch_link_map_offsets);
+  set_gdbarch_skip_solib_resolver (gdbarch, nbsd_skip_solib_resolver);
 
+#ifdef notyet
   tdep->dynamic_sigtramp_offset = alphanbsd_sigtramp_offset;
   tdep->pc_in_sigtramp = alphanbsd_pc_in_sigtramp;
   tdep->sigcontext_addr = alphanbsd_sigcontext_addr;
+#endif
 
   tdep->jb_pc = 2;
   tdep->jb_elt_size = 8;
 
+  tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_sc1);
+  tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_si2);
+  tramp_frame_prepend_unwinder (gdbarch, &alphanbsd_sigtramp_si4);
+
   set_gdbarch_iterate_over_regset_sections
     (gdbarch, alphanbsd_iterate_over_regset_sections);
 }
 
 
+static enum gdb_osabi
+alphanbsd_core_osabi_sniffer (bfd *abfd)
+{
+  if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
+    return GDB_OSABI_NETBSD;
+
+  return GDB_OSABI_UNKNOWN;
+}
+
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_alphanbsd_tdep (void);
 
 void
 _initialize_alphanbsd_tdep (void)
 {
-  /* Even though NetBSD/alpha used ELF since day one, it used the
-     traditional a.out-style core dump format before NetBSD 1.6, but
-     we don't support those.  */
+  /* BFD doesn't set a flavour for NetBSD style a.out core files.  */
+  gdbarch_register_osabi_sniffer (bfd_arch_alpha, bfd_target_unknown_flavour,
+                                  alphanbsd_core_osabi_sniffer);
+
   gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_NETBSD,
                           alphanbsd_init_abi);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c 2017/11/28 18:18:06 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for NetBSD/amd64.
 
-   Copyright (C) 2003-2017 Free Software Foundation, Inc.
+   Copyright (C) 2003-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -23,7 +23,24 @@
 #include "nbsd-nat.h"
 #include "amd64-tdep.h"
 #include "amd64-nat.h"
+#include "regcache.h"
+#include "gdbcore.h"
+#include "bsd-kvm.h"
 
+#include <machine/frame.h>
+#include <machine/pcb.h>
+#include <machine/reg.h>
+
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+
+#include "gregset.h"
+
 /* Mapping between the general-purpose registers in NetBSD/amd64
    `struct reg' format and GDB's register cache layout for
    NetBSD/i386.
@@ -54,6 +71,96 @@
 };
 
 
+static int
+amd64nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
+{
+  struct switchframe sf;
+  int regnum;
+  long zero = 0;
+
+  /* The following is true for NetBSD/amd64:
+
+     The pcb contains the stack pointer at the point of the context
+     switch in cpu_switchto().  At that point we have a stack frame as
+     described by `struct switchframe', which for NetBSD/amd64 has the
+     following layout:
+
+     interrupt level
+     %r15
+     %r14
+     %r13
+     %r12
+     %rbx
+     return address
+
+     Together with %rsp in the pcb, this accounts for all callee-saved
+     registers specified by the psABI.  From this information we
+     reconstruct the register state as it would look when we just
+     returned from cpu_switchto().
+
+     For kernel core dumps, dumpsys() builds a fake switchframe for us. */
+
+  /* The stack pointer shouldn't be zero.  */
+  if (pcb->pcb_rsp == 0)
+    return 0;
+
+  /* Read the stack frame, and check its validity.  */
+  read_memory (pcb->pcb_rsp, (gdb_byte *) &sf, sizeof sf);
+  pcb->pcb_rsp += sizeof (struct switchframe);
+  regcache_raw_supply (regcache, 12, &sf.sf_r12);
+  regcache_raw_supply (regcache, 13, &sf.sf_r13);
+  regcache_raw_supply (regcache, 14, &sf.sf_r14);
+  regcache_raw_supply (regcache, 15, &sf.sf_r15);
+  regcache_raw_supply (regcache, AMD64_RBX_REGNUM, &sf.sf_rbx);
+  regcache_raw_supply (regcache, AMD64_RIP_REGNUM, &sf.sf_rip);
+
+  regcache_raw_supply (regcache, AMD64_RSP_REGNUM, &pcb->pcb_rsp);
+  regcache_raw_supply (regcache, AMD64_RBP_REGNUM, &pcb->pcb_rbp);
+  regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs);
+  regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs);
+
+  return 1;
+}
+
+void
+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
+{
+  amd64_supply_native_gregset (regcache, gregsetp, -1);
+}
+
+/* Fill register REGNUM (if it is a general-purpose register) in
+   *GREGSETP with the value in GDB's register cache.  If REGNUM is -1,
+   do this for all registers.  */
+
+void
+fill_gregset (const struct regcache *regcache,
+	      gregset_t *gregsetp, int regnum)
+{
+  amd64_collect_native_gregset (regcache, gregsetp, regnum);
+}
+
+/* Transfering floating-point registers between GDB, inferiors and cores.  */
+
+/* Fill GDB's register cache with the floating-point and SSE register
+   values in *FPREGSETP.  */
+
+void
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
+{
+  amd64_supply_fxsave (regcache, -1, fpregsetp);
+}
+
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+   *FPREGSETP with the value in GDB's register cache.  If REGNUM is
+   -1, do this for all registers.  */
+
+void
+fill_fpregset (const struct regcache *regcache,
+	       fpregset_t *fpregsetp, int regnum)
+{
+  amd64_collect_fxsave (regcache, regnum, fpregsetp);
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_amd64nbsd_nat (void);
 
@@ -70,4 +177,7 @@
   t = amd64bsd_target ();
   t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
   add_target (t);
+
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (amd64nbsd_supply_pcb);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/amd64-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/amd64-nbsd-tdep.c 2017/11/28 18:18:24 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/amd64-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/amd64.
 
-   Copyright (C) 2003-2017 Free Software Foundation, Inc.
+   Copyright (C) 2003-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -27,6 +27,8 @@
 #include "amd64-tdep.h"
 #include "nbsd-tdep.h"
 #include "solib-svr4.h"
+#include "trad-frame.h"
+#include "frame-unwind.h"
 
 /* Support for signal handlers.  */
 
@@ -93,7 +95,179 @@
   15 * 8			/* %gs */
 };
 
+/* Kernel debugging support */
+static const int amd64nbsd_tf_reg_offset[] =
+{
+  18 * 8,			/* %rax */
+  17 * 8,			/* %rbx */
+  10 * 8,			/* %rcx */
+  2 * 8,			/* %rdx */
+  1 * 8,			/* %rsi */
+  0 * 8,			/* %rdi */
+  16 * 8,			/* %rbp */
+  28 * 8,			/* %rsp */
+  4 * 8,			/* %r8 .. */
+  5 * 8,			
+  3 * 8,			
+  11 * 8,			
+  12 * 8,			
+  13 * 8,			
+  14 * 8,			
+  15 * 8,			/* ... %r15 */
+  25 * 8,			/* %rip */
+  27 * 8,			/* %eflags */
+  26 * 8,			/* %cs */
+  29 * 8,			/* %ss */
+  22 * 8,			/* %ds */
+  21 * 8,			/* %es */
+  20 * 8,			/* %fs */
+  19 * 8,			/* %gs */
+};
+
+static struct trad_frame_cache *
+amd64nbsd_trapframe_cache(struct frame_info *this_frame, void **this_cache)
+{
+  struct trad_frame_cache *cache;
+  CORE_ADDR func, sp, addr;
+  ULONGEST cs = 0, rip = 0;
+  const char *name;
+  int i;
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+  if (*this_cache)
+    return (struct trad_frame_cache *)*this_cache;
+
+  cache = trad_frame_cache_zalloc (this_frame);
+  *this_cache = cache;
+
+  func = get_frame_func (this_frame);
+  sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM);
+
+  find_pc_partial_function (func, &name, NULL, NULL);
+
+  /* There is an extra 'call' in the interrupt sequence - ignore the extra
+   * return address */
+  if (name && strncmp (name, "Xintr", 5) == 0)
+    addr = sp + 8;		/* It's an interrupt frame.  */
+  else
+    addr = sp;
+
+  for (i = 0; i < ARRAY_SIZE (amd64nbsd_tf_reg_offset); i++)
+    if (amd64nbsd_tf_reg_offset[i] != -1)
+      trad_frame_set_reg_addr (cache, i, addr + amd64nbsd_tf_reg_offset[i]);
+
+  /* Read %cs and %rip when we have the addresses to hand */
+  cs = read_memory_unsigned_integer (addr
+    + amd64nbsd_tf_reg_offset[AMD64_CS_REGNUM], 8, byte_order);
+  rip = read_memory_unsigned_integer (addr
+    + amd64nbsd_tf_reg_offset[AMD64_RIP_REGNUM], 8, byte_order);
+
+  /* The trap frame layout was changed lf the %rip value is less than 2^16 it
+   * is almost certainly the %ss of the old format. */
+  if (rip < (1 << 16))
+    {
+
+      for (i = 0; i < ARRAY_SIZE (amd64nbsd_tf_reg_offset); i++)
+        {
+
+          if (amd64nbsd_tf_reg_offset[i] == -1)
+            continue;
+
+          trad_frame_set_reg_addr (cache, i, addr + amd64nbsd_r_reg_offset[i]);
+
+          /* Read %cs when we have the address to hand */
+          if (i == AMD64_CS_REGNUM)
+	    cs = read_memory_unsigned_integer (addr + amd64nbsd_r_reg_offset[i],
+	    8, byte_order);
+        }
+    }
+
+  if ((cs & I386_SEL_RPL) == I386_SEL_UPL ||
+	(name && strncmp(name, "Xsoft", 5) == 0))
+    {
+      /* Trap from user space or soft interrupt; terminate backtrace.  */
+      trad_frame_set_id (cache, outer_frame_id);
+    }
+  else
+    {
+      /* Construct the frame ID using the function start.  */
+      trad_frame_set_id (cache, frame_id_build (sp + 16, func));
+    }
+
+  return cache;
+}
+
 static void
+amd64nbsd_trapframe_this_id (struct frame_info *this_frame,
+			     void **this_cache,
+			     struct frame_id *this_id)
+{
+  struct trad_frame_cache *cache =
+    amd64nbsd_trapframe_cache (this_frame, this_cache);
+  
+  trad_frame_get_id (cache, this_id);
+}
+
+static struct value *
+amd64nbsd_trapframe_prev_register (struct frame_info *this_frame,
+				   void **this_cache, int regnum) 
+{
+  struct trad_frame_cache *cache =
+    amd64nbsd_trapframe_cache (this_frame, this_cache);
+
+  return trad_frame_get_register (cache, this_frame, regnum);
+}
+
+static int
+amd64nbsd_trapframe_sniffer (const struct frame_unwind *self,
+			     struct frame_info *this_frame,
+			     void **this_prologue_cache)
+{
+  ULONGEST cs = 0;
+  const char *name;
+  volatile struct gdb_exception ex;
+
+  TRY
+    {
+      cs = get_frame_register_unsigned (this_frame, AMD64_CS_REGNUM);
+    }
+  CATCH (ex, RETURN_MASK_ERROR)
+    {
+      if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+	throw_exception (ex);
+    }
+  END_CATCH
+  if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
+    return 0;
+
+  find_pc_partial_function (get_frame_pc (this_frame), &name, NULL, NULL);
+  return (name && ((strcmp (name, "alltraps") == 0)
+		   || (strcmp (name, "calltrap") == 0)
+		   || (strncmp (name, "Xtrap", 5) == 0)
+		   || (strcmp (name, "osyscall1") == 0)
+		   || (strcmp (name, "Xsyscall") == 0)
+		   || (strncmp (name, "Xintr", 5) == 0)
+		   || (strncmp (name, "Xresume", 7) == 0)
+		   || (strncmp (name, "Xstray", 6) == 0)
+		   || (strncmp (name, "Xrecurse", 8) == 0)
+		   || (strncmp (name, "Xsoft", 5) == 0)
+		   || (strcmp (name, "Xdoreti") == 0)));
+}
+
+static const struct frame_unwind amd64nbsd_trapframe_unwind = {
+  /* FIXME: kettenis/20051219: This really is more like an interrupt
+     frame, but SIGTRAMP_FRAME would print <signal handler called>,
+     which really is not what we want here.  */
+  NORMAL_FRAME,
+  default_frame_unwind_stop_reason,
+  amd64nbsd_trapframe_this_id,
+  amd64nbsd_trapframe_prev_register,
+  NULL,
+  amd64nbsd_trapframe_sniffer
+};
+
+static void
 amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -116,6 +290,8 @@
   /* NetBSD uses SVR4-style shared libraries.  */
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_lp64_fetch_link_map_offsets);
+  /* Unwind kernel trap frames correctly.  */
+  frame_unwind_prepend_unwinder (gdbarch, &amd64nbsd_trapframe_unwind);
 }
 
 

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c 2017/11/28 18:18:23 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for BSD Unix running on ARM's, for GDB.
 
-   Copyright (C) 1988-2017 Free Software Foundation, Inc.
+   Copyright (C) 1988-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -17,21 +17,87 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNTYPES
+#define _KERNTYPES
+#endif
 #include "defs.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "target.h"
+
+#include "nbsd-nat.h"
 #include <sys/types.h>
 #include <sys/ptrace.h>
 #include <machine/reg.h>
 #include <machine/frame.h>
+#include <arm/arm32/frame.h>
 
+/* Support for debugging kernel virtual memory images.  */
+#include <machine/pcb.h>
+
 #include "arm-tdep.h"
 #include "inf-ptrace.h"
+#include "bsd-kvm.h"
 
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+
+#include "gregset.h"
+
 extern int arm_apcs_32;
 
+static int
+armnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
+{
+  struct switchframe sf;
+
+  /* The following is true for NetBSD/arm32 in 5.0 and after:
+
+     The pcb contains r8-r13 (sp) at the point of context switch in
+     cpu_switchto() or call of dumpsys(). At that point we have a
+     stack frame as described by `struct switchframe', which for
+     NetBSD/arm32 has the following layout:
+
+	r4   ascending.
+	r5        |
+	r6        |
+	r7       \|/
+	old sp
+	pc
+
+     we reconstruct the register state as it would look when we just
+     returned from cpu_switchto() or dumpsys().  */
+
+  if (!arm_apcs_32)
+    return 0;
+
+  /* The stack pointer shouldn't be zero.  */
+  if (pcb->pcb_un.un_32.pcb32_sp == 0)
+    return 0;
+
+  read_memory (pcb->pcb_un.un_32.pcb32_sp, (gdb_byte *) &sf, sizeof sf);
+
+  regcache_raw_supply (regcache, ARM_PC_REGNUM, &sf.sf_pc);
+  regcache_raw_supply (regcache, ARM_SP_REGNUM, &pcb->pcb_un.un_32.pcb32_sp);
+  regcache_raw_supply (regcache, 12, &pcb->pcb_un.un_32.pcb32_r12);
+  regcache_raw_supply (regcache, 11, &pcb->pcb_un.un_32.pcb32_r11);
+  regcache_raw_supply (regcache, 10, &pcb->pcb_un.un_32.pcb32_r10);
+  regcache_raw_supply (regcache, 9, &pcb->pcb_un.un_32.pcb32_r9);
+  regcache_raw_supply (regcache, 8, &pcb->pcb_un.un_32.pcb32_r8);
+  regcache_raw_supply (regcache, 7, &sf.sf_r7);
+  regcache_raw_supply (regcache, 6, &sf.sf_r6);
+  regcache_raw_supply (regcache, 5, &sf.sf_r5);
+  regcache_raw_supply (regcache, 4, &sf.sf_r4);
+
+  return 1;
+}
+
 static void
 arm_supply_gregset (struct regcache *regcache, struct reg *gregset)
 {
@@ -59,26 +125,87 @@
 }
 
 static void
-arm_supply_fparegset (struct regcache *regcache, struct fpreg *fparegset)
+arm_supply_vfpregset (struct regcache *regcache, struct fpreg *vfpregset)
 {
   int regno;
 
-  for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++)
-    regcache_raw_supply (regcache, regno,
-			 (char *) &fparegset->fpr[regno - ARM_F0_REGNUM]);
+  for (regno = 0; regno < 16; regno++)
+    regcache_raw_supply (regcache, regno + ARM_D0_REGNUM,
+			 (char *) vfpregset->fpr_vfp.vfp_regs + 8*regno);
 
-  regcache_raw_supply (regcache, ARM_FPS_REGNUM,
-		       (char *) &fparegset->fpr_fpsr);
+  regcache_raw_supply (regcache, ARM_FPSCR_REGNUM,
+		       (char *) &vfpregset->fpr_vfp.vfp_fpscr);
 }
 
+void
+fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
+{
+  if (-1 == regno)
+    {
+      int regnum;
+      for (regnum = ARM_A1_REGNUM; regnum < ARM_SP_REGNUM; regnum++) 
+	regcache_raw_collect (regcache, regnum, (char *) &gregsetp->r[regnum]);
+    }
+  else if (regno >= ARM_A1_REGNUM && regno < ARM_SP_REGNUM)
+    regcache_raw_collect (regcache, regno, (char *) &gregsetp->r[regno]);
+
+  if (ARM_SP_REGNUM == regno || -1 == regno)
+    regcache_raw_collect (regcache, ARM_SP_REGNUM, (char *) &gregsetp->r_sp);
+
+  if (ARM_LR_REGNUM == regno || -1 == regno)
+    regcache_raw_collect (regcache, ARM_LR_REGNUM, (char *) &gregsetp->r_lr);
+
+  if (ARM_PC_REGNUM == regno || -1 == regno)
+    regcache_raw_collect (regcache, ARM_PC_REGNUM, (char *) &gregsetp->r_pc);
+
+  if (ARM_PS_REGNUM == regno || -1 == regno)
+    {
+      if (arm_apcs_32)
+	regcache_raw_collect (regcache, ARM_PS_REGNUM, (char *) &gregsetp->r_cpsr);
+      else
+	regcache_raw_collect (regcache, ARM_PS_REGNUM, (char *) &gregsetp->r_pc);
+    }
+ }
+ 
+void
+fill_fpregset (const struct regcache *regcache, fpregset_t *vfpregsetp, int regno)
+{
+  if (-1 == regno)
+    {
+       int regnum;
+       for (regnum = 0; regnum <= 15; regnum++)
+         regcache_raw_collect(regcache, regnum + ARM_D0_REGNUM,
+			      (char *) vfpregsetp->fpr_vfp.vfp_regs + 8*regnum);
+    }
+  else if (regno >= ARM_D0_REGNUM && regno <= ARM_D0_REGNUM + 15)
+    regcache_raw_collect(regcache, regno,
+			 (char *) vfpregsetp->fpr_vfp.vfp_regs + 8 * (regno - ARM_D0_REGNUM));
+
+  if (ARM_FPSCR_REGNUM == regno || -1 == regno)
+    regcache_raw_collect (regcache, ARM_FPSCR_REGNUM,
+			  (char *) &vfpregsetp->fpr_vfp.vfp_fpscr);
+}
+
+void
+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
+{
+  arm_supply_gregset (regcache, (struct reg *)gregsetp);
+}
+
+void
+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
+{
+  arm_supply_vfpregset (regcache, (struct fpreg *)fpregsetp);
+}
+
 static void
 fetch_register (struct regcache *regcache, int regno)
 {
   struct reg inferior_registers;
   int ret;
 
-  ret = ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     {
@@ -130,8 +257,8 @@
   int ret;
   int regno;
 
-  ret = ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     {
@@ -148,8 +275,8 @@
   struct fpreg inferior_fp_registers;
   int ret;
 
-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_fp_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     {
@@ -159,14 +286,14 @@
 
   switch (regno)
     {
-    case ARM_FPS_REGNUM:
-      regcache_raw_supply (regcache, ARM_FPS_REGNUM,
-			   (char *) &inferior_fp_registers.fpr_fpsr);
+    case ARM_FPSCR_REGNUM:
+      regcache_raw_supply (regcache, ARM_FPSCR_REGNUM,
+			   (char *) &inferior_fp_registers.fpr_vfp.vfp_fpscr);
       break;
 
     default:
       regcache_raw_supply (regcache, regno,
-			   (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
+			   (char *) inferior_fp_registers.fpr_vfp.vfp_regs + 8 * (regno - ARM_D0_REGNUM));
       break;
     }
 }
@@ -178,16 +305,16 @@
   int ret;
   int regno;
 
-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_fp_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     {
-      warning (_("unable to fetch general registers"));
+      warning (_("unable to fetch floating-point registers"));
       return;
     }
 
-  arm_supply_fparegset (regcache, &inferior_fp_registers);
+  arm_supply_vfpregset (regcache, &inferior_fp_registers);
 }
 
 static void
@@ -196,10 +323,10 @@
 {
   if (regno >= 0)
     {
-      if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
-	fetch_register (regcache, regno);
-      else
+      if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM)
 	fetch_fp_register (regcache, regno);
+      else
+	fetch_register (regcache, regno);
     }
   else
     {
@@ -216,8 +343,8 @@
   struct reg inferior_registers;
   int ret;
 
-  ret = ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     {
@@ -279,8 +406,8 @@
       break;
     }
 
-  ret = ptrace (PT_SETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+  ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
@@ -327,8 +454,8 @@
       inferior_registers.r_pc = pc_val | psr_val;
     }
 
-  ret = ptrace (PT_SETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+  ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     warning (_("unable to store general registers"));
@@ -340,8 +467,8 @@
   struct fpreg inferior_fp_registers;
   int ret;
 
-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_fp_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     {
@@ -351,19 +478,20 @@
 
   switch (regno)
     {
-    case ARM_FPS_REGNUM:
+    case ARM_FPSCR_REGNUM:
       regcache_raw_collect (regcache, ARM_FPS_REGNUM,
-			    (char *) &inferior_fp_registers.fpr_fpsr);
+			    (char *) &inferior_fp_registers.fpr_vfp.vfp_fpscr);
       break;
 
     default:
       regcache_raw_collect (regcache, regno,
-			    (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
+			    (char *) inferior_fp_registers.fpr_vfp.vfp_regs
+			    + 8 * (regno - ARM_D0_REGNUM));
       break;
     }
 
-  ret = ptrace (PT_SETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+  ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_fp_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
@@ -377,15 +505,16 @@
   int regno;
 
 
-  for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++)
-    regcache_raw_collect (regcache, regno,
-			  (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
+  for (regno = 0; regno <= 15; regno++)
+    regcache_raw_collect (regcache, regno + ARM_D0_REGNUM,
+			  (char *) inferior_fp_registers.fpr_vfp.vfp_regs
+				   + 8 * regno);
 
-  regcache_raw_collect (regcache, ARM_FPS_REGNUM,
-			(char *) &inferior_fp_registers.fpr_fpsr);
+  regcache_raw_collect (regcache, ARM_FPSCR_REGNUM,
+			(char *) &inferior_fp_registers.fpr_vfp.vfp_fpscr);
 
-  ret = ptrace (PT_SETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
-		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+  ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+		(PTRACE_TYPE_ARG3) &inferior_fp_registers, ptid_get_lwp(inferior_ptid));
 
   if (ret < 0)
     warning (_("unable to store floating-point registers"));
@@ -397,10 +526,10 @@
 {
   if (regno >= 0)
     {
-      if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
-	store_register (regcache, regno);
-      else
+      if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM)
 	store_fp_register (regcache, regno);
+      else
+	store_register (regcache, regno);
     }
   else
     {
@@ -409,13 +538,32 @@
     }
 }
 
+struct md_core
+{
+  struct reg intreg;
+  struct fpreg freg;
+};
+
 static void
+fetch_core_registers (struct regcache *regcache,
+		      char *core_reg_sect, unsigned core_reg_size,
+		      int which, CORE_ADDR ignore)
+{
+  struct md_core *core_reg = (struct md_core *) core_reg_sect;
+  int regno;
+  CORE_ADDR r_pc;
+
+  arm_supply_gregset (regcache, &core_reg->intreg);
+  arm_supply_vfpregset (regcache, &core_reg->freg);
+}
+
+static void
 fetch_elfcore_registers (struct regcache *regcache,
 			 char *core_reg_sect, unsigned core_reg_size,
 			 int which, CORE_ADDR ignore)
 {
   struct reg gregset;
-  struct fpreg fparegset;
+  struct fpreg vfpregset;
 
   switch (which)
     {
@@ -438,8 +586,8 @@
 	{
 	  /* The memcpy may be unnecessary, but we can't really be sure
 	     of the alignment of the data in the core file.  */
-	  memcpy (&fparegset, core_reg_sect, sizeof (fparegset));
-	  arm_supply_fparegset (regcache, &fparegset);
+	  memcpy (&vfpregset, core_reg_sect, sizeof (vfpregset));
+	  arm_supply_vfpregset (regcache, &vfpregset);
 	}
       break;
 
@@ -449,6 +597,15 @@
     }
 }
 
+static struct core_fns arm_netbsd_core_fns =
+{
+  bfd_target_unknown_flavour,		/* core_flovour.  */
+  default_check_format,			/* check_format.  */
+  default_core_sniffer,			/* core_sniffer.  */
+  fetch_core_registers,			/* core_read_registers.  */
+  NULL
+};
+
 static struct core_fns arm_netbsd_elfcore_fns =
 {
   bfd_target_elf_flavour,		/* core_flovour.  */
@@ -466,7 +623,12 @@
   t = inf_ptrace_target ();
   t->to_fetch_registers = armnbsd_fetch_registers;
   t->to_store_registers = armnbsd_store_registers;
+  t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
   add_target (t);
 
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (armnbsd_supply_pcb);
+
+  deprecated_add_core_fns (&arm_netbsd_core_fns);
   deprecated_add_core_fns (&arm_netbsd_elfcore_fns);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/arm-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/arm-nbsd-tdep.c 2017/11/28 18:18:14 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/arm-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/arm.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -22,6 +22,7 @@
 
 #include "arch/arm.h"
 #include "arm-tdep.h"
+#include "nbsd-tdep.h"
 #include "solib-svr4.h"
 
 /* Description of the longjmp buffer.  */
@@ -42,7 +43,7 @@
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   tdep->lowest_pc = 0x8000;
-  switch (info.byte_order)
+  switch (info.byte_order_for_code)
     {
     case BFD_ENDIAN_LITTLE:
       tdep->arm_breakpoint = arm_nbsd_arm_le_breakpoint;
@@ -68,9 +69,24 @@
 
   /* Single stepping.  */
   set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
+  /* Core support */
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, armbsd_iterate_over_regset_sections);
+
 }
-  
+
 static void
+arm_netbsd_aout_init_abi (struct gdbarch_info info,
+			  struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  arm_netbsd_init_abi_common (info, gdbarch);
+  if (tdep->fp_model == ARM_FLOAT_AUTO)
+    tdep->fp_model = ARM_FLOAT_SOFT_FPA;
+}
+
+static void
 arm_netbsd_elf_init_abi (struct gdbarch_info info,
 			 struct gdbarch *gdbarch)
 {
@@ -83,6 +99,9 @@
   /* NetBSD ELF uses SVR4-style shared libraries.  */
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+
+  /* for single stepping; see PR/50773 */
+  set_gdbarch_skip_solib_resolver (gdbarch, nbsd_skip_solib_resolver);
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
@@ -91,6 +110,9 @@
 void
 _initialize_arm_netbsd_tdep (void)
 {
+  gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_aout_flavour,
+				  arm_netbsd_aout_osabi_sniffer);
+
   gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_NETBSD,
                           arm_netbsd_elf_init_abi);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/hppa-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/hppa-nbsd-nat.c 2017/11/28 18:18:13 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/hppa-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for NetBSD/hppa.
 
-   Copyright (C) 2008-2017 Free Software Foundation, Inc.
+   Copyright (C) 2008-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -30,6 +30,16 @@
 
 #include "nbsd-nat.h"
 
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+
+#include "gregset.h"
+
 static int
 hppanbsd_gregset_supplies_p (int regnum)
 {
@@ -50,8 +60,7 @@
 static void
 hppanbsd_supply_gregset (struct regcache *regcache, const void *gregs)
 {
-  const char *regs = gregs;
-  const int *r = gregs;
+  const char *regs = (const char *) gregs;
   int regnum;
 
   for (regnum = HPPA_R1_REGNUM; regnum <= HPPA_R31_REGNUM; regnum++)
@@ -75,7 +84,7 @@
 static void
 hppanbsd_supply_fpregset (struct regcache *regcache, const void *fpregs)
 {
-  const char *regs = fpregs;
+  const char *regs = (const char *) fpregs;
   int regnum;
 
   for (regnum = HPPA_FP0_REGNUM; regnum <= HPPA_FP31R_REGNUM;
@@ -93,8 +102,7 @@
 hppanbsd_collect_gregset (const struct regcache *regcache,
 			  void *gregs, int regnum)
 {
-  char *regs = gregs;
-  int *r = gregs;
+  char *regs = (char *) gregs;
   int i;
 
   for (i = HPPA_R1_REGNUM; i <= HPPA_R31_REGNUM; i++)
@@ -138,10 +146,10 @@
    in FPREGS.  */
 
 static void
-hppanbsd_collect_fpregset (struct regcache *regcache,
+hppanbsd_collect_fpregset (const struct regcache *regcache,
 			  void *fpregs, int regnum)
 {
-  char *regs = fpregs;
+  char *regs = (char *) fpregs;
   int i;
 
   for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i += 2, regs += 8)
@@ -163,13 +171,12 @@
 			  struct regcache *regcache, int regnum)
 
 {
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
-
   if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       hppanbsd_supply_gregset (regcache, &regs);
@@ -179,7 +186,8 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       hppanbsd_supply_fpregset (regcache, &fpregs);
@@ -193,18 +201,18 @@
 hppanbsd_store_registers (struct target_ops *ops,
 			  struct regcache *regcache, int regnum)
 {
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
-
   if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+                  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       hppanbsd_collect_gregset (regcache, &regs, regnum);
 
-      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+	          (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
         perror_with_name (_("Couldn't write registers"));
     }
 
@@ -212,16 +220,56 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       hppanbsd_collect_fpregset (regcache, &fpregs, regnum);
 
-      if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't write floating point status"));
     }
 }
 
+void
+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
+{
+  hppanbsd_supply_gregset (regcache, gregsetp);
+}
+
+/* Fill register REGNUM (if it is a general-purpose register) in
+   *GREGSETP with the value in GDB's register cache.  If REGNUM is -1,
+   do this for all registers.  */
+
+void
+fill_gregset (const struct regcache *regcache,
+              gregset_t *gregsetp, int regnum)
+{
+  hppanbsd_collect_gregset (regcache, gregsetp, regnum);
+}
+
+/* Transfering floating-point registers between GDB, inferiors and cores.  */
+
+/* Fill GDB's register cache with the floating-point and SSE register
+   values in *FPREGSETP.  */
+
+void
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
+{
+  hppanbsd_supply_fpregset (regcache, fpregsetp);
+}
+
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+   *FPREGSETP with the value in GDB's register cache.  If REGNUM is
+   -1, do this for all registers.  */
+
+void
+fill_fpregset (const struct regcache *regcache,
+               fpregset_t *fpregsetp, int regnum)
+{
+  hppanbsd_collect_fpregset (regcache, fpregsetp, regnum);
+}
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_hppanbsd_nat (void);

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/hppa-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/hppa-nbsd-tdep.c 2017/11/28 18:18:02 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/hppa-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/hppa
 
-   Copyright (C) 2008-2017 Free Software Foundation, Inc.
+   Copyright (C) 2008-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -26,7 +26,7 @@
 #include "tramp-frame.h"
 
 #include "hppa-tdep.h"
-#include "hppa-bsd-tdep.h"
+#include "hppabsd-tdep.h"
 
 /* From <machine/mcontext.h>.  */
 static int hppanbsd_mc_reg_offset[] =
@@ -57,6 +57,19 @@
   38 * 4,	/* sr1 */
   39 * 4,	/* sr2 */
   40 * 4,	/* sr3 */
+  -1,		/* 48 */
+  -1,		/* 49 */
+  -1,		/* 50 */
+  -1,		/* 51 */
+  -1,		/* 52 */
+  -1,		/* 53 */
+  -1,		/* 54 */
+  -1,		/* 55 */
+  -1,		/* 56 */
+  -1,		/* 57 CR24 */
+  -1,		/* 58 CR25 */
+  -1,		/* 59 CR26 */
+  43 * 4,	/* HPPA_CR27_REGNUM */
 
   /* more tbd */
 };
@@ -128,7 +141,7 @@
 /* Core file support.  */
 
 /* Sizeof `struct reg' in <machine/reg.h>.  */
-#define HPPANBSD_SIZEOF_GREGS	(44 * 4)
+#define HPPANBSD_SIZEOF_GREGS	(47 * 4)
 
 static int hppanbsd_reg_offset[] =
 {
@@ -152,6 +165,25 @@
   -1,		/* HPPA_ISR_REGNUM */
   -1,		/* HPPA_IOR_REGNUM */
   0 * 4,	/* HPPA_IPSW_REGNUM */
+  -1,		/* spare? */
+  41 * 4,	/* HPPA_SR4_REGNUM */
+  37 * 4,	/* sr0 */
+  38 * 4,	/* sr1 */
+  39 * 4,	/* sr2 */
+  40 * 4,	/* sr3 */
+  -1,		/* 48 */
+  -1,		/* 49 */
+  -1,		/* 50 */
+  -1,		/* 51 */
+  -1,		/* 52 */
+  -1,		/* 53 */
+  -1,		/* 54 */
+  -1,		/* 55 */
+  -1,		/* 56 */
+  -1,		/* 57 */
+  -1,		/* 58 */
+  -1,		/* 59 */
+  46 * 4,	/* HPPA_CR27_REGNUM */
 };
 
 /* Supply register REGNUM from the buffer specified by GREGS and LEN

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/i386-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/i386-nbsd-nat.c 2017/11/28 18:18:05 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/i386-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for NetBSD/i386.
 
-   Copyright (C) 2004-2017 Free Software Foundation, Inc.
+   Copyright (C) 2004-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -23,52 +23,128 @@
 #include "target.h"
 
 #include "i386-tdep.h"
-#include "i386-bsd-nat.h"
+#include "i387-tdep.h"
+#include "i386bsd-nat.h"
 
 /* Support for debugging kernel virtual memory images.  */
 
 #include <sys/types.h>
+#include <machine/reg.h>
 #include <machine/frame.h>
 #include <machine/pcb.h>
 
 #include "nbsd-nat.h"
 #include "bsd-kvm.h"
 
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+
+#include "gregset.h" 
+
 static int
 i386nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
   struct switchframe sf;
 
-  /* The following is true for NetBSD 1.6.2:
+  /* The following is true for NetBSD 1.6.2 and after:
 
      The pcb contains %esp and %ebp at the point of the context switch
-     in cpu_switch().  At that point we have a stack frame as
-     described by `struct switchframe', which for NetBSD 1.6.2 has the
-     following layout:
+     in cpu_switch()/cpu_switchto().  At that point we have a stack frame as
+     described by `struct switchframe', which for NetBSD (2.0 and later) has
+     the following layout:
 
-     interrupt level
      %edi
      %esi
      %ebx
-     %eip
+     return address
 
      we reconstruct the register state as it would look when we just
-     returned from cpu_switch().  */
+     returned from cpu_switch()/cpu_switchto().
 
+     For core dumps the pcb is saved by savectx()/dumpsys() and contains the
+     stack pointer and frame pointer.  A new dumpsys() fakes a switchframe
+     whereas older code isn't reliable so use an iffy heuristic to detect this
+     and use the frame pointer to recover enough state.  */
+
   /* The stack pointer shouldn't be zero.  */
   if (pcb->pcb_esp == 0)
     return 0;
 
-  read_memory (pcb->pcb_esp, (gdb_byte *)&sf, sizeof sf);
-  pcb->pcb_esp += sizeof (struct switchframe);
-  regcache_raw_supply (regcache, I386_EDI_REGNUM, &sf.sf_edi);
-  regcache_raw_supply (regcache, I386_ESI_REGNUM, &sf.sf_esi);
-  regcache_raw_supply (regcache, I386_EBP_REGNUM, &pcb->pcb_ebp);
-  regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_esp);
-  regcache_raw_supply (regcache, I386_EBX_REGNUM, &sf.sf_ebx);
-  regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
+  read_memory (pcb->pcb_esp, (gdb_byte *) &sf, sizeof sf);
 
+  if ( (unsigned long)sf.sf_eip >= (unsigned long)0xc0100000 )
+    {
+      /* Yes, we have a switchframe that matches cpu_switchto() or
+         the new dumpsys().  */
+
+      pcb->pcb_esp += sizeof (struct switchframe);
+      regcache_raw_supply (regcache, I386_EDI_REGNUM, &sf.sf_edi);
+      regcache_raw_supply (regcache, I386_ESI_REGNUM, &sf.sf_esi);
+      regcache_raw_supply (regcache, I386_EBP_REGNUM, &pcb->pcb_ebp);
+      regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_esp);
+      regcache_raw_supply (regcache, I386_EBX_REGNUM, &sf.sf_ebx);
+      regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
+    }
+  else
+    {
+      CORE_ADDR pc, fp;
+
+      /* No, the pcb must have been last updated by savectx() in old
+         dumpsys(). Use the frame pointer to recover enough state.  */
+
+      read_memory (pcb->pcb_ebp, (gdb_byte *) &fp, sizeof(fp));
+      read_memory (pcb->pcb_ebp + 4, (gdb_byte *) &pc, sizeof(pc));
+
+      regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_ebp);
+      regcache_raw_supply (regcache, I386_EBP_REGNUM, &fp);
+      regcache_raw_supply (regcache, I386_EIP_REGNUM, &pc);
+    }
+
   return 1;
+}
+
+void
+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
+{
+  i386bsd_supply_gregset (regcache, gregsetp);
+}
+
+/* Fill register REGNUM (if it is a general-purpose register) in
+   *GREGSETP with the value in GDB's register cache.  If REGNUM is -1,
+   do this for all registers.  */
+
+void
+fill_gregset (const struct regcache *regcache,
+              gregset_t *gregsetp, int regnum)
+{
+  i386bsd_collect_gregset (regcache, gregsetp, regnum);
+}
+
+/* Transfering floating-point registers between GDB, inferiors and cores.  */
+   
+/* Fill GDB's register cache with the floating-point and SSE register
+   values in *FPREGSETP.  */
+
+void
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
+{  
+  i387_supply_fsave (regcache, -1, fpregsetp);
+}
+   
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+   *FPREGSETP with the value in GDB's register cache.  If REGNUM is
+   -1, do this for all registers.  */
+
+void
+fill_fpregset (const struct regcache *regcache,
+               fpregset_t *fpregsetp, int regnum)
+{
+  i387_collect_fsave (regcache, regnum, fpregsetp);
 }
 
 

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/i386-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/i386-nbsd-tdep.c 2017/11/28 18:18:04 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/i386-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/i386.
 
-   Copyright (C) 1988-2017 Free Software Foundation, Inc.
+   Copyright (C) 1988-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -33,6 +33,11 @@
 #include "nbsd-tdep.h"
 #include "solib-svr4.h"
 
+#include "elf-bfd.h"		/* for header hack */
+#include "trad-frame.h"		/* signal trampoline/kernel frame support */
+#include "frame-unwind.h"	/* kernel frame support */
+#include "tramp-frame.h"	/* signal trampoline/kernel frame support */
+
 /* From <machine/reg.h>.  */
 static int i386nbsd_r_reg_offset[] =
 {
@@ -264,6 +269,152 @@
 }
 
 
+/* From <machine/frame.h>.  Note that %esp and %ess are only saved in
+   a trap frame when entering the kernel from user space.  */
+static int i386nbsd_tf_reg_offset[] =
+{
+  10 * 4,			/* %eax */
+   9 * 4,			/* %ecx */
+   8 * 4,			/* %edx */
+   7 * 4,			/* %ebx */
+  -1,				/* %esp */
+   6 * 4,			/* %ebp */
+   5 * 4,			/* %esi */
+   4 * 4,			/* %edi */
+  13 * 4,			/* %eip */
+  15 * 4,			/* %eflags */
+  14 * 4,			/* %cs */
+  -1,				/* %ss */
+   3 * 4,			/* %ds */
+   2 * 4,			/* %es */
+   1 * 4,			/* %fs */
+   0 * 4			/* %gs */
+};
+ 
+static struct trad_frame_cache *
+i386nbsd_trapframe_cache(struct frame_info *this_frame, void **this_cache)
+{
+  struct trad_frame_cache *cache;
+  CORE_ADDR func, sp, addr, tmp;
+  ULONGEST cs;
+  const char *name;
+  int i;
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+  if (*this_cache)
+    return (struct trad_frame_cache *)*this_cache;
+
+  cache = trad_frame_cache_zalloc (this_frame);
+  *this_cache = cache;
+
+  func = get_frame_func (this_frame);
+  sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
+
+  find_pc_partial_function (func, &name, NULL, NULL);
+  if (name && strncmp (name, "Xintr", 5) == 0)
+    {
+      /* It's an interrupt frame. */
+      tmp = read_memory_unsigned_integer (sp + 4, 4, byte_order);
+      if (tmp < 15)
+        {
+          /* Reasonable value for 'ppl': already on interrupt stack. */
+          addr = sp + 8;
+        }
+      else
+        {
+          /* Switch to previous stack. */
+          addr = tmp + 4;
+        }
+    }
+  else
+    {
+      /* It's a trap frame. */
+      addr = sp + 4;
+    }
+
+  for (i = 0; i < ARRAY_SIZE (i386nbsd_tf_reg_offset); i++)
+    if (i386nbsd_tf_reg_offset[i] != -1)
+      trad_frame_set_reg_addr (cache, i, addr + i386nbsd_tf_reg_offset[i]);
+
+  /* Read %cs from trap frame.  */
+  addr += i386nbsd_tf_reg_offset[I386_CS_REGNUM];
+  cs = read_memory_unsigned_integer (addr, 4, byte_order); 
+  if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
+    {
+      /* Trap from user space; terminate backtrace.  */
+      trad_frame_set_id (cache, outer_frame_id);
+    }
+  else
+    {
+      /* Construct the frame ID using the function start.  */
+      trad_frame_set_id (cache, frame_id_build (sp + 8, func));
+    }
+
+  return cache;
+}
+
+static void
+i386nbsd_trapframe_this_id (struct frame_info *this_frame,
+			    void **this_cache, struct frame_id *this_id)
+{
+  struct trad_frame_cache *cache =
+    i386nbsd_trapframe_cache (this_frame, this_cache);
+  
+  trad_frame_get_id (cache, this_id);
+}
+
+static struct value *
+i386nbsd_trapframe_prev_register (struct frame_info *this_frame,
+				  void **this_cache, int regnum)
+{
+  struct trad_frame_cache *cache =
+    i386nbsd_trapframe_cache (this_frame, this_cache);
+
+  return trad_frame_get_register (cache, this_frame, regnum);
+}
+
+static int
+i386nbsd_trapframe_sniffer (const struct frame_unwind *self,
+			    struct frame_info *this_frame,
+			    void **this_prologue_cache)
+{
+  ULONGEST cs;
+  const char *name;
+
+  /* Check Current Privilege Level and bail out if we're not executing
+     in kernel space.  */
+  cs = get_frame_register_unsigned (this_frame, I386_CS_REGNUM);
+  if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
+    return 0;
+
+
+  find_pc_partial_function (get_frame_pc (this_frame), &name, NULL, NULL);
+  return (name && ((strcmp (name, "alltraps") == 0)
+		   || (strcmp (name, "calltrap") == 0)
+		   || (strncmp (name, "Xtrap", 5) == 0)
+		   || (strcmp (name, "syscall1") == 0)
+		   || (strcmp (name, "Xsyscall") == 0)
+		   || (strncmp (name, "Xintr", 5) == 0)
+		   || (strncmp (name, "Xresume", 7) == 0)
+		   || (strncmp (name, "Xstray", 6) == 0)
+		   || (strncmp (name, "Xrecurse", 8) == 0)
+		   || (strncmp (name, "Xsoft", 5) == 0)
+		   || (strncmp (name, "Xdoreti", 5) == 0)));
+}
+
+const struct frame_unwind i386nbsd_trapframe_unwind = {
+  /* FIXME: kettenis/20051219: This really is more like an interrupt
+     frame, but SIGTRAMP_FRAME would print <signal handler called>,
+     which really is not what we want here.  */
+  NORMAL_FRAME,
+  default_frame_unwind_stop_reason,
+  i386nbsd_trapframe_this_id,
+  i386nbsd_trapframe_prev_register,
+  NULL,
+  i386nbsd_trapframe_sniffer
+};
+
 static void 
 i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
@@ -293,6 +444,9 @@
   tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si2);
   tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si31);
   tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si4);
+
+  /* Unwind kernel trap frames correctly.  */
+  frame_unwind_prepend_unwinder (gdbarch, &i386nbsd_trapframe_unwind);
 }
 
 /* NetBSD ELF.  */
@@ -319,6 +473,7 @@
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern initialize_file_ftype _initialize_i386nbsd_tdep;
 
+
 void
 _initialize_i386nbsd_tdep (void)
 {

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/mips-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/mips-nbsd-nat.c 2017/11/28 18:18:22 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/mips-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for MIPS systems running NetBSD.
 
-   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -16,7 +16,9 @@
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
+#ifndef _KERNTYPES
+#define _KERNTYPES
+#endif
 #include "defs.h"
 #include "inferior.h"
 #include "regcache.h"
@@ -26,10 +28,23 @@
 #include <sys/ptrace.h>
 #include <machine/reg.h>
 
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+
+#include "gregset.h"
+
 #include "mips-tdep.h"
-#include "mips-nbsd-tdep.h"
+#include "mipsnbsd-tdep.h"
 #include "inf-ptrace.h"
+#include "bsd-kvm.h"
 
+#include "machine/pcb.h"
+
 /* Determine if PT_GETREGS fetches this register.  */
 static int
 getregs_supplies (struct gdbarch *gdbarch, int regno)
@@ -42,14 +57,13 @@
 mipsnbsd_fetch_inferior_registers (struct target_ops *ops,
 				   struct regcache *regcache, int regno)
 {
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
-
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   if (regno == -1 || getregs_supplies (gdbarch, regno))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get registers"));
       
       mipsnbsd_supply_reg (regcache, (char *) &regs, regno);
@@ -62,7 +76,8 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       mipsnbsd_supply_fpreg (regcache, (char *) &fpregs, regno);
@@ -73,19 +88,19 @@
 mipsnbsd_store_inferior_registers (struct target_ops *ops,
 				   struct regcache *regcache, int regno)
 {
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
-
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   if (regno == -1 || getregs_supplies (gdbarch, regno))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       mipsnbsd_fill_reg (regcache, (char *) &regs, regno);
 
-      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), 
+		  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't write registers"));
 
       if (regno != -1)
@@ -97,17 +112,82 @@
     {
       struct fpreg fpregs; 
 
-      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       mipsnbsd_fill_fpreg (regcache, (char *) &fpregs, regno);
 
-      if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't write floating point status"));
     }
 }
+
+static int mipsnbsd_supply_pcb (struct regcache *, struct pcb *);
+
+static int
+mipsnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
+{
+  struct label_t sf;
+
+  sf = pcb->pcb_context;
+
+  /* really should test for n{32,64} abi for this register
+     unless this is purely the "n" ABI */
+
+  regcache_raw_supply (regcache, MIPS_S0_REGNUM, &sf.val[_L_S0]);
+  regcache_raw_supply (regcache, MIPS_S1_REGNUM, &sf.val[_L_S1]);
+  regcache_raw_supply (regcache, MIPS_S2_REGNUM, &sf.val[_L_S2]);
+  regcache_raw_supply (regcache, MIPS_S3_REGNUM, &sf.val[_L_S3]);
+  regcache_raw_supply (regcache, MIPS_S4_REGNUM, &sf.val[_L_S4]);
+  regcache_raw_supply (regcache, MIPS_S5_REGNUM, &sf.val[_L_S5]);
+  regcache_raw_supply (regcache, MIPS_S6_REGNUM, &sf.val[_L_S6]);
+  regcache_raw_supply (regcache, MIPS_S7_REGNUM, &sf.val[_L_S7]);
+
+  regcache_raw_supply (regcache, MIPS_S8_REGNUM, &sf.val[_L_S8]);
+
+  regcache_raw_supply (regcache, MIPS_T8_REGNUM, &sf.val[_L_T8]);
+
+  regcache_raw_supply (regcache, MIPS_GP_REGNUM, &sf.val[_L_GP]);
+
+  regcache_raw_supply (regcache, MIPS_SP_REGNUM, &sf.val[_L_SP]);
+  regcache_raw_supply (regcache, MIPS_RA_REGNUM, &sf.val[_L_RA]);
+  regcache_raw_supply (regcache, MIPS_PS_REGNUM, &sf.val[_L_SR]);
+
+  /* provide the return address of the savectx as the current pc */
+  regcache_raw_supply (regcache, MIPS_EMBED_PC_REGNUM, &sf.val[_L_RA]);
+
+  return 0;
+}
 
+/* Wrapper functions.  These are only used by nbsd-thread.  */
+void
+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
+{
+  mipsnbsd_supply_reg (regcache, (const char *) gregsetp, -1);
+}   
 
+void
+fill_gregset (const struct regcache *regcache,
+              gdb_gregset_t *gregsetp, int regno)
+{
+  mipsnbsd_fill_reg (regcache, (char *) gregsetp, -1);
+}   
+
+void
+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
+{   
+  mipsnbsd_supply_fpreg (regcache, (const char *) fpregsetp, -1);
+}
+
+void
+fill_fpregset (const struct regcache *regcache,
+               gdb_fpregset_t *fpregsetp, int regno)
+{
+  mipsnbsd_fill_fpreg (regcache, (char *) fpregsetp, -1);
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_mipsnbsd_nat (void);
 
@@ -120,4 +200,7 @@
   t->to_fetch_registers = mipsnbsd_fetch_inferior_registers;
   t->to_store_registers = mipsnbsd_store_inferior_registers;
   add_target (t);
+
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (mipsnbsd_supply_pcb);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.c 2017/11/28 18:18:25 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/mips.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    Contributed by Wasabi Systems, Inc.
 
@@ -28,7 +28,7 @@
 #include "osabi.h"
 
 #include "nbsd-tdep.h"
-#include "mips-nbsd-tdep.h"
+#include "mipsnbsd-tdep.h"
 #include "mips-tdep.h"
 
 #include "solib-svr4.h"
@@ -79,15 +79,23 @@
 			 const void *gregs, size_t len)
 {
   size_t regsize = mips_isa_regsize (get_regcache_arch (regcache));
+  char zerobuf[MAX_REGISTER_SIZE];
   const char *regs = (const char *) gregs;
   int i;
 
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
+
   gdb_assert (len >= MIPSNBSD_NUM_GREGS * regsize);
 
   for (i = 0; i <= MIPS_PC_REGNUM; i++)
     {
       if (regnum == i || regnum == -1)
-	regcache_raw_supply (regcache, i, regs + i * regsize);
+        {
+          if (i == MIPS_ZERO_REGNUM || i == MIPS_UNUSED_REGNUM)
+            regcache_raw_supply (regcache, i, zerobuf);
+          else
+	    regcache_raw_supply (regcache, i, regs + i * regsize);
+	}
     }
 
   if (len >= (MIPSNBSD_NUM_GREGS + MIPSNBSD_NUM_FPREGS) * regsize)
@@ -138,13 +146,18 @@
 mipsnbsd_supply_reg (struct regcache *regcache, const char *regs, int regno)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  char zerobuf[MAX_REGISTER_SIZE];
   int i;
 
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
+
   for (i = 0; i <= gdbarch_pc_regnum (gdbarch); i++)
     {
       if (regno == i || regno == -1)
 	{
-	  if (gdbarch_cannot_fetch_register (gdbarch, i))
+          if (i == MIPS_ZERO_REGNUM || i == MIPS_UNUSED_REGNUM)
+            regcache_raw_supply (regcache, i, zerobuf);
+	  else if (gdbarch_cannot_fetch_register (gdbarch, i))
 	    regcache_raw_supply (regcache, i, NULL);
 	  else
             regcache_raw_supply (regcache, i,

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.h (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.h 2017/11/28 18:18:11 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.h 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Common target dependent code for GDB on MIPS systems running NetBSD.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef MIPS_NBSD_TDEP_H
-#define MIPS_NBSD_TDEP_H
+#ifndef MIPSNBSD_TDEP_H
+#define MIPSNBSD_TDEP_H
 
 void mipsnbsd_supply_reg (struct regcache *, const char *, int);
 void mipsnbsd_fill_reg (const struct regcache *, char *, int);
@@ -26,4 +26,4 @@
 void mipsnbsd_supply_fpreg (struct regcache *, const char *, int);
 void mipsnbsd_fill_fpreg (const struct regcache *, char *, int);
 
-#endif /* MIPS_NBSD_TDEP_H */
+#endif /* MIPSNBSD_TDEP_H */

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/ppc-nbsd-nat.c 2017/11/28 18:18:13 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/ppc-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for NetBSD/powerpc.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    Contributed by Wasabi Systems, Inc.
 
@@ -19,6 +19,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#define _KMEMUSER
 #include "defs.h"
 
 #include <sys/types.h>
@@ -31,11 +32,24 @@
 #include "inferior.h"
 #include "regcache.h"
 
+#include "gdb_assert.h"
+
+#include "nbsd-nat.h"
 #include "ppc-tdep.h"
-#include "ppc-nbsd-tdep.h"
+#include "ppcnbsd-tdep.h"
 #include "bsd-kvm.h"
 #include "inf-ptrace.h"
 
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+#include "gregset.h"
+ 
+
 /* Returns true if PT_GETREGS fetches this register.  */
 
 static int
@@ -81,13 +95,13 @@
 				  struct regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
 
   if (regnum == -1 || getregs_supplies (gdbarch, regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       ppc_supply_gregset (&ppcnbsd_gregset, regcache,
@@ -98,7 +112,8 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get FP registers"));
 
       ppc_supply_fpregset (&ppcnbsd_fpregset, regcache,
@@ -111,19 +126,20 @@
 				  struct regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
 
   if (regnum == -1 || getregs_supplies (gdbarch, regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       ppc_collect_gregset (&ppcnbsd_gregset, regcache,
 			   regnum, &regs, sizeof regs);
 
-      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't write registers"));
     }
 
@@ -131,17 +147,51 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get FP registers"));
 
       ppc_collect_fpregset (&ppcnbsd_fpregset, regcache,
 			    regnum, &fpregs, sizeof fpregs);
 
-      if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't set FP registers"));
     }
 }
 
+void
+supply_gregset (struct regcache *regcache, const gregset_t *gregs)
+{
+  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+	      (PTRACE_TYPE_ARG3) gregs, ptid_get_lwp (inferior_ptid)) == -1)
+    perror_with_name (_("Couldn't write registers"));
+}
+
+void
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregs)
+{
+  if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+	      (PTRACE_TYPE_ARG3) fpregs, ptid_get_lwp (inferior_ptid)) == -1)
+    perror_with_name (_("Couldn't set FP registers"));
+}
+
+void
+fill_gregset (const struct regcache *regcache, gregset_t *gregs, int regnum)
+{
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) gregs, ptid_get_lwp (inferior_ptid)) == -1)
+        perror_with_name (_("Couldn't get registers"));
+}
+
+void
+fill_fpregset (const struct regcache *regcache, fpregset_t *fpregs, int regnum)
+{
+      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) fpregs, ptid_get_lwp (inferior_ptid)) == -1)
+	perror_with_name (_("Couldn't get FP registers"));
+}
+
 static int
 ppcnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
@@ -156,20 +206,20 @@
     return 0;
 
   read_memory (pcb->pcb_sp, (gdb_byte *)&sf, sizeof sf);
-  regcache_raw_supply (regcache, tdep->ppc_cr_regnum, &sf.cr);
-  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 2, &sf.fixreg2);
+  regcache_raw_supply (regcache, tdep->ppc_cr_regnum, &sf.sf_cr);
+  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 2, &sf.sf_fixreg2);
   for (i = 0 ; i < 19 ; i++)
     regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 13 + i,
-			 &sf.fixreg[i]);
+			 &sf.sf_fixreg[i]);
 
-  read_memory(sf.sp, (gdb_byte *)&cf, sizeof(cf));
-  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 30, &cf.r30);
-  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 31, &cf.r31);
-  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 1, &cf.sp);
+  read_memory(sf.sf_sp, (gdb_byte *)&cf, sizeof(cf));
+  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 30, &cf.cf_r30);
+  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 31, &cf.cf_r31);
+  regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 1, &cf.cf_sp);
 
-  read_memory(cf.sp, (gdb_byte *)&cf, sizeof(cf));
-  regcache_raw_supply (regcache, tdep->ppc_lr_regnum, &cf.lr);
-  regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch), &cf.lr);
+  read_memory(cf.cf_sp, (gdb_byte *)&cf, sizeof(cf));
+  regcache_raw_supply (regcache, tdep->ppc_lr_regnum, &cf.cf_lr);
+  regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch), &cf.cf_lr);
 
   return 1;
 }
@@ -189,5 +239,6 @@
   t = inf_ptrace_target ();
   t->to_fetch_registers = ppcnbsd_fetch_inferior_registers;
   t->to_store_registers = ppcnbsd_store_inferior_registers;
+  t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
   add_target (t);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c 2017/11/28 18:18:03 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/powerpc.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    Contributed by Wasabi Systems, Inc.
 
@@ -28,7 +28,7 @@
 #include "tramp-frame.h"
 
 #include "ppc-tdep.h"
-#include "ppc-nbsd-tdep.h"
+#include "ppcnbsd-tdep.h"
 #include "solib-svr4.h"
 
 /* Register offsets from <machine/reg.h>.  */
@@ -199,7 +199,7 @@
 			  ppcnbsd_init_abi);
 
   /* Avoid initializing the register offsets again if they were
-     already initialized by ppcnbsd-nat.c.  */
+     already initailized by ppcnbsd-nat.c.  */
   if (ppcnbsd_reg_offsets.pc_offset == 0)
     {
       /* General-purpose registers.  */

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.h (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.h 2017/11/28 18:18:13 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.h 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/powerpc.
 
-   Copyright (C) 2004-2017 Free Software Foundation, Inc.
+   Copyright (C) 2004-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef PPC_NBSD_TDEP_H
-#define PPC_NBSD_TDEP_H
+#ifndef PPCNBSD_TDEP_H
+#define PPCNBSD_TDEP_H
 
 struct regset;
 
@@ -29,4 +29,4 @@
 extern const struct regset ppcnbsd_gregset;
 extern const struct regset ppcnbsd_fpregset;
 
-#endif /* ppc-nbsd-tdep.h */
+#endif /* ppcnbsd-tdep.h */

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sh-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/sh-nbsd-nat.c 2017/11/28 18:18:11 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/sh-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for NetBSD/sh.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    Contributed by Wasabi Systems, Inc.
 
@@ -29,30 +29,40 @@
 #include "sh-tdep.h"
 #include "inf-ptrace.h"
 #include "regcache.h"
+#include "inf-ptrace.h"
 
+#include "nbsd-nat.h"
 
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+struct fpreg { };
+typedef struct fpreg fpregset_t;
+#endif
+#include "gregset.h"
+ 
 /* Determine if PT_GETREGS fetches this register.  */
 #define GETREGS_SUPPLIES(gdbarch, regno) \
   (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
 || (regno) == gdbarch_pc_regnum (gdbarch) || (regno) == PR_REGNUM \
 || (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
-|| (regno) == SR_REGNUM)
+|| (regno) == SR_REGNUM || (regno) == GBR_REGNUM)
 
 /* Sizeof `struct reg' in <machine/reg.h>.  */
-#define SHNBSD_SIZEOF_GREGS	(21 * 4)
+#define SHNBSD_SIZEOF_GREGS	(22 * 4)
 
 static void
 shnbsd_fetch_inferior_registers (struct target_ops *ops,
 				 struct regcache *regcache, int regno)
 {
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
-
   if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
     {
       struct reg inferior_registers;
 
-      if (ptrace (PT_GETREGS, pid,
-		  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       sh_corefile_supply_regset (&sh_corefile_gregset, regcache, regno,
@@ -68,22 +78,20 @@
 shnbsd_store_inferior_registers (struct target_ops *ops,
 				 struct regcache *regcache, int regno)
 {
-  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
-
   if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
     {
       struct reg inferior_registers;
 
-      if (ptrace (PT_GETREGS, pid,
-		  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
+      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       sh_corefile_collect_regset (&sh_corefile_gregset, regcache, regno,
 				  (char *) &inferior_registers,
 				  SHNBSD_SIZEOF_GREGS);
 
-      if (ptrace (PT_SETREGS, pid,
-		  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
+      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) &inferior_registers, ptid_get_lwp (inferior_ptid)) == -1)
 	perror_with_name (_("Couldn't set registers"));
 
       if (regno != -1)
@@ -91,6 +99,22 @@
     }
 }
 
+void
+supply_gregset (struct regcache *regcache, const gregset_t *gregs)
+{
+      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+		  (PTRACE_TYPE_ARG3) gregs, ptid_get_lwp (inferior_ptid)) == -1)
+	perror_with_name (_("Couldn't set registers"));
+}
+
+void
+fill_gregset (const struct regcache *regcache, gregset_t *gregs, int regnum)
+{
+   if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+	(PTRACE_TYPE_ARG3) gregs, ptid_get_lwp (inferior_ptid)) == -1)
+	perror_with_name (_("Couldn't get registers"));
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_shnbsd_nat (void);
 
@@ -102,5 +126,6 @@
   t = inf_ptrace_target ();
   t->to_fetch_registers = shnbsd_fetch_inferior_registers;
   t->to_store_registers = shnbsd_store_inferior_registers;
+  t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
   add_target (t);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sh-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/sh-nbsd-tdep.c 2017/11/28 18:18:06 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/sh-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/sh.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    Contributed by Wasabi Systems, Inc.
 
@@ -8,7 +8,7 @@
 
    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
+   the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -17,20 +17,32 @@
    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/>.  */
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "gdbcore.h"
+#include "inferior.h"
+#include "regcache.h"
 #include "regset.h"
 #include "value.h"
 #include "osabi.h"
 
-#include "sh-tdep.h"
+#include "trad-frame.h"
+#include "tramp-frame.h"
+
+#include "gdb_assert.h"
+
 #include "solib-svr4.h"
 
+#include "sh-tdep.h"
+#include "shnbsd-tdep.h"
+#include "nbsd-tdep.h"
+
 /* Convert a register number into an offset into a ptrace
    register structure.  */
-static const struct sh_corefile_regmap regmap[] =
+static const struct sh_corefile_regmap gregs_table[] =
 {
   {R0_REGNUM,      20 * 4},
   {R0_REGNUM + 1,  19 * 4},
@@ -53,32 +65,177 @@
   {PR_REGNUM,	    2 * 4},
   {MACH_REGNUM,	    3 * 4},
   {MACL_REGNUM,	    4 * 4},
+  {GBR_REGNUM,	   21 * 4},
   {-1 /* Terminator.  */, 0}
 };
+
+
+#define REGSx16(base) \
+  {(base),      0}, \
+  {(base) +  1, 4}, \
+  {(base) +  2, 8}, \
+  {(base) +  3, 12}, \
+  {(base) +  4, 16}, \
+  {(base) +  5, 20}, \
+  {(base) +  6, 24}, \
+  {(base) +  7, 28}, \
+  {(base) +  8, 32}, \
+  {(base) +  9, 36}, \
+  {(base) + 10, 40}, \
+  {(base) + 11, 44}, \
+  {(base) + 12, 48}, \
+  {(base) + 13, 52}, \
+  {(base) + 14, 56}, \
+  {(base) + 15, 60}
+
+/* Convert an FPU register number into an offset into a ptrace
+   register structure.  */
+static const struct sh_corefile_regmap fpregs_table[] =
+{
+  REGSx16 (FR0_REGNUM),
+  /* XXX: REGSx16(XF0_REGNUM) omitted.  */
+  {FPSCR_REGNUM, 128},
+  {FPUL_REGNUM,  132},
+  {-1 /* Terminator.  */, 0}
+};
+
+
+/* From <machine/mcontext.h>.  */
+static const int shnbsd_mc_reg_offset[] =
+{
+  (20 * 4),	/* r0 */
+  (19 * 4),	/* r1 */
+  (18 * 4),	/* r2 */ 
+  (17 * 4),	/* r3 */ 
+  (16 * 4),	/* r4 */
+  (15 * 4),	/* r5 */
+  (14 * 4),	/* r6 */
+  (13 * 4),	/* r7 */
+  (12 * 4),	/* r8 */ 
+  (11 * 4),	/* r9 */
+  (10 * 4),	/* r10 */
+  ( 9 * 4),	/* r11 */
+  ( 8 * 4),	/* r12 */
+  ( 7 * 4),	/* r13 */
+  ( 6 * 4),	/* r14 */
+  (21 * 4),	/* r15/sp */
+  ( 1 * 4),	/* pc */
+  ( 5 * 4),	/* pr */
+  ( 0 * 4),	/* gbr */
+  -1,
+  ( 4 * 4),	/* mach */
+  ( 3 * 4),	/* macl */
+  ( 2 * 4),	/* sr */
+};
+
+/* SH register sets.  */
+
 
+static void
+shnbsd_sigtramp_cache_init (const struct tramp_frame *,
+			     struct frame_info *,
+			     struct trad_frame_cache *,
+			     CORE_ADDR);
 
+/* The siginfo signal trampoline for NetBSD/sh3 versions 2.0 and later */
+static const struct tramp_frame shnbsd_sigtramp_si2 =
+{
+  SIGTRAMP_FRAME,
+  2,
+  {
+    { 0x64f3, -1 },			/* mov     r15,r4 */
+    { 0xd002, -1 },			/* mov.l   .LSYS_setcontext */
+    { 0xc380, -1 },			/* trapa   #-128 */
+    { 0xa003, -1 },			/* bra     .Lskip1 */
+    { 0x0009, -1 },			/* nop */
+    { 0x0009, -1 },			/* nop */
+ /* .LSYS_setcontext */
+    { 0x0134, -1 }, { 0x0000, -1 },     /* 0x134 */
+ /* .Lskip1 */
+    { 0x6403, -1 },			/* mov     r0,r4 */
+    { 0xd002, -1 },			/* mov.l   .LSYS_exit  */
+    { 0xc380, -1 },			/* trapa   #-128 */
+    { 0xa003, -1 },			/* bra     .Lskip2 */
+    { 0x0009, -1 },			/* nop */
+    { 0x0009, -1 },			/* nop */
+ /* .LSYS_exit */
+    { 0x0001, -1 }, { 0x0000, -1 },     /* 0x1 */
+/* .Lskip2 */
+    { TRAMP_SENTINEL_INSN, -1 }
+  },
+  shnbsd_sigtramp_cache_init
+};
+
 static void
+shnbsd_sigtramp_cache_init (const struct tramp_frame *self,
+			    struct frame_info *next_frame,
+			    struct trad_frame_cache *this_cache,
+			    CORE_ADDR func)
+{
+  struct gdbarch *gdbarch = get_frame_arch (next_frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int sp_regnum = gdbarch_sp_regnum (gdbarch);
+  CORE_ADDR sp = get_frame_register_unsigned (next_frame, sp_regnum);
+  CORE_ADDR base;
+  const int *reg_offset;
+  int num_regs;
+  int i;
+
+  reg_offset = shnbsd_mc_reg_offset;
+  num_regs = ARRAY_SIZE (shnbsd_mc_reg_offset);
+  /* SP already points at the ucontext. */
+  base = sp;
+  /* offsetof(ucontext_t, uc_mcontext) == 36 */
+  base += 36;
+
+  for (i = 0; i < num_regs; i++)
+    if (reg_offset[i] != -1)
+      trad_frame_set_reg_addr (this_cache, i, base + reg_offset[i]);
+
+  /* Construct the frame ID using the function start.  */
+  trad_frame_set_id (this_cache, frame_id_build (sp, func));
+}
+
+static void
 shnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-  tdep->core_gregmap = (struct sh_corefile_regmap *)regmap;
-  tdep->sizeof_gregset = 84;
+  tdep->core_gregmap = (struct sh_corefile_regmap *)gregs_table;
+  tdep->sizeof_gregset = 88;
 
+  tdep->core_fpregmap = (struct sh_corefile_regmap *)fpregs_table;
+  tdep->sizeof_fpregset = 0;	/* XXX */
+
   set_solib_svr4_fetch_link_map_offsets
-    (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+    (gdbarch, nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
+
+  tramp_frame_prepend_unwinder (gdbarch, &shnbsd_sigtramp_si2);
 }
 
 
+#define GDB_OSABI_NETBSD_CORE GDB_OSABI_NETBSD
+
+static enum gdb_osabi
+shnbsd_core_osabi_sniffer (bfd *abfd)
+{
+  if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
+    return GDB_OSABI_NETBSD_CORE;
+
+  return GDB_OSABI_UNKNOWN;
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern initialize_file_ftype _initialize_shnbsd_tdep;
 
 void
 _initialize_shnbsd_tdep (void)
 {
+  /* BFD doesn't set a flavour for NetBSD style a.out core files.  */
+  gdbarch_register_osabi_sniffer (bfd_arch_sh, bfd_target_unknown_flavour,
+                                  shnbsd_core_osabi_sniffer);
+
   gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_NETBSD,
-			  shnbsd_init_abi);
-  gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_OPENBSD,
 			  shnbsd_init_abi);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/sparc-nbsd-nat.c 2017/11/28 18:18:22 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/sparc-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for NetBSD/sparc.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,6 +21,7 @@
 #include "regcache.h"
 #include "target.h"
 
+#include "nbsd-nat.h"
 #include "sparc-tdep.h"
 #include "sparc-nat.h"
 
@@ -28,9 +29,43 @@
 
 #include <sys/types.h>
 #include <machine/pcb.h>
+#include <machine/reg.h>
 
 #include "bsd-kvm.h"
 
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+#include "gregset.h"
+ 
+void
+supply_gregset (struct regcache *regcache, const gregset_t *gregs)
+{
+  sparc_supply_gregset (sparc_gregmap, regcache, -1, gregs);
+}
+
+void
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregs)
+{
+  sparc_supply_fpregset (sparc_fpregmap, regcache, -1, fpregs);
+}
+
+void
+fill_gregset (const struct regcache *regcache, gregset_t *gregs, int regnum)
+{
+  sparc_collect_gregset (sparc_gregmap, regcache, regnum, gregs);
+}
+
+void
+fill_fpregset (const struct regcache *regcache, fpregset_t *fpregs, int regnum)
+{
+  sparc_collect_fpregset (sparc_fpregmap, regcache, regnum, fpregs);
+}
+
 static int
 sparc32nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
@@ -62,11 +97,14 @@
 void
 _initialize_sparcnbsd_nat (void)
 {
+  struct target_ops *t;
   sparc_gregmap = &sparc32nbsd_gregmap;
   sparc_fpregmap = &sparc32_bsd_fpregmap;
 
-  /* We've got nothing to add to the generic SPARC target.  */
-  add_target (sparc_target ());
+  /* Add some extra features to the generic SPARC target.  */
+  t = sparc_target ();
+  t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
+  add_target (t);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (sparc32nbsd_supply_pcb);

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/sparc-nbsd-tdep.c 2017/11/28 18:18:07 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/sparc-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/sparc.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
    Contributed by Wasabi Systems, Inc.
 
    This file is part of GDB.
@@ -290,7 +290,7 @@
     NULL, sparc32nbsd_supply_fpregset, NULL
   };
 
-void
+static void
 sparc32nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -309,11 +309,41 @@
   tdep->step_trap = sparcnbsd_step_trap;
 
   frame_unwind_append_unwinder (gdbarch, &sparc32nbsd_sigcontext_frame_unwind);
+}
 
+static void
+sparc32nbsd_aout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  sparc32nbsd_init_abi (info, gdbarch);
+}
+
+void
+sparc32nbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  sparc32nbsd_init_abi (info, gdbarch);
+
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 }
 
+/* OpenBSD uses the traditional NetBSD core file format, even for
+   ports that use ELF.  Therefore, if the default OS ABI is OpenBSD
+   ELF, we return that instead of NetBSD a.out.  This is mainly for
+   the benfit of OpenBSD/sparc64, which inherits the sniffer below
+   since we include this file for an OpenBSD/sparc64 target.  For
+   OpenBSD/sparc, the NetBSD a.out OS ABI is probably similar enough
+   to both the OpenBSD a.out and the OpenBSD ELF OS ABI.  */
+#define GDB_OSABI_NETBSD_CORE GDB_OSABI_NETBSD
+
+static enum gdb_osabi
+sparcnbsd_core_osabi_sniffer (bfd *abfd)
+{
+  if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
+    return GDB_OSABI_NETBSD_CORE;
+
+  return GDB_OSABI_UNKNOWN;
+}
+
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_sparcnbsd_tdep (void);
@@ -321,6 +351,13 @@
 void
 _initialize_sparcnbsd_tdep (void)
 {
+  gdbarch_register_osabi_sniffer (bfd_arch_sparc, bfd_target_aout_flavour,
+				  sparcnbsd_aout_osabi_sniffer);
+
+  /* BFD doesn't set a flavour for NetBSD style a.out core files.  */
+  gdbarch_register_osabi_sniffer (bfd_arch_sparc, bfd_target_unknown_flavour,
+                                  sparcnbsd_core_osabi_sniffer);
+
   gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_NETBSD,
-			  sparc32nbsd_init_abi);
+			  sparc32nbsd_elf_init_abi);
 }

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-nat.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-nat.c 2017/11/28 18:18:03 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-nat.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Native-dependent code for NetBSD/sparc64.
 
-   Copyright (C) 2003-2017 Free Software Foundation, Inc.
+   Copyright (C) 2003-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -22,9 +22,21 @@
 #include "regcache.h"
 #include "target.h"
 
+#include "nbsd-nat.h"
 #include "sparc64-tdep.h"
 #include "sparc-nat.h"
 
+#include <machine/reg.h>
+
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+#include "gregset.h"
+ 
 /* NetBSD is different from the other OSes that support both SPARC and
    UltraSPARC in that the result of ptrace(2) depends on whether the
    traced process is 32-bit or 64-bit.  */
@@ -126,7 +138,29 @@
   return 0;
 }
 
+void
+supply_gregset (struct regcache *regcache, const gregset_t *gregs)
+{
+  sparc64nbsd_supply_gregset (sparc_gregmap, regcache, -1, gregs);
+}
 
+void
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregs)
+{
+  sparc64nbsd_supply_fpregset (sparc_fpregmap, regcache, -1, fpregs);
+}
+
+void
+fill_gregset (const struct regcache *regcache, gregset_t *gregs, int regnum)
+{
+  sparc64nbsd_collect_gregset (sparc_gregmap, regcache, regnum, gregs);
+}
+
+void
+fill_fpregset (const struct regcache *regcache, fpregset_t *fpregs, int regnum)
+{
+  sparc64nbsd_collect_fpregset (sparc_fpregmap, regcache, regnum, fpregs);
+}
 /* Support for debugging kernel virtual memory images.  */
 
 #include <sys/types.h>
@@ -174,6 +208,8 @@
 void
 _initialize_sparc64nbsd_nat (void)
 {
+  struct target_ops *t;
+
   sparc_supply_gregset = sparc64nbsd_supply_gregset;
   sparc_collect_gregset = sparc64nbsd_collect_gregset;
   sparc_supply_fpregset = sparc64nbsd_supply_fpregset;
@@ -181,8 +217,10 @@
   sparc_gregset_supplies_p = sparc64nbsd_gregset_supplies_p;
   sparc_fpregset_supplies_p = sparc64nbsd_fpregset_supplies_p;
 
-  /* We've got nothing to add to the generic SPARC target.  */
-  add_target (sparc_target ());
+  /* Add some extra features to the generic SPARC target.  */
+  t = sparc_target ();
+  t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
+  add_target (t);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (sparc64nbsd_supply_pcb);

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-tdep.c 2017/11/28 18:18:11 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/sparc64-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/sparc64.
 
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
    Based on code contributed by Wasabi Systems, Inc.
 
    This file is part of GDB.

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/vax-nbsd-tdep.c (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/vax-nbsd-tdep.c 2017/11/28 18:18:04 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/vax-nbsd-tdep.c 2017/11/29 03:35:15 1.2
@@ -1,6 +1,6 @@
 /* Target-dependent code for NetBSD/vax.
 
-   Copyright (C) 2004-2017 Free Software Foundation, Inc.
+   Copyright (C) 2004-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/alpha/Attic/nbsd.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/alpha/Attic/nbsd.mh 2012/02/06 10:46:34 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/alpha/Attic/nbsd.mh 2017/11/29 03:35:16 1.4
@@ -1,5 +1,5 @@
 # Host: NetBSD/alpha
-NATDEPFILES= fork-child.o inf-ptrace.o alphabsd-nat.o bsd-kvm.o nbsd-nat.o \
+NATDEPFILES= fork-child.o inf-ptrace.o alpha-bsd-nat.o bsd-kvm.o nbsd-nat.o \
 	nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.5 -r1.6 src/external/gpl3/gdb/dist/gdb/config/arm/Attic/nbsdelf.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/arm/Attic/nbsdelf.mh 2016/10/22 14:57:50 1.5
+++ src/external/gpl3/gdb/dist/gdb/config/arm/Attic/nbsdelf.mh 2017/11/29 03:35:16 1.6
@@ -1,5 +1,5 @@
 # Host: NetBSD/arm
-NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o armnbsd-nat.o \
+NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o arm-nbsd-nat.o \
 	bsd-kvm.o nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.4 -r1.5 src/external/gpl3/gdb/dist/gdb/config/i386/Attic/nbsd64.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/i386/Attic/nbsd64.mh 2016/10/12 20:20:33 1.4
+++ src/external/gpl3/gdb/dist/gdb/config/i386/Attic/nbsd64.mh 2017/11/29 03:35:16 1.5
@@ -1,6 +1,6 @@
 # Host: NetBSD/amd64
 NATDEPFILES= fork-child.o inf-ptrace.o \
-	nbsd-nat.o amd64-nat.o x86bsd-nat.o amd64bsd-nat.o amd64nbsd-nat.o \
+	nbsd-nat.o amd64-nat.o x86-bsd-nat.o amd64-bsd-nat.o amd64-nbsd-nat.o \
 	bsd-kvm.o nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/i386/Attic/nbsdelf.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/i386/Attic/nbsdelf.mh 2016/10/12 20:20:33 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/i386/Attic/nbsdelf.mh 2017/11/29 03:35:16 1.4
@@ -1,6 +1,7 @@
 # Host: NetBSD/i386 ELF
 NATDEPFILES= fork-child.o inf-ptrace.o \
-	nbsd-nat.o x86bsd-nat.o i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o \
-	nbsd-thread.o
+	nbsd-nat.o nbsd-thread.o x86-bsd-nat.o x86-nat.o x86-dregs.o \
+	i386-bsd-nat.o i386-nbsd-nat.o \
+	bsd-kvm.o
 
 LOADLIBES= -lkvm

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/m68k/Attic/nbsdelf.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/m68k/Attic/nbsdelf.mh 2012/02/06 10:46:35 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/m68k/Attic/nbsdelf.mh 2017/11/29 03:35:16 1.4
@@ -1,5 +1,5 @@
 # Host: NetBSD/m68k ELF
-NATDEPFILES= nbsd-nat.o m68kbsd-nat.o bsd-kvm.o fork-child.o inf-ptrace.o \
+NATDEPFILES= nbsd-nat.o m68k-bsd-nat.o bsd-kvm.o fork-child.o inf-ptrace.o \
 	nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.5 -r1.6 src/external/gpl3/gdb/dist/gdb/config/mips/Attic/nbsd.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/mips/Attic/nbsd.mh 2012/11/03 15:07:40 1.5
+++ src/external/gpl3/gdb/dist/gdb/config/mips/Attic/nbsd.mh 2017/11/29 03:35:16 1.6
@@ -1,4 +1,4 @@
 # Host: NetBSD/mips
-NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o mipsnbsd-nat.o \
+NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o mips-nbsd-nat.o \
 	nbsd-thread.o bsd-kvm.o
 LOADLIBES= -lkvm

cvs diff -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdb/config/pa/Attic/nbsd.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/pa/Attic/nbsd.mh 2012/02/06 10:46:35 1.2
+++ src/external/gpl3/gdb/dist/gdb/config/pa/Attic/nbsd.mh 2017/11/29 03:35:16 1.3
@@ -1,3 +1,3 @@
 # Host: NetBSD/hppa
-NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o hppanbsd-nat.o \
+NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o hppa-nbsd-nat.o \
 	nbsd-thread.o

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/powerpc/Attic/nbsd.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/powerpc/Attic/nbsd.mh 2012/02/06 10:46:35 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/powerpc/Attic/nbsd.mh 2017/11/29 03:35:16 1.4
@@ -1,5 +1,5 @@
 # Host: NetBSD/powerpc
-NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o ppcnbsd-nat.o bsd-kvm.o \
+NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o ppc-nbsd-nat.o bsd-kvm.o \
 	nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdb/config/powerpc/ppc64-nbsd.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/powerpc/ppc64-nbsd.mh 2012/02/06 10:46:35 1.2
+++ src/external/gpl3/gdb/dist/gdb/config/powerpc/ppc64-nbsd.mh 2017/11/29 03:35:16 1.3
@@ -1,5 +1,5 @@
 # Host: NetBSD/powerpc64
-NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o ppcnbsd-nat.o bsd-kvm.o \
+NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o ppc-nbsd-nat.o bsd-kvm.o \
 	nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/sh/Attic/nbsd.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/sh/Attic/nbsd.mh 2012/02/06 10:46:36 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/sh/Attic/nbsd.mh 2017/11/29 03:35:16 1.4
@@ -1,3 +1,3 @@
 # Host: NetBSD/sh
-NATDEPFILES= inf-ptrace.o fork-child.o nbsd-nat.o shnbsd-nat.o \
+NATDEPFILES= inf-ptrace.o fork-child.o nbsd-nat.o sh-nbsd-nat.o \
 	nbsd-thread.o

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/sparc/Attic/nbsd64.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/sparc/Attic/nbsd64.mh 2012/02/06 10:46:36 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/sparc/Attic/nbsd64.mh 2017/11/29 03:35:16 1.4
@@ -1,6 +1,6 @@
 # Host: NetBSD/sparc64
 NATDEPFILES= fork-child.o inf-ptrace.o \
-	nbsd-nat.o sparc64nbsd-nat.o sparc-nat.o bsd-kvm.o \
+	nbsd-nat.o sparc64-nbsd-nat.o sparc-nat.o bsd-kvm.o \
 	nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/sparc/Attic/nbsdelf.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/sparc/Attic/nbsdelf.mh 2012/02/06 10:46:36 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/sparc/Attic/nbsdelf.mh 2017/11/29 03:35:16 1.4
@@ -1,6 +1,6 @@
 # Host: NetBSD/sparc ELF
 NATDEPFILES= fork-child.o inf-ptrace.o \
-	nbsd-nat.o sparcnbsd-nat.o sparc-nat.o bsd-kvm.o \
+	nbsd-nat.o sparc-nbsd-nat.o sparc-nat.o bsd-kvm.o \
 	nbsd-thread.o
 
 LOADLIBES= -lkvm

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/config/vax/Attic/nbsdelf.mh (expand / switch to context diff)
--- src/external/gpl3/gdb/dist/gdb/config/vax/Attic/nbsdelf.mh 2012/02/06 10:46:36 1.3
+++ src/external/gpl3/gdb/dist/gdb/config/vax/Attic/nbsdelf.mh 2017/11/29 03:35:16 1.4
@@ -1,6 +1,6 @@
 # Host: NetBSD/vax ELF
 NATDEPFILES= fork-child.o inf-ptrace.o \
-	nbsd-nat.o vaxbsd-nat.o bsd-kvm.o \
+	nbsd-nat.o vax-bsd-nat.o bsd-kvm.o \
 	nbsd-thread.o
 
 LOADLIBES= -lkvm