1 /* Target-dependent code for i386 BSD's.
3 Copyright 2001, 2002, 2003, 2004 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"
29 #include "gdb_string.h"
31 #include "i386-tdep.h"
33 /* Support for signal handlers. */
35 /* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
36 routine, return the address of the associated sigcontext structure. */
39 i386bsd_sigcontext_addr (struct frame_info *next_frame)
44 frame_unwind_register (next_frame, I386_ESP_REGNUM, buf);
45 sp = extract_unsigned_integer (buf, 4);
47 return read_memory_unsigned_integer (sp + 8, 4);
51 /* Support for shared libraries. */
53 /* Return non-zero if we are in a shared library trampoline code stub. */
56 i386bsd_aout_in_solib_call_trampoline (CORE_ADDR pc, char *name)
58 return (name && !strcmp (name, "_DYNAMIC"));
61 /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
63 /* From <machine/signal.h>. */
64 int i386bsd_sc_reg_offset[] =
75 8 + 4 * 4, /* %eflags */
85 i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
87 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
89 /* Assume SunOS-style shared libraries. */
90 set_gdbarch_in_solib_call_trampoline (gdbarch,
91 i386bsd_aout_in_solib_call_trampoline);
93 tdep->jb_pc_offset = 0;
95 tdep->sigtramp_start = 0xfdbfdfc0;
96 tdep->sigtramp_end = 0xfdbfe000;
97 tdep->sigcontext_addr = i386bsd_sigcontext_addr;
98 tdep->sc_reg_offset = i386bsd_sc_reg_offset;
99 tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
103 static enum gdb_osabi
104 i386bsd_aout_osabi_sniffer (bfd *abfd)
106 if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
107 return GDB_OSABI_NETBSD_AOUT;
109 if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
110 return GDB_OSABI_FREEBSD_AOUT;
112 return GDB_OSABI_UNKNOWN;
115 static enum gdb_osabi
116 i386bsd_core_osabi_sniffer (bfd *abfd)
118 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
119 return GDB_OSABI_NETBSD_AOUT;
121 return GDB_OSABI_UNKNOWN;
125 /* Provide a prototype to silence -Wmissing-prototypes. */
126 void _initialize_i386bsd_tdep (void);
129 _initialize_i386bsd_tdep (void)
131 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
132 i386bsd_aout_osabi_sniffer);
134 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
135 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour,
136 i386bsd_core_osabi_sniffer);