summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2003-12-26 23:42:59 +0000
committerMark Kettenis <kettenis@gnu.org>2003-12-26 23:42:59 +0000
commit156bc2a3fc1587a9a424a56f71d1000731156752 (patch)
tree0fd1ef2b9b5585bba2970b7f08aea3aea2c9accf
parent31338aa86ccd90bf3afc01696409873ec197e59d (diff)
downloadgdb-156bc2a3fc1587a9a424a56f71d1000731156752.tar.gz
* 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.
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/Makefile.in5
-rw-r--r--gdb/config/sparc/nbsd64.mh5
-rw-r--r--gdb/config/sparc/nbsd64.mt9
-rw-r--r--gdb/config/sparc/tm-nbsd64.h27
-rw-r--r--gdb/configure.host1
-rw-r--r--gdb/configure.tgt1
-rw-r--r--gdb/sparc64-tdep.h5
-rw-r--r--gdb/sparc64nbsd-nat.c227
-rw-r--r--gdb/sparc64nbsd-tdep.c109
10 files changed, 199 insertions, 204 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 27dfb9e1d56..10655c35b1d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index eec508055ef..77c8c36db87 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -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) \
diff --git a/gdb/config/sparc/nbsd64.mh b/gdb/config/sparc/nbsd64.mh
index eb54e489eb8..4301c92313e 100644
--- a/gdb/config/sparc/nbsd64.mh
+++ b/gdb/config/sparc/nbsd64.mh
@@ -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
diff --git a/gdb/config/sparc/nbsd64.mt b/gdb/config/sparc/nbsd64.mt
index 93b8f7841d4..4a1b13b9bb6 100644
--- a/gdb/config/sparc/nbsd64.mt
+++ b/gdb/config/sparc/nbsd64.mt
@@ -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
index cc1d6b32297..00000000000
--- a/gdb/config/sparc/tm-nbsd64.h
+++ /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 */
diff --git a/gdb/configure.host b/gdb/configure.host
index a828c272ed2..bd434d6cb54 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -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
;;
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index c5cff25106a..0d21c5ddca1 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -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 ;;
diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
index 115e992ac22..f84ea442e1f 100644
--- a/gdb/sparc64-tdep.h
+++ b/gdb/sparc64-tdep.h
@@ -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 */
diff --git a/gdb/sparc64nbsd-nat.c b/gdb/sparc64nbsd-nat.c
index 1e68d6961a9..ec324591470 100644
--- a/gdb/sparc64nbsd-nat.c
+++ b/gdb/sparc64nbsd-nat.c
@@ -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.
@@ -20,189 +21,73 @@
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);
}
+
+/* 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
index 00000000000..6c60e71ed62
--- /dev/null
+++ b/gdb/sparc64nbsd-tdep.c
@@ -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);
+}
+
+
+/* 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);
+}