]>
Commit | Line | Data |
---|---|---|
b7247919 | 1 | /* Target-dependent code for i386 BSD's. |
8a96bc77 | 2 | |
5d93ae8c | 3 | Copyright 2001, 2002, 2003, 2004 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 | |
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" | |
9c5045b5 | 23 | #include "arch-utils.h" |
b7247919 MK |
24 | #include "frame.h" |
25 | #include "gdbcore.h" | |
26 | #include "regcache.h" | |
4be87837 | 27 | #include "osabi.h" |
b7247919 | 28 | |
ca39387d MK |
29 | #include "gdb_string.h" |
30 | ||
8201327c | 31 | #include "i386-tdep.h" |
b7247919 | 32 | |
8201327c | 33 | /* Support for signal handlers. */ |
b7247919 MK |
34 | |
35 | /* Return whether PC is in a BSD sigtramp routine. */ | |
36 | ||
5d93ae8c | 37 | int |
8201327c | 38 | i386bsd_pc_in_sigtramp (CORE_ADDR pc, char *name) |
b7247919 | 39 | { |
8201327c | 40 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
b7247919 | 41 | |
8201327c MK |
42 | return (pc >= tdep->sigtramp_start && pc < tdep->sigtramp_end); |
43 | } | |
b7247919 | 44 | |
acd5c798 MK |
45 | /* Assuming NEXT_FRAME is for a frame following a BSD sigtramp |
46 | routine, return the address of the associated sigcontext structure. */ | |
b7247919 | 47 | |
acd5c798 MK |
48 | static CORE_ADDR |
49 | i386bsd_sigcontext_addr (struct frame_info *next_frame) | |
b7247919 | 50 | { |
acd5c798 MK |
51 | char buf[4]; |
52 | CORE_ADDR sp; | |
b4700d91 | 53 | |
c7f16359 | 54 | frame_unwind_register (next_frame, I386_ESP_REGNUM, buf); |
acd5c798 | 55 | sp = extract_unsigned_integer (buf, 4); |
b7247919 | 56 | |
acd5c798 | 57 | return read_memory_unsigned_integer (sp + 8, 4); |
b7247919 MK |
58 | } |
59 | ||
8201327c MK |
60 | /* Return the start address of the sigtramp routine. */ |
61 | ||
62 | CORE_ADDR | |
63 | i386bsd_sigtramp_start (CORE_ADDR pc) | |
64 | { | |
65 | return gdbarch_tdep (current_gdbarch)->sigtramp_start; | |
66 | } | |
67 | ||
68 | /* Return the end address of the sigtramp routine. */ | |
69 | ||
70 | CORE_ADDR | |
71 | i386bsd_sigtramp_end (CORE_ADDR pc) | |
72 | { | |
73 | return gdbarch_tdep (current_gdbarch)->sigtramp_end; | |
74 | } | |
75 | \f | |
76 | ||
9c5045b5 MK |
77 | /* Support for shared libraries. */ |
78 | ||
79 | /* Return non-zero if we are in a shared library trampoline code stub. */ | |
80 | ||
81 | int | |
82 | i386bsd_aout_in_solib_call_trampoline (CORE_ADDR pc, char *name) | |
83 | { | |
84 | return (name && !strcmp (name, "_DYNAMIC")); | |
85 | } | |
86 | ||
8201327c MK |
87 | /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */ |
88 | ||
89 | /* From <machine/signal.h>. */ | |
155c1d33 | 90 | int i386bsd_sc_reg_offset[] = |
a3386186 MK |
91 | { |
92 | -1, /* %eax */ | |
93 | -1, /* %ecx */ | |
94 | -1, /* %edx */ | |
95 | -1, /* %ebx */ | |
96 | 8 + 0 * 4, /* %esp */ | |
97 | 8 + 1 * 4, /* %ebp */ | |
98 | -1, /* %esi */ | |
99 | -1, /* %edi */ | |
100 | 8 + 3 * 4, /* %eip */ | |
101 | 8 + 4 * 4, /* %eflags */ | |
102 | -1, /* %cs */ | |
103 | -1, /* %ss */ | |
104 | -1, /* %ds */ | |
105 | -1, /* %es */ | |
106 | -1, /* %fs */ | |
107 | -1 /* %gs */ | |
108 | }; | |
8201327c | 109 | |
3cac699e | 110 | void |
8201327c MK |
111 | i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
112 | { | |
113 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
114 | ||
f561f026 | 115 | set_gdbarch_deprecated_pc_in_sigtramp (gdbarch, i386bsd_pc_in_sigtramp); |
8201327c | 116 | |
4b218c18 MK |
117 | /* Allow the recognition of sigtramps as a function named <sigtramp>. */ |
118 | set_gdbarch_sigtramp_start (gdbarch, i386bsd_sigtramp_start); | |
119 | set_gdbarch_sigtramp_end (gdbarch, i386bsd_sigtramp_end); | |
120 | ||
9c5045b5 MK |
121 | /* Assume SunOS-style shared libraries. */ |
122 | set_gdbarch_in_solib_call_trampoline (gdbarch, | |
123 | i386bsd_aout_in_solib_call_trampoline); | |
124 | ||
8201327c MK |
125 | tdep->jb_pc_offset = 0; |
126 | ||
8201327c MK |
127 | tdep->sigtramp_start = 0xfdbfdfc0; |
128 | tdep->sigtramp_end = 0xfdbfe000; | |
21d0e8a4 | 129 | tdep->sigcontext_addr = i386bsd_sigcontext_addr; |
a3386186 | 130 | tdep->sc_reg_offset = i386bsd_sc_reg_offset; |
155c1d33 | 131 | tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset); |
8201327c MK |
132 | } |
133 | ||
8201327c MK |
134 | \f |
135 | static enum gdb_osabi | |
136 | i386bsd_aout_osabi_sniffer (bfd *abfd) | |
137 | { | |
138 | if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0) | |
139 | return GDB_OSABI_NETBSD_AOUT; | |
140 | ||
141 | if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0) | |
142 | return GDB_OSABI_FREEBSD_AOUT; | |
143 | ||
144 | return GDB_OSABI_UNKNOWN; | |
145 | } | |
146 | ||
f6943e4a MK |
147 | static enum gdb_osabi |
148 | i386bsd_core_osabi_sniffer (bfd *abfd) | |
149 | { | |
150 | if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) | |
151 | return GDB_OSABI_NETBSD_AOUT; | |
152 | ||
153 | return GDB_OSABI_UNKNOWN; | |
154 | } | |
155 | ||
8201327c MK |
156 | \f |
157 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
158 | void _initialize_i386bsd_tdep (void); | |
159 | ||
160 | void | |
161 | _initialize_i386bsd_tdep (void) | |
162 | { | |
163 | gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour, | |
164 | i386bsd_aout_osabi_sniffer); | |
f6943e4a | 165 | |
8b0c3633 MK |
166 | /* BFD doesn't set a flavour for NetBSD style a.out core files. */ |
167 | gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour, | |
f6943e4a | 168 | i386bsd_core_osabi_sniffer); |
8201327c | 169 | } |