2007-11-07 Markus Deuling <deuling@de.ibm.com>
[deliverable/binutils-gdb.git] / gdb / i386bsd-tdep.c
CommitLineData
b7247919 1/* Target-dependent code for i386 BSD's.
8a96bc77 2
6aba47ca 3 Copyright (C) 2001, 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
b7247919
MK
4
5 This file is part of GDB.
6
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
b7247919
MK
10 (at your option) any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
b7247919
MK
19
20#include "defs.h"
9c5045b5 21#include "arch-utils.h"
b7247919
MK
22#include "frame.h"
23#include "gdbcore.h"
24#include "regcache.h"
4be87837 25#include "osabi.h"
b7247919 26
ca39387d
MK
27#include "gdb_string.h"
28
8201327c 29#include "i386-tdep.h"
b7247919 30
8201327c 31/* Support for signal handlers. */
b7247919 32
acd5c798
MK
33/* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
34 routine, return the address of the associated sigcontext structure. */
b7247919 35
acd5c798
MK
36static CORE_ADDR
37i386bsd_sigcontext_addr (struct frame_info *next_frame)
b7247919 38{
63c0089f 39 gdb_byte buf[4];
acd5c798 40 CORE_ADDR sp;
b4700d91 41
c7f16359 42 frame_unwind_register (next_frame, I386_ESP_REGNUM, buf);
acd5c798 43 sp = extract_unsigned_integer (buf, 4);
b7247919 44
acd5c798 45 return read_memory_unsigned_integer (sp + 8, 4);
b7247919 46}
8201327c
MK
47\f
48
9c5045b5
MK
49/* Support for shared libraries. */
50
8201327c
MK
51/* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
52
53/* From <machine/signal.h>. */
155c1d33 54int i386bsd_sc_reg_offset[] =
a3386186
MK
55{
56 -1, /* %eax */
57 -1, /* %ecx */
58 -1, /* %edx */
59 -1, /* %ebx */
60 8 + 0 * 4, /* %esp */
61 8 + 1 * 4, /* %ebp */
62 -1, /* %esi */
63 -1, /* %edi */
64 8 + 3 * 4, /* %eip */
65 8 + 4 * 4, /* %eflags */
66 -1, /* %cs */
67 -1, /* %ss */
68 -1, /* %ds */
69 -1, /* %es */
70 -1, /* %fs */
71 -1 /* %gs */
72};
8201327c 73
3cac699e 74void
8201327c
MK
75i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
76{
77 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
78
8201327c
MK
79 tdep->jb_pc_offset = 0;
80
8201327c
MK
81 tdep->sigtramp_start = 0xfdbfdfc0;
82 tdep->sigtramp_end = 0xfdbfe000;
21d0e8a4 83 tdep->sigcontext_addr = i386bsd_sigcontext_addr;
a3386186 84 tdep->sc_reg_offset = i386bsd_sc_reg_offset;
155c1d33 85 tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
8201327c
MK
86}
87
8201327c
MK
88\f
89static enum gdb_osabi
90i386bsd_aout_osabi_sniffer (bfd *abfd)
91{
92 if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
93 return GDB_OSABI_NETBSD_AOUT;
94
95 if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
96 return GDB_OSABI_FREEBSD_AOUT;
97
98 return GDB_OSABI_UNKNOWN;
99}
100
f6943e4a
MK
101static enum gdb_osabi
102i386bsd_core_osabi_sniffer (bfd *abfd)
103{
104 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
105 return GDB_OSABI_NETBSD_AOUT;
106
107 return GDB_OSABI_UNKNOWN;
108}
109
8201327c
MK
110\f
111/* Provide a prototype to silence -Wmissing-prototypes. */
112void _initialize_i386bsd_tdep (void);
113
114void
115_initialize_i386bsd_tdep (void)
116{
117 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
118 i386bsd_aout_osabi_sniffer);
f6943e4a 119
8b0c3633
MK
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,
f6943e4a 122 i386bsd_core_osabi_sniffer);
8201327c 123}
This page took 0.485712 seconds and 4 git commands to generate.