1 /* Target-dependent code for i386 BSD's.
3 Copyright (C) 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010
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 3 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, see <http://www.gnu.org/licenses/>. */
22 #include "arch-utils.h"
28 #include "gdb_string.h"
30 #include "i386-tdep.h"
32 /* Support for signal handlers. */
34 /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
35 address of the associated sigcontext structure. */
38 i386bsd_sigcontext_addr (struct frame_info *this_frame)
40 struct gdbarch *gdbarch = get_frame_arch (this_frame);
41 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
45 get_frame_register (this_frame, I386_ESP_REGNUM, buf);
46 sp = extract_unsigned_integer (buf, 4, byte_order);
48 return read_memory_unsigned_integer (sp + 8, 4, byte_order);
52 /* Support for shared libraries. */
54 /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
56 /* From <machine/signal.h>. */
57 int i386bsd_sc_reg_offset[] =
68 8 + 4 * 4, /* %eflags */
78 i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
80 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
82 tdep->jb_pc_offset = 0;
84 tdep->sigtramp_start = 0xfdbfdfc0;
85 tdep->sigtramp_end = 0xfdbfe000;
86 tdep->sigcontext_addr = i386bsd_sigcontext_addr;
87 tdep->sc_reg_offset = i386bsd_sc_reg_offset;
88 tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
93 i386bsd_aout_osabi_sniffer (bfd *abfd)
95 if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
96 return GDB_OSABI_NETBSD_AOUT;
98 if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
99 return GDB_OSABI_FREEBSD_AOUT;
101 return GDB_OSABI_UNKNOWN;
104 static enum gdb_osabi
105 i386bsd_core_osabi_sniffer (bfd *abfd)
107 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
108 return GDB_OSABI_NETBSD_AOUT;
110 return GDB_OSABI_UNKNOWN;
114 /* Provide a prototype to silence -Wmissing-prototypes. */
115 void _initialize_i386bsd_tdep (void);
118 _initialize_i386bsd_tdep (void)
120 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
121 i386bsd_aout_osabi_sniffer);
123 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
124 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour,
125 i386bsd_core_osabi_sniffer);