summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2006-08-02 21:32:37 +0000
committerMark Kettenis <kettenis@gnu.org>2006-08-02 21:32:37 +0000
commit47ccd04848b5dac105ea353a2a98019c49d3000a (patch)
treefeb00c96dc77ff51bfc35e08e335eb9aa66b65b0
parent9d7cbccda0d0b223261e33efb609a7a43401ec5e (diff)
downloadbinutils-gdb-47ccd04848b5dac105ea353a2a98019c49d3000a.tar.gz
* arm-tdep.h: Add multiple inclusion protection.
(struct gdbarch): Add forward declaration. (armobsd_regset_from_core_section): New prototype. * armbsd-tdep.c: New file. * armobsd-tdep.c: Include "gdb_string.h". (armobsd_init_abi): Set regset_from_core_section. (armobsd_core_osabi_sniffer): New function. (_initialize_armobsd_tdep): Register armobsd_core_osabi_sniffer. * Makefile.in (ALLDEPFILES): Add armbsd-tdep.c. (armbsd-tdep.o): New dependency. (armnbsd-tdep.o): Update dependencies. * config/arm/obsd.mt (TDEPFILES): Add armbsd-tdep.o and corelow.o.
-rw-r--r--gdb/ChangeLog15
-rw-r--r--gdb/Makefile.in7
-rw-r--r--gdb/arm-tdep.h15
-rw-r--r--gdb/armbsd-tdep.c129
-rw-r--r--gdb/armobsd-tdep.c19
-rw-r--r--gdb/config/arm/obsd.mt3
6 files changed, 185 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 43367f8cd28..99beeee611e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,18 @@
+2006-08-02 Mark Kettenis <kettenis@gnu.org>
+
+ * arm-tdep.h: Add multiple inclusion protection.
+ (struct gdbarch): Add forward declaration.
+ (armobsd_regset_from_core_section): New prototype.
+ * armbsd-tdep.c: New file.
+ * armobsd-tdep.c: Include "gdb_string.h".
+ (armobsd_init_abi): Set regset_from_core_section.
+ (armobsd_core_osabi_sniffer): New function.
+ (_initialize_armobsd_tdep): Register armobsd_core_osabi_sniffer.
+ * Makefile.in (ALLDEPFILES): Add armbsd-tdep.c.
+ (armbsd-tdep.o): New dependency.
+ (armnbsd-tdep.o): Update dependencies.
+ * config/arm/obsd.mt (TDEPFILES): Add armbsd-tdep.o and corelow.o.
+
2006-08-02 Thiemo Seufer <ths@mips.com>
* linux-thread-db.c (thread_db_get_thread_local_address): Fix type
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3f3673f5d78..f114df81051 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1418,7 +1418,7 @@ ALLDEPFILES = \
amd64-linux-nat.c amd64-linux-tdep.c \
amd64-sol2-tdep.c \
arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \
- armnbsd-nat.c armnbsd-tdep.c armobsd-tdep.c \
+ armnbsd-nat.c armbsd-tdep.c armnbsd-tdep.c armobsd-tdep.c \
avr-tdep.c \
bsd-uthread.c bsd-kvm.c \
coff-solib.c \
@@ -1778,10 +1778,13 @@ arm-linux-tdep.o: arm-linux-tdep.c $(defs_h) $(target_h) $(value_h) \
$(glibc_tdep_h) $(trad_frame_h) $(tramp_frame_h) $(gdb_string_h)
armnbsd-nat.o: armnbsd-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) \
$(regcache_h) $(target_h) $(gdb_string_h) $(arm_tdep_h) $(inf_ptrace_h)
+armbsd-tdep.o: armbsd-tdep.c $(defs_h) $(osabi_h) $(regcache_h) $(regset_h) \
+ $(gdb_assert_h) $(gdb_string_h) $(arm_tdep_h)
armnbsd-tdep.o: armnbsd-tdep.c $(defs_h) $(osabi_h) $(gdb_string_h) \
$(arm_tdep_h) $(solib_svr4_h)
armobsd-tdep.o: armobsd-tdep.c $(defs_h) $(osabi_h) $(trad_frame_h) \
- $(tramp_frame_h) $(obsd_tdep_h) $(arm_tdep_h) $(solib_svr4_h)
+ $(tramp_frame_h) $(gdb_string_h) $(obsd_tdep_h) $(arm_tdep_h) \
+ $(solib_svr4_h)
arm-tdep.o: arm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(gdbcmd_h) \
$(gdbcore_h) $(gdb_string_h) $(dis_asm_h) $(regcache_h) \
$(doublest_h) $(value_h) $(arch_utils_h) $(osabi_h) \
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 7b369d5fb90..a5fc99df5b4 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -18,7 +18,11 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
+#ifndef ARM_TDEP_H
+#define ARM_TDEP_H
+
/* Forward declarations. */
+struct gdbarch;
struct regset;
/* Register numbers of various important registers. Note that some of
@@ -176,3 +180,14 @@ int arm_pc_is_thumb (CORE_ADDR);
CORE_ADDR thumb_get_next_pc (CORE_ADDR);
CORE_ADDR arm_get_next_pc (CORE_ADDR);
+
+/* Functions exported from armbsd-tdep.h. */
+
+/* Return the appropriate register set for the core section identified
+ by SECT_NAME and SECT_SIZE. */
+
+extern const struct regset *
+ armbsd_regset_from_core_section (struct gdbarch *gdbarch,
+ const char *sect_name, size_t sect_size);
+
+#endif /* arm-tdep.h */
diff --git a/gdb/armbsd-tdep.c b/gdb/armbsd-tdep.c
new file mode 100644
index 00000000000..95ecd425dff
--- /dev/null
+++ b/gdb/armbsd-tdep.c
@@ -0,0 +1,129 @@
+/* Target-dependent code for ARM BSD's.
+
+ Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+#include "defs.h"
+#include "osabi.h"
+#include "regcache.h"
+#include "regset.h"
+
+#include "gdb_assert.h"
+#include "gdb_string.h"
+
+#include "arm-tdep.h"
+
+/* Core file support. */
+
+/* Sizeof `struct reg' in <machine/reg.h>. */
+#define ARMBSD_SIZEOF_GREGS (17 * 4)
+
+/* Sizeof `struct fpreg' in <machine/reg.h. */
+#define ARMBSD_SIZEOF_FPREGS ((1 + (8 * 3)) * 4)
+
+int
+armbsd_fpreg_offset (int regnum)
+{
+ if (regnum == ARM_FPS_REGNUM)
+ return 0;
+
+ return 4 + (regnum - ARM_F0_REGNUM) * 12;
+}
+
+/* Supply register REGNUM from the buffer specified by FPREGS and LEN
+ in the floating-point register set REGSET to register cache
+ REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
+
+static void
+armbsd_supply_fpregset (const struct regset *regset,
+ struct regcache *regcache,
+ int regnum, const void *fpregs, size_t len)
+{
+ const gdb_byte *regs = fpregs;
+ int i;
+
+ gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);
+
+ for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
+ {
+ if (regnum == i || regnum == -1)
+ regcache_raw_supply (regcache, i, regs + armbsd_fpreg_offset (i));
+ }
+}
+
+/* Supply register REGNUM from the buffer specified by GREGS and LEN
+ in the general-purpose register set REGSET to register cache
+ REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
+
+static void
+armbsd_supply_gregset (const struct regset *regset,
+ struct regcache *regcache,
+ int regnum, const void *gregs, size_t len)
+{
+ const gdb_byte *regs = gregs;
+ int i;
+
+ gdb_assert (len >= ARMBSD_SIZEOF_GREGS);
+
+ for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
+ {
+ if (regnum == i || regnum == -1)
+ regcache_raw_supply (regcache, i, regs + i * 4);
+ }
+
+ if (regnum == ARM_PS_REGNUM || regnum == -1)
+ regcache_raw_supply (regcache, i, regs + 16 * 4);
+
+ if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
+ {
+ regs += ARMBSD_SIZEOF_GREGS;
+ len -= ARMBSD_SIZEOF_GREGS;
+ armbsd_supply_fpregset (regset, regcache, regnum, regs, len);
+ }
+}
+
+/* ARM register sets. */
+
+static struct regset armbsd_gregset =
+{
+ NULL,
+ armbsd_supply_gregset
+};
+
+static struct regset armbsd_fpregset =
+{
+ NULL,
+ armbsd_supply_fpregset
+};
+
+/* Return the appropriate register set for the core section identified
+ by SECT_NAME and SECT_SIZE. */
+
+const struct regset *
+armbsd_regset_from_core_section (struct gdbarch *gdbarch,
+ const char *sect_name, size_t sect_size)
+{
+ if (strcmp (sect_name, ".reg") == 0 && sect_size >= ARMBSD_SIZEOF_GREGS)
+ return &armbsd_gregset;
+
+ if (strcmp (sect_name, ".reg2") == 0 && sect_size >= ARMBSD_SIZEOF_FPREGS)
+ return &armbsd_fpregset;
+
+ return NULL;
+}
diff --git a/gdb/armobsd-tdep.c b/gdb/armobsd-tdep.c
index 9b14382a7d7..cc769b70486 100644
--- a/gdb/armobsd-tdep.c
+++ b/gdb/armobsd-tdep.c
@@ -24,6 +24,8 @@
#include "trad-frame.h"
#include "tramp-frame.h"
+#include "gdb_string.h"
+
#include "obsd-tdep.h"
#include "arm-tdep.h"
#include "solib-svr4.h"
@@ -89,13 +91,30 @@ armobsd_init_abi (struct gdbarch_info info,
tdep->jb_pc = 24;
tdep->jb_elt_size = 4;
+ set_gdbarch_regset_from_core_section
+ (gdbarch, armbsd_regset_from_core_section);
+
/* OpenBSD/arm uses -fpcc-struct-return by default. */
tdep->struct_return = pcc_struct_return;
}
+
+
+static enum gdb_osabi
+armobsd_core_osabi_sniffer (bfd *abfd)
+{
+ if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
+ return GDB_OSABI_OPENBSD_ELF;
+
+ return GDB_OSABI_UNKNOWN;
+}
void
_initialize_armobsd_tdep (void)
{
+ /* BFD doesn't set a flavour for NetBSD style a.out core files. */
+ gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_unknown_flavour,
+ armobsd_core_osabi_sniffer);
+
gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_OPENBSD_ELF,
armobsd_init_abi);
}
diff --git a/gdb/config/arm/obsd.mt b/gdb/config/arm/obsd.mt
index c3803310b42..fcb1a761d55 100644
--- a/gdb/config/arm/obsd.mt
+++ b/gdb/config/arm/obsd.mt
@@ -1,2 +1,3 @@
# Target: OpenBSD/arm
-TDEPFILES= arm-tdep.o armobsd-tdep.o obsd-tdep.o solib.o solib-svr4.o
+TDEPFILES= arm-tdep.o armbsd-tdep.o armobsd-tdep.o obsd-tdep.o \
+ corelow.o solib.o solib-svr4.o