Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gdb/dist/gdb bring back all our foonbsd-{nat, t...



details:   https://anonhg.NetBSD.org/src/rev/0ec292d6547b
branches:  trunk
changeset: 828122:0ec292d6547b
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Nov 29 03:35:15 2017 +0000

description:
bring back all our foonbsd-{nat,tdep} files as foo-nbsd-{nat,tdep}. Account
for that in the config glue.

diffstat:

 external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c            |  138 ++++++-
 external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c             |  112 ++++++-
 external/gpl3/gdb/dist/gdb/amd64-nbsd-tdep.c            |  178 ++++++++++-
 external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c               |  262 ++++++++++++---
 external/gpl3/gdb/dist/gdb/arm-nbsd-tdep.c              |   28 +-
 external/gpl3/gdb/dist/gdb/config/alpha/nbsd.mh         |    2 +-
 external/gpl3/gdb/dist/gdb/config/arm/nbsdelf.mh        |    2 +-
 external/gpl3/gdb/dist/gdb/config/i386/nbsd64.mh        |    2 +-
 external/gpl3/gdb/dist/gdb/config/i386/nbsdelf.mh       |    5 +-
 external/gpl3/gdb/dist/gdb/config/m68k/nbsdelf.mh       |    2 +-
 external/gpl3/gdb/dist/gdb/config/mips/nbsd.mh          |    2 +-
 external/gpl3/gdb/dist/gdb/config/pa/nbsd.mh            |    2 +-
 external/gpl3/gdb/dist/gdb/config/powerpc/nbsd.mh       |    2 +-
 external/gpl3/gdb/dist/gdb/config/powerpc/ppc64-nbsd.mh |    2 +-
 external/gpl3/gdb/dist/gdb/config/sh/nbsd.mh            |    2 +-
 external/gpl3/gdb/dist/gdb/config/sparc/nbsd64.mh       |    2 +-
 external/gpl3/gdb/dist/gdb/config/sparc/nbsdelf.mh      |    2 +-
 external/gpl3/gdb/dist/gdb/config/vax/nbsdelf.mh        |    2 +-
 external/gpl3/gdb/dist/gdb/hppa-nbsd-nat.c              |   84 ++++-
 external/gpl3/gdb/dist/gdb/hppa-nbsd-tdep.c             |   38 ++-
 external/gpl3/gdb/dist/gdb/i386-nbsd-nat.c              |  110 +++++-
 external/gpl3/gdb/dist/gdb/i386-nbsd-tdep.c             |  157 +++++++++-
 external/gpl3/gdb/dist/gdb/mips-nbsd-nat.c              |  109 +++++-
 external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.c             |   21 +-
 external/gpl3/gdb/dist/gdb/mips-nbsd-tdep.h             |    8 +-
 external/gpl3/gdb/dist/gdb/ppc-nbsd-nat.c               |   91 ++++-
 external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.c              |    6 +-
 external/gpl3/gdb/dist/gdb/ppc-nbsd-tdep.h              |    8 +-
 external/gpl3/gdb/dist/gdb/sh-nbsd-nat.c                |   51 ++-
 external/gpl3/gdb/dist/gdb/sh-nbsd-tdep.c               |  177 ++++++++++-
 external/gpl3/gdb/dist/gdb/sparc-nbsd-nat.c             |   44 ++-
 external/gpl3/gdb/dist/gdb/sparc-nbsd-tdep.c            |   43 ++-
 external/gpl3/gdb/dist/gdb/sparc64-nbsd-nat.c           |   44 ++-
 external/gpl3/gdb/dist/gdb/sparc64-nbsd-tdep.c          |    2 +-
 external/gpl3/gdb/dist/gdb/vax-nbsd-tdep.c              |    2 +-
 35 files changed, 1527 insertions(+), 215 deletions(-)

diffs (truncated from 2963 to 300 lines):

diff -r b4021b73ca30 -r 0ec292d6547b external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c
--- a/external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c      Wed Nov 29 03:34:22 2017 +0000
+++ b/external/gpl3/gdb/dist/gdb/alpha-nbsd-tdep.c      Wed Nov 29 03:35:15 2017 +0000
@@ -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,31 +174,95 @@
 
 /* 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:
-
-       ldq     a0, 0(sp)
-       lda     sp, 16(sp)
-       lda     v0, 295(zero)   # __sigreturn14
-       call_pal callsys
+   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
+};
 
-   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 =
+{
+  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
+};
+/* The siginfo signal trampoline for NetBSD/alpha introduced in 4.0 */
+static const struct tramp_frame alphanbsd_sigtramp_si4 =
 {
-  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,
+  {
+    { 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
 };
-#define RETCODE_NWORDS         4
-#define RETCODE_SIZE           (RETCODE_NWORDS * 4)
+
+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);
 }
diff -r b4021b73ca30 -r 0ec292d6547b external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c
--- a/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c       Wed Nov 29 03:34:22 2017 +0000
+++ b/external/gpl3/gdb/dist/gdb/amd64-nbsd-nat.c       Wed Nov 29 03:35:15 2017 +0000
@@ -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,6 +23,23 @@
 #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
@@ -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



Home | Main Index | Thread Index | Old Index