1 /* Target-dependent code for OpenBSD/i386.
2 Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "arch-utils.h"
28 #include "i386-tdep.h"
29 #include "i387-tdep.h"
31 /* Provide a prototype to silence -Wmissing-prototypes. */
32 void _initialize_i386obsd_tdep (void);
34 #define SIZEOF_STRUCT_REG (16 * 4)
37 i386obsd_supply_reg (char *regs
, int regno
)
41 for (i
= 0; i
<= 15; i
++)
42 if (regno
== i
|| regno
== -1)
43 supply_register (i
, regs
+ i
* 4);
47 fetch_core_registers (char *core_reg_sect
, unsigned core_reg_size
, int which
,
52 /* We get everything from one section. */
56 if (core_reg_size
< (SIZEOF_STRUCT_REG
+ 108))
58 warning ("Wrong size register set in core file.");
63 fsave
= core_reg_sect
+ SIZEOF_STRUCT_REG
;
65 /* Integer registers. */
66 i386obsd_supply_reg (regs
, -1);
68 /* Floating point registers. */
69 i387_supply_fsave (fsave
, -1);
72 static struct core_fns i386obsd_core_fns
=
74 bfd_target_unknown_flavour
, /* core_flavour */
75 default_check_format
, /* check_format */
76 default_core_sniffer
, /* core_sniffer */
77 fetch_core_registers
, /* core_read_registers */
82 CORE_ADDR i386obsd_sigtramp_start
= 0xbfbfdf20;
83 CORE_ADDR i386obsd_sigtramp_end
= 0xbfbfdff0;
85 /* From <machine/signal.h>. */
86 int i386obsd_sc_reg_offset
[I386_NUM_GREGS
] =
107 i386obsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
109 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
111 /* Obviously OpenBSD is BSD-based. */
112 i386bsd_init_abi (info
, gdbarch
);
114 /* OpenBSD uses -freg-struct-return by default. */
115 tdep
->struct_return
= reg_struct_return
;
117 /* OpenBSD uses a different memory layout. */
118 tdep
->sigtramp_start
= i386obsd_sigtramp_start
;
119 tdep
->sigtramp_end
= i386obsd_sigtramp_end
;
121 /* OpenBSD has a `struct sigcontext' that's different from the
122 origional 4.3 BSD. */
123 tdep
->sc_reg_offset
= i386obsd_sc_reg_offset
;
124 tdep
->sc_num_regs
= I386_NUM_GREGS
;
128 _initialize_i386obsd_tdep (void)
130 add_core_fns (&i386obsd_core_fns
);
132 /* FIXME: kettenis/20021020: Since OpenBSD/i386 binaries are
133 indistingushable from NetBSD/i386 a.out binaries, building a GDB
134 that should support both these targets will probably not work as
136 #define GDB_OSABI_OPENBSD_AOUT GDB_OSABI_NETBSD_AOUT
138 gdbarch_register_osabi (bfd_arch_i386
, 0, GDB_OSABI_OPENBSD_AOUT
,