]>
Commit | Line | Data |
---|---|---|
a80b95ba TG |
1 | /* Darwin support for GDB, the GNU debugger. |
2 | Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2008 | |
3 | Free Software Foundation, Inc. | |
4 | ||
5 | Contributed by Apple Computer, Inc. | |
6 | ||
7 | This file is part of GDB. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 3 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "frame.h" | |
24 | #include "inferior.h" | |
25 | #include "gdbcore.h" | |
26 | #include "target.h" | |
27 | #include "floatformat.h" | |
28 | #include "symtab.h" | |
29 | #include "regcache.h" | |
30 | #include "libbfd.h" | |
31 | #include "objfiles.h" | |
32 | ||
33 | #include "i387-tdep.h" | |
34 | #include "i386-tdep.h" | |
35 | #include "amd64-tdep.h" | |
36 | #include "osabi.h" | |
37 | #include "ui-out.h" | |
38 | #include "symtab.h" | |
39 | #include "frame.h" | |
40 | #include "gdb_assert.h" | |
41 | #include "i386-darwin-tdep.h" | |
42 | ||
43 | /* Offsets into the struct i386_thread_state where we'll find the saved regs. | |
44 | From <mach/i386/thread_status.h> and i386-tdep.h. */ | |
45 | int i386_darwin_thread_state_reg_offset[] = | |
46 | { | |
47 | 0 * 4, /* EAX */ | |
48 | 2 * 4, /* ECX */ | |
49 | 3 * 4, /* EDX */ | |
50 | 1 * 4, /* EBX */ | |
51 | 7 * 4, /* ESP */ | |
52 | 6 * 4, /* EBP */ | |
53 | 5 * 4, /* ESI */ | |
54 | 4 * 4, /* EDI */ | |
55 | 10 * 4, /* EIP */ | |
56 | 9 * 4, /* EFLAGS */ | |
57 | 11 * 4, /* CS */ | |
58 | 8, /* SS */ | |
59 | 12 * 4, /* DS */ | |
60 | 13 * 4, /* ES */ | |
61 | 14 * 4, /* FS */ | |
62 | 15 * 4 /* GS */ | |
63 | }; | |
64 | ||
65 | const int i386_darwin_thread_state_num_regs = | |
66 | ARRAY_SIZE (i386_darwin_thread_state_reg_offset); | |
67 | ||
68 | /* Offsets into the struct x86_thread_state64 where we'll find the saved regs. | |
69 | From <mach/i386/thread_status.h> and amd64-tdep.h. */ | |
70 | int amd64_darwin_thread_state_reg_offset[] = | |
71 | { | |
72 | 0 * 8, /* %rax */ | |
73 | 1 * 8, /* %rbx */ | |
74 | 2 * 8, /* %rcx */ | |
75 | 3 * 8, /* %rdx */ | |
76 | 5 * 8, /* %rsi */ | |
77 | 4 * 8, /* %rdi */ | |
78 | 6 * 8, /* %rbp */ | |
79 | 7 * 8, /* %rsp */ | |
80 | 8 * 8, /* %r8 ... */ | |
81 | 9 * 8, | |
82 | 10 * 8, | |
83 | 11 * 8, | |
84 | 12 * 8, | |
85 | 13 * 8, | |
86 | 14 * 8, | |
87 | 15 * 8, /* ... %r15 */ | |
88 | 16 * 8, /* %rip */ | |
89 | 17 * 8, /* %rflags */ | |
90 | 18 * 8, /* %cs */ | |
91 | -1, /* %ss */ | |
92 | -1, /* %ds */ | |
93 | -1, /* %es */ | |
94 | 19 * 8, /* %fs */ | |
95 | 20 * 8 /* %gs */ | |
96 | }; | |
97 | ||
98 | const int amd64_darwin_thread_state_num_regs = | |
99 | ARRAY_SIZE (amd64_darwin_thread_state_reg_offset); | |
100 | ||
101 | static void | |
102 | i386_darwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
103 | { | |
104 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
105 | ||
106 | /* We support the SSE registers. */ | |
107 | tdep->num_xmm_regs = I386_NUM_XREGS - 1; | |
108 | set_gdbarch_num_regs (gdbarch, I386_SSE_NUM_REGS); | |
109 | ||
110 | tdep->struct_return = reg_struct_return; | |
111 | ||
112 | tdep->sigcontext_addr = NULL; | |
113 | tdep->sc_reg_offset = i386_darwin_thread_state_reg_offset; | |
114 | tdep->sc_num_regs = 16; | |
115 | ||
116 | tdep->jb_pc_offset = 20; | |
117 | } | |
118 | ||
119 | static void | |
120 | x86_darwin_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch) | |
121 | { | |
122 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
123 | ||
124 | amd64_init_abi (info, gdbarch); | |
125 | ||
126 | tdep->struct_return = reg_struct_return; | |
127 | ||
128 | /* We don't do signals yet. */ | |
129 | tdep->sigcontext_addr = NULL; | |
130 | tdep->sc_reg_offset = amd64_darwin_thread_state_reg_offset; | |
131 | tdep->sc_num_regs = ARRAY_SIZE (amd64_darwin_thread_state_reg_offset); | |
132 | ||
133 | tdep->jb_pc_offset = 148; | |
134 | } | |
135 | ||
136 | static enum gdb_osabi | |
137 | i386_mach_o_osabi_sniffer (bfd *abfd) | |
138 | { | |
139 | if (!bfd_check_format (abfd, bfd_object)) | |
140 | return GDB_OSABI_UNKNOWN; | |
141 | ||
142 | if (bfd_get_arch (abfd) == bfd_arch_i386) | |
143 | return GDB_OSABI_DARWIN; | |
144 | ||
145 | return GDB_OSABI_UNKNOWN; | |
146 | } | |
147 | ||
148 | void | |
149 | _initialize_i386_darwin_tdep (void) | |
150 | { | |
151 | gdbarch_register_osabi_sniffer (bfd_arch_unknown, bfd_target_mach_o_flavour, | |
152 | i386_mach_o_osabi_sniffer); | |
153 | ||
154 | gdbarch_register_osabi (bfd_arch_i386, bfd_mach_i386_i386, | |
155 | GDB_OSABI_DARWIN, i386_darwin_init_abi); | |
156 | ||
157 | gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, | |
158 | GDB_OSABI_DARWIN, x86_darwin_init_abi_64); | |
159 | } |