1 /* Target-dependent code for GDB, the GNU debugger.
3 Copyright (C) 1986-2013 Free Software Foundation, Inc.
5 This file is part of GDB.
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 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
33 #include "solib-svr4.h"
34 #include "solib-spu.h"
38 #include "ppc64-tdep.h"
39 #include "ppc-linux-tdep.h"
40 #include "glibc-tdep.h"
41 #include "trad-frame.h"
42 #include "frame-unwind.h"
43 #include "tramp-frame.h"
46 #include "elf/common.h"
47 #include "exceptions.h"
48 #include "arch-utils.h"
50 #include "xml-syscall.h"
51 #include "linux-tdep.h"
53 #include "stap-probe.h"
56 #include "cli/cli-utils.h"
57 #include "parser-defs.h"
58 #include "user-regs.h"
61 #include "features/rs6000/powerpc-32l.c"
62 #include "features/rs6000/powerpc-altivec32l.c"
63 #include "features/rs6000/powerpc-cell32l.c"
64 #include "features/rs6000/powerpc-vsx32l.c"
65 #include "features/rs6000/powerpc-isa205-32l.c"
66 #include "features/rs6000/powerpc-isa205-altivec32l.c"
67 #include "features/rs6000/powerpc-isa205-vsx32l.c"
68 #include "features/rs6000/powerpc-64l.c"
69 #include "features/rs6000/powerpc-altivec64l.c"
70 #include "features/rs6000/powerpc-cell64l.c"
71 #include "features/rs6000/powerpc-vsx64l.c"
72 #include "features/rs6000/powerpc-isa205-64l.c"
73 #include "features/rs6000/powerpc-isa205-altivec64l.c"
74 #include "features/rs6000/powerpc-isa205-vsx64l.c"
75 #include "features/rs6000/powerpc-e500l.c"
77 /* Shared library operations for PowerPC-Linux. */
78 static struct target_so_ops powerpc_so_ops
;
80 /* The syscall's XML filename for PPC and PPC64. */
81 #define XML_SYSCALL_FILENAME_PPC "syscalls/ppc-linux.xml"
82 #define XML_SYSCALL_FILENAME_PPC64 "syscalls/ppc64-linux.xml"
84 /* ppc_linux_memory_remove_breakpoints attempts to remove a breakpoint
85 in much the same fashion as memory_remove_breakpoint in mem-break.c,
86 but is careful not to write back the previous contents if the code
87 in question has changed in between inserting the breakpoint and
90 Here is the problem that we're trying to solve...
92 Once upon a time, before introducing this function to remove
93 breakpoints from the inferior, setting a breakpoint on a shared
94 library function prior to running the program would not work
95 properly. In order to understand the problem, it is first
96 necessary to understand a little bit about dynamic linking on
99 A call to a shared library function is accomplished via a bl
100 (branch-and-link) instruction whose branch target is an entry
101 in the procedure linkage table (PLT). The PLT in the object
102 file is uninitialized. To gdb, prior to running the program, the
103 entries in the PLT are all zeros.
105 Once the program starts running, the shared libraries are loaded
106 and the procedure linkage table is initialized, but the entries in
107 the table are not (necessarily) resolved. Once a function is
108 actually called, the code in the PLT is hit and the function is
109 resolved. In order to better illustrate this, an example is in
110 order; the following example is from the gdb testsuite.
112 We start the program shmain.
114 [kev@arroyo testsuite]$ ../gdb gdb.base/shmain
117 We place two breakpoints, one on shr1 and the other on main.
120 Breakpoint 1 at 0x100409d4
122 Breakpoint 2 at 0x100006a0: file gdb.base/shmain.c, line 44.
124 Examine the instruction (and the immediatly following instruction)
125 upon which the breakpoint was placed. Note that the PLT entry
126 for shr1 contains zeros.
128 (gdb) x/2i 0x100409d4
129 0x100409d4 <shr1>: .long 0x0
130 0x100409d8 <shr1+4>: .long 0x0
135 Starting program: gdb.base/shmain
136 Breakpoint 1 at 0xffaf790: file gdb.base/shr1.c, line 19.
138 Breakpoint 2, main ()
139 at gdb.base/shmain.c:44
142 Examine the PLT again. Note that the loading of the shared
143 library has initialized the PLT to code which loads a constant
144 (which I think is an index into the GOT) into r11 and then
145 branchs a short distance to the code which actually does the
148 (gdb) x/2i 0x100409d4
149 0x100409d4 <shr1>: li r11,4
150 0x100409d8 <shr1+4>: b 0x10040984 <sg+4>
154 Breakpoint 1, shr1 (x=1)
155 at gdb.base/shr1.c:19
158 Now we've hit the breakpoint at shr1. (The breakpoint was
159 reset from the PLT entry to the actual shr1 function after the
160 shared library was loaded.) Note that the PLT entry has been
161 resolved to contain a branch that takes us directly to shr1.
162 (The real one, not the PLT entry.)
164 (gdb) x/2i 0x100409d4
165 0x100409d4 <shr1>: b 0xffaf76c <shr1>
166 0x100409d8 <shr1+4>: b 0x10040984 <sg+4>
168 The thing to note here is that the PLT entry for shr1 has been
171 Now the problem should be obvious. GDB places a breakpoint (a
172 trap instruction) on the zero value of the PLT entry for shr1.
173 Later on, after the shared library had been loaded and the PLT
174 initialized, GDB gets a signal indicating this fact and attempts
175 (as it always does when it stops) to remove all the breakpoints.
177 The breakpoint removal was causing the former contents (a zero
178 word) to be written back to the now initialized PLT entry thus
179 destroying a portion of the initialization that had occurred only a
180 short time ago. When execution continued, the zero word would be
181 executed as an instruction an illegal instruction trap was
182 generated instead. (0 is not a legal instruction.)
184 The fix for this problem was fairly straightforward. The function
185 memory_remove_breakpoint from mem-break.c was copied to this file,
186 modified slightly, and renamed to ppc_linux_memory_remove_breakpoint.
187 In tm-linux.h, MEMORY_REMOVE_BREAKPOINT is defined to call this new
190 The differences between ppc_linux_memory_remove_breakpoint () and
191 memory_remove_breakpoint () are minor. All that the former does
192 that the latter does not is check to make sure that the breakpoint
193 location actually contains a breakpoint (trap instruction) prior
194 to attempting to write back the old contents. If it does contain
195 a trap instruction, we allow the old contents to be written back.
196 Otherwise, we silently do nothing.
198 The big question is whether memory_remove_breakpoint () should be
199 changed to have the same functionality. The downside is that more
200 traffic is generated for remote targets since we'll have an extra
201 fetch of a memory word each time a breakpoint is removed.
203 For the time being, we'll leave this self-modifying-code-friendly
204 version in ppc-linux-tdep.c, but it ought to be migrated somewhere
205 else in the event that some other platform has similar needs with
206 regard to removing breakpoints in some potentially self modifying
209 ppc_linux_memory_remove_breakpoint (struct gdbarch
*gdbarch
,
210 struct bp_target_info
*bp_tgt
)
212 CORE_ADDR addr
= bp_tgt
->placed_address
;
213 const unsigned char *bp
;
216 gdb_byte old_contents
[BREAKPOINT_MAX
];
217 struct cleanup
*cleanup
;
219 /* Determine appropriate breakpoint contents and size for this address. */
220 bp
= gdbarch_breakpoint_from_pc (gdbarch
, &addr
, &bplen
);
222 error (_("Software breakpoints not implemented for this target."));
224 /* Make sure we see the memory breakpoints. */
225 cleanup
= make_show_memory_breakpoints_cleanup (1);
226 val
= target_read_memory (addr
, old_contents
, bplen
);
228 /* If our breakpoint is no longer at the address, this means that the
229 program modified the code on us, so it is wrong to put back the
231 if (val
== 0 && memcmp (bp
, old_contents
, bplen
) == 0)
232 val
= target_write_raw_memory (addr
, bp_tgt
->shadow_contents
, bplen
);
234 do_cleanups (cleanup
);
238 /* For historic reasons, PPC 32 GNU/Linux follows PowerOpen rather
239 than the 32 bit SYSV R4 ABI structure return convention - all
240 structures, no matter their size, are put in memory. Vectors,
241 which were added later, do get returned in a register though. */
243 static enum return_value_convention
244 ppc_linux_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
245 struct type
*valtype
, struct regcache
*regcache
,
246 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
248 if ((TYPE_CODE (valtype
) == TYPE_CODE_STRUCT
249 || TYPE_CODE (valtype
) == TYPE_CODE_UNION
)
250 && !((TYPE_LENGTH (valtype
) == 16 || TYPE_LENGTH (valtype
) == 8)
251 && TYPE_VECTOR (valtype
)))
252 return RETURN_VALUE_STRUCT_CONVENTION
;
254 return ppc_sysv_abi_return_value (gdbarch
, function
, valtype
, regcache
,
258 static struct core_regset_section ppc_linux_vsx_regset_sections
[] =
260 { ".reg", 48 * 4, "general-purpose" },
261 { ".reg2", 264, "floating-point" },
262 { ".reg-ppc-vmx", 544, "ppc Altivec" },
263 { ".reg-ppc-vsx", 256, "POWER7 VSX" },
267 static struct core_regset_section ppc_linux_vmx_regset_sections
[] =
269 { ".reg", 48 * 4, "general-purpose" },
270 { ".reg2", 264, "floating-point" },
271 { ".reg-ppc-vmx", 544, "ppc Altivec" },
275 static struct core_regset_section ppc_linux_fp_regset_sections
[] =
277 { ".reg", 48 * 4, "general-purpose" },
278 { ".reg2", 264, "floating-point" },
282 static struct core_regset_section ppc64_linux_vsx_regset_sections
[] =
284 { ".reg", 48 * 8, "general-purpose" },
285 { ".reg2", 264, "floating-point" },
286 { ".reg-ppc-vmx", 544, "ppc Altivec" },
287 { ".reg-ppc-vsx", 256, "POWER7 VSX" },
291 static struct core_regset_section ppc64_linux_vmx_regset_sections
[] =
293 { ".reg", 48 * 8, "general-purpose" },
294 { ".reg2", 264, "floating-point" },
295 { ".reg-ppc-vmx", 544, "ppc Altivec" },
299 static struct core_regset_section ppc64_linux_fp_regset_sections
[] =
301 { ".reg", 48 * 8, "general-purpose" },
302 { ".reg2", 264, "floating-point" },
306 /* PLT stub in executable. */
307 static struct ppc_insn_pattern powerpc32_plt_stub
[] =
309 { 0xffff0000, 0x3d600000, 0 }, /* lis r11, xxxx */
310 { 0xffff0000, 0x816b0000, 0 }, /* lwz r11, xxxx(r11) */
311 { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */
312 { 0xffffffff, 0x4e800420, 0 }, /* bctr */
316 /* PLT stub in shared library. */
317 static struct ppc_insn_pattern powerpc32_plt_stub_so
[] =
319 { 0xffff0000, 0x817e0000, 0 }, /* lwz r11, xxxx(r30) */
320 { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */
321 { 0xffffffff, 0x4e800420, 0 }, /* bctr */
322 { 0xffffffff, 0x60000000, 0 }, /* nop */
325 #define POWERPC32_PLT_STUB_LEN ARRAY_SIZE (powerpc32_plt_stub)
327 /* Check if PC is in PLT stub. For non-secure PLT, stub is in .plt
328 section. For secure PLT, stub is in .text and we need to check
329 instruction patterns. */
332 powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc
)
334 struct minimal_symbol
*sym
;
336 /* Check whether PC is in the dynamic linker. This also checks
337 whether it is in the .plt section, used by non-PIC executables. */
338 if (svr4_in_dynsym_resolve_code (pc
))
341 /* Check if we are in the resolver. */
342 sym
= lookup_minimal_symbol_by_pc (pc
);
344 && (strcmp (SYMBOL_LINKAGE_NAME (sym
), "__glink") == 0
345 || strcmp (SYMBOL_LINKAGE_NAME (sym
), "__glink_PLTresolve") == 0))
351 /* Follow PLT stub to actual routine. */
354 ppc_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
356 int insnbuf
[POWERPC32_PLT_STUB_LEN
];
357 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
358 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
359 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
360 CORE_ADDR target
= 0;
362 if (ppc_insns_match_pattern (pc
, powerpc32_plt_stub
, insnbuf
))
367 Branch target is in r11. */
369 target
= (ppc_insn_d_field (insnbuf
[0]) << 16)
370 | ppc_insn_d_field (insnbuf
[1]);
371 target
= read_memory_unsigned_integer (target
, 4, byte_order
);
374 if (ppc_insns_match_pattern (pc
, powerpc32_plt_stub_so
, insnbuf
))
378 Branch target is in r11. */
380 target
= get_frame_register_unsigned (frame
, tdep
->ppc_gp0_regnum
+ 30)
381 + ppc_insn_d_field (insnbuf
[0]);
382 target
= read_memory_unsigned_integer (target
, 4, byte_order
);
388 /* Wrappers to handle Linux-only registers. */
391 ppc_linux_supply_gregset (const struct regset
*regset
,
392 struct regcache
*regcache
,
393 int regnum
, const void *gregs
, size_t len
)
395 const struct ppc_reg_offsets
*offsets
= regset
->descr
;
397 ppc_supply_gregset (regset
, regcache
, regnum
, gregs
, len
);
399 if (ppc_linux_trap_reg_p (get_regcache_arch (regcache
)))
401 /* "orig_r3" is stored 2 slots after "pc". */
402 if (regnum
== -1 || regnum
== PPC_ORIG_R3_REGNUM
)
403 ppc_supply_reg (regcache
, PPC_ORIG_R3_REGNUM
, gregs
,
404 offsets
->pc_offset
+ 2 * offsets
->gpr_size
,
407 /* "trap" is stored 8 slots after "pc". */
408 if (regnum
== -1 || regnum
== PPC_TRAP_REGNUM
)
409 ppc_supply_reg (regcache
, PPC_TRAP_REGNUM
, gregs
,
410 offsets
->pc_offset
+ 8 * offsets
->gpr_size
,
416 ppc_linux_collect_gregset (const struct regset
*regset
,
417 const struct regcache
*regcache
,
418 int regnum
, void *gregs
, size_t len
)
420 const struct ppc_reg_offsets
*offsets
= regset
->descr
;
422 /* Clear areas in the linux gregset not written elsewhere. */
424 memset (gregs
, 0, len
);
426 ppc_collect_gregset (regset
, regcache
, regnum
, gregs
, len
);
428 if (ppc_linux_trap_reg_p (get_regcache_arch (regcache
)))
430 /* "orig_r3" is stored 2 slots after "pc". */
431 if (regnum
== -1 || regnum
== PPC_ORIG_R3_REGNUM
)
432 ppc_collect_reg (regcache
, PPC_ORIG_R3_REGNUM
, gregs
,
433 offsets
->pc_offset
+ 2 * offsets
->gpr_size
,
436 /* "trap" is stored 8 slots after "pc". */
437 if (regnum
== -1 || regnum
== PPC_TRAP_REGNUM
)
438 ppc_collect_reg (regcache
, PPC_TRAP_REGNUM
, gregs
,
439 offsets
->pc_offset
+ 8 * offsets
->gpr_size
,
444 /* Regset descriptions. */
445 static const struct ppc_reg_offsets ppc32_linux_reg_offsets
=
447 /* General-purpose registers. */
448 /* .r0_offset = */ 0,
451 /* .pc_offset = */ 128,
452 /* .ps_offset = */ 132,
453 /* .cr_offset = */ 152,
454 /* .lr_offset = */ 144,
455 /* .ctr_offset = */ 140,
456 /* .xer_offset = */ 148,
457 /* .mq_offset = */ 156,
459 /* Floating-point registers. */
460 /* .f0_offset = */ 0,
461 /* .fpscr_offset = */ 256,
462 /* .fpscr_size = */ 8,
464 /* AltiVec registers. */
465 /* .vr0_offset = */ 0,
466 /* .vscr_offset = */ 512 + 12,
467 /* .vrsave_offset = */ 528
470 static const struct ppc_reg_offsets ppc64_linux_reg_offsets
=
472 /* General-purpose registers. */
473 /* .r0_offset = */ 0,
476 /* .pc_offset = */ 256,
477 /* .ps_offset = */ 264,
478 /* .cr_offset = */ 304,
479 /* .lr_offset = */ 288,
480 /* .ctr_offset = */ 280,
481 /* .xer_offset = */ 296,
482 /* .mq_offset = */ 312,
484 /* Floating-point registers. */
485 /* .f0_offset = */ 0,
486 /* .fpscr_offset = */ 256,
487 /* .fpscr_size = */ 8,
489 /* AltiVec registers. */
490 /* .vr0_offset = */ 0,
491 /* .vscr_offset = */ 512 + 12,
492 /* .vrsave_offset = */ 528
495 static const struct regset ppc32_linux_gregset
= {
496 &ppc32_linux_reg_offsets
,
497 ppc_linux_supply_gregset
,
498 ppc_linux_collect_gregset
,
502 static const struct regset ppc64_linux_gregset
= {
503 &ppc64_linux_reg_offsets
,
504 ppc_linux_supply_gregset
,
505 ppc_linux_collect_gregset
,
509 static const struct regset ppc32_linux_fpregset
= {
510 &ppc32_linux_reg_offsets
,
512 ppc_collect_fpregset
,
516 static const struct regset ppc32_linux_vrregset
= {
517 &ppc32_linux_reg_offsets
,
519 ppc_collect_vrregset
,
523 static const struct regset ppc32_linux_vsxregset
= {
524 &ppc32_linux_reg_offsets
,
525 ppc_supply_vsxregset
,
526 ppc_collect_vsxregset
,
530 const struct regset
*
531 ppc_linux_gregset (int wordsize
)
533 return wordsize
== 8 ? &ppc64_linux_gregset
: &ppc32_linux_gregset
;
536 const struct regset
*
537 ppc_linux_fpregset (void)
539 return &ppc32_linux_fpregset
;
542 static const struct regset
*
543 ppc_linux_regset_from_core_section (struct gdbarch
*core_arch
,
544 const char *sect_name
, size_t sect_size
)
546 struct gdbarch_tdep
*tdep
= gdbarch_tdep (core_arch
);
547 if (strcmp (sect_name
, ".reg") == 0)
549 if (tdep
->wordsize
== 4)
550 return &ppc32_linux_gregset
;
552 return &ppc64_linux_gregset
;
554 if (strcmp (sect_name
, ".reg2") == 0)
555 return &ppc32_linux_fpregset
;
556 if (strcmp (sect_name
, ".reg-ppc-vmx") == 0)
557 return &ppc32_linux_vrregset
;
558 if (strcmp (sect_name
, ".reg-ppc-vsx") == 0)
559 return &ppc32_linux_vsxregset
;
564 ppc_linux_sigtramp_cache (struct frame_info
*this_frame
,
565 struct trad_frame_cache
*this_cache
,
566 CORE_ADDR func
, LONGEST offset
,
574 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
575 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
576 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
578 base
= get_frame_register_unsigned (this_frame
,
579 gdbarch_sp_regnum (gdbarch
));
580 if (bias
> 0 && get_frame_pc (this_frame
) != func
)
581 /* See below, some signal trampolines increment the stack as their
582 first instruction, need to compensate for that. */
585 /* Find the address of the register buffer pointer. */
586 regs
= base
+ offset
;
587 /* Use that to find the address of the corresponding register
589 gpregs
= read_memory_unsigned_integer (regs
, tdep
->wordsize
, byte_order
);
590 fpregs
= gpregs
+ 48 * tdep
->wordsize
;
592 /* General purpose. */
593 for (i
= 0; i
< 32; i
++)
595 int regnum
= i
+ tdep
->ppc_gp0_regnum
;
596 trad_frame_set_reg_addr (this_cache
,
597 regnum
, gpregs
+ i
* tdep
->wordsize
);
599 trad_frame_set_reg_addr (this_cache
,
600 gdbarch_pc_regnum (gdbarch
),
601 gpregs
+ 32 * tdep
->wordsize
);
602 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_ctr_regnum
,
603 gpregs
+ 35 * tdep
->wordsize
);
604 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_lr_regnum
,
605 gpregs
+ 36 * tdep
->wordsize
);
606 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_xer_regnum
,
607 gpregs
+ 37 * tdep
->wordsize
);
608 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_cr_regnum
,
609 gpregs
+ 38 * tdep
->wordsize
);
611 if (ppc_linux_trap_reg_p (gdbarch
))
613 trad_frame_set_reg_addr (this_cache
, PPC_ORIG_R3_REGNUM
,
614 gpregs
+ 34 * tdep
->wordsize
);
615 trad_frame_set_reg_addr (this_cache
, PPC_TRAP_REGNUM
,
616 gpregs
+ 40 * tdep
->wordsize
);
619 if (ppc_floating_point_unit_p (gdbarch
))
621 /* Floating point registers. */
622 for (i
= 0; i
< 32; i
++)
624 int regnum
= i
+ gdbarch_fp0_regnum (gdbarch
);
625 trad_frame_set_reg_addr (this_cache
, regnum
,
626 fpregs
+ i
* tdep
->wordsize
);
628 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_fpscr_regnum
,
629 fpregs
+ 32 * tdep
->wordsize
);
631 trad_frame_set_id (this_cache
, frame_id_build (base
, func
));
635 ppc32_linux_sigaction_cache_init (const struct tramp_frame
*self
,
636 struct frame_info
*this_frame
,
637 struct trad_frame_cache
*this_cache
,
640 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
641 0xd0 /* Offset to ucontext_t. */
642 + 0x30 /* Offset to .reg. */,
647 ppc64_linux_sigaction_cache_init (const struct tramp_frame
*self
,
648 struct frame_info
*this_frame
,
649 struct trad_frame_cache
*this_cache
,
652 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
653 0x80 /* Offset to ucontext_t. */
654 + 0xe0 /* Offset to .reg. */,
659 ppc32_linux_sighandler_cache_init (const struct tramp_frame
*self
,
660 struct frame_info
*this_frame
,
661 struct trad_frame_cache
*this_cache
,
664 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
665 0x40 /* Offset to ucontext_t. */
666 + 0x1c /* Offset to .reg. */,
671 ppc64_linux_sighandler_cache_init (const struct tramp_frame
*self
,
672 struct frame_info
*this_frame
,
673 struct trad_frame_cache
*this_cache
,
676 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
677 0x80 /* Offset to struct sigcontext. */
678 + 0x38 /* Offset to .reg. */,
682 static struct tramp_frame ppc32_linux_sigaction_tramp_frame
= {
686 { 0x380000ac, -1 }, /* li r0, 172 */
687 { 0x44000002, -1 }, /* sc */
688 { TRAMP_SENTINEL_INSN
},
690 ppc32_linux_sigaction_cache_init
692 static struct tramp_frame ppc64_linux_sigaction_tramp_frame
= {
696 { 0x38210080, -1 }, /* addi r1,r1,128 */
697 { 0x380000ac, -1 }, /* li r0, 172 */
698 { 0x44000002, -1 }, /* sc */
699 { TRAMP_SENTINEL_INSN
},
701 ppc64_linux_sigaction_cache_init
703 static struct tramp_frame ppc32_linux_sighandler_tramp_frame
= {
707 { 0x38000077, -1 }, /* li r0,119 */
708 { 0x44000002, -1 }, /* sc */
709 { TRAMP_SENTINEL_INSN
},
711 ppc32_linux_sighandler_cache_init
713 static struct tramp_frame ppc64_linux_sighandler_tramp_frame
= {
717 { 0x38210080, -1 }, /* addi r1,r1,128 */
718 { 0x38000077, -1 }, /* li r0,119 */
719 { 0x44000002, -1 }, /* sc */
720 { TRAMP_SENTINEL_INSN
},
722 ppc64_linux_sighandler_cache_init
726 /* Address to use for displaced stepping. When debugging a stand-alone
727 SPU executable, entry_point_address () will point to an SPU local-store
728 address and is thus not usable as displaced stepping location. We use
729 the auxiliary vector to determine the PowerPC-side entry point address
732 static CORE_ADDR ppc_linux_entry_point_addr
= 0;
735 ppc_linux_inferior_created (struct target_ops
*target
, int from_tty
)
737 ppc_linux_entry_point_addr
= 0;
741 ppc_linux_displaced_step_location (struct gdbarch
*gdbarch
)
743 if (ppc_linux_entry_point_addr
== 0)
747 /* Determine entry point from target auxiliary vector. */
748 if (target_auxv_search (¤t_target
, AT_ENTRY
, &addr
) <= 0)
749 error (_("Cannot find AT_ENTRY auxiliary vector entry."));
751 /* Make certain that the address points at real code, and not a
752 function descriptor. */
753 addr
= gdbarch_convert_from_func_ptr_addr (gdbarch
, addr
,
756 /* Inferior calls also use the entry point as a breakpoint location.
757 We don't want displaced stepping to interfere with those
758 breakpoints, so leave space. */
759 ppc_linux_entry_point_addr
= addr
+ 2 * PPC_INSN_SIZE
;
762 return ppc_linux_entry_point_addr
;
766 /* Return 1 if PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM are usable. */
768 ppc_linux_trap_reg_p (struct gdbarch
*gdbarch
)
770 /* If we do not have a target description with registers, then
771 the special registers will not be included in the register set. */
772 if (!tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
775 /* If we do, then it is safe to check the size. */
776 return register_size (gdbarch
, PPC_ORIG_R3_REGNUM
) > 0
777 && register_size (gdbarch
, PPC_TRAP_REGNUM
) > 0;
780 /* Return the current system call's number present in the
781 r0 register. When the function fails, it returns -1. */
783 ppc_linux_get_syscall_number (struct gdbarch
*gdbarch
,
786 struct regcache
*regcache
= get_thread_regcache (ptid
);
787 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
788 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
789 struct cleanup
*cleanbuf
;
790 /* The content of a register */
795 /* Make sure we're in a 32- or 64-bit machine */
796 gdb_assert (tdep
->wordsize
== 4 || tdep
->wordsize
== 8);
798 buf
= (gdb_byte
*) xmalloc (tdep
->wordsize
* sizeof (gdb_byte
));
800 cleanbuf
= make_cleanup (xfree
, buf
);
802 /* Getting the system call number from the register.
803 When dealing with PowerPC architecture, this information
804 is stored at 0th register. */
805 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
, buf
);
807 ret
= extract_signed_integer (buf
, tdep
->wordsize
, byte_order
);
808 do_cleanups (cleanbuf
);
814 ppc_linux_write_pc (struct regcache
*regcache
, CORE_ADDR pc
)
816 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
818 regcache_cooked_write_unsigned (regcache
, gdbarch_pc_regnum (gdbarch
), pc
);
820 /* Set special TRAP register to -1 to prevent the kernel from
821 messing with the PC we just installed, if we happen to be
822 within an interrupted system call that the kernel wants to
825 Note that after we return from the dummy call, the TRAP and
826 ORIG_R3 registers will be automatically restored, and the
827 kernel continues to restart the system call at this point. */
828 if (ppc_linux_trap_reg_p (gdbarch
))
829 regcache_cooked_write_unsigned (regcache
, PPC_TRAP_REGNUM
, -1);
833 ppc_linux_spu_section (bfd
*abfd
, asection
*asect
, void *user_data
)
835 return strncmp (bfd_section_name (abfd
, asect
), "SPU/", 4) == 0;
838 static const struct target_desc
*
839 ppc_linux_core_read_description (struct gdbarch
*gdbarch
,
840 struct target_ops
*target
,
843 asection
*cell
= bfd_sections_find_if (abfd
, ppc_linux_spu_section
, NULL
);
844 asection
*altivec
= bfd_get_section_by_name (abfd
, ".reg-ppc-vmx");
845 asection
*vsx
= bfd_get_section_by_name (abfd
, ".reg-ppc-vsx");
846 asection
*section
= bfd_get_section_by_name (abfd
, ".reg");
850 switch (bfd_section_size (abfd
, section
))
854 return tdesc_powerpc_cell32l
;
856 return tdesc_powerpc_vsx32l
;
858 return tdesc_powerpc_altivec32l
;
860 return tdesc_powerpc_32l
;
864 return tdesc_powerpc_cell64l
;
866 return tdesc_powerpc_vsx64l
;
868 return tdesc_powerpc_altivec64l
;
870 return tdesc_powerpc_64l
;
877 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
881 ppc_stap_is_single_operand (struct gdbarch
*gdbarch
, const char *s
)
883 return (*s
== 'i' /* Literal number. */
884 || (isdigit (*s
) && s
[1] == '('
885 && isdigit (s
[2])) /* Displacement. */
886 || (*s
== '(' && isdigit (s
[1])) /* Register indirection. */
887 || isdigit (*s
)); /* Register value. */
890 /* Implementation of `gdbarch_stap_parse_special_token', as defined in
894 ppc_stap_parse_special_token (struct gdbarch
*gdbarch
,
895 struct stap_parse_info
*p
)
897 if (isdigit (*p
->arg
))
899 /* This temporary pointer is needed because we have to do a lookahead.
900 We could be dealing with a register displacement, and in such case
901 we would not need to do anything. */
902 const char *s
= p
->arg
;
912 /* It is a register displacement indeed. Returning 0 means we are
913 deferring the treatment of this case to the generic parser. */
918 regname
= alloca (len
+ 2);
921 strncpy (regname
+ 1, p
->arg
, len
);
925 if (user_reg_map_name_to_regnum (gdbarch
, regname
, len
) == -1)
926 error (_("Invalid register name `%s' on expression `%s'."),
927 regname
, p
->saved_arg
);
929 write_exp_elt_opcode (OP_REGISTER
);
932 write_exp_string (str
);
933 write_exp_elt_opcode (OP_REGISTER
);
939 /* All the other tokens should be handled correctly by the generic
947 /* Cell/B.E. active SPE context tracking support. */
949 static struct objfile
*spe_context_objfile
= NULL
;
950 static CORE_ADDR spe_context_lm_addr
= 0;
951 static CORE_ADDR spe_context_offset
= 0;
953 static ptid_t spe_context_cache_ptid
;
954 static CORE_ADDR spe_context_cache_address
;
956 /* Hook into inferior_created, solib_loaded, and solib_unloaded observers
957 to track whether we've loaded a version of libspe2 (as static or dynamic
958 library) that provides the __spe_current_active_context variable. */
960 ppc_linux_spe_context_lookup (struct objfile
*objfile
)
962 struct minimal_symbol
*sym
;
966 spe_context_objfile
= NULL
;
967 spe_context_lm_addr
= 0;
968 spe_context_offset
= 0;
969 spe_context_cache_ptid
= minus_one_ptid
;
970 spe_context_cache_address
= 0;
974 sym
= lookup_minimal_symbol ("__spe_current_active_context", NULL
, objfile
);
977 spe_context_objfile
= objfile
;
978 spe_context_lm_addr
= svr4_fetch_objfile_link_map (objfile
);
979 spe_context_offset
= SYMBOL_VALUE_ADDRESS (sym
);
980 spe_context_cache_ptid
= minus_one_ptid
;
981 spe_context_cache_address
= 0;
987 ppc_linux_spe_context_inferior_created (struct target_ops
*t
, int from_tty
)
989 struct objfile
*objfile
;
991 ppc_linux_spe_context_lookup (NULL
);
992 ALL_OBJFILES (objfile
)
993 ppc_linux_spe_context_lookup (objfile
);
997 ppc_linux_spe_context_solib_loaded (struct so_list
*so
)
999 if (strstr (so
->so_original_name
, "/libspe") != NULL
)
1001 solib_read_symbols (so
, 0);
1002 ppc_linux_spe_context_lookup (so
->objfile
);
1007 ppc_linux_spe_context_solib_unloaded (struct so_list
*so
)
1009 if (so
->objfile
== spe_context_objfile
)
1010 ppc_linux_spe_context_lookup (NULL
);
1013 /* Retrieve contents of the N'th element in the current thread's
1014 linked SPE context list into ID and NPC. Return the address of
1015 said context element, or 0 if not found. */
1017 ppc_linux_spe_context (int wordsize
, enum bfd_endian byte_order
,
1018 int n
, int *id
, unsigned int *npc
)
1020 CORE_ADDR spe_context
= 0;
1024 /* Quick exit if we have not found __spe_current_active_context. */
1025 if (!spe_context_objfile
)
1028 /* Look up cached address of thread-local variable. */
1029 if (!ptid_equal (spe_context_cache_ptid
, inferior_ptid
))
1031 struct target_ops
*target
= ¤t_target
;
1032 volatile struct gdb_exception ex
;
1034 while (target
&& !target
->to_get_thread_local_address
)
1035 target
= find_target_beneath (target
);
1039 TRY_CATCH (ex
, RETURN_MASK_ERROR
)
1041 /* We do not call target_translate_tls_address here, because
1042 svr4_fetch_objfile_link_map may invalidate the frame chain,
1043 which must not do while inside a frame sniffer.
1045 Instead, we have cached the lm_addr value, and use that to
1046 directly call the target's to_get_thread_local_address. */
1047 spe_context_cache_address
1048 = target
->to_get_thread_local_address (target
, inferior_ptid
,
1049 spe_context_lm_addr
,
1050 spe_context_offset
);
1051 spe_context_cache_ptid
= inferior_ptid
;
1058 /* Read variable value. */
1059 if (target_read_memory (spe_context_cache_address
, buf
, wordsize
) == 0)
1060 spe_context
= extract_unsigned_integer (buf
, wordsize
, byte_order
);
1062 /* Cyle through to N'th linked list element. */
1063 for (i
= 0; i
< n
&& spe_context
; i
++)
1064 if (target_read_memory (spe_context
+ align_up (12, wordsize
),
1065 buf
, wordsize
) == 0)
1066 spe_context
= extract_unsigned_integer (buf
, wordsize
, byte_order
);
1070 /* Read current context. */
1072 && target_read_memory (spe_context
, buf
, 12) != 0)
1075 /* Extract data elements. */
1079 *id
= extract_signed_integer (buf
, 4, byte_order
);
1081 *npc
= extract_unsigned_integer (buf
+ 4, 4, byte_order
);
1088 /* Cell/B.E. cross-architecture unwinder support. */
1090 struct ppu2spu_cache
1092 struct frame_id frame_id
;
1093 struct regcache
*regcache
;
1096 static struct gdbarch
*
1097 ppu2spu_prev_arch (struct frame_info
*this_frame
, void **this_cache
)
1099 struct ppu2spu_cache
*cache
= *this_cache
;
1100 return get_regcache_arch (cache
->regcache
);
1104 ppu2spu_this_id (struct frame_info
*this_frame
,
1105 void **this_cache
, struct frame_id
*this_id
)
1107 struct ppu2spu_cache
*cache
= *this_cache
;
1108 *this_id
= cache
->frame_id
;
1111 static struct value
*
1112 ppu2spu_prev_register (struct frame_info
*this_frame
,
1113 void **this_cache
, int regnum
)
1115 struct ppu2spu_cache
*cache
= *this_cache
;
1116 struct gdbarch
*gdbarch
= get_regcache_arch (cache
->regcache
);
1119 buf
= alloca (register_size (gdbarch
, regnum
));
1121 if (regnum
< gdbarch_num_regs (gdbarch
))
1122 regcache_raw_read (cache
->regcache
, regnum
, buf
);
1124 gdbarch_pseudo_register_read (gdbarch
, cache
->regcache
, regnum
, buf
);
1126 return frame_unwind_got_bytes (this_frame
, regnum
, buf
);
1131 struct gdbarch
*gdbarch
;
1134 gdb_byte gprs
[128*16];
1138 ppu2spu_unwind_register (void *src
, int regnum
, gdb_byte
*buf
)
1140 struct ppu2spu_data
*data
= src
;
1141 enum bfd_endian byte_order
= gdbarch_byte_order (data
->gdbarch
);
1143 if (regnum
>= 0 && regnum
< SPU_NUM_GPRS
)
1144 memcpy (buf
, data
->gprs
+ 16*regnum
, 16);
1145 else if (regnum
== SPU_ID_REGNUM
)
1146 store_unsigned_integer (buf
, 4, byte_order
, data
->id
);
1147 else if (regnum
== SPU_PC_REGNUM
)
1148 store_unsigned_integer (buf
, 4, byte_order
, data
->npc
);
1150 return REG_UNAVAILABLE
;
1156 ppu2spu_sniffer (const struct frame_unwind
*self
,
1157 struct frame_info
*this_frame
, void **this_prologue_cache
)
1159 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1160 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1161 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1162 struct ppu2spu_data data
;
1163 struct frame_info
*fi
;
1164 CORE_ADDR base
, func
, backchain
, spe_context
;
1168 /* Count the number of SPU contexts already in the frame chain. */
1169 for (fi
= get_next_frame (this_frame
); fi
; fi
= get_next_frame (fi
))
1170 if (get_frame_type (fi
) == ARCH_FRAME
1171 && gdbarch_bfd_arch_info (get_frame_arch (fi
))->arch
== bfd_arch_spu
)
1174 base
= get_frame_sp (this_frame
);
1175 func
= get_frame_pc (this_frame
);
1176 if (target_read_memory (base
, buf
, tdep
->wordsize
))
1178 backchain
= extract_unsigned_integer (buf
, tdep
->wordsize
, byte_order
);
1180 spe_context
= ppc_linux_spe_context (tdep
->wordsize
, byte_order
,
1181 n
, &data
.id
, &data
.npc
);
1182 if (spe_context
&& base
<= spe_context
&& spe_context
< backchain
)
1186 /* Find gdbarch for SPU. */
1187 struct gdbarch_info info
;
1188 gdbarch_info_init (&info
);
1189 info
.bfd_arch_info
= bfd_lookup_arch (bfd_arch_spu
, bfd_mach_spu
);
1190 info
.byte_order
= BFD_ENDIAN_BIG
;
1191 info
.osabi
= GDB_OSABI_LINUX
;
1192 info
.tdep_info
= (void *) &data
.id
;
1193 data
.gdbarch
= gdbarch_find_by_info (info
);
1197 xsnprintf (annex
, sizeof annex
, "%d/regs", data
.id
);
1198 if (target_read (¤t_target
, TARGET_OBJECT_SPU
, annex
,
1199 data
.gprs
, 0, sizeof data
.gprs
)
1200 == sizeof data
.gprs
)
1202 struct ppu2spu_cache
*cache
1203 = FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache
);
1205 struct address_space
*aspace
= get_frame_address_space (this_frame
);
1206 struct regcache
*regcache
= regcache_xmalloc (data
.gdbarch
, aspace
);
1207 struct cleanup
*cleanups
= make_cleanup_regcache_xfree (regcache
);
1208 regcache_save (regcache
, ppu2spu_unwind_register
, &data
);
1209 discard_cleanups (cleanups
);
1211 cache
->frame_id
= frame_id_build (base
, func
);
1212 cache
->regcache
= regcache
;
1213 *this_prologue_cache
= cache
;
1222 ppu2spu_dealloc_cache (struct frame_info
*self
, void *this_cache
)
1224 struct ppu2spu_cache
*cache
= this_cache
;
1225 regcache_xfree (cache
->regcache
);
1228 static const struct frame_unwind ppu2spu_unwind
= {
1230 default_frame_unwind_stop_reason
,
1232 ppu2spu_prev_register
,
1235 ppu2spu_dealloc_cache
,
1241 ppc_linux_init_abi (struct gdbarch_info info
,
1242 struct gdbarch
*gdbarch
)
1244 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1245 struct tdesc_arch_data
*tdesc_data
= (void *) info
.tdep_info
;
1247 linux_init_abi (info
, gdbarch
);
1249 /* PPC GNU/Linux uses either 64-bit or 128-bit long doubles; where
1250 128-bit, they are IBM long double, not IEEE quad long double as
1251 in the System V ABI PowerPC Processor Supplement. We can safely
1252 let them default to 128-bit, since the debug info will give the
1253 size of type actually used in each case. */
1254 set_gdbarch_long_double_bit (gdbarch
, 16 * TARGET_CHAR_BIT
);
1255 set_gdbarch_long_double_format (gdbarch
, floatformats_ibm_long_double
);
1257 /* Handle inferior calls during interrupted system calls. */
1258 set_gdbarch_write_pc (gdbarch
, ppc_linux_write_pc
);
1260 /* Get the syscall number from the arch's register. */
1261 set_gdbarch_get_syscall_number (gdbarch
, ppc_linux_get_syscall_number
);
1263 /* SystemTap functions. */
1264 set_gdbarch_stap_integer_prefix (gdbarch
, "i");
1265 set_gdbarch_stap_register_indirection_prefix (gdbarch
, "(");
1266 set_gdbarch_stap_register_indirection_suffix (gdbarch
, ")");
1267 set_gdbarch_stap_gdb_register_prefix (gdbarch
, "r");
1268 set_gdbarch_stap_is_single_operand (gdbarch
, ppc_stap_is_single_operand
);
1269 set_gdbarch_stap_parse_special_token (gdbarch
,
1270 ppc_stap_parse_special_token
);
1272 if (tdep
->wordsize
== 4)
1274 /* Until November 2001, gcc did not comply with the 32 bit SysV
1275 R4 ABI requirement that structures less than or equal to 8
1276 bytes should be returned in registers. Instead GCC was using
1277 the AIX/PowerOpen ABI - everything returned in memory
1278 (well ignoring vectors that is). When this was corrected, it
1279 wasn't fixed for GNU/Linux native platform. Use the
1280 PowerOpen struct convention. */
1281 set_gdbarch_return_value (gdbarch
, ppc_linux_return_value
);
1283 set_gdbarch_memory_remove_breakpoint (gdbarch
,
1284 ppc_linux_memory_remove_breakpoint
);
1286 /* Shared library handling. */
1287 set_gdbarch_skip_trampoline_code (gdbarch
, ppc_skip_trampoline_code
);
1288 set_solib_svr4_fetch_link_map_offsets
1289 (gdbarch
, svr4_ilp32_fetch_link_map_offsets
);
1291 /* Setting the correct XML syscall filename. */
1292 set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC
);
1295 tramp_frame_prepend_unwinder (gdbarch
,
1296 &ppc32_linux_sigaction_tramp_frame
);
1297 tramp_frame_prepend_unwinder (gdbarch
,
1298 &ppc32_linux_sighandler_tramp_frame
);
1300 /* BFD target for core files. */
1301 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_LITTLE
)
1302 set_gdbarch_gcore_bfd_target (gdbarch
, "elf32-powerpcle");
1304 set_gdbarch_gcore_bfd_target (gdbarch
, "elf32-powerpc");
1306 /* Supported register sections. */
1307 if (tdesc_find_feature (info
.target_desc
,
1308 "org.gnu.gdb.power.vsx"))
1309 set_gdbarch_core_regset_sections (gdbarch
,
1310 ppc_linux_vsx_regset_sections
);
1311 else if (tdesc_find_feature (info
.target_desc
,
1312 "org.gnu.gdb.power.altivec"))
1313 set_gdbarch_core_regset_sections (gdbarch
,
1314 ppc_linux_vmx_regset_sections
);
1316 set_gdbarch_core_regset_sections (gdbarch
,
1317 ppc_linux_fp_regset_sections
);
1319 if (powerpc_so_ops
.in_dynsym_resolve_code
== NULL
)
1321 powerpc_so_ops
= svr4_so_ops
;
1322 /* Override dynamic resolve function. */
1323 powerpc_so_ops
.in_dynsym_resolve_code
=
1324 powerpc_linux_in_dynsym_resolve_code
;
1326 set_solib_ops (gdbarch
, &powerpc_so_ops
);
1328 set_gdbarch_skip_solib_resolver (gdbarch
, glibc_skip_solib_resolver
);
1331 if (tdep
->wordsize
== 8)
1333 /* Handle PPC GNU/Linux 64-bit function pointers (which are really
1334 function descriptors). */
1335 set_gdbarch_convert_from_func_ptr_addr
1336 (gdbarch
, ppc64_convert_from_func_ptr_addr
);
1338 /* Shared library handling. */
1339 set_gdbarch_skip_trampoline_code (gdbarch
, ppc64_skip_trampoline_code
);
1340 set_solib_svr4_fetch_link_map_offsets
1341 (gdbarch
, svr4_lp64_fetch_link_map_offsets
);
1343 /* Setting the correct XML syscall filename. */
1344 set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC64
);
1347 tramp_frame_prepend_unwinder (gdbarch
,
1348 &ppc64_linux_sigaction_tramp_frame
);
1349 tramp_frame_prepend_unwinder (gdbarch
,
1350 &ppc64_linux_sighandler_tramp_frame
);
1352 /* BFD target for core files. */
1353 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_LITTLE
)
1354 set_gdbarch_gcore_bfd_target (gdbarch
, "elf64-powerpcle");
1356 set_gdbarch_gcore_bfd_target (gdbarch
, "elf64-powerpc");
1358 /* Supported register sections. */
1359 if (tdesc_find_feature (info
.target_desc
,
1360 "org.gnu.gdb.power.vsx"))
1361 set_gdbarch_core_regset_sections (gdbarch
,
1362 ppc64_linux_vsx_regset_sections
);
1363 else if (tdesc_find_feature (info
.target_desc
,
1364 "org.gnu.gdb.power.altivec"))
1365 set_gdbarch_core_regset_sections (gdbarch
,
1366 ppc64_linux_vmx_regset_sections
);
1368 set_gdbarch_core_regset_sections (gdbarch
,
1369 ppc64_linux_fp_regset_sections
);
1371 set_gdbarch_regset_from_core_section (gdbarch
,
1372 ppc_linux_regset_from_core_section
);
1373 set_gdbarch_core_read_description (gdbarch
, ppc_linux_core_read_description
);
1375 /* Enable TLS support. */
1376 set_gdbarch_fetch_tls_load_module_address (gdbarch
,
1377 svr4_fetch_objfile_link_map
);
1381 const struct tdesc_feature
*feature
;
1383 /* If we have target-described registers, then we can safely
1384 reserve a number for PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM
1385 (whether they are described or not). */
1386 gdb_assert (gdbarch_num_regs (gdbarch
) <= PPC_ORIG_R3_REGNUM
);
1387 set_gdbarch_num_regs (gdbarch
, PPC_TRAP_REGNUM
+ 1);
1389 /* If they are present, then assign them to the reserved number. */
1390 feature
= tdesc_find_feature (info
.target_desc
,
1391 "org.gnu.gdb.power.linux");
1392 if (feature
!= NULL
)
1394 tdesc_numbered_register (feature
, tdesc_data
,
1395 PPC_ORIG_R3_REGNUM
, "orig_r3");
1396 tdesc_numbered_register (feature
, tdesc_data
,
1397 PPC_TRAP_REGNUM
, "trap");
1401 /* Enable Cell/B.E. if supported by the target. */
1402 if (tdesc_compatible_p (info
.target_desc
,
1403 bfd_lookup_arch (bfd_arch_spu
, bfd_mach_spu
)))
1405 /* Cell/B.E. multi-architecture support. */
1406 set_spu_solib_ops (gdbarch
);
1408 /* Cell/B.E. cross-architecture unwinder support. */
1409 frame_unwind_prepend_unwinder (gdbarch
, &ppu2spu_unwind
);
1411 /* The default displaced_step_at_entry_point doesn't work for
1412 SPU stand-alone executables. */
1413 set_gdbarch_displaced_step_location (gdbarch
,
1414 ppc_linux_displaced_step_location
);
1417 set_gdbarch_get_siginfo_type (gdbarch
, linux_get_siginfo_type
);
1420 /* Provide a prototype to silence -Wmissing-prototypes. */
1421 extern initialize_file_ftype _initialize_ppc_linux_tdep
;
1424 _initialize_ppc_linux_tdep (void)
1426 /* Register for all sub-familes of the POWER/PowerPC: 32-bit and
1427 64-bit PowerPC, and the older rs6k. */
1428 gdbarch_register_osabi (bfd_arch_powerpc
, bfd_mach_ppc
, GDB_OSABI_LINUX
,
1429 ppc_linux_init_abi
);
1430 gdbarch_register_osabi (bfd_arch_powerpc
, bfd_mach_ppc64
, GDB_OSABI_LINUX
,
1431 ppc_linux_init_abi
);
1432 gdbarch_register_osabi (bfd_arch_rs6000
, bfd_mach_rs6k
, GDB_OSABI_LINUX
,
1433 ppc_linux_init_abi
);
1435 /* Attach to inferior_created observer. */
1436 observer_attach_inferior_created (ppc_linux_inferior_created
);
1438 /* Attach to observers to track __spe_current_active_context. */
1439 observer_attach_inferior_created (ppc_linux_spe_context_inferior_created
);
1440 observer_attach_solib_loaded (ppc_linux_spe_context_solib_loaded
);
1441 observer_attach_solib_unloaded (ppc_linux_spe_context_solib_unloaded
);
1443 /* Initialize the Linux target descriptions. */
1444 initialize_tdesc_powerpc_32l ();
1445 initialize_tdesc_powerpc_altivec32l ();
1446 initialize_tdesc_powerpc_cell32l ();
1447 initialize_tdesc_powerpc_vsx32l ();
1448 initialize_tdesc_powerpc_isa205_32l ();
1449 initialize_tdesc_powerpc_isa205_altivec32l ();
1450 initialize_tdesc_powerpc_isa205_vsx32l ();
1451 initialize_tdesc_powerpc_64l ();
1452 initialize_tdesc_powerpc_altivec64l ();
1453 initialize_tdesc_powerpc_cell64l ();
1454 initialize_tdesc_powerpc_vsx64l ();
1455 initialize_tdesc_powerpc_isa205_64l ();
1456 initialize_tdesc_powerpc_isa205_altivec64l ();
1457 initialize_tdesc_powerpc_isa205_vsx64l ();
1458 initialize_tdesc_powerpc_e500l ();