aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2003-12-26 18:07:00 +0000
committerMark Kettenis <kettenis@gnu.org>2003-12-26 18:07:00 +0000
commit6745701255aa6bf93505fad23734aed68290d4ce (patch)
tree6ac38500a223f3d7d073bdfe51b9f8e479a8b4cc /gdb
parentf6943e4a1d18d45ef98400032e606499209710ee (diff)
downloadgdb-6745701255aa6bf93505fad23734aed68290d4ce.zip
gdb-6745701255aa6bf93505fad23734aed68290d4ce.tar.gz
gdb-6745701255aa6bf93505fad23734aed68290d4ce.tar.bz2
* i386obsd-tdep.c: Include "regset.h", "gdb_assert.h" and
"gdb_string.h". (i386obsd_r_reg_offset): New variable. (i386obsd_aout_supply_regset) (i386obsd_aout_regset_from_core_section): New functions. (i386obsd_supply_reg, fetch_core_registers): Remove functions. (i286obsd_core_fns): Remove variable. (i386obsd_init_abi): Initialize TDEP->gregset_reg_offset, TDEP->gregset_num_regs and TDEP->sizeof_gregset. Set regset_from_core_section. Use ARRAY_SIZE to initialize TDEP->sc_num_regs. (_initialize_i386obsd_tdep): Don't call add_core_fns.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/i386obsd-tdep.c102
2 files changed, 77 insertions, 38 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 55cf600..698ccc9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
2003-12-26 Mark Kettenis <kettenis@gnu.org>
+ * i386obsd-tdep.c: Include "regset.h", "gdb_assert.h" and
+ "gdb_string.h".
+ (i386obsd_r_reg_offset): New variable.
+ (i386obsd_aout_supply_regset)
+ (i386obsd_aout_regset_from_core_section): New functions.
+ (i386obsd_supply_reg, fetch_core_registers): Remove functions.
+ (i286obsd_core_fns): Remove variable.
+ (i386obsd_init_abi): Initialize TDEP->gregset_reg_offset,
+ TDEP->gregset_num_regs and TDEP->sizeof_gregset. Set
+ regset_from_core_section. Use ARRAY_SIZE to initialize
+ TDEP->sc_num_regs.
+ (_initialize_i386obsd_tdep): Don't call add_core_fns.
+
* i386bsd-tdep.c (i386bsd_core_osabi_sniffer): New function.
(_initialize_i386bsd_tdep): Register i386bsd_core_osabi_sniffer.
diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c
index a7e9441..ed7a771 100644
--- a/gdb/i386obsd-tdep.c
+++ b/gdb/i386obsd-tdep.c
@@ -1,4 +1,5 @@
/* Target-dependent code for OpenBSD/i386.
+
Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
@@ -23,60 +24,74 @@
#include "arch-utils.h"
#include "gdbcore.h"
#include "regcache.h"
+#include "regset.h"
#include "osabi.h"
+#include "gdb_assert.h"
+#include "gdb_string.h"
+
#include "i386-tdep.h"
#include "i387-tdep.h"
-/* Provide a prototype to silence -Wmissing-prototypes. */
-void _initialize_i386obsd_tdep (void);
-
-#define SIZEOF_STRUCT_REG (16 * 4)
+/* From <machine/reg.h>. */
+static int i386obsd_r_reg_offset[] =
+{
+ 0 * 4, /* %eax */
+ 1 * 4, /* %ecx */
+ 2 * 4, /* %edx */
+ 3 * 4, /* %ebx */
+ 4 * 4, /* %esp */
+ 5 * 4, /* %ebp */
+ 6 * 4, /* %esi */
+ 7 * 4, /* %edi */
+ 8 * 4, /* %eip */
+ 9 * 4, /* %eflags */
+ 10 * 4, /* %cs */
+ 11 * 4, /* %ss */
+ 12 * 4, /* %ds */
+ 13 * 4, /* %es */
+ 14 * 4, /* %fs */
+ 15 * 4 /* %gs */
+};
static void
-i386obsd_supply_reg (char *regs, int regno)
+i386obsd_aout_supply_regset (const struct regset *regset,
+ struct regcache *regcache, int regnum,
+ const void *regs, size_t len)
{
- int i;
+ const struct gdbarch_tdep *tdep = regset->descr;
+
+ gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE);
- for (i = 0; i <= 15; i++)
- if (regno == i || regno == -1)
- supply_register (i, regs + i * 4);
+ i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
+ i387_supply_fsave (regcache, regnum, (char *) regs + tdep->sizeof_gregset);
}
-static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
- CORE_ADDR ignore)
+const struct regset *
+i386obsd_aout_regset_from_core_section (struct gdbarch *gdbarch,
+ const char *sect_name,
+ size_t sect_size)
{
- char *regs, *fsave;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- /* We get everything from one section. */
- if (which != 0)
- return;
+ /* OpenBSD a.out core dumps don't use seperate register sets for the
+ general-purpose and floating-point registers. */
- if (core_reg_size < (SIZEOF_STRUCT_REG + 108))
+ if (strcmp (sect_name, ".reg") == 0
+ && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
{
- warning ("Wrong size register set in core file.");
- return;
+ if (tdep->gregset == NULL)
+ {
+ tdep->gregset = XMALLOC (struct regset);
+ tdep->gregset->descr = tdep;
+ tdep->gregset->supply_regset = i386obsd_aout_supply_regset;
+ }
+ return tdep->gregset;
}
- regs = core_reg_sect;
- fsave = core_reg_sect + SIZEOF_STRUCT_REG;
-
- /* Integer registers. */
- i386obsd_supply_reg (regs, -1);
-
- /* Floating point registers. */
- i387_supply_fsave (current_regcache, -1, fsave);
+ return NULL;
}
-static struct core_fns i386obsd_core_fns =
-{
- bfd_target_unknown_flavour, /* core_flavour */
- default_check_format, /* check_format */
- default_core_sniffer, /* core_sniffer */
- fetch_core_registers, /* core_read_registers */
- NULL /* next */
-};
CORE_ADDR i386obsd_sigtramp_start = 0xbfbfdf20;
@@ -111,6 +126,15 @@ i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Obviously OpenBSD is BSD-based. */
i386bsd_init_abi (info, gdbarch);
+ /* OpenBSD has a different `struct reg'. */
+ tdep->gregset_reg_offset = i386obsd_r_reg_offset;
+ tdep->gregset_num_regs = ARRAY_SIZE (i386obsd_r_reg_offset);
+ tdep->sizeof_gregset = 16 * 4;
+
+ /* OpenBSD has a single register set. */
+ set_gdbarch_regset_from_core_section
+ (gdbarch, i386obsd_aout_regset_from_core_section);
+
/* OpenBSD uses -freg-struct-return by default. */
tdep->struct_return = reg_struct_return;
@@ -121,14 +145,16 @@ i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* OpenBSD has a `struct sigcontext' that's different from the
origional 4.3 BSD. */
tdep->sc_reg_offset = i386obsd_sc_reg_offset;
- tdep->sc_num_regs = I386_NUM_GREGS;
+ tdep->sc_num_regs = ARRAY_SIZE (i386obsd_sc_reg_offset);
}
+
+
+/* Provide a prototype to silence -Wmissing-prototypes. */
+void _initialize_i386obsd_tdep (void);
void
_initialize_i386obsd_tdep (void)
{
- add_core_fns (&i386obsd_core_fns);
-
/* FIXME: kettenis/20021020: Since OpenBSD/i386 binaries are
indistingushable from NetBSD/i386 a.out binaries, building a GDB
that should support both these targets will probably not work as