Commit | Line | Data |
---|---|---|
c877c8e6 | 1 | /* Target-dependent code for GDB, the GNU debugger. |
4e052eda | 2 | |
28e7fd62 | 3 | Copyright (C) 1986-2013 Free Software Foundation, Inc. |
c877c8e6 KB |
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 |
c877c8e6 KB |
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/>. */ |
c877c8e6 KB |
19 | |
20 | #include "defs.h" | |
21 | #include "frame.h" | |
22 | #include "inferior.h" | |
23 | #include "symtab.h" | |
24 | #include "target.h" | |
25 | #include "gdbcore.h" | |
26 | #include "gdbcmd.h" | |
27 | #include "symfile.h" | |
28 | #include "objfiles.h" | |
4e052eda | 29 | #include "regcache.h" |
fd0407d6 | 30 | #include "value.h" |
4be87837 | 31 | #include "osabi.h" |
f9be684a | 32 | #include "regset.h" |
6ded7999 | 33 | #include "solib-svr4.h" |
85e747d2 | 34 | #include "solib-spu.h" |
cc5f0d61 UW |
35 | #include "solib.h" |
36 | #include "solist.h" | |
9aa1e687 | 37 | #include "ppc-tdep.h" |
d78489bf | 38 | #include "ppc64-tdep.h" |
7284e1be | 39 | #include "ppc-linux-tdep.h" |
5d853008 | 40 | #include "glibc-tdep.h" |
61a65099 KB |
41 | #include "trad-frame.h" |
42 | #include "frame-unwind.h" | |
a8f60bfc | 43 | #include "tramp-frame.h" |
85e747d2 UW |
44 | #include "observer.h" |
45 | #include "auxv.h" | |
46 | #include "elf/common.h" | |
cc5f0d61 UW |
47 | #include "exceptions.h" |
48 | #include "arch-utils.h" | |
49 | #include "spu-tdep.h" | |
a96d9b2e | 50 | #include "xml-syscall.h" |
a5ee0f0c | 51 | #include "linux-tdep.h" |
9aa1e687 | 52 | |
55aa24fb SDJ |
53 | #include "stap-probe.h" |
54 | #include "ax.h" | |
55 | #include "ax-gdb.h" | |
56 | #include "cli/cli-utils.h" | |
57 | #include "parser-defs.h" | |
58 | #include "user-regs.h" | |
59 | #include <ctype.h> | |
b3ac9c77 | 60 | #include "elf-bfd.h" /* for elfcore_write_* */ |
55aa24fb | 61 | |
7284e1be UW |
62 | #include "features/rs6000/powerpc-32l.c" |
63 | #include "features/rs6000/powerpc-altivec32l.c" | |
f4d9bade | 64 | #include "features/rs6000/powerpc-cell32l.c" |
604c2f83 | 65 | #include "features/rs6000/powerpc-vsx32l.c" |
69abc51c TJB |
66 | #include "features/rs6000/powerpc-isa205-32l.c" |
67 | #include "features/rs6000/powerpc-isa205-altivec32l.c" | |
68 | #include "features/rs6000/powerpc-isa205-vsx32l.c" | |
7284e1be UW |
69 | #include "features/rs6000/powerpc-64l.c" |
70 | #include "features/rs6000/powerpc-altivec64l.c" | |
f4d9bade | 71 | #include "features/rs6000/powerpc-cell64l.c" |
604c2f83 | 72 | #include "features/rs6000/powerpc-vsx64l.c" |
69abc51c TJB |
73 | #include "features/rs6000/powerpc-isa205-64l.c" |
74 | #include "features/rs6000/powerpc-isa205-altivec64l.c" | |
75 | #include "features/rs6000/powerpc-isa205-vsx64l.c" | |
7284e1be UW |
76 | #include "features/rs6000/powerpc-e500l.c" |
77 | ||
5d853008 ME |
78 | /* Shared library operations for PowerPC-Linux. */ |
79 | static struct target_so_ops powerpc_so_ops; | |
80 | ||
a96d9b2e SDJ |
81 | /* The syscall's XML filename for PPC and PPC64. */ |
82 | #define XML_SYSCALL_FILENAME_PPC "syscalls/ppc-linux.xml" | |
83 | #define XML_SYSCALL_FILENAME_PPC64 "syscalls/ppc64-linux.xml" | |
c877c8e6 | 84 | |
122a33de KB |
85 | /* ppc_linux_memory_remove_breakpoints attempts to remove a breakpoint |
86 | in much the same fashion as memory_remove_breakpoint in mem-break.c, | |
87 | but is careful not to write back the previous contents if the code | |
88 | in question has changed in between inserting the breakpoint and | |
89 | removing it. | |
90 | ||
91 | Here is the problem that we're trying to solve... | |
92 | ||
93 | Once upon a time, before introducing this function to remove | |
94 | breakpoints from the inferior, setting a breakpoint on a shared | |
95 | library function prior to running the program would not work | |
96 | properly. In order to understand the problem, it is first | |
97 | necessary to understand a little bit about dynamic linking on | |
98 | this platform. | |
99 | ||
100 | A call to a shared library function is accomplished via a bl | |
101 | (branch-and-link) instruction whose branch target is an entry | |
102 | in the procedure linkage table (PLT). The PLT in the object | |
103 | file is uninitialized. To gdb, prior to running the program, the | |
104 | entries in the PLT are all zeros. | |
105 | ||
106 | Once the program starts running, the shared libraries are loaded | |
107 | and the procedure linkage table is initialized, but the entries in | |
108 | the table are not (necessarily) resolved. Once a function is | |
109 | actually called, the code in the PLT is hit and the function is | |
110 | resolved. In order to better illustrate this, an example is in | |
111 | order; the following example is from the gdb testsuite. | |
112 | ||
113 | We start the program shmain. | |
114 | ||
115 | [kev@arroyo testsuite]$ ../gdb gdb.base/shmain | |
116 | [...] | |
117 | ||
118 | We place two breakpoints, one on shr1 and the other on main. | |
119 | ||
120 | (gdb) b shr1 | |
121 | Breakpoint 1 at 0x100409d4 | |
122 | (gdb) b main | |
123 | Breakpoint 2 at 0x100006a0: file gdb.base/shmain.c, line 44. | |
124 | ||
125 | Examine the instruction (and the immediatly following instruction) | |
126 | upon which the breakpoint was placed. Note that the PLT entry | |
127 | for shr1 contains zeros. | |
128 | ||
129 | (gdb) x/2i 0x100409d4 | |
130 | 0x100409d4 <shr1>: .long 0x0 | |
131 | 0x100409d8 <shr1+4>: .long 0x0 | |
132 | ||
133 | Now run 'til main. | |
134 | ||
135 | (gdb) r | |
136 | Starting program: gdb.base/shmain | |
137 | Breakpoint 1 at 0xffaf790: file gdb.base/shr1.c, line 19. | |
138 | ||
139 | Breakpoint 2, main () | |
140 | at gdb.base/shmain.c:44 | |
141 | 44 g = 1; | |
142 | ||
143 | Examine the PLT again. Note that the loading of the shared | |
144 | library has initialized the PLT to code which loads a constant | |
145 | (which I think is an index into the GOT) into r11 and then | |
146 | branchs a short distance to the code which actually does the | |
147 | resolving. | |
148 | ||
149 | (gdb) x/2i 0x100409d4 | |
150 | 0x100409d4 <shr1>: li r11,4 | |
151 | 0x100409d8 <shr1+4>: b 0x10040984 <sg+4> | |
152 | (gdb) c | |
153 | Continuing. | |
154 | ||
155 | Breakpoint 1, shr1 (x=1) | |
156 | at gdb.base/shr1.c:19 | |
157 | 19 l = 1; | |
158 | ||
159 | Now we've hit the breakpoint at shr1. (The breakpoint was | |
160 | reset from the PLT entry to the actual shr1 function after the | |
161 | shared library was loaded.) Note that the PLT entry has been | |
0df8b418 | 162 | resolved to contain a branch that takes us directly to shr1. |
122a33de KB |
163 | (The real one, not the PLT entry.) |
164 | ||
165 | (gdb) x/2i 0x100409d4 | |
166 | 0x100409d4 <shr1>: b 0xffaf76c <shr1> | |
167 | 0x100409d8 <shr1+4>: b 0x10040984 <sg+4> | |
168 | ||
169 | The thing to note here is that the PLT entry for shr1 has been | |
170 | changed twice. | |
171 | ||
172 | Now the problem should be obvious. GDB places a breakpoint (a | |
0df8b418 | 173 | trap instruction) on the zero value of the PLT entry for shr1. |
122a33de KB |
174 | Later on, after the shared library had been loaded and the PLT |
175 | initialized, GDB gets a signal indicating this fact and attempts | |
176 | (as it always does when it stops) to remove all the breakpoints. | |
177 | ||
178 | The breakpoint removal was causing the former contents (a zero | |
179 | word) to be written back to the now initialized PLT entry thus | |
180 | destroying a portion of the initialization that had occurred only a | |
181 | short time ago. When execution continued, the zero word would be | |
766062f6 | 182 | executed as an instruction an illegal instruction trap was |
122a33de KB |
183 | generated instead. (0 is not a legal instruction.) |
184 | ||
185 | The fix for this problem was fairly straightforward. The function | |
186 | memory_remove_breakpoint from mem-break.c was copied to this file, | |
187 | modified slightly, and renamed to ppc_linux_memory_remove_breakpoint. | |
188 | In tm-linux.h, MEMORY_REMOVE_BREAKPOINT is defined to call this new | |
189 | function. | |
190 | ||
191 | The differences between ppc_linux_memory_remove_breakpoint () and | |
192 | memory_remove_breakpoint () are minor. All that the former does | |
193 | that the latter does not is check to make sure that the breakpoint | |
194 | location actually contains a breakpoint (trap instruction) prior | |
195 | to attempting to write back the old contents. If it does contain | |
0df8b418 | 196 | a trap instruction, we allow the old contents to be written back. |
122a33de KB |
197 | Otherwise, we silently do nothing. |
198 | ||
199 | The big question is whether memory_remove_breakpoint () should be | |
200 | changed to have the same functionality. The downside is that more | |
201 | traffic is generated for remote targets since we'll have an extra | |
202 | fetch of a memory word each time a breakpoint is removed. | |
203 | ||
204 | For the time being, we'll leave this self-modifying-code-friendly | |
205 | version in ppc-linux-tdep.c, but it ought to be migrated somewhere | |
206 | else in the event that some other platform has similar needs with | |
207 | regard to removing breakpoints in some potentially self modifying | |
208 | code. */ | |
63807e1d | 209 | static int |
ae4b2284 MD |
210 | ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, |
211 | struct bp_target_info *bp_tgt) | |
482ca3f5 | 212 | { |
8181d85f | 213 | CORE_ADDR addr = bp_tgt->placed_address; |
f4f9705a | 214 | const unsigned char *bp; |
482ca3f5 KB |
215 | int val; |
216 | int bplen; | |
50fd1280 | 217 | gdb_byte old_contents[BREAKPOINT_MAX]; |
8defab1a | 218 | struct cleanup *cleanup; |
482ca3f5 KB |
219 | |
220 | /* Determine appropriate breakpoint contents and size for this address. */ | |
ae4b2284 | 221 | bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen); |
482ca3f5 | 222 | if (bp == NULL) |
8a3fe4f8 | 223 | error (_("Software breakpoints not implemented for this target.")); |
482ca3f5 | 224 | |
8defab1a DJ |
225 | /* Make sure we see the memory breakpoints. */ |
226 | cleanup = make_show_memory_breakpoints_cleanup (1); | |
482ca3f5 KB |
227 | val = target_read_memory (addr, old_contents, bplen); |
228 | ||
229 | /* If our breakpoint is no longer at the address, this means that the | |
230 | program modified the code on us, so it is wrong to put back the | |
0df8b418 | 231 | old value. */ |
482ca3f5 | 232 | if (val == 0 && memcmp (bp, old_contents, bplen) == 0) |
dd110abf | 233 | val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen); |
482ca3f5 | 234 | |
8defab1a | 235 | do_cleanups (cleanup); |
482ca3f5 KB |
236 | return val; |
237 | } | |
6ded7999 | 238 | |
b9ff3018 AC |
239 | /* For historic reasons, PPC 32 GNU/Linux follows PowerOpen rather |
240 | than the 32 bit SYSV R4 ABI structure return convention - all | |
241 | structures, no matter their size, are put in memory. Vectors, | |
242 | which were added later, do get returned in a register though. */ | |
243 | ||
05580c65 | 244 | static enum return_value_convention |
6a3a010b | 245 | ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function, |
c055b101 CV |
246 | struct type *valtype, struct regcache *regcache, |
247 | gdb_byte *readbuf, const gdb_byte *writebuf) | |
b9ff3018 | 248 | { |
05580c65 AC |
249 | if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT |
250 | || TYPE_CODE (valtype) == TYPE_CODE_UNION) | |
251 | && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8) | |
252 | && TYPE_VECTOR (valtype))) | |
253 | return RETURN_VALUE_STRUCT_CONVENTION; | |
254 | else | |
6a3a010b | 255 | return ppc_sysv_abi_return_value (gdbarch, function, valtype, regcache, |
c055b101 | 256 | readbuf, writebuf); |
b9ff3018 AC |
257 | } |
258 | ||
6207416c | 259 | static struct core_regset_section ppc_linux_vsx_regset_sections[] = |
17ea7499 | 260 | { |
2f2241f1 | 261 | { ".reg", 48 * 4, "general-purpose" }, |
1b1818e4 UW |
262 | { ".reg2", 264, "floating-point" }, |
263 | { ".reg-ppc-vmx", 544, "ppc Altivec" }, | |
264 | { ".reg-ppc-vsx", 256, "POWER7 VSX" }, | |
17ea7499 CES |
265 | { NULL, 0} |
266 | }; | |
267 | ||
6207416c LM |
268 | static struct core_regset_section ppc_linux_vmx_regset_sections[] = |
269 | { | |
2f2241f1 | 270 | { ".reg", 48 * 4, "general-purpose" }, |
1b1818e4 UW |
271 | { ".reg2", 264, "floating-point" }, |
272 | { ".reg-ppc-vmx", 544, "ppc Altivec" }, | |
6207416c LM |
273 | { NULL, 0} |
274 | }; | |
275 | ||
276 | static struct core_regset_section ppc_linux_fp_regset_sections[] = | |
277 | { | |
2f2241f1 UW |
278 | { ".reg", 48 * 4, "general-purpose" }, |
279 | { ".reg2", 264, "floating-point" }, | |
280 | { NULL, 0} | |
281 | }; | |
282 | ||
283 | static struct core_regset_section ppc64_linux_vsx_regset_sections[] = | |
284 | { | |
285 | { ".reg", 48 * 8, "general-purpose" }, | |
286 | { ".reg2", 264, "floating-point" }, | |
287 | { ".reg-ppc-vmx", 544, "ppc Altivec" }, | |
288 | { ".reg-ppc-vsx", 256, "POWER7 VSX" }, | |
289 | { NULL, 0} | |
290 | }; | |
291 | ||
292 | static struct core_regset_section ppc64_linux_vmx_regset_sections[] = | |
293 | { | |
294 | { ".reg", 48 * 8, "general-purpose" }, | |
295 | { ".reg2", 264, "floating-point" }, | |
296 | { ".reg-ppc-vmx", 544, "ppc Altivec" }, | |
297 | { NULL, 0} | |
298 | }; | |
299 | ||
300 | static struct core_regset_section ppc64_linux_fp_regset_sections[] = | |
301 | { | |
302 | { ".reg", 48 * 8, "general-purpose" }, | |
1b1818e4 | 303 | { ".reg2", 264, "floating-point" }, |
6207416c LM |
304 | { NULL, 0} |
305 | }; | |
306 | ||
5d853008 | 307 | /* PLT stub in executable. */ |
d78489bf | 308 | static struct ppc_insn_pattern powerpc32_plt_stub[] = |
5d853008 ME |
309 | { |
310 | { 0xffff0000, 0x3d600000, 0 }, /* lis r11, xxxx */ | |
311 | { 0xffff0000, 0x816b0000, 0 }, /* lwz r11, xxxx(r11) */ | |
312 | { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */ | |
313 | { 0xffffffff, 0x4e800420, 0 }, /* bctr */ | |
314 | { 0, 0, 0 } | |
315 | }; | |
316 | ||
317 | /* PLT stub in shared library. */ | |
d78489bf | 318 | static struct ppc_insn_pattern powerpc32_plt_stub_so[] = |
5d853008 ME |
319 | { |
320 | { 0xffff0000, 0x817e0000, 0 }, /* lwz r11, xxxx(r30) */ | |
321 | { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */ | |
322 | { 0xffffffff, 0x4e800420, 0 }, /* bctr */ | |
323 | { 0xffffffff, 0x60000000, 0 }, /* nop */ | |
324 | { 0, 0, 0 } | |
325 | }; | |
326 | #define POWERPC32_PLT_STUB_LEN ARRAY_SIZE (powerpc32_plt_stub) | |
327 | ||
328 | /* Check if PC is in PLT stub. For non-secure PLT, stub is in .plt | |
329 | section. For secure PLT, stub is in .text and we need to check | |
330 | instruction patterns. */ | |
331 | ||
332 | static int | |
333 | powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc) | |
334 | { | |
7cbd4a93 | 335 | struct bound_minimal_symbol sym; |
5d853008 ME |
336 | |
337 | /* Check whether PC is in the dynamic linker. This also checks | |
338 | whether it is in the .plt section, used by non-PIC executables. */ | |
339 | if (svr4_in_dynsym_resolve_code (pc)) | |
340 | return 1; | |
341 | ||
342 | /* Check if we are in the resolver. */ | |
343 | sym = lookup_minimal_symbol_by_pc (pc); | |
7cbd4a93 TT |
344 | if (sym.minsym != NULL |
345 | && (strcmp (SYMBOL_LINKAGE_NAME (sym.minsym), "__glink") == 0 | |
346 | || strcmp (SYMBOL_LINKAGE_NAME (sym.minsym), | |
347 | "__glink_PLTresolve") == 0)) | |
5d853008 ME |
348 | return 1; |
349 | ||
350 | return 0; | |
351 | } | |
352 | ||
353 | /* Follow PLT stub to actual routine. */ | |
354 | ||
355 | static CORE_ADDR | |
356 | ppc_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) | |
357 | { | |
463920bf | 358 | unsigned int insnbuf[POWERPC32_PLT_STUB_LEN]; |
5d853008 ME |
359 | struct gdbarch *gdbarch = get_frame_arch (frame); |
360 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
361 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
362 | CORE_ADDR target = 0; | |
363 | ||
845d4708 | 364 | if (ppc_insns_match_pattern (frame, pc, powerpc32_plt_stub, insnbuf)) |
5d853008 ME |
365 | { |
366 | /* Insn pattern is | |
367 | lis r11, xxxx | |
368 | lwz r11, xxxx(r11) | |
369 | Branch target is in r11. */ | |
370 | ||
d78489bf AT |
371 | target = (ppc_insn_d_field (insnbuf[0]) << 16) |
372 | | ppc_insn_d_field (insnbuf[1]); | |
5d853008 ME |
373 | target = read_memory_unsigned_integer (target, 4, byte_order); |
374 | } | |
375 | ||
845d4708 | 376 | if (ppc_insns_match_pattern (frame, pc, powerpc32_plt_stub_so, insnbuf)) |
5d853008 ME |
377 | { |
378 | /* Insn pattern is | |
379 | lwz r11, xxxx(r30) | |
380 | Branch target is in r11. */ | |
381 | ||
382 | target = get_frame_register_unsigned (frame, tdep->ppc_gp0_regnum + 30) | |
d78489bf | 383 | + ppc_insn_d_field (insnbuf[0]); |
5d853008 ME |
384 | target = read_memory_unsigned_integer (target, 4, byte_order); |
385 | } | |
386 | ||
387 | return target; | |
388 | } | |
f470a70a | 389 | |
7284e1be UW |
390 | /* Wrappers to handle Linux-only registers. */ |
391 | ||
392 | static void | |
393 | ppc_linux_supply_gregset (const struct regset *regset, | |
394 | struct regcache *regcache, | |
395 | int regnum, const void *gregs, size_t len) | |
396 | { | |
397 | const struct ppc_reg_offsets *offsets = regset->descr; | |
398 | ||
399 | ppc_supply_gregset (regset, regcache, regnum, gregs, len); | |
400 | ||
401 | if (ppc_linux_trap_reg_p (get_regcache_arch (regcache))) | |
402 | { | |
403 | /* "orig_r3" is stored 2 slots after "pc". */ | |
404 | if (regnum == -1 || regnum == PPC_ORIG_R3_REGNUM) | |
405 | ppc_supply_reg (regcache, PPC_ORIG_R3_REGNUM, gregs, | |
406 | offsets->pc_offset + 2 * offsets->gpr_size, | |
407 | offsets->gpr_size); | |
408 | ||
409 | /* "trap" is stored 8 slots after "pc". */ | |
410 | if (regnum == -1 || regnum == PPC_TRAP_REGNUM) | |
411 | ppc_supply_reg (regcache, PPC_TRAP_REGNUM, gregs, | |
412 | offsets->pc_offset + 8 * offsets->gpr_size, | |
413 | offsets->gpr_size); | |
414 | } | |
415 | } | |
f2db237a | 416 | |
f9be684a | 417 | static void |
f2db237a AM |
418 | ppc_linux_collect_gregset (const struct regset *regset, |
419 | const struct regcache *regcache, | |
420 | int regnum, void *gregs, size_t len) | |
f9be684a | 421 | { |
7284e1be UW |
422 | const struct ppc_reg_offsets *offsets = regset->descr; |
423 | ||
424 | /* Clear areas in the linux gregset not written elsewhere. */ | |
f2db237a AM |
425 | if (regnum == -1) |
426 | memset (gregs, 0, len); | |
7284e1be | 427 | |
f2db237a | 428 | ppc_collect_gregset (regset, regcache, regnum, gregs, len); |
7284e1be UW |
429 | |
430 | if (ppc_linux_trap_reg_p (get_regcache_arch (regcache))) | |
431 | { | |
432 | /* "orig_r3" is stored 2 slots after "pc". */ | |
433 | if (regnum == -1 || regnum == PPC_ORIG_R3_REGNUM) | |
434 | ppc_collect_reg (regcache, PPC_ORIG_R3_REGNUM, gregs, | |
435 | offsets->pc_offset + 2 * offsets->gpr_size, | |
436 | offsets->gpr_size); | |
437 | ||
438 | /* "trap" is stored 8 slots after "pc". */ | |
439 | if (regnum == -1 || regnum == PPC_TRAP_REGNUM) | |
440 | ppc_collect_reg (regcache, PPC_TRAP_REGNUM, gregs, | |
441 | offsets->pc_offset + 8 * offsets->gpr_size, | |
442 | offsets->gpr_size); | |
443 | } | |
f9be684a AC |
444 | } |
445 | ||
f2db237a AM |
446 | /* Regset descriptions. */ |
447 | static const struct ppc_reg_offsets ppc32_linux_reg_offsets = | |
448 | { | |
449 | /* General-purpose registers. */ | |
450 | /* .r0_offset = */ 0, | |
451 | /* .gpr_size = */ 4, | |
452 | /* .xr_size = */ 4, | |
453 | /* .pc_offset = */ 128, | |
454 | /* .ps_offset = */ 132, | |
455 | /* .cr_offset = */ 152, | |
456 | /* .lr_offset = */ 144, | |
457 | /* .ctr_offset = */ 140, | |
458 | /* .xer_offset = */ 148, | |
459 | /* .mq_offset = */ 156, | |
460 | ||
461 | /* Floating-point registers. */ | |
462 | /* .f0_offset = */ 0, | |
463 | /* .fpscr_offset = */ 256, | |
464 | /* .fpscr_size = */ 8, | |
465 | ||
466 | /* AltiVec registers. */ | |
467 | /* .vr0_offset = */ 0, | |
06caf7d2 CES |
468 | /* .vscr_offset = */ 512 + 12, |
469 | /* .vrsave_offset = */ 528 | |
f2db237a | 470 | }; |
f9be684a | 471 | |
f2db237a AM |
472 | static const struct ppc_reg_offsets ppc64_linux_reg_offsets = |
473 | { | |
474 | /* General-purpose registers. */ | |
475 | /* .r0_offset = */ 0, | |
476 | /* .gpr_size = */ 8, | |
477 | /* .xr_size = */ 8, | |
478 | /* .pc_offset = */ 256, | |
479 | /* .ps_offset = */ 264, | |
480 | /* .cr_offset = */ 304, | |
481 | /* .lr_offset = */ 288, | |
482 | /* .ctr_offset = */ 280, | |
483 | /* .xer_offset = */ 296, | |
484 | /* .mq_offset = */ 312, | |
485 | ||
486 | /* Floating-point registers. */ | |
487 | /* .f0_offset = */ 0, | |
488 | /* .fpscr_offset = */ 256, | |
489 | /* .fpscr_size = */ 8, | |
490 | ||
491 | /* AltiVec registers. */ | |
492 | /* .vr0_offset = */ 0, | |
06caf7d2 CES |
493 | /* .vscr_offset = */ 512 + 12, |
494 | /* .vrsave_offset = */ 528 | |
f2db237a | 495 | }; |
2fda4977 | 496 | |
f2db237a AM |
497 | static const struct regset ppc32_linux_gregset = { |
498 | &ppc32_linux_reg_offsets, | |
7284e1be | 499 | ppc_linux_supply_gregset, |
f2db237a AM |
500 | ppc_linux_collect_gregset, |
501 | NULL | |
f9be684a AC |
502 | }; |
503 | ||
f2db237a AM |
504 | static const struct regset ppc64_linux_gregset = { |
505 | &ppc64_linux_reg_offsets, | |
7284e1be | 506 | ppc_linux_supply_gregset, |
f2db237a AM |
507 | ppc_linux_collect_gregset, |
508 | NULL | |
509 | }; | |
f9be684a | 510 | |
f2db237a AM |
511 | static const struct regset ppc32_linux_fpregset = { |
512 | &ppc32_linux_reg_offsets, | |
513 | ppc_supply_fpregset, | |
514 | ppc_collect_fpregset, | |
515 | NULL | |
f9be684a AC |
516 | }; |
517 | ||
06caf7d2 CES |
518 | static const struct regset ppc32_linux_vrregset = { |
519 | &ppc32_linux_reg_offsets, | |
520 | ppc_supply_vrregset, | |
521 | ppc_collect_vrregset, | |
522 | NULL | |
523 | }; | |
524 | ||
604c2f83 LM |
525 | static const struct regset ppc32_linux_vsxregset = { |
526 | &ppc32_linux_reg_offsets, | |
527 | ppc_supply_vsxregset, | |
528 | ppc_collect_vsxregset, | |
529 | NULL | |
530 | }; | |
531 | ||
f2db237a AM |
532 | const struct regset * |
533 | ppc_linux_gregset (int wordsize) | |
2fda4977 | 534 | { |
f2db237a | 535 | return wordsize == 8 ? &ppc64_linux_gregset : &ppc32_linux_gregset; |
2fda4977 DJ |
536 | } |
537 | ||
f2db237a AM |
538 | const struct regset * |
539 | ppc_linux_fpregset (void) | |
540 | { | |
541 | return &ppc32_linux_fpregset; | |
542 | } | |
2fda4977 | 543 | |
f9be684a AC |
544 | static const struct regset * |
545 | ppc_linux_regset_from_core_section (struct gdbarch *core_arch, | |
546 | const char *sect_name, size_t sect_size) | |
2fda4977 | 547 | { |
f9be684a AC |
548 | struct gdbarch_tdep *tdep = gdbarch_tdep (core_arch); |
549 | if (strcmp (sect_name, ".reg") == 0) | |
2fda4977 | 550 | { |
f9be684a AC |
551 | if (tdep->wordsize == 4) |
552 | return &ppc32_linux_gregset; | |
2fda4977 | 553 | else |
f9be684a | 554 | return &ppc64_linux_gregset; |
2fda4977 | 555 | } |
f9be684a | 556 | if (strcmp (sect_name, ".reg2") == 0) |
f2db237a | 557 | return &ppc32_linux_fpregset; |
06caf7d2 CES |
558 | if (strcmp (sect_name, ".reg-ppc-vmx") == 0) |
559 | return &ppc32_linux_vrregset; | |
604c2f83 LM |
560 | if (strcmp (sect_name, ".reg-ppc-vsx") == 0) |
561 | return &ppc32_linux_vsxregset; | |
f9be684a | 562 | return NULL; |
2fda4977 DJ |
563 | } |
564 | ||
a8f60bfc | 565 | static void |
5366653e | 566 | ppc_linux_sigtramp_cache (struct frame_info *this_frame, |
a8f60bfc AC |
567 | struct trad_frame_cache *this_cache, |
568 | CORE_ADDR func, LONGEST offset, | |
569 | int bias) | |
570 | { | |
571 | CORE_ADDR base; | |
572 | CORE_ADDR regs; | |
573 | CORE_ADDR gpregs; | |
574 | CORE_ADDR fpregs; | |
575 | int i; | |
5366653e | 576 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
a8f60bfc | 577 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
e17a4113 | 578 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
a8f60bfc | 579 | |
5366653e DJ |
580 | base = get_frame_register_unsigned (this_frame, |
581 | gdbarch_sp_regnum (gdbarch)); | |
582 | if (bias > 0 && get_frame_pc (this_frame) != func) | |
a8f60bfc AC |
583 | /* See below, some signal trampolines increment the stack as their |
584 | first instruction, need to compensate for that. */ | |
585 | base -= bias; | |
586 | ||
587 | /* Find the address of the register buffer pointer. */ | |
588 | regs = base + offset; | |
589 | /* Use that to find the address of the corresponding register | |
590 | buffers. */ | |
e17a4113 | 591 | gpregs = read_memory_unsigned_integer (regs, tdep->wordsize, byte_order); |
a8f60bfc AC |
592 | fpregs = gpregs + 48 * tdep->wordsize; |
593 | ||
594 | /* General purpose. */ | |
595 | for (i = 0; i < 32; i++) | |
596 | { | |
597 | int regnum = i + tdep->ppc_gp0_regnum; | |
0df8b418 MS |
598 | trad_frame_set_reg_addr (this_cache, |
599 | regnum, gpregs + i * tdep->wordsize); | |
a8f60bfc | 600 | } |
3e8c568d | 601 | trad_frame_set_reg_addr (this_cache, |
40a6adc1 | 602 | gdbarch_pc_regnum (gdbarch), |
3e8c568d | 603 | gpregs + 32 * tdep->wordsize); |
a8f60bfc AC |
604 | trad_frame_set_reg_addr (this_cache, tdep->ppc_ctr_regnum, |
605 | gpregs + 35 * tdep->wordsize); | |
606 | trad_frame_set_reg_addr (this_cache, tdep->ppc_lr_regnum, | |
607 | gpregs + 36 * tdep->wordsize); | |
608 | trad_frame_set_reg_addr (this_cache, tdep->ppc_xer_regnum, | |
609 | gpregs + 37 * tdep->wordsize); | |
610 | trad_frame_set_reg_addr (this_cache, tdep->ppc_cr_regnum, | |
611 | gpregs + 38 * tdep->wordsize); | |
612 | ||
7284e1be UW |
613 | if (ppc_linux_trap_reg_p (gdbarch)) |
614 | { | |
615 | trad_frame_set_reg_addr (this_cache, PPC_ORIG_R3_REGNUM, | |
616 | gpregs + 34 * tdep->wordsize); | |
617 | trad_frame_set_reg_addr (this_cache, PPC_TRAP_REGNUM, | |
618 | gpregs + 40 * tdep->wordsize); | |
619 | } | |
620 | ||
60f140f9 PG |
621 | if (ppc_floating_point_unit_p (gdbarch)) |
622 | { | |
623 | /* Floating point registers. */ | |
624 | for (i = 0; i < 32; i++) | |
625 | { | |
40a6adc1 | 626 | int regnum = i + gdbarch_fp0_regnum (gdbarch); |
60f140f9 PG |
627 | trad_frame_set_reg_addr (this_cache, regnum, |
628 | fpregs + i * tdep->wordsize); | |
629 | } | |
630 | trad_frame_set_reg_addr (this_cache, tdep->ppc_fpscr_regnum, | |
4019046a | 631 | fpregs + 32 * tdep->wordsize); |
60f140f9 | 632 | } |
a8f60bfc AC |
633 | trad_frame_set_id (this_cache, frame_id_build (base, func)); |
634 | } | |
635 | ||
636 | static void | |
637 | ppc32_linux_sigaction_cache_init (const struct tramp_frame *self, | |
5366653e | 638 | struct frame_info *this_frame, |
a8f60bfc AC |
639 | struct trad_frame_cache *this_cache, |
640 | CORE_ADDR func) | |
641 | { | |
5366653e | 642 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
643 | 0xd0 /* Offset to ucontext_t. */ |
644 | + 0x30 /* Offset to .reg. */, | |
645 | 0); | |
646 | } | |
647 | ||
648 | static void | |
649 | ppc64_linux_sigaction_cache_init (const struct tramp_frame *self, | |
5366653e | 650 | struct frame_info *this_frame, |
a8f60bfc AC |
651 | struct trad_frame_cache *this_cache, |
652 | CORE_ADDR func) | |
653 | { | |
5366653e | 654 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
655 | 0x80 /* Offset to ucontext_t. */ |
656 | + 0xe0 /* Offset to .reg. */, | |
657 | 128); | |
658 | } | |
659 | ||
660 | static void | |
661 | ppc32_linux_sighandler_cache_init (const struct tramp_frame *self, | |
5366653e | 662 | struct frame_info *this_frame, |
a8f60bfc AC |
663 | struct trad_frame_cache *this_cache, |
664 | CORE_ADDR func) | |
665 | { | |
5366653e | 666 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
667 | 0x40 /* Offset to ucontext_t. */ |
668 | + 0x1c /* Offset to .reg. */, | |
669 | 0); | |
670 | } | |
671 | ||
672 | static void | |
673 | ppc64_linux_sighandler_cache_init (const struct tramp_frame *self, | |
5366653e | 674 | struct frame_info *this_frame, |
a8f60bfc AC |
675 | struct trad_frame_cache *this_cache, |
676 | CORE_ADDR func) | |
677 | { | |
5366653e | 678 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
679 | 0x80 /* Offset to struct sigcontext. */ |
680 | + 0x38 /* Offset to .reg. */, | |
681 | 128); | |
682 | } | |
683 | ||
684 | static struct tramp_frame ppc32_linux_sigaction_tramp_frame = { | |
685 | SIGTRAMP_FRAME, | |
686 | 4, | |
687 | { | |
688 | { 0x380000ac, -1 }, /* li r0, 172 */ | |
689 | { 0x44000002, -1 }, /* sc */ | |
690 | { TRAMP_SENTINEL_INSN }, | |
691 | }, | |
692 | ppc32_linux_sigaction_cache_init | |
693 | }; | |
694 | static struct tramp_frame ppc64_linux_sigaction_tramp_frame = { | |
695 | SIGTRAMP_FRAME, | |
696 | 4, | |
697 | { | |
698 | { 0x38210080, -1 }, /* addi r1,r1,128 */ | |
699 | { 0x380000ac, -1 }, /* li r0, 172 */ | |
700 | { 0x44000002, -1 }, /* sc */ | |
701 | { TRAMP_SENTINEL_INSN }, | |
702 | }, | |
703 | ppc64_linux_sigaction_cache_init | |
704 | }; | |
705 | static struct tramp_frame ppc32_linux_sighandler_tramp_frame = { | |
706 | SIGTRAMP_FRAME, | |
707 | 4, | |
708 | { | |
709 | { 0x38000077, -1 }, /* li r0,119 */ | |
710 | { 0x44000002, -1 }, /* sc */ | |
711 | { TRAMP_SENTINEL_INSN }, | |
712 | }, | |
713 | ppc32_linux_sighandler_cache_init | |
714 | }; | |
715 | static struct tramp_frame ppc64_linux_sighandler_tramp_frame = { | |
716 | SIGTRAMP_FRAME, | |
717 | 4, | |
718 | { | |
719 | { 0x38210080, -1 }, /* addi r1,r1,128 */ | |
720 | { 0x38000077, -1 }, /* li r0,119 */ | |
721 | { 0x44000002, -1 }, /* sc */ | |
722 | { TRAMP_SENTINEL_INSN }, | |
723 | }, | |
724 | ppc64_linux_sighandler_cache_init | |
725 | }; | |
726 | ||
7284e1be | 727 | |
85e747d2 UW |
728 | /* Address to use for displaced stepping. When debugging a stand-alone |
729 | SPU executable, entry_point_address () will point to an SPU local-store | |
730 | address and is thus not usable as displaced stepping location. We use | |
731 | the auxiliary vector to determine the PowerPC-side entry point address | |
732 | instead. */ | |
733 | ||
734 | static CORE_ADDR ppc_linux_entry_point_addr = 0; | |
735 | ||
736 | static void | |
737 | ppc_linux_inferior_created (struct target_ops *target, int from_tty) | |
738 | { | |
739 | ppc_linux_entry_point_addr = 0; | |
740 | } | |
741 | ||
742 | static CORE_ADDR | |
743 | ppc_linux_displaced_step_location (struct gdbarch *gdbarch) | |
744 | { | |
745 | if (ppc_linux_entry_point_addr == 0) | |
746 | { | |
747 | CORE_ADDR addr; | |
748 | ||
749 | /* Determine entry point from target auxiliary vector. */ | |
750 | if (target_auxv_search (¤t_target, AT_ENTRY, &addr) <= 0) | |
751 | error (_("Cannot find AT_ENTRY auxiliary vector entry.")); | |
752 | ||
753 | /* Make certain that the address points at real code, and not a | |
754 | function descriptor. */ | |
755 | addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, | |
756 | ¤t_target); | |
757 | ||
758 | /* Inferior calls also use the entry point as a breakpoint location. | |
759 | We don't want displaced stepping to interfere with those | |
760 | breakpoints, so leave space. */ | |
5931a2fa | 761 | ppc_linux_entry_point_addr = addr + 2 * PPC_INSN_SIZE; |
85e747d2 UW |
762 | } |
763 | ||
764 | return ppc_linux_entry_point_addr; | |
765 | } | |
766 | ||
767 | ||
7284e1be UW |
768 | /* Return 1 if PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM are usable. */ |
769 | int | |
770 | ppc_linux_trap_reg_p (struct gdbarch *gdbarch) | |
771 | { | |
772 | /* If we do not have a target description with registers, then | |
773 | the special registers will not be included in the register set. */ | |
774 | if (!tdesc_has_registers (gdbarch_target_desc (gdbarch))) | |
775 | return 0; | |
776 | ||
777 | /* If we do, then it is safe to check the size. */ | |
778 | return register_size (gdbarch, PPC_ORIG_R3_REGNUM) > 0 | |
779 | && register_size (gdbarch, PPC_TRAP_REGNUM) > 0; | |
780 | } | |
781 | ||
a96d9b2e SDJ |
782 | /* Return the current system call's number present in the |
783 | r0 register. When the function fails, it returns -1. */ | |
784 | static LONGEST | |
785 | ppc_linux_get_syscall_number (struct gdbarch *gdbarch, | |
786 | ptid_t ptid) | |
787 | { | |
788 | struct regcache *regcache = get_thread_regcache (ptid); | |
789 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
790 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
791 | struct cleanup *cleanbuf; | |
792 | /* The content of a register */ | |
793 | gdb_byte *buf; | |
794 | /* The result */ | |
795 | LONGEST ret; | |
796 | ||
797 | /* Make sure we're in a 32- or 64-bit machine */ | |
798 | gdb_assert (tdep->wordsize == 4 || tdep->wordsize == 8); | |
799 | ||
800 | buf = (gdb_byte *) xmalloc (tdep->wordsize * sizeof (gdb_byte)); | |
801 | ||
802 | cleanbuf = make_cleanup (xfree, buf); | |
803 | ||
804 | /* Getting the system call number from the register. | |
805 | When dealing with PowerPC architecture, this information | |
806 | is stored at 0th register. */ | |
807 | regcache_cooked_read (regcache, tdep->ppc_gp0_regnum, buf); | |
808 | ||
809 | ret = extract_signed_integer (buf, tdep->wordsize, byte_order); | |
810 | do_cleanups (cleanbuf); | |
811 | ||
812 | return ret; | |
813 | } | |
814 | ||
7284e1be UW |
815 | static void |
816 | ppc_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) | |
817 | { | |
818 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
819 | ||
820 | regcache_cooked_write_unsigned (regcache, gdbarch_pc_regnum (gdbarch), pc); | |
821 | ||
822 | /* Set special TRAP register to -1 to prevent the kernel from | |
823 | messing with the PC we just installed, if we happen to be | |
824 | within an interrupted system call that the kernel wants to | |
825 | restart. | |
826 | ||
827 | Note that after we return from the dummy call, the TRAP and | |
828 | ORIG_R3 registers will be automatically restored, and the | |
829 | kernel continues to restart the system call at this point. */ | |
830 | if (ppc_linux_trap_reg_p (gdbarch)) | |
831 | regcache_cooked_write_unsigned (regcache, PPC_TRAP_REGNUM, -1); | |
832 | } | |
833 | ||
f4d9bade UW |
834 | static int |
835 | ppc_linux_spu_section (bfd *abfd, asection *asect, void *user_data) | |
836 | { | |
837 | return strncmp (bfd_section_name (abfd, asect), "SPU/", 4) == 0; | |
838 | } | |
839 | ||
7284e1be UW |
840 | static const struct target_desc * |
841 | ppc_linux_core_read_description (struct gdbarch *gdbarch, | |
842 | struct target_ops *target, | |
843 | bfd *abfd) | |
844 | { | |
f4d9bade | 845 | asection *cell = bfd_sections_find_if (abfd, ppc_linux_spu_section, NULL); |
7284e1be | 846 | asection *altivec = bfd_get_section_by_name (abfd, ".reg-ppc-vmx"); |
604c2f83 | 847 | asection *vsx = bfd_get_section_by_name (abfd, ".reg-ppc-vsx"); |
7284e1be UW |
848 | asection *section = bfd_get_section_by_name (abfd, ".reg"); |
849 | if (! section) | |
850 | return NULL; | |
851 | ||
852 | switch (bfd_section_size (abfd, section)) | |
853 | { | |
854 | case 48 * 4: | |
f4d9bade UW |
855 | if (cell) |
856 | return tdesc_powerpc_cell32l; | |
857 | else if (vsx) | |
604c2f83 LM |
858 | return tdesc_powerpc_vsx32l; |
859 | else if (altivec) | |
860 | return tdesc_powerpc_altivec32l; | |
861 | else | |
862 | return tdesc_powerpc_32l; | |
7284e1be UW |
863 | |
864 | case 48 * 8: | |
f4d9bade UW |
865 | if (cell) |
866 | return tdesc_powerpc_cell64l; | |
867 | else if (vsx) | |
604c2f83 LM |
868 | return tdesc_powerpc_vsx64l; |
869 | else if (altivec) | |
870 | return tdesc_powerpc_altivec64l; | |
871 | else | |
872 | return tdesc_powerpc_64l; | |
7284e1be UW |
873 | |
874 | default: | |
875 | return NULL; | |
876 | } | |
877 | } | |
878 | ||
55aa24fb SDJ |
879 | /* Implementation of `gdbarch_stap_is_single_operand', as defined in |
880 | gdbarch.h. */ | |
881 | ||
882 | static int | |
883 | ppc_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) | |
884 | { | |
885 | return (*s == 'i' /* Literal number. */ | |
886 | || (isdigit (*s) && s[1] == '(' | |
887 | && isdigit (s[2])) /* Displacement. */ | |
888 | || (*s == '(' && isdigit (s[1])) /* Register indirection. */ | |
889 | || isdigit (*s)); /* Register value. */ | |
890 | } | |
891 | ||
892 | /* Implementation of `gdbarch_stap_parse_special_token', as defined in | |
893 | gdbarch.h. */ | |
894 | ||
895 | static int | |
896 | ppc_stap_parse_special_token (struct gdbarch *gdbarch, | |
897 | struct stap_parse_info *p) | |
898 | { | |
899 | if (isdigit (*p->arg)) | |
900 | { | |
901 | /* This temporary pointer is needed because we have to do a lookahead. | |
902 | We could be dealing with a register displacement, and in such case | |
903 | we would not need to do anything. */ | |
904 | const char *s = p->arg; | |
905 | char *regname; | |
906 | int len; | |
907 | struct stoken str; | |
908 | ||
909 | while (isdigit (*s)) | |
910 | ++s; | |
911 | ||
912 | if (*s == '(') | |
913 | { | |
914 | /* It is a register displacement indeed. Returning 0 means we are | |
915 | deferring the treatment of this case to the generic parser. */ | |
916 | return 0; | |
917 | } | |
918 | ||
919 | len = s - p->arg; | |
920 | regname = alloca (len + 2); | |
921 | regname[0] = 'r'; | |
922 | ||
923 | strncpy (regname + 1, p->arg, len); | |
924 | ++len; | |
925 | regname[len] = '\0'; | |
926 | ||
927 | if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1) | |
928 | error (_("Invalid register name `%s' on expression `%s'."), | |
929 | regname, p->saved_arg); | |
930 | ||
931 | write_exp_elt_opcode (OP_REGISTER); | |
932 | str.ptr = regname; | |
933 | str.length = len; | |
934 | write_exp_string (str); | |
935 | write_exp_elt_opcode (OP_REGISTER); | |
936 | ||
937 | p->arg = s; | |
938 | } | |
939 | else | |
940 | { | |
941 | /* All the other tokens should be handled correctly by the generic | |
942 | parser. */ | |
943 | return 0; | |
944 | } | |
945 | ||
946 | return 1; | |
947 | } | |
cc5f0d61 UW |
948 | |
949 | /* Cell/B.E. active SPE context tracking support. */ | |
950 | ||
951 | static struct objfile *spe_context_objfile = NULL; | |
952 | static CORE_ADDR spe_context_lm_addr = 0; | |
953 | static CORE_ADDR spe_context_offset = 0; | |
954 | ||
955 | static ptid_t spe_context_cache_ptid; | |
956 | static CORE_ADDR spe_context_cache_address; | |
957 | ||
958 | /* Hook into inferior_created, solib_loaded, and solib_unloaded observers | |
959 | to track whether we've loaded a version of libspe2 (as static or dynamic | |
960 | library) that provides the __spe_current_active_context variable. */ | |
961 | static void | |
962 | ppc_linux_spe_context_lookup (struct objfile *objfile) | |
963 | { | |
964 | struct minimal_symbol *sym; | |
965 | ||
966 | if (!objfile) | |
967 | { | |
968 | spe_context_objfile = NULL; | |
969 | spe_context_lm_addr = 0; | |
970 | spe_context_offset = 0; | |
971 | spe_context_cache_ptid = minus_one_ptid; | |
972 | spe_context_cache_address = 0; | |
973 | return; | |
974 | } | |
975 | ||
976 | sym = lookup_minimal_symbol ("__spe_current_active_context", NULL, objfile); | |
977 | if (sym) | |
978 | { | |
979 | spe_context_objfile = objfile; | |
980 | spe_context_lm_addr = svr4_fetch_objfile_link_map (objfile); | |
981 | spe_context_offset = SYMBOL_VALUE_ADDRESS (sym); | |
982 | spe_context_cache_ptid = minus_one_ptid; | |
983 | spe_context_cache_address = 0; | |
984 | return; | |
985 | } | |
986 | } | |
987 | ||
988 | static void | |
989 | ppc_linux_spe_context_inferior_created (struct target_ops *t, int from_tty) | |
990 | { | |
991 | struct objfile *objfile; | |
992 | ||
993 | ppc_linux_spe_context_lookup (NULL); | |
994 | ALL_OBJFILES (objfile) | |
995 | ppc_linux_spe_context_lookup (objfile); | |
996 | } | |
997 | ||
998 | static void | |
999 | ppc_linux_spe_context_solib_loaded (struct so_list *so) | |
1000 | { | |
1001 | if (strstr (so->so_original_name, "/libspe") != NULL) | |
1002 | { | |
7e559477 | 1003 | solib_read_symbols (so, 0); |
cc5f0d61 UW |
1004 | ppc_linux_spe_context_lookup (so->objfile); |
1005 | } | |
1006 | } | |
1007 | ||
1008 | static void | |
1009 | ppc_linux_spe_context_solib_unloaded (struct so_list *so) | |
1010 | { | |
1011 | if (so->objfile == spe_context_objfile) | |
1012 | ppc_linux_spe_context_lookup (NULL); | |
1013 | } | |
1014 | ||
1015 | /* Retrieve contents of the N'th element in the current thread's | |
1016 | linked SPE context list into ID and NPC. Return the address of | |
1017 | said context element, or 0 if not found. */ | |
1018 | static CORE_ADDR | |
1019 | ppc_linux_spe_context (int wordsize, enum bfd_endian byte_order, | |
1020 | int n, int *id, unsigned int *npc) | |
1021 | { | |
1022 | CORE_ADDR spe_context = 0; | |
1023 | gdb_byte buf[16]; | |
1024 | int i; | |
1025 | ||
1026 | /* Quick exit if we have not found __spe_current_active_context. */ | |
1027 | if (!spe_context_objfile) | |
1028 | return 0; | |
1029 | ||
1030 | /* Look up cached address of thread-local variable. */ | |
1031 | if (!ptid_equal (spe_context_cache_ptid, inferior_ptid)) | |
1032 | { | |
1033 | struct target_ops *target = ¤t_target; | |
1034 | volatile struct gdb_exception ex; | |
1035 | ||
1036 | while (target && !target->to_get_thread_local_address) | |
1037 | target = find_target_beneath (target); | |
1038 | if (!target) | |
1039 | return 0; | |
1040 | ||
1041 | TRY_CATCH (ex, RETURN_MASK_ERROR) | |
1042 | { | |
1043 | /* We do not call target_translate_tls_address here, because | |
1044 | svr4_fetch_objfile_link_map may invalidate the frame chain, | |
1045 | which must not do while inside a frame sniffer. | |
1046 | ||
1047 | Instead, we have cached the lm_addr value, and use that to | |
1048 | directly call the target's to_get_thread_local_address. */ | |
1049 | spe_context_cache_address | |
1050 | = target->to_get_thread_local_address (target, inferior_ptid, | |
1051 | spe_context_lm_addr, | |
1052 | spe_context_offset); | |
1053 | spe_context_cache_ptid = inferior_ptid; | |
1054 | } | |
1055 | ||
1056 | if (ex.reason < 0) | |
1057 | return 0; | |
1058 | } | |
1059 | ||
1060 | /* Read variable value. */ | |
1061 | if (target_read_memory (spe_context_cache_address, buf, wordsize) == 0) | |
1062 | spe_context = extract_unsigned_integer (buf, wordsize, byte_order); | |
1063 | ||
1064 | /* Cyle through to N'th linked list element. */ | |
1065 | for (i = 0; i < n && spe_context; i++) | |
1066 | if (target_read_memory (spe_context + align_up (12, wordsize), | |
1067 | buf, wordsize) == 0) | |
1068 | spe_context = extract_unsigned_integer (buf, wordsize, byte_order); | |
1069 | else | |
1070 | spe_context = 0; | |
1071 | ||
1072 | /* Read current context. */ | |
1073 | if (spe_context | |
1074 | && target_read_memory (spe_context, buf, 12) != 0) | |
1075 | spe_context = 0; | |
1076 | ||
1077 | /* Extract data elements. */ | |
1078 | if (spe_context) | |
1079 | { | |
1080 | if (id) | |
1081 | *id = extract_signed_integer (buf, 4, byte_order); | |
1082 | if (npc) | |
1083 | *npc = extract_unsigned_integer (buf + 4, 4, byte_order); | |
1084 | } | |
1085 | ||
1086 | return spe_context; | |
1087 | } | |
1088 | ||
1089 | ||
1090 | /* Cell/B.E. cross-architecture unwinder support. */ | |
1091 | ||
1092 | struct ppu2spu_cache | |
1093 | { | |
1094 | struct frame_id frame_id; | |
1095 | struct regcache *regcache; | |
1096 | }; | |
1097 | ||
1098 | static struct gdbarch * | |
1099 | ppu2spu_prev_arch (struct frame_info *this_frame, void **this_cache) | |
1100 | { | |
1101 | struct ppu2spu_cache *cache = *this_cache; | |
1102 | return get_regcache_arch (cache->regcache); | |
1103 | } | |
1104 | ||
1105 | static void | |
1106 | ppu2spu_this_id (struct frame_info *this_frame, | |
1107 | void **this_cache, struct frame_id *this_id) | |
1108 | { | |
1109 | struct ppu2spu_cache *cache = *this_cache; | |
1110 | *this_id = cache->frame_id; | |
1111 | } | |
1112 | ||
1113 | static struct value * | |
1114 | ppu2spu_prev_register (struct frame_info *this_frame, | |
1115 | void **this_cache, int regnum) | |
1116 | { | |
1117 | struct ppu2spu_cache *cache = *this_cache; | |
1118 | struct gdbarch *gdbarch = get_regcache_arch (cache->regcache); | |
1119 | gdb_byte *buf; | |
1120 | ||
1121 | buf = alloca (register_size (gdbarch, regnum)); | |
a536c6d7 UW |
1122 | |
1123 | if (regnum < gdbarch_num_regs (gdbarch)) | |
1124 | regcache_raw_read (cache->regcache, regnum, buf); | |
1125 | else | |
1126 | gdbarch_pseudo_register_read (gdbarch, cache->regcache, regnum, buf); | |
1127 | ||
cc5f0d61 UW |
1128 | return frame_unwind_got_bytes (this_frame, regnum, buf); |
1129 | } | |
1130 | ||
1131 | struct ppu2spu_data | |
1132 | { | |
1133 | struct gdbarch *gdbarch; | |
1134 | int id; | |
1135 | unsigned int npc; | |
1136 | gdb_byte gprs[128*16]; | |
1137 | }; | |
1138 | ||
1139 | static int | |
1140 | ppu2spu_unwind_register (void *src, int regnum, gdb_byte *buf) | |
1141 | { | |
1142 | struct ppu2spu_data *data = src; | |
1143 | enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch); | |
1144 | ||
1145 | if (regnum >= 0 && regnum < SPU_NUM_GPRS) | |
1146 | memcpy (buf, data->gprs + 16*regnum, 16); | |
1147 | else if (regnum == SPU_ID_REGNUM) | |
1148 | store_unsigned_integer (buf, 4, byte_order, data->id); | |
1149 | else if (regnum == SPU_PC_REGNUM) | |
1150 | store_unsigned_integer (buf, 4, byte_order, data->npc); | |
1151 | else | |
a536c6d7 | 1152 | return REG_UNAVAILABLE; |
cc5f0d61 | 1153 | |
a536c6d7 | 1154 | return REG_VALID; |
cc5f0d61 UW |
1155 | } |
1156 | ||
1157 | static int | |
1158 | ppu2spu_sniffer (const struct frame_unwind *self, | |
1159 | struct frame_info *this_frame, void **this_prologue_cache) | |
1160 | { | |
1161 | struct gdbarch *gdbarch = get_frame_arch (this_frame); | |
1162 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
1163 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
1164 | struct ppu2spu_data data; | |
1165 | struct frame_info *fi; | |
1166 | CORE_ADDR base, func, backchain, spe_context; | |
1167 | gdb_byte buf[8]; | |
1168 | int n = 0; | |
1169 | ||
1170 | /* Count the number of SPU contexts already in the frame chain. */ | |
1171 | for (fi = get_next_frame (this_frame); fi; fi = get_next_frame (fi)) | |
1172 | if (get_frame_type (fi) == ARCH_FRAME | |
1173 | && gdbarch_bfd_arch_info (get_frame_arch (fi))->arch == bfd_arch_spu) | |
1174 | n++; | |
1175 | ||
1176 | base = get_frame_sp (this_frame); | |
1177 | func = get_frame_pc (this_frame); | |
1178 | if (target_read_memory (base, buf, tdep->wordsize)) | |
1179 | return 0; | |
1180 | backchain = extract_unsigned_integer (buf, tdep->wordsize, byte_order); | |
1181 | ||
1182 | spe_context = ppc_linux_spe_context (tdep->wordsize, byte_order, | |
1183 | n, &data.id, &data.npc); | |
1184 | if (spe_context && base <= spe_context && spe_context < backchain) | |
1185 | { | |
1186 | char annex[32]; | |
1187 | ||
1188 | /* Find gdbarch for SPU. */ | |
1189 | struct gdbarch_info info; | |
1190 | gdbarch_info_init (&info); | |
1191 | info.bfd_arch_info = bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu); | |
1192 | info.byte_order = BFD_ENDIAN_BIG; | |
1193 | info.osabi = GDB_OSABI_LINUX; | |
1194 | info.tdep_info = (void *) &data.id; | |
1195 | data.gdbarch = gdbarch_find_by_info (info); | |
1196 | if (!data.gdbarch) | |
1197 | return 0; | |
1198 | ||
1199 | xsnprintf (annex, sizeof annex, "%d/regs", data.id); | |
1200 | if (target_read (¤t_target, TARGET_OBJECT_SPU, annex, | |
1201 | data.gprs, 0, sizeof data.gprs) | |
1202 | == sizeof data.gprs) | |
1203 | { | |
1204 | struct ppu2spu_cache *cache | |
1205 | = FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache); | |
1206 | ||
d37346f0 DJ |
1207 | struct address_space *aspace = get_frame_address_space (this_frame); |
1208 | struct regcache *regcache = regcache_xmalloc (data.gdbarch, aspace); | |
cc5f0d61 UW |
1209 | struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache); |
1210 | regcache_save (regcache, ppu2spu_unwind_register, &data); | |
1211 | discard_cleanups (cleanups); | |
1212 | ||
1213 | cache->frame_id = frame_id_build (base, func); | |
1214 | cache->regcache = regcache; | |
1215 | *this_prologue_cache = cache; | |
1216 | return 1; | |
1217 | } | |
1218 | } | |
1219 | ||
1220 | return 0; | |
1221 | } | |
1222 | ||
1223 | static void | |
1224 | ppu2spu_dealloc_cache (struct frame_info *self, void *this_cache) | |
1225 | { | |
1226 | struct ppu2spu_cache *cache = this_cache; | |
1227 | regcache_xfree (cache->regcache); | |
1228 | } | |
1229 | ||
1230 | static const struct frame_unwind ppu2spu_unwind = { | |
1231 | ARCH_FRAME, | |
8fbca658 | 1232 | default_frame_unwind_stop_reason, |
cc5f0d61 UW |
1233 | ppu2spu_this_id, |
1234 | ppu2spu_prev_register, | |
1235 | NULL, | |
1236 | ppu2spu_sniffer, | |
1237 | ppu2spu_dealloc_cache, | |
1238 | ppu2spu_prev_arch, | |
1239 | }; | |
1240 | ||
1241 | ||
7b112f9c JT |
1242 | static void |
1243 | ppc_linux_init_abi (struct gdbarch_info info, | |
1244 | struct gdbarch *gdbarch) | |
1245 | { | |
1246 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
7284e1be | 1247 | struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info; |
05c0465e SDJ |
1248 | static const char *const stap_integer_prefixes[] = { "i", NULL }; |
1249 | static const char *const stap_register_indirection_prefixes[] = { "(", | |
1250 | NULL }; | |
1251 | static const char *const stap_register_indirection_suffixes[] = { ")", | |
1252 | NULL }; | |
7b112f9c | 1253 | |
a5ee0f0c PA |
1254 | linux_init_abi (info, gdbarch); |
1255 | ||
b14d30e1 JM |
1256 | /* PPC GNU/Linux uses either 64-bit or 128-bit long doubles; where |
1257 | 128-bit, they are IBM long double, not IEEE quad long double as | |
1258 | in the System V ABI PowerPC Processor Supplement. We can safely | |
1259 | let them default to 128-bit, since the debug info will give the | |
1260 | size of type actually used in each case. */ | |
1261 | set_gdbarch_long_double_bit (gdbarch, 16 * TARGET_CHAR_BIT); | |
1262 | set_gdbarch_long_double_format (gdbarch, floatformats_ibm_long_double); | |
0598a43c | 1263 | |
7284e1be UW |
1264 | /* Handle inferior calls during interrupted system calls. */ |
1265 | set_gdbarch_write_pc (gdbarch, ppc_linux_write_pc); | |
1266 | ||
a96d9b2e SDJ |
1267 | /* Get the syscall number from the arch's register. */ |
1268 | set_gdbarch_get_syscall_number (gdbarch, ppc_linux_get_syscall_number); | |
1269 | ||
55aa24fb | 1270 | /* SystemTap functions. */ |
05c0465e SDJ |
1271 | set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes); |
1272 | set_gdbarch_stap_register_indirection_prefixes (gdbarch, | |
1273 | stap_register_indirection_prefixes); | |
1274 | set_gdbarch_stap_register_indirection_suffixes (gdbarch, | |
1275 | stap_register_indirection_suffixes); | |
55aa24fb SDJ |
1276 | set_gdbarch_stap_gdb_register_prefix (gdbarch, "r"); |
1277 | set_gdbarch_stap_is_single_operand (gdbarch, ppc_stap_is_single_operand); | |
1278 | set_gdbarch_stap_parse_special_token (gdbarch, | |
1279 | ppc_stap_parse_special_token); | |
1280 | ||
7b112f9c JT |
1281 | if (tdep->wordsize == 4) |
1282 | { | |
b9ff3018 AC |
1283 | /* Until November 2001, gcc did not comply with the 32 bit SysV |
1284 | R4 ABI requirement that structures less than or equal to 8 | |
1285 | bytes should be returned in registers. Instead GCC was using | |
b021a221 | 1286 | the AIX/PowerOpen ABI - everything returned in memory |
b9ff3018 AC |
1287 | (well ignoring vectors that is). When this was corrected, it |
1288 | wasn't fixed for GNU/Linux native platform. Use the | |
1289 | PowerOpen struct convention. */ | |
05580c65 | 1290 | set_gdbarch_return_value (gdbarch, ppc_linux_return_value); |
b9ff3018 | 1291 | |
7b112f9c JT |
1292 | set_gdbarch_memory_remove_breakpoint (gdbarch, |
1293 | ppc_linux_memory_remove_breakpoint); | |
61a65099 | 1294 | |
f470a70a | 1295 | /* Shared library handling. */ |
5d853008 | 1296 | set_gdbarch_skip_trampoline_code (gdbarch, ppc_skip_trampoline_code); |
7b112f9c | 1297 | set_solib_svr4_fetch_link_map_offsets |
76a9d10f | 1298 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); |
a8f60bfc | 1299 | |
a96d9b2e SDJ |
1300 | /* Setting the correct XML syscall filename. */ |
1301 | set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC); | |
1302 | ||
a8f60bfc | 1303 | /* Trampolines. */ |
0df8b418 MS |
1304 | tramp_frame_prepend_unwinder (gdbarch, |
1305 | &ppc32_linux_sigaction_tramp_frame); | |
1306 | tramp_frame_prepend_unwinder (gdbarch, | |
1307 | &ppc32_linux_sighandler_tramp_frame); | |
a78c2d62 UW |
1308 | |
1309 | /* BFD target for core files. */ | |
1310 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) | |
1311 | set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpcle"); | |
1312 | else | |
1313 | set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpc"); | |
2f2241f1 UW |
1314 | |
1315 | /* Supported register sections. */ | |
1316 | if (tdesc_find_feature (info.target_desc, | |
1317 | "org.gnu.gdb.power.vsx")) | |
1318 | set_gdbarch_core_regset_sections (gdbarch, | |
1319 | ppc_linux_vsx_regset_sections); | |
1320 | else if (tdesc_find_feature (info.target_desc, | |
1321 | "org.gnu.gdb.power.altivec")) | |
1322 | set_gdbarch_core_regset_sections (gdbarch, | |
1323 | ppc_linux_vmx_regset_sections); | |
1324 | else | |
1325 | set_gdbarch_core_regset_sections (gdbarch, | |
1326 | ppc_linux_fp_regset_sections); | |
5d853008 ME |
1327 | |
1328 | if (powerpc_so_ops.in_dynsym_resolve_code == NULL) | |
1329 | { | |
1330 | powerpc_so_ops = svr4_so_ops; | |
1331 | /* Override dynamic resolve function. */ | |
1332 | powerpc_so_ops.in_dynsym_resolve_code = | |
1333 | powerpc_linux_in_dynsym_resolve_code; | |
1334 | } | |
1335 | set_solib_ops (gdbarch, &powerpc_so_ops); | |
1336 | ||
1337 | set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver); | |
7b112f9c | 1338 | } |
f470a70a JB |
1339 | |
1340 | if (tdep->wordsize == 8) | |
1341 | { | |
00d5f93a UW |
1342 | /* Handle PPC GNU/Linux 64-bit function pointers (which are really |
1343 | function descriptors). */ | |
1344 | set_gdbarch_convert_from_func_ptr_addr | |
d78489bf | 1345 | (gdbarch, ppc64_convert_from_func_ptr_addr); |
00d5f93a | 1346 | |
24c274a1 AM |
1347 | set_gdbarch_elf_make_msymbol_special (gdbarch, |
1348 | ppc64_elf_make_msymbol_special); | |
1349 | ||
fb318ff7 | 1350 | /* Shared library handling. */ |
2bbe3cc1 | 1351 | set_gdbarch_skip_trampoline_code (gdbarch, ppc64_skip_trampoline_code); |
fb318ff7 DJ |
1352 | set_solib_svr4_fetch_link_map_offsets |
1353 | (gdbarch, svr4_lp64_fetch_link_map_offsets); | |
1354 | ||
a96d9b2e SDJ |
1355 | /* Setting the correct XML syscall filename. */ |
1356 | set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC64); | |
1357 | ||
a8f60bfc | 1358 | /* Trampolines. */ |
0df8b418 MS |
1359 | tramp_frame_prepend_unwinder (gdbarch, |
1360 | &ppc64_linux_sigaction_tramp_frame); | |
1361 | tramp_frame_prepend_unwinder (gdbarch, | |
1362 | &ppc64_linux_sighandler_tramp_frame); | |
a78c2d62 UW |
1363 | |
1364 | /* BFD target for core files. */ | |
1365 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) | |
1366 | set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle"); | |
1367 | else | |
1368 | set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc"); | |
2f2241f1 UW |
1369 | |
1370 | /* Supported register sections. */ | |
1371 | if (tdesc_find_feature (info.target_desc, | |
1372 | "org.gnu.gdb.power.vsx")) | |
1373 | set_gdbarch_core_regset_sections (gdbarch, | |
1374 | ppc64_linux_vsx_regset_sections); | |
1375 | else if (tdesc_find_feature (info.target_desc, | |
1376 | "org.gnu.gdb.power.altivec")) | |
1377 | set_gdbarch_core_regset_sections (gdbarch, | |
1378 | ppc64_linux_vmx_regset_sections); | |
1379 | else | |
1380 | set_gdbarch_core_regset_sections (gdbarch, | |
1381 | ppc64_linux_fp_regset_sections); | |
f470a70a | 1382 | } |
b3ac9c77 SDJ |
1383 | |
1384 | /* PPC32 uses a different prpsinfo32 compared to most other Linux | |
1385 | archs. */ | |
1386 | if (tdep->wordsize == 4) | |
1387 | set_gdbarch_elfcore_write_linux_prpsinfo (gdbarch, | |
1388 | elfcore_write_ppc_linux_prpsinfo32); | |
1389 | ||
0df8b418 MS |
1390 | set_gdbarch_regset_from_core_section (gdbarch, |
1391 | ppc_linux_regset_from_core_section); | |
7284e1be | 1392 | set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description); |
b2756930 KB |
1393 | |
1394 | /* Enable TLS support. */ | |
1395 | set_gdbarch_fetch_tls_load_module_address (gdbarch, | |
1396 | svr4_fetch_objfile_link_map); | |
7284e1be UW |
1397 | |
1398 | if (tdesc_data) | |
1399 | { | |
1400 | const struct tdesc_feature *feature; | |
1401 | ||
1402 | /* If we have target-described registers, then we can safely | |
1403 | reserve a number for PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM | |
1404 | (whether they are described or not). */ | |
1405 | gdb_assert (gdbarch_num_regs (gdbarch) <= PPC_ORIG_R3_REGNUM); | |
1406 | set_gdbarch_num_regs (gdbarch, PPC_TRAP_REGNUM + 1); | |
1407 | ||
1408 | /* If they are present, then assign them to the reserved number. */ | |
1409 | feature = tdesc_find_feature (info.target_desc, | |
1410 | "org.gnu.gdb.power.linux"); | |
1411 | if (feature != NULL) | |
1412 | { | |
1413 | tdesc_numbered_register (feature, tdesc_data, | |
1414 | PPC_ORIG_R3_REGNUM, "orig_r3"); | |
1415 | tdesc_numbered_register (feature, tdesc_data, | |
1416 | PPC_TRAP_REGNUM, "trap"); | |
1417 | } | |
1418 | } | |
85e747d2 UW |
1419 | |
1420 | /* Enable Cell/B.E. if supported by the target. */ | |
1421 | if (tdesc_compatible_p (info.target_desc, | |
1422 | bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu))) | |
1423 | { | |
1424 | /* Cell/B.E. multi-architecture support. */ | |
1425 | set_spu_solib_ops (gdbarch); | |
1426 | ||
cc5f0d61 UW |
1427 | /* Cell/B.E. cross-architecture unwinder support. */ |
1428 | frame_unwind_prepend_unwinder (gdbarch, &ppu2spu_unwind); | |
1429 | ||
85e747d2 UW |
1430 | /* The default displaced_step_at_entry_point doesn't work for |
1431 | SPU stand-alone executables. */ | |
1432 | set_gdbarch_displaced_step_location (gdbarch, | |
1433 | ppc_linux_displaced_step_location); | |
1434 | } | |
f782ad9b AS |
1435 | |
1436 | set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type); | |
7b112f9c JT |
1437 | } |
1438 | ||
63807e1d PA |
1439 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
1440 | extern initialize_file_ftype _initialize_ppc_linux_tdep; | |
1441 | ||
7b112f9c JT |
1442 | void |
1443 | _initialize_ppc_linux_tdep (void) | |
1444 | { | |
0a0a4ac3 AC |
1445 | /* Register for all sub-familes of the POWER/PowerPC: 32-bit and |
1446 | 64-bit PowerPC, and the older rs6k. */ | |
1447 | gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc, GDB_OSABI_LINUX, | |
1448 | ppc_linux_init_abi); | |
1449 | gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc64, GDB_OSABI_LINUX, | |
1450 | ppc_linux_init_abi); | |
1451 | gdbarch_register_osabi (bfd_arch_rs6000, bfd_mach_rs6k, GDB_OSABI_LINUX, | |
1452 | ppc_linux_init_abi); | |
7284e1be | 1453 | |
85e747d2 UW |
1454 | /* Attach to inferior_created observer. */ |
1455 | observer_attach_inferior_created (ppc_linux_inferior_created); | |
1456 | ||
cc5f0d61 UW |
1457 | /* Attach to observers to track __spe_current_active_context. */ |
1458 | observer_attach_inferior_created (ppc_linux_spe_context_inferior_created); | |
1459 | observer_attach_solib_loaded (ppc_linux_spe_context_solib_loaded); | |
1460 | observer_attach_solib_unloaded (ppc_linux_spe_context_solib_unloaded); | |
1461 | ||
7284e1be UW |
1462 | /* Initialize the Linux target descriptions. */ |
1463 | initialize_tdesc_powerpc_32l (); | |
1464 | initialize_tdesc_powerpc_altivec32l (); | |
f4d9bade | 1465 | initialize_tdesc_powerpc_cell32l (); |
604c2f83 | 1466 | initialize_tdesc_powerpc_vsx32l (); |
69abc51c TJB |
1467 | initialize_tdesc_powerpc_isa205_32l (); |
1468 | initialize_tdesc_powerpc_isa205_altivec32l (); | |
1469 | initialize_tdesc_powerpc_isa205_vsx32l (); | |
7284e1be UW |
1470 | initialize_tdesc_powerpc_64l (); |
1471 | initialize_tdesc_powerpc_altivec64l (); | |
f4d9bade | 1472 | initialize_tdesc_powerpc_cell64l (); |
604c2f83 | 1473 | initialize_tdesc_powerpc_vsx64l (); |
69abc51c TJB |
1474 | initialize_tdesc_powerpc_isa205_64l (); |
1475 | initialize_tdesc_powerpc_isa205_altivec64l (); | |
1476 | initialize_tdesc_powerpc_isa205_vsx64l (); | |
7284e1be | 1477 | initialize_tdesc_powerpc_e500l (); |
7b112f9c | 1478 | } |