1 /* Target-dependent code for OpenBSD/i386.
3 Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002, 2003
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 #include "arch-utils.h"
30 #include "gdb_assert.h"
31 #include "gdb_string.h"
33 #include "i386-tdep.h"
34 #include "i387-tdep.h"
36 /* From <machine/reg.h>. */
37 static int i386obsd_r_reg_offset[] =
58 i386obsd_aout_supply_regset (const struct regset *regset,
59 struct regcache *regcache, int regnum,
60 const void *regs, size_t len)
62 const struct gdbarch_tdep *tdep = regset->descr;
64 gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE);
66 i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
67 i387_supply_fsave (regcache, regnum, (char *) regs + tdep->sizeof_gregset);
71 i386obsd_aout_regset_from_core_section (struct gdbarch *gdbarch,
72 const char *sect_name,
75 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
77 /* OpenBSD a.out core dumps don't use seperate register sets for the
78 general-purpose and floating-point registers. */
80 if (strcmp (sect_name, ".reg") == 0
81 && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
83 if (tdep->gregset == NULL)
85 tdep->gregset = XMALLOC (struct regset);
86 tdep->gregset->descr = tdep;
87 tdep->gregset->supply_regset = i386obsd_aout_supply_regset;
97 CORE_ADDR i386obsd_sigtramp_start = 0xbfbfdf20;
98 CORE_ADDR i386obsd_sigtramp_end = 0xbfbfdff0;
100 /* From <machine/signal.h>. */
101 int i386obsd_sc_reg_offset[I386_NUM_GREGS] =
112 13 * 4, /* %eflags */
122 i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
124 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
126 /* Obviously OpenBSD is BSD-based. */
127 i386bsd_init_abi (info, gdbarch);
129 /* OpenBSD has a different `struct reg'. */
130 tdep->gregset_reg_offset = i386obsd_r_reg_offset;
131 tdep->gregset_num_regs = ARRAY_SIZE (i386obsd_r_reg_offset);
132 tdep->sizeof_gregset = 16 * 4;
134 /* OpenBSD has a single register set. */
135 set_gdbarch_regset_from_core_section
136 (gdbarch, i386obsd_aout_regset_from_core_section);
138 /* OpenBSD uses -freg-struct-return by default. */
139 tdep->struct_return = reg_struct_return;
141 /* OpenBSD uses a different memory layout. */
142 tdep->sigtramp_start = i386obsd_sigtramp_start;
143 tdep->sigtramp_end = i386obsd_sigtramp_end;
145 /* OpenBSD has a `struct sigcontext' that's different from the
146 origional 4.3 BSD. */
147 tdep->sc_reg_offset = i386obsd_sc_reg_offset;
148 tdep->sc_num_regs = ARRAY_SIZE (i386obsd_sc_reg_offset);
152 /* Provide a prototype to silence -Wmissing-prototypes. */
153 void _initialize_i386obsd_tdep (void);
156 _initialize_i386obsd_tdep (void)
158 /* FIXME: kettenis/20021020: Since OpenBSD/i386 binaries are
159 indistingushable from NetBSD/i386 a.out binaries, building a GDB
160 that should support both these targets will probably not work as
162 #define GDB_OSABI_OPENBSD_AOUT GDB_OSABI_NETBSD_AOUT
164 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_OPENBSD_AOUT,