* i386nbsd-tdep.c (fetch_elfcore_registers): Wrap long line.
[deliverable/binutils-gdb.git] / gdb / i386bsd-tdep.c
CommitLineData
b7247919 1/* Target-dependent code for i386 BSD's.
8201327c 2 Copyright 2001, 2002 Free Software Foundation, Inc.
b7247919
MK
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include "defs.h"
9c5045b5 22#include "arch-utils.h"
b7247919
MK
23#include "frame.h"
24#include "gdbcore.h"
25#include "regcache.h"
26
8201327c 27#include "i386-tdep.h"
b7247919 28
8201327c 29/* Support for signal handlers. */
b7247919
MK
30
31/* Return whether PC is in a BSD sigtramp routine. */
32
8201327c
MK
33static int
34i386bsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
b7247919 35{
8201327c 36 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
b7247919 37
8201327c
MK
38 return (pc >= tdep->sigtramp_start && pc < tdep->sigtramp_end);
39}
b7247919
MK
40
41/* Assuming FRAME is for a BSD sigtramp routine, return the address of
21d0e8a4 42 the associated sigcontext structure.
b7247919 43
21d0e8a4
MK
44 Note: This function is used for Solaris 2 too, so don't make it
45 static. */
46
47CORE_ADDR
b7247919
MK
48i386bsd_sigcontext_addr (struct frame_info *frame)
49{
50 if (frame->next)
51 /* If this isn't the top frame, the next frame must be for the
52 signal handler itself. A pointer to the sigcontext structure
53 is passed as the third argument to the signal handler. */
54 return read_memory_unsigned_integer (frame->next->frame + 16, 4);
55
56 /* This is the top frame. We'll have to find the address of the
57 sigcontext structure by looking at the stack pointer. */
58 return read_memory_unsigned_integer (read_register (SP_REGNUM) + 8, 4);
59}
60
8201327c
MK
61/* Return the start address of the sigtramp routine. */
62
63CORE_ADDR
64i386bsd_sigtramp_start (CORE_ADDR pc)
65{
66 return gdbarch_tdep (current_gdbarch)->sigtramp_start;
67}
68
69/* Return the end address of the sigtramp routine. */
70
71CORE_ADDR
72i386bsd_sigtramp_end (CORE_ADDR pc)
73{
74 return gdbarch_tdep (current_gdbarch)->sigtramp_end;
75}
76\f
77
9c5045b5
MK
78/* Support for shared libraries. */
79
80/* Return non-zero if we are in a shared library trampoline code stub. */
81
82int
83i386bsd_aout_in_solib_call_trampoline (CORE_ADDR pc, char *name)
84{
85 return (name && !strcmp (name, "_DYNAMIC"));
86}
87
8201327c
MK
88/* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
89
90/* From <machine/signal.h>. */
91int i386bsd_sc_pc_offset = 20;
92
93static void
94i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
95{
96 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
97
98 set_gdbarch_pc_in_sigtramp (gdbarch, i386bsd_pc_in_sigtramp);
99
9c5045b5
MK
100 /* Assume SunOS-style shared libraries. */
101 set_gdbarch_in_solib_call_trampoline (gdbarch,
102 i386bsd_aout_in_solib_call_trampoline);
103
8201327c
MK
104 tdep->jb_pc_offset = 0;
105
8201327c
MK
106 tdep->sigtramp_start = 0xfdbfdfc0;
107 tdep->sigtramp_end = 0xfdbfe000;
21d0e8a4 108 tdep->sigcontext_addr = i386bsd_sigcontext_addr;
8201327c
MK
109 tdep->sc_pc_offset = i386bsd_sc_pc_offset;
110}
111
112/* NetBSD 1.0 or later. */
113
114/* From <machine/signal.h>. */
115int i386nbsd_sc_pc_offset = 44;
116
117static void
118i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
119{
120 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
121
122 /* Obviously NetBSD is BSD-based. */
123 i386bsd_init_abi (info, gdbarch);
124
125 /* NetBSD uses -freg-struct-return by default. */
126 tdep->struct_return = reg_struct_return;
127
128 /* NetBSD uses a different memory layout. */
129 tdep->sigtramp_start = 0xbfbfdf20;
130 tdep->sigtramp_end = 0xbfbfdff0;
131
132 /* NetBSD has a `struct sigcontext' that's different from the
133 origional 4.3 BSD. */
134 tdep->sc_pc_offset = i386nbsd_sc_pc_offset;
135}
136
137/* NetBSD ELF. */
138static void
139i386nbsdelf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
140{
141 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
142
143 /* It's still NetBSD. */
144 i386nbsd_init_abi (info, gdbarch);
145
146 /* But ELF-based. */
147 i386_elf_init_abi (info, gdbarch);
148
9c5045b5
MK
149 /* NetBSD ELF uses SVR4-style shared libraries. */
150 set_gdbarch_in_solib_call_trampoline (gdbarch,
151 generic_in_solib_call_trampoline);
152
8201327c
MK
153 /* NetBSD ELF uses -fpcc-struct-return by default. */
154 tdep->struct_return = pcc_struct_return;
155
156 /* We support the SSE registers on NetBSD ELF. */
157 tdep->num_xmm_regs = I386_NUM_XREGS - 1;
158 set_gdbarch_num_regs (gdbarch, I386_NUM_GREGS + I386_NUM_FREGS
159 + I386_NUM_XREGS);
160}
161
162/* FreeBSD 3.0-RELEASE or later. */
163
164CORE_ADDR i386fbsd_sigtramp_start = 0xbfbfdf20;
165CORE_ADDR i386fbsd_sigtramp_end = 0xbfbfdff0;
166
167static void
168i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
169{
170 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
171
172 /* Obviously FreeBSD is BSD-based. */
173 i386bsd_init_abi (info, gdbarch);
174
175 /* FreeBSD uses -freg-struct-return by default. */
176 tdep->struct_return = reg_struct_return;
177
178 /* FreeBSD uses a different memory layout. */
179 tdep->sigtramp_start = i386fbsd_sigtramp_start;
180 tdep->sigtramp_end = i386fbsd_sigtramp_end;
181}
182
183static void
184i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
185{
186 /* It's almost identical to FreeBSD a.out. */
187 i386fbsdaout_init_abi (info, gdbarch);
188
189 /* Except that it uses ELF. */
190 i386_elf_init_abi (info, gdbarch);
9c5045b5
MK
191
192 /* FreeBSD ELF uses SVR4-style shared libraries. */
193 set_gdbarch_in_solib_call_trampoline (gdbarch,
194 generic_in_solib_call_trampoline);
8201327c
MK
195}
196
197/* FreeBSD 4.0-RELEASE or later. */
198
199/* From <machine/signal.h>. */
200int i386fbsd4_sc_pc_offset = 76;
201
202static void
203i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
204{
205 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
206
207 /* Inherit stuff from older releases. We assume that FreeBSD
208 4.0-RELEASE always uses ELF. */
209 i386fbsd_init_abi (info, gdbarch);
210
211 /* FreeBSD 4.0 introduced a new `struct sigcontext'. */
212 tdep->sc_pc_offset = i386fbsd4_sc_pc_offset;
213}
214
215\f
216static enum gdb_osabi
217i386bsd_aout_osabi_sniffer (bfd *abfd)
218{
219 if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0)
220 return GDB_OSABI_NETBSD_AOUT;
221
222 if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0)
223 return GDB_OSABI_FREEBSD_AOUT;
224
225 return GDB_OSABI_UNKNOWN;
226}
227
228\f
229/* Provide a prototype to silence -Wmissing-prototypes. */
230void _initialize_i386bsd_tdep (void);
231
232void
233_initialize_i386bsd_tdep (void)
234{
235 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
236 i386bsd_aout_osabi_sniffer);
237
238 gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_AOUT,
239 i386nbsd_init_abi);
240 gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_ELF,
241 i386nbsdelf_init_abi);
242 gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_FREEBSD_AOUT,
243 i386fbsdaout_init_abi);
244 gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_FREEBSD_ELF,
245 i386fbsd4_init_abi);
246}
This page took 0.110668 seconds and 4 git commands to generate.