2003-11-22 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / i386fbsd-tdep.c
CommitLineData
8a96bc77
MK
1/* Target-dependent code for FreeBSD/i386.
2
3 Copyright 2003 Free Software Foundation, Inc.
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
9 the Free Software Foundation; either version 2 of the License, or
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
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. */
21
22#include "defs.h"
23#include "arch-utils.h"
24#include "osabi.h"
25
26#include "i386-tdep.h"
27#include "i387-tdep.h"
28
29/* FreeBSD 3.0-RELEASE or later. */
30
31/* From <machine/reg.h>. */
32static int i386fbsd_r_reg_offset[] =
33{
34 9 * 4, 8 * 4, 7 * 4, 6 * 4, /* %eax, %ecx, %edx, %ebx */
35 15 * 4, 4 * 4, /* %esp, %ebp */
36 3 * 4, 2 * 4, /* %esi, %edi */
37 12 * 4, 14 * 4, /* %eip, %eflags */
38 13 * 4, 16 * 4, /* %cs, %ss */
39 1 * 4, 0 * 4, -1, -1 /* %ds, %es, %fs, %gs */
40};
41
42CORE_ADDR i386fbsd_sigtramp_start = 0xbfbfdf20;
43CORE_ADDR i386fbsd_sigtramp_end = 0xbfbfdff0;
44
45/* From <machine/signal.h>. */
46static int i386fbsd_sc_reg_offset[] =
47{
48 8 + 14 * 4, /* %eax */
49 8 + 13 * 4, /* %ecx */
50 8 + 12 * 4, /* %edx */
51 8 + 11 * 4, /* %ebx */
52 8 + 0 * 4, /* %esp */
53 8 + 1 * 4, /* %ebp */
54 8 + 10 * 4, /* %esi */
55 8 + 9 * 4, /* %edi */
56 8 + 3 * 4, /* %eip */
57 8 + 4 * 4, /* %eflags */
58 8 + 7 * 4, /* %cs */
59 8 + 8 * 4, /* %ss */
60 8 + 6 * 4, /* %ds */
61 8 + 5 * 4, /* %es */
62 8 + 15 * 4, /* %fs */
63 8 + 16 * 4 /* %gs */
64};
65
66static void
67i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
68{
69 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
70
71 /* Obviously FreeBSD is BSD-based. */
72 i386bsd_init_abi (info, gdbarch);
73
74 /* FreeBSD has a different `struct reg', and reserves some space for
75 its FPU emulator in `struct fpreg'. */
76 tdep->gregset_reg_offset = i386fbsd_r_reg_offset;
77 tdep->gregset_num_regs = ARRAY_SIZE (i386fbsd_r_reg_offset);
78 tdep->sizeof_gregset = 18 * 4;
79 tdep->sizeof_fpregset = 176;
80
81 /* FreeBSD uses -freg-struct-return by default. */
82 tdep->struct_return = reg_struct_return;
83
84 /* FreeBSD uses a different memory layout. */
85 tdep->sigtramp_start = i386fbsd_sigtramp_start;
86 tdep->sigtramp_end = i386fbsd_sigtramp_end;
87
88 /* FreeBSD has a more complete `struct sigcontext'. */
89 tdep->sc_reg_offset = i386fbsd_sc_reg_offset;
90 tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset);
91}
92
93static void
94i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
95{
96 /* It's almost identical to FreeBSD a.out. */
97 i386fbsdaout_init_abi (info, gdbarch);
98
99 /* Except that it uses ELF. */
100 i386_elf_init_abi (info, gdbarch);
101
102 /* FreeBSD ELF uses SVR4-style shared libraries. */
103 set_gdbarch_in_solib_call_trampoline (gdbarch,
104 generic_in_solib_call_trampoline);
105}
106
107/* FreeBSD 4.0-RELEASE or later. */
108
109/* From <machine/reg.h>. */
110static int i386fbsd4_r_reg_offset[] =
111{
112 10 * 4, 9 * 4, 8 * 4, 7 * 4, /* %eax, %ecx, %edx, %ebx */
113 16 * 4, 5 * 4, /* %esp, %ebp */
114 4 * 4, 3 * 4, /* %esi, %edi */
115 13 * 4, 15 * 4, /* %eip, %eflags */
116 14 * 4, 17 * 4, /* %cs, %ss */
117 2 * 4, 1 * 4, 0 * 4, 18 * 4 /* %ds, %es, %fs, %gs */
118};
119
120/* From <machine/signal.h>. */
121int i386fbsd4_sc_reg_offset[] =
122{
123 20 + 11 * 4, /* %eax */
124 20 + 10 * 4, /* %ecx */
125 20 + 9 * 4, /* %edx */
126 20 + 8 * 4, /* %ebx */
127 20 + 17 * 4, /* %esp */
128 20 + 6 * 4, /* %ebp */
129 20 + 5 * 4, /* %esi */
130 20 + 4 * 4, /* %edi */
131 20 + 14 * 4, /* %eip */
132 20 + 16 * 4, /* %eflags */
133 20 + 15 * 4, /* %cs */
134 20 + 18 * 4, /* %ss */
135 20 + 3 * 4, /* %ds */
136 20 + 2 * 4, /* %es */
137 20 + 1 * 4, /* %fs */
138 20 + 0 * 4 /* %gs */
139};
140
141static void
142i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
143{
144 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
145
146 /* Inherit stuff from older releases. We assume that FreeBSD
147 4.0-RELEASE always uses ELF. */
148 i386fbsd_init_abi (info, gdbarch);
149
150 /* FreeBSD 4.0 introduced a new `struct reg'. */
151 tdep->gregset_reg_offset = i386fbsd4_r_reg_offset;
152 tdep->gregset_num_regs = ARRAY_SIZE (i386fbsd4_r_reg_offset);
153 tdep->sizeof_gregset = 19 * 4;
154
155 /* FreeBSD 4.0 introduced a new `struct sigcontext'. */
156 tdep->sc_reg_offset = i386fbsd4_sc_reg_offset;
157 tdep->sc_num_regs = ARRAY_SIZE (i386fbsd4_sc_reg_offset);
158}
159
160\f
161/* Provide a prototype to silence -Wmissing-prototypes. */
162void _initialize_i386fbsd_tdep (void);
163
164void
165_initialize_i386fbsd_tdep (void)
166{
167 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_AOUT,
168 i386fbsdaout_init_abi);
169 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_ELF,
170 i386fbsd4_init_abi);
171}
This page took 0.037087 seconds and 4 git commands to generate.