1 /* Target-dependent code for i386 BSD's.
3 Copyright (C) 2001, 2002, 2003, 2004, 2007 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 3 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, see <http://www.gnu.org/licenses/>. */
21 #include "arch-utils.h"
27 #include "gdb_string.h"
29 #include "i386-tdep.h"
31 /* Support for signal handlers. */
33 /* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
34 routine, return the address of the associated sigcontext structure. */
37 i386bsd_sigcontext_addr (struct frame_info
*next_frame
)
42 frame_unwind_register (next_frame
, I386_ESP_REGNUM
, buf
);
43 sp
= extract_unsigned_integer (buf
, 4);
45 return read_memory_unsigned_integer (sp
+ 8, 4);
49 /* Support for shared libraries. */
51 /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
53 /* From <machine/signal.h>. */
54 int i386bsd_sc_reg_offset
[] =
65 8 + 4 * 4, /* %eflags */
75 i386bsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
77 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
79 tdep
->jb_pc_offset
= 0;
81 tdep
->sigtramp_start
= 0xfdbfdfc0;
82 tdep
->sigtramp_end
= 0xfdbfe000;
83 tdep
->sigcontext_addr
= i386bsd_sigcontext_addr
;
84 tdep
->sc_reg_offset
= i386bsd_sc_reg_offset
;
85 tdep
->sc_num_regs
= ARRAY_SIZE (i386bsd_sc_reg_offset
);
90 i386bsd_aout_osabi_sniffer (bfd
*abfd
)
92 if (strcmp (bfd_get_target (abfd
), "a.out-i386-netbsd") == 0)
93 return GDB_OSABI_NETBSD_AOUT
;
95 if (strcmp (bfd_get_target (abfd
), "a.out-i386-freebsd") == 0)
96 return GDB_OSABI_FREEBSD_AOUT
;
98 return GDB_OSABI_UNKNOWN
;
101 static enum gdb_osabi
102 i386bsd_core_osabi_sniffer (bfd
*abfd
)
104 if (strcmp (bfd_get_target (abfd
), "netbsd-core") == 0)
105 return GDB_OSABI_NETBSD_AOUT
;
107 return GDB_OSABI_UNKNOWN
;
111 /* Provide a prototype to silence -Wmissing-prototypes. */
112 void _initialize_i386bsd_tdep (void);
115 _initialize_i386bsd_tdep (void)
117 gdbarch_register_osabi_sniffer (bfd_arch_i386
, bfd_target_aout_flavour
,
118 i386bsd_aout_osabi_sniffer
);
120 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
121 gdbarch_register_osabi_sniffer (bfd_arch_i386
, bfd_target_unknown_flavour
,
122 i386bsd_core_osabi_sniffer
);