OLD | NEW |
1 /* Darwin support for GDB, the GNU debugger. | 1 /* Darwin support for GDB, the GNU debugger. |
2 Copyright 1997-2002, 2008-2012 Free Software Foundation, Inc. | 2 Copyright 1997-2002, 2008-2012 Free Software Foundation, Inc. |
3 | 3 |
4 Contributed by Apple Computer, Inc. | 4 Contributed by Apple Computer, Inc. |
5 | 5 |
6 This file is part of GDB. | 6 This file is part of GDB. |
7 | 7 |
8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "objfiles.h" | 27 #include "objfiles.h" |
28 #include "gdbcmd.h" | 28 #include "gdbcmd.h" |
29 #include "regcache.h" | 29 #include "regcache.h" |
30 #include "gdb_assert.h" | 30 #include "gdb_assert.h" |
31 #include "i386-tdep.h" | 31 #include "i386-tdep.h" |
32 #include "i387-tdep.h" | 32 #include "i387-tdep.h" |
33 #include "gdbarch.h" | 33 #include "gdbarch.h" |
34 #include "arch-utils.h" | 34 #include "arch-utils.h" |
35 #include "gdbcore.h" | 35 #include "gdbcore.h" |
36 | 36 |
| 37 #include "i386-nat.h" |
37 #include "darwin-nat.h" | 38 #include "darwin-nat.h" |
38 #include "i386-darwin-tdep.h" | 39 #include "i386-darwin-tdep.h" |
39 | 40 |
40 #ifdef BFD64 | 41 #ifdef BFD64 |
41 #include "amd64-nat.h" | 42 #include "amd64-nat.h" |
42 #include "amd64-tdep.h" | 43 #include "amd64-tdep.h" |
43 #include "amd64-darwin-tdep.h" | 44 #include "amd64-darwin-tdep.h" |
44 #endif | 45 #endif |
45 | 46 |
46 /* Read register values from the inferior process. | 47 /* Read register values from the inferior process. |
(...skipping 15 matching lines...) Expand all Loading... |
62 x86_thread_state_t gp_regs; | 63 x86_thread_state_t gp_regs; |
63 unsigned int gp_count = x86_THREAD_STATE_COUNT; | 64 unsigned int gp_count = x86_THREAD_STATE_COUNT; |
64 kern_return_t ret; | 65 kern_return_t ret; |
65 | 66 |
66 ret = thread_get_state | 67 ret = thread_get_state |
67 (current_thread, x86_THREAD_STATE, (thread_state_t) & gp_regs, | 68 (current_thread, x86_THREAD_STATE, (thread_state_t) & gp_regs, |
68 &gp_count); | 69 &gp_count); |
69 if (ret != KERN_SUCCESS) | 70 if (ret != KERN_SUCCESS) |
70 { | 71 { |
71 printf_unfiltered (_("Error calling thread_get_state for " | 72 printf_unfiltered (_("Error calling thread_get_state for " |
72 » » » » "GP registers for thread 0x%ulx"), | 73 » » » » "GP registers for thread 0x%lx\n"), |
73 » » » » current_thread); | 74 » » » » (unsigned long) current_thread); |
74 MACH_CHECK_ERROR (ret); | 75 MACH_CHECK_ERROR (ret); |
75 } | 76 } |
76 amd64_supply_native_gregset (regcache, &gp_regs.uts, -1); | 77 amd64_supply_native_gregset (regcache, &gp_regs.uts, -1); |
77 fetched++; | 78 fetched++; |
78 } | 79 } |
79 | 80 |
80 if (regno == -1 || !amd64_native_gregset_supplies_p (gdbarch, regno)) | 81 if (regno == -1 || !amd64_native_gregset_supplies_p (gdbarch, regno)) |
81 { | 82 { |
82 x86_float_state_t fp_regs; | 83 x86_float_state_t fp_regs; |
83 unsigned int fp_count = x86_FLOAT_STATE_COUNT; | 84 unsigned int fp_count = x86_FLOAT_STATE_COUNT; |
84 kern_return_t ret; | 85 kern_return_t ret; |
85 | 86 |
86 ret = thread_get_state | 87 ret = thread_get_state |
87 (current_thread, x86_FLOAT_STATE, (thread_state_t) & fp_regs, | 88 (current_thread, x86_FLOAT_STATE, (thread_state_t) & fp_regs, |
88 &fp_count); | 89 &fp_count); |
89 if (ret != KERN_SUCCESS) | 90 if (ret != KERN_SUCCESS) |
90 { | 91 { |
91 printf_unfiltered (_("Error calling thread_get_state for " | 92 printf_unfiltered (_("Error calling thread_get_state for " |
92 » » » » "float registers for thread 0x%ulx"), | 93 » » » » "float registers for thread 0x%lx\n"), |
93 » » » » current_thread); | 94 » » » » (unsigned long) current_thread); |
94 MACH_CHECK_ERROR (ret); | 95 MACH_CHECK_ERROR (ret); |
95 } | 96 } |
96 amd64_supply_fxsave (regcache, -1, &fp_regs.ufs.fs64.__fpu_fcw); | 97 amd64_supply_fxsave (regcache, -1, &fp_regs.ufs.fs64.__fpu_fcw); |
97 fetched++; | 98 fetched++; |
98 } | 99 } |
99 } | 100 } |
100 else | 101 else |
101 #endif | 102 #endif |
102 { | 103 { |
103 if (regno == -1 || regno < I386_NUM_GREGS) | 104 if (regno == -1 || regno < I386_NUM_GREGS) |
104 { | 105 { |
105 i386_thread_state_t gp_regs; | 106 x86_thread_state32_t gp_regs; |
106 unsigned int gp_count = i386_THREAD_STATE_COUNT; | 107 unsigned int gp_count = x86_THREAD_STATE32_COUNT; |
107 kern_return_t ret; | 108 kern_return_t ret; |
108 int i; | 109 int i; |
109 | 110 |
110 ret = thread_get_state | 111 ret = thread_get_state |
111 (current_thread, i386_THREAD_STATE, (thread_state_t) & gp_regs, | 112 (current_thread, x86_THREAD_STATE32, (thread_state_t) &gp_regs, |
112 &gp_count); | 113 &gp_count); |
113 if (ret != KERN_SUCCESS) | 114 if (ret != KERN_SUCCESS) |
114 { | 115 { |
115 printf_unfiltered (_("Error calling thread_get_state for " | 116 printf_unfiltered (_("Error calling thread_get_state for " |
116 » » » » "GP registers for thread 0x%ulx"), | 117 » » » » "GP registers for thread 0x%lx\n"), |
117 » » » » current_thread); | 118 » » » » (unsigned long) current_thread); |
118 MACH_CHECK_ERROR (ret); | 119 MACH_CHECK_ERROR (ret); |
119 } | 120 } |
120 for (i = 0; i < I386_NUM_GREGS; i++) | 121 for (i = 0; i < I386_NUM_GREGS; i++) |
121 regcache_raw_supply | 122 regcache_raw_supply |
122 (regcache, i, | 123 (regcache, i, |
123 (char *)&gp_regs + i386_darwin_thread_state_reg_offset[i]); | 124 (char *)&gp_regs + i386_darwin_thread_state_reg_offset[i]); |
124 | 125 |
125 fetched++; | 126 fetched++; |
126 } | 127 } |
127 | 128 |
128 if (regno == -1 | 129 if (regno == -1 |
129 || (regno >= I386_ST0_REGNUM && regno < I386_SSE_NUM_REGS)) | 130 || (regno >= I386_ST0_REGNUM && regno < I386_SSE_NUM_REGS)) |
130 { | 131 { |
131 i386_float_state_t fp_regs; | 132 x86_float_state32_t fp_regs; |
132 unsigned int fp_count = i386_FLOAT_STATE_COUNT; | 133 unsigned int fp_count = x86_FLOAT_STATE32_COUNT; |
133 kern_return_t ret; | 134 kern_return_t ret; |
134 | 135 |
135 ret = thread_get_state | 136 ret = thread_get_state |
136 (current_thread, i386_FLOAT_STATE, (thread_state_t) & fp_regs, | 137 (current_thread, x86_FLOAT_STATE32, (thread_state_t) &fp_regs, |
137 &fp_count); | 138 &fp_count); |
138 if (ret != KERN_SUCCESS) | 139 if (ret != KERN_SUCCESS) |
139 { | 140 { |
140 printf_unfiltered (_("Error calling thread_get_state for " | 141 printf_unfiltered (_("Error calling thread_get_state for " |
141 » » » » "float registers for thread 0x%ulx"), | 142 » » » » "float registers for thread 0x%lx\n"), |
142 » » » » current_thread); | 143 » » » » (unsigned long) current_thread); |
143 MACH_CHECK_ERROR (ret); | 144 MACH_CHECK_ERROR (ret); |
144 } | 145 } |
145 i387_supply_fxsave (regcache, -1, &fp_regs.__fpu_fcw); | 146 i387_supply_fxsave (regcache, -1, &fp_regs.__fpu_fcw); |
146 fetched++; | 147 fetched++; |
147 } | 148 } |
148 } | 149 } |
149 | 150 |
150 if (! fetched) | 151 if (! fetched) |
151 { | 152 { |
152 warning (_("unknown register %d"), regno); | 153 warning (_("unknown register %d"), regno); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 (thread_state_t) & fp_regs, | 209 (thread_state_t) & fp_regs, |
209 x86_FLOAT_STATE_COUNT); | 210 x86_FLOAT_STATE_COUNT); |
210 MACH_CHECK_ERROR (ret); | 211 MACH_CHECK_ERROR (ret); |
211 } | 212 } |
212 } | 213 } |
213 else | 214 else |
214 #endif | 215 #endif |
215 { | 216 { |
216 if (regno == -1 || regno < I386_NUM_GREGS) | 217 if (regno == -1 || regno < I386_NUM_GREGS) |
217 { | 218 { |
218 i386_thread_state_t gp_regs; | 219 x86_thread_state32_t gp_regs; |
219 kern_return_t ret; | 220 kern_return_t ret; |
220 unsigned int gp_count = i386_THREAD_STATE_COUNT; | 221 unsigned int gp_count = x86_THREAD_STATE32_COUNT; |
221 int i; | 222 int i; |
222 | 223 |
223 ret = thread_get_state | 224 ret = thread_get_state |
224 (current_thread, i386_THREAD_STATE, (thread_state_t) & gp_regs, | 225 (current_thread, x86_THREAD_STATE32, (thread_state_t) &gp_regs, |
225 &gp_count); | 226 &gp_count); |
226 MACH_CHECK_ERROR (ret); | 227 MACH_CHECK_ERROR (ret); |
227 | 228 |
228 for (i = 0; i < I386_NUM_GREGS; i++) | 229 for (i = 0; i < I386_NUM_GREGS; i++) |
229 if (regno == -1 || regno == i) | 230 if (regno == -1 || regno == i) |
230 regcache_raw_collect | 231 regcache_raw_collect |
231 (regcache, i, | 232 (regcache, i, |
232 (char *)&gp_regs + i386_darwin_thread_state_reg_offset[i]); | 233 (char *)&gp_regs + i386_darwin_thread_state_reg_offset[i]); |
233 | 234 |
234 ret = thread_set_state (current_thread, i386_THREAD_STATE, | 235 ret = thread_set_state (current_thread, x86_THREAD_STATE32, |
235 (thread_state_t) & gp_regs, | 236 (thread_state_t) &gp_regs, |
236 i386_THREAD_STATE_COUNT); | 237 x86_THREAD_STATE32_COUNT); |
237 MACH_CHECK_ERROR (ret); | 238 MACH_CHECK_ERROR (ret); |
238 } | 239 } |
239 | 240 |
240 if (regno == -1 | 241 if (regno == -1 |
241 || (regno >= I386_ST0_REGNUM && regno < I386_SSE_NUM_REGS)) | 242 || (regno >= I386_ST0_REGNUM && regno < I386_SSE_NUM_REGS)) |
242 { | 243 { |
243 i386_float_state_t fp_regs; | 244 x86_float_state32_t fp_regs; |
244 unsigned int fp_count = i386_FLOAT_STATE_COUNT; | 245 unsigned int fp_count = x86_FLOAT_STATE32_COUNT; |
245 kern_return_t ret; | 246 kern_return_t ret; |
246 | 247 |
247 ret = thread_get_state | 248 ret = thread_get_state |
248 (current_thread, i386_FLOAT_STATE, (thread_state_t) & fp_regs, | 249 (current_thread, x86_FLOAT_STATE32, (thread_state_t) & fp_regs, |
249 &fp_count); | 250 &fp_count); |
250 MACH_CHECK_ERROR (ret); | 251 MACH_CHECK_ERROR (ret); |
251 | 252 |
252 i387_collect_fxsave (regcache, regno, &fp_regs.__fpu_fcw); | 253 i387_collect_fxsave (regcache, regno, &fp_regs.__fpu_fcw); |
253 | 254 |
254 » ret = thread_set_state (current_thread, i386_FLOAT_STATE, | 255 » ret = thread_set_state (current_thread, x86_FLOAT_STATE32, |
255 » » » » (thread_state_t) & fp_regs, | 256 » » » » (thread_state_t) &fp_regs, |
256 » » » » i386_FLOAT_STATE_COUNT); | 257 » » » » x86_FLOAT_STATE32_COUNT); |
257 MACH_CHECK_ERROR (ret); | 258 MACH_CHECK_ERROR (ret); |
258 } | 259 } |
259 } | 260 } |
260 } | 261 } |
261 | 262 |
262 | 263 #ifdef HW_WATCHPOINT_NOT_YET_ENABLED |
263 /* Support for debug registers, boosted mostly from i386-linux-nat.c. */ | 264 /* Support for debug registers, boosted mostly from i386-linux-nat.c. */ |
264 | 265 |
265 #ifndef DR_FIRSTADDR | |
266 #define DR_FIRSTADDR 0 | |
267 #endif | |
268 | |
269 #ifndef DR_LASTADDR | |
270 #define DR_LASTADDR 3 | |
271 #endif | |
272 | |
273 #ifndef DR_STATUS | |
274 #define DR_STATUS 6 | |
275 #endif | |
276 | |
277 #ifndef DR_CONTROL | |
278 #define DR_CONTROL 7 | |
279 #endif | |
280 | |
281 | |
282 static void | 266 static void |
283 i386_darwin_dr_set (int regnum, uint32_t value) | 267 i386_darwin_dr_set (int regnum, uint32_t value) |
284 { | 268 { |
285 int current_pid; | 269 int current_pid; |
286 thread_t current_thread; | 270 thread_t current_thread; |
287 x86_debug_state_t dr_regs; | 271 x86_debug_state_t dr_regs; |
288 kern_return_t ret; | 272 kern_return_t ret; |
289 unsigned int dr_count = x86_DEBUG_STATE_COUNT; | 273 unsigned int dr_count = x86_DEBUG_STATE_COUNT; |
290 | 274 |
291 gdb_assert (regnum >= 0 && regnum <= DR_CONTROL); | 275 gdb_assert (regnum >= 0 && regnum <= DR_CONTROL); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 386 } |
403 | 387 |
404 void | 388 void |
405 i386_darwin_dr_set_addr (int regnum, CORE_ADDR addr) | 389 i386_darwin_dr_set_addr (int regnum, CORE_ADDR addr) |
406 { | 390 { |
407 gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); | 391 gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); |
408 | 392 |
409 i386_darwin_dr_set (DR_FIRSTADDR + regnum, addr); | 393 i386_darwin_dr_set (DR_FIRSTADDR + regnum, addr); |
410 } | 394 } |
411 | 395 |
412 void | 396 CORE_ADDR |
413 i386_darwin_dr_reset_addr (int regnum) | 397 i386_darwin_dr_get_addr (int regnum) |
414 { | 398 { |
415 gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); | 399 return i386_darwin_dr_get (regnum); |
416 | |
417 i386_darwin_dr_set (DR_FIRSTADDR + regnum, 0L); | |
418 } | 400 } |
419 | 401 |
420 unsigned long | 402 unsigned long |
421 i386_darwin_dr_get_status (void) | 403 i386_darwin_dr_get_status (void) |
422 { | 404 { |
423 return i386_darwin_dr_get (DR_STATUS); | 405 return i386_darwin_dr_get (DR_STATUS); |
424 } | 406 } |
425 | 407 |
| 408 unsigned long |
| 409 i386_darwin_dr_get_control (void) |
| 410 { |
| 411 return i386_darwin_dr_get (DR_CONTROL); |
| 412 } |
| 413 #endif |
| 414 |
426 void | 415 void |
427 darwin_check_osabi (darwin_inferior *inf, thread_t thread) | 416 darwin_check_osabi (darwin_inferior *inf, thread_t thread) |
428 { | 417 { |
429 if (gdbarch_osabi (target_gdbarch) == GDB_OSABI_UNKNOWN) | 418 if (gdbarch_osabi (target_gdbarch) == GDB_OSABI_UNKNOWN) |
430 { | 419 { |
431 /* Attaching to a process. Let's figure out what kind it is. */ | 420 /* Attaching to a process. Let's figure out what kind it is. */ |
432 x86_thread_state_t gp_regs; | 421 x86_thread_state_t gp_regs; |
433 struct gdbarch_info info; | 422 struct gdbarch_info info; |
434 unsigned int gp_count = x86_THREAD_STATE_COUNT; | 423 unsigned int gp_count = x86_THREAD_STATE_COUNT; |
435 kern_return_t ret; | 424 kern_return_t ret; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 #ifdef BFD64 | 579 #ifdef BFD64 |
591 amd64_native_gregset64_reg_offset = amd64_darwin_thread_state_reg_offset; | 580 amd64_native_gregset64_reg_offset = amd64_darwin_thread_state_reg_offset; |
592 amd64_native_gregset64_num_regs = amd64_darwin_thread_state_num_regs; | 581 amd64_native_gregset64_num_regs = amd64_darwin_thread_state_num_regs; |
593 amd64_native_gregset32_reg_offset = i386_darwin_thread_state_reg_offset; | 582 amd64_native_gregset32_reg_offset = i386_darwin_thread_state_reg_offset; |
594 amd64_native_gregset32_num_regs = i386_darwin_thread_state_num_regs; | 583 amd64_native_gregset32_num_regs = i386_darwin_thread_state_num_regs; |
595 #endif | 584 #endif |
596 | 585 |
597 target->to_fetch_registers = i386_darwin_fetch_inferior_registers; | 586 target->to_fetch_registers = i386_darwin_fetch_inferior_registers; |
598 target->to_store_registers = i386_darwin_store_inferior_registers; | 587 target->to_store_registers = i386_darwin_store_inferior_registers; |
599 } | 588 } |
OLD | NEW |