]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* sparc64-tdep.h (sparc64nbsd_gregset): Add extern declaration.
authorMark Kettenis <kettenis@gnu.org>
Fri, 26 Dec 2003 23:42:59 +0000 (23:42 +0000)
committerMark Kettenis <kettenis@gnu.org>
Fri, 26 Dec 2003 23:42:59 +0000 (23:42 +0000)
* sparc64nbsd-nat.c: Rewrite.
* sparc64nbsd-tdep.c: New file.
* configure.tgt: Add sparc64-*-netbsd*.
* configure.host: Add sparc64-*-netbsd*.
* Makefile.in (ALLDEPFILES): Add sparc64nbsd-tdep.c and
sparc64nbsd-nat.c.
(sparc64nbsd-tdep.o, sparc64nbsd-nat.o): New dependencies.
* config/sparc/nbsd64.mh (NATDEPFILES): Add sparc-nat.o.
* config/sparc/nbsd64.mt (TDEPFILES): Add sparc64-tdep.o and
sparc64nbsd-tdep.o.
(TM_FILE): Set to tm-nbsd.h.
* config/sparc/tm-nbsd64.h: Remove file.

gdb/ChangeLog
gdb/Makefile.in
gdb/config/sparc/nbsd64.mh
gdb/config/sparc/nbsd64.mt
gdb/config/sparc/tm-nbsd64.h [deleted file]
gdb/configure.host
gdb/configure.tgt
gdb/sparc64-tdep.h
gdb/sparc64nbsd-nat.c
gdb/sparc64nbsd-tdep.c [new file with mode: 0644]

index 27dfb9e1d569e37afd6f57eeeca267566abaaf2f..10655c35b1d3e096d2298d248adc0eb27d0874d1 100644 (file)
@@ -1,5 +1,19 @@
 2003-12-27  Mark Kettenis  <kettenis@gnu.org>
 
+       * sparc64-tdep.h (sparc64nbsd_gregset): Add extern declaration.
+       * sparc64nbsd-nat.c: Rewrite.
+       * sparc64nbsd-tdep.c: New file.
+       * configure.tgt: Add sparc64-*-netbsd*.
+       * configure.host: Add sparc64-*-netbsd*.
+       * Makefile.in (ALLDEPFILES): Add sparc64nbsd-tdep.c and
+       sparc64nbsd-nat.c.
+       (sparc64nbsd-tdep.o, sparc64nbsd-nat.o): New dependencies.
+       * config/sparc/nbsd64.mh (NATDEPFILES): Add sparc-nat.o.
+       * config/sparc/nbsd64.mt (TDEPFILES): Add sparc64-tdep.o and
+       sparc64nbsd-tdep.o.
+       (TM_FILE): Set to tm-nbsd.h.
+       * config/sparc/tm-nbsd64.h: Remove file.
+
        * sparc64fbsd-tdep.c: Include "frame.h", "frame-unwind.h",
        "trad-frame.h" and "gdb_assert.h".
        (BIAS): New define.
index eec508055ef34a6787c16d1cfeea40861c4dd3c9..77c8c36db87aba0c7570511f295ca820d9d34b85 100644 (file)
@@ -2342,6 +2342,11 @@ sparc64fbsd-tdep.o: sparc64fbsd-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \
        $(regcache_h) $(target_h) $(gdb_string_h) $(sparc64_tdep_h)
 sparc64fbsd-nat.o: sparc64fbsd-nat.c $(defs_h) $(sparc64_tdep_h) \
        $(sparc_nat_h)
+sparc64nbsd-tdep.o: sparc64nbsd-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \
+       $(regcache_h) $(solib_svr4_h) $(gdb_string_h) $(sparc64_tdep_h) \
+       $(nbsd_tdep_h)
+sparc64nbsd-nat.o: sparc64nbsd-nat.c $(defs_h) $(sparc64_tdep_h) \
+       $(sparc_nat_h)
 sparc-stub.o: sparc-stub.c
 stabsread.o: stabsread.c $(defs_h) $(gdb_string_h) $(bfd_h) $(gdb_obstack_h) \
        $(symtab_h) $(gdbtypes_h) $(expression_h) $(symfile_h) $(objfiles_h) \
index eb54e489eb866129adca096d36910a241f2ed6d4..4301c92313e1426ec0d91da23d819a548940f8b4 100644 (file)
@@ -1,3 +1,4 @@
-# Host: UltraSPARC running NetBSD
-NATDEPFILES= fork-child.o infptrace.o inftarg.o sparc64nbsd-nat.o
+# Host: NetBSD/sparc64
+NATDEPFILES= sparc-nat.o sparc64nbsd-nat.o \
+       fork-child.o infptrace.o inftarg.o
 NAT_FILE= nm-nbsd.h
index 93b8f7841d4e22eb9ef25e89e28845bf22c67852..4a1b13b9bb6826b8fb8b457a9a6548d55240afe6 100644 (file)
@@ -1,4 +1,5 @@
-# Target: UltraSPARC running NetBSD
-TDEPFILES= sparc-tdep.o sparcnbsd-tdep.o nbsd-tdep.o corelow.o solib.o \
-       solib-svr4.o
-TM_FILE= tm-nbsd64.h
+# Target: NetBSD/sparc64
+TDEPFILES= sparc64-tdep.o sparc64nbsd-tdep.o \
+       sparc-tdep.o sparcnbsd-tdep.o nbsd-tdep.o \
+       corelow.o solib.o solib-svr4.o
+TM_FILE= tm-nbsd.h
diff --git a/gdb/config/sparc/tm-nbsd64.h b/gdb/config/sparc/tm-nbsd64.h
deleted file mode 100644 (file)
index cc1d6b3..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Macro definitions for UltraSPARC running under NetBSD.
-   Copyright 1994, 2002 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-#ifndef TM_NBSD64_H
-#define TM_NBSD64_H
-
-#include "sparc/tm-sp64.h" /* sets GDB_MULTI_ARCH */
-#include "solib.h"
-
-#endif /* TM_NBSD64_H */
index a828c272ed2caba41603e5b5a106a4be34eb7f4e..bd434d6cb546952ecc4aedac50bd378ff2537a31 100644 (file)
@@ -136,6 +136,7 @@ sparc-*-netbsdaout*)        gdb_host_nbsdaout ;;
 sparc-*-netbsd*)       gdb_host=nbsdaout ;;
 sparc64-*-freebsd*)    gdb_host=fbsd ;;
 sparc64-*-linux*)      gdb_host=linux64 ;;
+sparc64-*-netbsd*)     gdb_host=nbsd64 ;;
 sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*)
                        gdb_host=sol2
                        ;;
index c5cff25106a917f318bb79eeffb015fc7d9575d0..0d21c5ddca15ee87f0417d39050c9741fa7d73c2 100644 (file)
@@ -212,6 +212,7 @@ sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*)
                        ;;
 sparc-*-*)             gdb_target=sparc ;;
 sparc64-*-linux*)      gdb_target=linux64 ;;
+sparc64-*-netbsd*)     gdb_target=nbsd64 ;;
 
 xstormy16-*-*)          gdb_target=xstormy16 ;;
 
index 115e992ac22da41fa5cc91f6d735e5ccd994fc49..f84ea442e1f8598397c30db9fb13da2cddaee0b1 100644 (file)
@@ -99,4 +99,9 @@ extern void sparc64_sol2_init_abi (struct gdbarch_info info,
 /* Register offsets for FreeBSD/sparc64.  */
 extern const struct sparc_gregset sparc64fbsd_gregset;
 
+/* Variables exported from sparc64nbsd-tdep.c.  */
+
+/* Register offsets for NetBSD/sparc64.  */
+extern const struct sparc_gregset sparc64nbsd_gregset;
+
 #endif /* sparc64-tdep.h */
index 1e68d6961a97ca6ed8451ebee70b97ea18733634..ec324591470a90e94d75a4aacb862df3f5145f4d 100644 (file)
@@ -1,4 +1,5 @@
-/* Native-dependent code for UltraSPARC systems running NetBSD.
+/* Native-dependent code for NetBSD/sparc64.
+
    Copyright 2002, 2003 Free Software Foundation, Inc.
    Contributed by Wasabi Systems, Inc.
 
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
-#include "inferior.h"
-#include "regcache.h"
 
-#include "sparc-tdep.h"
-#include "sparcnbsd-tdep.h"
+#include "sparc64-tdep.h"
+#include "sparc-nat.h"
 
-#include <sys/types.h>
-#include <sys/ptrace.h>
-#include <machine/reg.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.  */
 
-/* NOTE: We don't bother with any of the deferred_store nonsense; it
-   makes things a lot more complicated than they need to be.  */
+static void
+sparc64nbsd_supply_gregset (const struct sparc_gregset *gregset,
+                           struct regcache *regcache,
+                           int regnum, const void *gregs)
+{
+  int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32);
 
-/* Determine if PT_GETREGS fetches this register.  */
-static int
-getregs_supplies (int regno)
+  if (sparc32)
+    sparc32_supply_gregset (&sparc32nbsd_gregset, regcache, regnum, gregs);
+  else
+    sparc64_supply_gregset (&sparc64nbsd_gregset, regcache, regnum, gregs);
+}
+
+static void
+sparc64nbsd_collect_gregset (const struct sparc_gregset *gregset,
+                            const struct regcache *regcache,
+                            int regnum, void *gregs)
 {
-  /* FIXME: PS_REGNUM for 32-bit code.  */
-  return (regno == TSTATE_REGNUM
-         || regno == PC_REGNUM
-         || regno == NPC_REGNUM
-         || regno == Y_REGNUM
-         || (regno >= G0_REGNUM && regno <= G7_REGNUM)
-         || (regno >= O0_REGNUM && regno <= O7_REGNUM)
-         /* stack regs (handled by sparcnbsd_supply_reg)  */
-         || (regno >= L0_REGNUM && regno <= I7_REGNUM));
+  int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32);
+
+  if (sparc32)
+    sparc32_collect_gregset (&sparc32nbsd_gregset, regcache, regnum, gregs);
+  else
+    sparc64_collect_gregset (&sparc64nbsd_gregset, regcache, regnum, gregs);
 }
 
-/* Determine if PT_GETFPREGS fetches this register.  */
-static int
-getfpregs_supplies (int regno)
+static void
+sparc64nbsd_supply_fpregset (struct regcache *regcache,
+                            int regnum, const void *fpregs)
 {
-  return ((regno >= FP0_REGNUM && regno <= (FP0_REGNUM + 47))
-         || regno == FPS_REGNUM);
+  int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32);
+
+  if (sparc32)
+    sparc32_supply_fpregset (regcache, regnum, fpregs);
+  else
+    sparc64_supply_fpregset (regcache, regnum, fpregs);
 }
 
-void
-fetch_inferior_registers (int regno)
+static void
+sparc64nbsd_collect_fpregset (const struct regcache *regcache,
+                             int regnum, void *fpregs)
 {
-  /* We don't use deferred stores.  */
-  if (deferred_stores)
-    internal_error (__FILE__, __LINE__,
-                   "fetch_inferior_registers: deferred stores pending");
-
-  if (regno == -1 || getregs_supplies (regno))
-    {
-      union {
-       struct reg32 regs32;
-       struct reg64 regs64;
-      } regs;
-
-      if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
-                 (PTRACE_ARG3_TYPE) &regs, 0) == -1)
-        perror_with_name ("Couldn't get registers");
-
-      if (gdbarch_ptr_bit (current_gdbarch) == 32)
-        sparcnbsd_supply_reg32 ((char *) &regs.regs32, regno);
-      else
-       sparcnbsd_supply_reg64 ((char *) &regs.regs64, regno);
-      if (regno != -1)
-       return;
-    }
-
-  if (regno == -1 || getfpregs_supplies (regno))
-    {
-      union {
-        struct fpreg32 fpregs32;
-       struct fpreg64 fpregs64;
-      } fpregs;
-
-      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
-                 (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
-        perror_with_name ("Couldn't get floating point registers");
-
-      if (gdbarch_ptr_bit (current_gdbarch) == 32)
-        sparcnbsd_supply_fpreg32 ((char *) &fpregs.fpregs32, regno);
-      else
-        sparcnbsd_supply_fpreg64 ((char *) &fpregs.fpregs64, regno);
-      if (regno != -1)
-       return;
-    }
+  int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32);
+
+  if (sparc32)
+    sparc32_collect_fpregset (regcache, regnum, fpregs);
+  else
+    sparc64_collect_fpregset (regcache, regnum, fpregs);
 }
 
+\f
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+void _initialize_sparcnbsd_nat (void);
+
 void
-store_inferior_registers (int regno)
+_initialize_sparcnbsd_nat (void)
 {
-  /* We don't use deferred stores.  */
-  if (deferred_stores)
-    internal_error (__FILE__, __LINE__,
-                   "store_inferior_registers: deferred stores pending");
-
-  if (regno == -1 || getregs_supplies (regno))
-    {
-      union {
-       struct reg32 regs32;
-       struct reg64 regs64;
-      } regs;
-
-      if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
-                 (PTRACE_ARG3_TYPE) &regs, 0) == -1)
-       perror_with_name ("Couldn't get registers");
-
-      if (gdbarch_ptr_bit (current_gdbarch) == 32)
-        sparcnbsd_fill_reg32 ((char *) &regs.regs32, regno);
-      else
-       sparcnbsd_fill_reg64 ((char *) &regs.regs64, regno);
-
-      if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
-                 (PTRACE_ARG3_TYPE) &regs, 0) == -1)
-       perror_with_name ("Couldn't write registers");
-
-      /* Deal with the stack regs.  */
-      if (regno == -1 || regno == SP_REGNUM
-         || (regno >= L0_REGNUM && regno <= I7_REGNUM))
-       {
-         CORE_ADDR sp = read_register (SP_REGNUM);
-         int i;
-         char buf[8];
-
-         if (sp & 1)
-           {
-             /* Registers are 64-bit.  */
-             sp += 2047;
-
-             for (i = L0_REGNUM; i <= I7_REGNUM; i++)
-               {
-                 if (regno == -1 || regno == SP_REGNUM || regno == i)
-                   {
-                     regcache_collect (i, buf);
-                     target_write_memory (sp + ((i - L0_REGNUM) * 8),
-                                          buf, sizeof (buf));
-                   }
-               }
-            }
-         else
-           {
-             /* Registers are 32-bit.  Toss any sign-extension of the stack
-                pointer.
-
-                FIXME: We don't currently handle 32-bit code in a binary
-                that indicated LP64.  Do we have to care about that?  */
-              if (gdbarch_ptr_bit (current_gdbarch) != 32)
-               internal_error
-                   (__FILE__, __LINE__,
-                   "store_inferior_registers: 32-bit code in 64-bit inferior");
-
-             sp &= 0xffffffffUL;
-             for (i = L0_REGNUM; i <= I7_REGNUM; i++)
-               {
-                 if (regno == -1 || regno == SP_REGNUM || regno == i)
-                   {
-                     regcache_collect (i, buf);
-                     target_write_memory (sp + ((i - L0_REGNUM) * 4), buf, 4);
-                   }
-               }
-           }
-       }
-
-      if (regno != -1)
-       return;
-    }
-
-  if (regno == -1 || getfpregs_supplies (regno))
-    {
-      union {
-       struct fpreg32 fpregs32;
-       struct fpreg64 fpregs64;
-      } fpregs;
-
-      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
-                 (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
-       perror_with_name ("Couldn't get floating point registers");
-
-      if (gdbarch_ptr_bit (current_gdbarch) == 32)
-        sparcnbsd_fill_fpreg32 ((char *) &fpregs.fpregs32, regno);
-      else
-       sparcnbsd_fill_fpreg64 ((char *) &fpregs.fpregs64, regno);
-      
-      if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
-                 (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
-       perror_with_name ("Couldn't write floating point registers");
-
-      if (regno != -1)
-       return;
-    }
+  sparc_supply_gregset = sparc64nbsd_supply_gregset;
+  sparc_collect_gregset = sparc64nbsd_collect_gregset;
+  sparc_supply_fpregset = sparc64nbsd_supply_fpregset;
+  sparc_collect_fpregset = sparc64nbsd_collect_fpregset;
 }
diff --git a/gdb/sparc64nbsd-tdep.c b/gdb/sparc64nbsd-tdep.c
new file mode 100644 (file)
index 0000000..6c60e71
--- /dev/null
@@ -0,0 +1,109 @@
+/* Target-dependent code for NetBSD/sparc64.
+
+   Copyright 2002, 2003 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include "defs.h"
+#include "gdbcore.h"
+#include "osabi.h"
+#include "regcache.h"
+#include "solib-svr4.h"
+
+#include "gdb_string.h"
+
+#include "sparc64-tdep.h"
+#include "nbsd-tdep.h"
+
+const struct sparc_gregset sparc64nbsd_gregset =
+{
+  0 * 8,                       /* "tstate" */
+  1 * 8,                       /* %pc */
+  2 * 8,                       /* %npc */
+  3 * 8,                       /* %y */
+  -1,                          /* %fprs */
+  -1,
+  5 * 8,                       /* %g1 */
+  -1,                          /* %l0 */
+  4                            /* sizeof (%y) */
+};
+
+/* Size of `struct reg' and `struct fpreg'.  */
+static const int sparc64nbsd_sizeof_struct_reg = 160;
+static const int sparc64nbsd_sizeof_struct_fpreg = 272;
+
+static void
+fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
+                      CORE_ADDR ignore)
+{
+  switch (which)
+    {
+    case 0:  /* Integer registers */
+      if (core_reg_size != sparc64nbsd_sizeof_struct_reg)
+       warning ("Wrong size register set in core file.");
+      else
+       sparc64_supply_gregset (&sparc64nbsd_gregset, current_regcache,
+                               -1, core_reg_sect);
+      break;
+
+    case 2:  /* Floating pointer registers */
+      if (core_reg_size != sparc64nbsd_sizeof_struct_fpreg)
+       warning ("Wrong size FP register set in core file.");
+      else
+       sparc64_supply_fpregset (current_regcache, -1, core_reg_sect);
+      break;
+
+    default:
+      /* Don't know what kind of register request this is; just ignore it.  */
+      break;
+    }
+}
+
+static struct core_fns sparc64nbsd_core_fns =
+{
+  bfd_target_elf_flavour,              /* core_flavour */
+  default_check_format,                        /* check_format */
+  default_core_sniffer,                        /* core_sniffer */
+  fetch_core_registers,                        /* core_read_registers */
+  NULL
+};
+
+static void
+sparc64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  sparc64_init_abi (info, gdbarch);
+
+  set_gdbarch_pc_in_sigtramp (gdbarch, nbsd_pc_in_sigtramp);
+
+  set_solib_svr4_fetch_link_map_offsets
+    (gdbarch, nbsd_lp64_solib_svr4_fetch_link_map_offsets);
+}
+
+\f
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+void _initialize_sparc64nbsd_tdep (void);
+
+void
+_initialize_sparc64nbsd_tdep (void)
+{
+  gdbarch_register_osabi (bfd_arch_sparc, bfd_mach_sparc_v9,
+                         GDB_OSABI_NETBSD_ELF, sparc64nbsd_init_abi);
+
+  add_core_fns (&sparc64nbsd_core_fns);
+}