* i386obsd-tdep.c: Include "regset.h", "gdb_assert.h" and
authorMark Kettenis <kettenis@gnu.org>
Fri, 26 Dec 2003 18:07:00 +0000 (18:07 +0000)
committerMark Kettenis <kettenis@gnu.org>
Fri, 26 Dec 2003 18:07:00 +0000 (18:07 +0000)
"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.

gdb/ChangeLog
gdb/i386obsd-tdep.c

index 55cf600f3af71783183b879b8998084b92cd7bff..698ccc923fd146a3cd26081e45306fe393662078 100644 (file)
@@ -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.
 
index a7e944150df30d927d1b28e3cdd1be8e1b7fd349..ed7a771a90021839bd1f89870764b1a92e5873c7 100644 (file)
@@ -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.
 
 #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 */
-};
 \f
 
 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);
 }
+\f
+
+/* 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
This page took 0.034378 seconds and 4 git commands to generate.