Commit | Line | Data |
---|---|---|
b7247919 | 1 | /* Target-dependent code for i386 BSD's. |
8a96bc77 | 2 | |
28e7fd62 | 3 | Copyright (C) 2001-2013 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 | |
10458914 DJ |
33 | /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the |
34 | address of the associated sigcontext structure. */ | |
b7247919 | 35 | |
acd5c798 | 36 | static CORE_ADDR |
10458914 | 37 | i386bsd_sigcontext_addr (struct frame_info *this_frame) |
b7247919 | 38 | { |
e17a4113 UW |
39 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
40 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
63c0089f | 41 | gdb_byte buf[4]; |
acd5c798 | 42 | CORE_ADDR sp; |
b4700d91 | 43 | |
10458914 | 44 | get_frame_register (this_frame, I386_ESP_REGNUM, buf); |
e17a4113 | 45 | sp = extract_unsigned_integer (buf, 4, byte_order); |
b7247919 | 46 | |
e17a4113 | 47 | return read_memory_unsigned_integer (sp + 8, 4, byte_order); |
b7247919 | 48 | } |
8201327c MK |
49 | \f |
50 | ||
9c5045b5 MK |
51 | /* Support for shared libraries. */ |
52 | ||
8201327c MK |
53 | /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */ |
54 | ||
55 | /* From <machine/signal.h>. */ | |
155c1d33 | 56 | int i386bsd_sc_reg_offset[] = |
a3386186 MK |
57 | { |
58 | -1, /* %eax */ | |
59 | -1, /* %ecx */ | |
60 | -1, /* %edx */ | |
61 | -1, /* %ebx */ | |
62 | 8 + 0 * 4, /* %esp */ | |
63 | 8 + 1 * 4, /* %ebp */ | |
64 | -1, /* %esi */ | |
65 | -1, /* %edi */ | |
66 | 8 + 3 * 4, /* %eip */ | |
67 | 8 + 4 * 4, /* %eflags */ | |
68 | -1, /* %cs */ | |
69 | -1, /* %ss */ | |
70 | -1, /* %ds */ | |
71 | -1, /* %es */ | |
72 | -1, /* %fs */ | |
73 | -1 /* %gs */ | |
74 | }; | |
8201327c | 75 | |
3cac699e | 76 | void |
8201327c MK |
77 | i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
78 | { | |
79 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
80 | ||
8201327c MK |
81 | tdep->jb_pc_offset = 0; |
82 | ||
8201327c MK |
83 | tdep->sigtramp_start = 0xfdbfdfc0; |
84 | tdep->sigtramp_end = 0xfdbfe000; | |
21d0e8a4 | 85 | tdep->sigcontext_addr = i386bsd_sigcontext_addr; |
a3386186 | 86 | tdep->sc_reg_offset = i386bsd_sc_reg_offset; |
155c1d33 | 87 | tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset); |
8201327c MK |
88 | } |
89 | ||
8201327c MK |
90 | \f |
91 | static enum gdb_osabi | |
92 | i386bsd_aout_osabi_sniffer (bfd *abfd) | |
93 | { | |
94 | if (strcmp (bfd_get_target (abfd), "a.out-i386-netbsd") == 0) | |
95 | return GDB_OSABI_NETBSD_AOUT; | |
96 | ||
97 | if (strcmp (bfd_get_target (abfd), "a.out-i386-freebsd") == 0) | |
98 | return GDB_OSABI_FREEBSD_AOUT; | |
99 | ||
100 | return GDB_OSABI_UNKNOWN; | |
101 | } | |
102 | ||
f6943e4a MK |
103 | static enum gdb_osabi |
104 | i386bsd_core_osabi_sniffer (bfd *abfd) | |
105 | { | |
106 | if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) | |
107 | return GDB_OSABI_NETBSD_AOUT; | |
108 | ||
109 | return GDB_OSABI_UNKNOWN; | |
110 | } | |
111 | ||
8201327c MK |
112 | \f |
113 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
114 | void _initialize_i386bsd_tdep (void); | |
115 | ||
116 | void | |
117 | _initialize_i386bsd_tdep (void) | |
118 | { | |
119 | gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour, | |
120 | i386bsd_aout_osabi_sniffer); | |
f6943e4a | 121 | |
8b0c3633 MK |
122 | /* BFD doesn't set a flavour for NetBSD style a.out core files. */ |
123 | gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_unknown_flavour, | |
f6943e4a | 124 | i386bsd_core_osabi_sniffer); |
8201327c | 125 | } |