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"
60 #include "elf-bfd.h" /* for elfcore_write_* */
62 #include "features/rs6000/powerpc-32l.c"
63 #include "features/rs6000/powerpc-altivec32l.c"
64 #include "features/rs6000/powerpc-cell32l.c"
65 #include "features/rs6000/powerpc-vsx32l.c"
66 #include "features/rs6000/powerpc-isa205-32l.c"
67 #include "features/rs6000/powerpc-isa205-altivec32l.c"
68 #include "features/rs6000/powerpc-isa205-vsx32l.c"
69 #include "features/rs6000/powerpc-64l.c"
70 #include "features/rs6000/powerpc-altivec64l.c"
71 #include "features/rs6000/powerpc-cell64l.c"
72 #include "features/rs6000/powerpc-vsx64l.c"
73 #include "features/rs6000/powerpc-isa205-64l.c"
74 #include "features/rs6000/powerpc-isa205-altivec64l.c"
75 #include "features/rs6000/powerpc-isa205-vsx64l.c"
76 #include "features/rs6000/powerpc-e500l.c"
78 /* Shared library operations for PowerPC-Linux. */
79 static struct target_so_ops powerpc_so_ops
;
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"
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
91 Here is the problem that we're trying to solve...
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
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.
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.
113 We start the program shmain.
115 [kev@arroyo testsuite]$ ../gdb gdb.base/shmain
118 We place two breakpoints, one on shr1 and the other on main.
121 Breakpoint 1 at 0x100409d4
123 Breakpoint 2 at 0x100006a0: file gdb.base/shmain.c, line 44.
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.
129 (gdb) x/2i 0x100409d4
130 0x100409d4 <shr1>: .long 0x0
131 0x100409d8 <shr1+4>: .long 0x0
136 Starting program: gdb.base/shmain
137 Breakpoint 1 at 0xffaf790: file gdb.base/shr1.c, line 19.
139 Breakpoint 2, main ()
140 at gdb.base/shmain.c:44
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
149 (gdb) x/2i 0x100409d4
150 0x100409d4 <shr1>: li r11,4
151 0x100409d8 <shr1+4>: b 0x10040984 <sg+4>
155 Breakpoint 1, shr1 (x=1)
156 at gdb.base/shr1.c:19
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
162 resolved to contain a branch that takes us directly to shr1.
163 (The real one, not the PLT entry.)
165 (gdb) x/2i 0x100409d4
166 0x100409d4 <shr1>: b 0xffaf76c <shr1>
167 0x100409d8 <shr1+4>: b 0x10040984 <sg+4>
169 The thing to note here is that the PLT entry for shr1 has been
172 Now the problem should be obvious. GDB places a breakpoint (a
173 trap instruction) on the zero value of the PLT entry for shr1.
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.
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
182 executed as an instruction an illegal instruction trap was
183 generated instead. (0 is not a legal instruction.)
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
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
196 a trap instruction, we allow the old contents to be written back.
197 Otherwise, we silently do nothing.
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.
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
210 ppc_linux_memory_remove_breakpoint (struct gdbarch
*gdbarch
,
211 struct bp_target_info
*bp_tgt
)
213 CORE_ADDR addr
= bp_tgt
->placed_address
;
214 const unsigned char *bp
;
217 gdb_byte old_contents
[BREAKPOINT_MAX
];
218 struct cleanup
*cleanup
;
220 /* Determine appropriate breakpoint contents and size for this address. */
221 bp
= gdbarch_breakpoint_from_pc (gdbarch
, &addr
, &bplen
);
223 error (_("Software breakpoints not implemented for this target."));
225 /* Make sure we see the memory breakpoints. */
226 cleanup
= make_show_memory_breakpoints_cleanup (1);
227 val
= target_read_memory (addr
, old_contents
, bplen
);
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
232 if (val
== 0 && memcmp (bp
, old_contents
, bplen
) == 0)
233 val
= target_write_raw_memory (addr
, bp_tgt
->shadow_contents
, bplen
);
235 do_cleanups (cleanup
);
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. */
244 static enum return_value_convention
245 ppc_linux_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
246 struct type
*valtype
, struct regcache
*regcache
,
247 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
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
;
255 return ppc_sysv_abi_return_value (gdbarch
, function
, valtype
, regcache
,
259 static struct core_regset_section ppc_linux_vsx_regset_sections
[] =
261 { ".reg", 48 * 4, "general-purpose" },
262 { ".reg2", 264, "floating-point" },
263 { ".reg-ppc-vmx", 544, "ppc Altivec" },
264 { ".reg-ppc-vsx", 256, "POWER7 VSX" },
268 static struct core_regset_section ppc_linux_vmx_regset_sections
[] =
270 { ".reg", 48 * 4, "general-purpose" },
271 { ".reg2", 264, "floating-point" },
272 { ".reg-ppc-vmx", 544, "ppc Altivec" },
276 static struct core_regset_section ppc_linux_fp_regset_sections
[] =
278 { ".reg", 48 * 4, "general-purpose" },
279 { ".reg2", 264, "floating-point" },
283 static struct core_regset_section ppc64_linux_vsx_regset_sections
[] =
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" },
292 static struct core_regset_section ppc64_linux_vmx_regset_sections
[] =
294 { ".reg", 48 * 8, "general-purpose" },
295 { ".reg2", 264, "floating-point" },
296 { ".reg-ppc-vmx", 544, "ppc Altivec" },
300 static struct core_regset_section ppc64_linux_fp_regset_sections
[] =
302 { ".reg", 48 * 8, "general-purpose" },
303 { ".reg2", 264, "floating-point" },
307 /* PLT stub in executable. */
308 static struct ppc_insn_pattern powerpc32_plt_stub
[] =
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 */
317 /* PLT stub in shared library. */
318 static struct ppc_insn_pattern powerpc32_plt_stub_so
[] =
320 { 0xffff0000, 0x817e0000, 0 }, /* lwz r11, xxxx(r30) */
321 { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */
322 { 0xffffffff, 0x4e800420, 0 }, /* bctr */
323 { 0xffffffff, 0x60000000, 0 }, /* nop */
326 #define POWERPC32_PLT_STUB_LEN ARRAY_SIZE (powerpc32_plt_stub)
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. */
333 powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc
)
335 struct minimal_symbol
*sym
;
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
))
342 /* Check if we are in the resolver. */
343 sym
= lookup_minimal_symbol_by_pc (pc
);
345 && (strcmp (SYMBOL_LINKAGE_NAME (sym
), "__glink") == 0
346 || strcmp (SYMBOL_LINKAGE_NAME (sym
), "__glink_PLTresolve") == 0))
352 /* Follow PLT stub to actual routine. */
355 ppc_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
357 int insnbuf
[POWERPC32_PLT_STUB_LEN
];
358 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
359 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
360 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
361 CORE_ADDR target
= 0;
363 if (ppc_insns_match_pattern (pc
, powerpc32_plt_stub
, insnbuf
))
368 Branch target is in r11. */
370 target
= (ppc_insn_d_field (insnbuf
[0]) << 16)
371 | ppc_insn_d_field (insnbuf
[1]);
372 target
= read_memory_unsigned_integer (target
, 4, byte_order
);
375 if (ppc_insns_match_pattern (pc
, powerpc32_plt_stub_so
, insnbuf
))
379 Branch target is in r11. */
381 target
= get_frame_register_unsigned (frame
, tdep
->ppc_gp0_regnum
+ 30)
382 + ppc_insn_d_field (insnbuf
[0]);
383 target
= read_memory_unsigned_integer (target
, 4, byte_order
);
389 /* Wrappers to handle Linux-only registers. */
392 ppc_linux_supply_gregset (const struct regset
*regset
,
393 struct regcache
*regcache
,
394 int regnum
, const void *gregs
, size_t len
)
396 const struct ppc_reg_offsets
*offsets
= regset
->descr
;
398 ppc_supply_gregset (regset
, regcache
, regnum
, gregs
, len
);
400 if (ppc_linux_trap_reg_p (get_regcache_arch (regcache
)))
402 /* "orig_r3" is stored 2 slots after "pc". */
403 if (regnum
== -1 || regnum
== PPC_ORIG_R3_REGNUM
)
404 ppc_supply_reg (regcache
, PPC_ORIG_R3_REGNUM
, gregs
,
405 offsets
->pc_offset
+ 2 * offsets
->gpr_size
,
408 /* "trap" is stored 8 slots after "pc". */
409 if (regnum
== -1 || regnum
== PPC_TRAP_REGNUM
)
410 ppc_supply_reg (regcache
, PPC_TRAP_REGNUM
, gregs
,
411 offsets
->pc_offset
+ 8 * offsets
->gpr_size
,
417 ppc_linux_collect_gregset (const struct regset
*regset
,
418 const struct regcache
*regcache
,
419 int regnum
, void *gregs
, size_t len
)
421 const struct ppc_reg_offsets
*offsets
= regset
->descr
;
423 /* Clear areas in the linux gregset not written elsewhere. */
425 memset (gregs
, 0, len
);
427 ppc_collect_gregset (regset
, regcache
, regnum
, gregs
, len
);
429 if (ppc_linux_trap_reg_p (get_regcache_arch (regcache
)))
431 /* "orig_r3" is stored 2 slots after "pc". */
432 if (regnum
== -1 || regnum
== PPC_ORIG_R3_REGNUM
)
433 ppc_collect_reg (regcache
, PPC_ORIG_R3_REGNUM
, gregs
,
434 offsets
->pc_offset
+ 2 * offsets
->gpr_size
,
437 /* "trap" is stored 8 slots after "pc". */
438 if (regnum
== -1 || regnum
== PPC_TRAP_REGNUM
)
439 ppc_collect_reg (regcache
, PPC_TRAP_REGNUM
, gregs
,
440 offsets
->pc_offset
+ 8 * offsets
->gpr_size
,
445 /* Regset descriptions. */
446 static const struct ppc_reg_offsets ppc32_linux_reg_offsets
=
448 /* General-purpose registers. */
449 /* .r0_offset = */ 0,
452 /* .pc_offset = */ 128,
453 /* .ps_offset = */ 132,
454 /* .cr_offset = */ 152,
455 /* .lr_offset = */ 144,
456 /* .ctr_offset = */ 140,
457 /* .xer_offset = */ 148,
458 /* .mq_offset = */ 156,
460 /* Floating-point registers. */
461 /* .f0_offset = */ 0,
462 /* .fpscr_offset = */ 256,
463 /* .fpscr_size = */ 8,
465 /* AltiVec registers. */
466 /* .vr0_offset = */ 0,
467 /* .vscr_offset = */ 512 + 12,
468 /* .vrsave_offset = */ 528
471 static const struct ppc_reg_offsets ppc64_linux_reg_offsets
=
473 /* General-purpose registers. */
474 /* .r0_offset = */ 0,
477 /* .pc_offset = */ 256,
478 /* .ps_offset = */ 264,
479 /* .cr_offset = */ 304,
480 /* .lr_offset = */ 288,
481 /* .ctr_offset = */ 280,
482 /* .xer_offset = */ 296,
483 /* .mq_offset = */ 312,
485 /* Floating-point registers. */
486 /* .f0_offset = */ 0,
487 /* .fpscr_offset = */ 256,
488 /* .fpscr_size = */ 8,
490 /* AltiVec registers. */
491 /* .vr0_offset = */ 0,
492 /* .vscr_offset = */ 512 + 12,
493 /* .vrsave_offset = */ 528
496 static const struct regset ppc32_linux_gregset
= {
497 &ppc32_linux_reg_offsets
,
498 ppc_linux_supply_gregset
,
499 ppc_linux_collect_gregset
,
503 static const struct regset ppc64_linux_gregset
= {
504 &ppc64_linux_reg_offsets
,
505 ppc_linux_supply_gregset
,
506 ppc_linux_collect_gregset
,
510 static const struct regset ppc32_linux_fpregset
= {
511 &ppc32_linux_reg_offsets
,
513 ppc_collect_fpregset
,
517 static const struct regset ppc32_linux_vrregset
= {
518 &ppc32_linux_reg_offsets
,
520 ppc_collect_vrregset
,
524 static const struct regset ppc32_linux_vsxregset
= {
525 &ppc32_linux_reg_offsets
,
526 ppc_supply_vsxregset
,
527 ppc_collect_vsxregset
,
531 const struct regset
*
532 ppc_linux_gregset (int wordsize
)
534 return wordsize
== 8 ? &ppc64_linux_gregset
: &ppc32_linux_gregset
;
537 const struct regset
*
538 ppc_linux_fpregset (void)
540 return &ppc32_linux_fpregset
;
543 static const struct regset
*
544 ppc_linux_regset_from_core_section (struct gdbarch
*core_arch
,
545 const char *sect_name
, size_t sect_size
)
547 struct gdbarch_tdep
*tdep
= gdbarch_tdep (core_arch
);
548 if (strcmp (sect_name
, ".reg") == 0)
550 if (tdep
->wordsize
== 4)
551 return &ppc32_linux_gregset
;
553 return &ppc64_linux_gregset
;
555 if (strcmp (sect_name
, ".reg2") == 0)
556 return &ppc32_linux_fpregset
;
557 if (strcmp (sect_name
, ".reg-ppc-vmx") == 0)
558 return &ppc32_linux_vrregset
;
559 if (strcmp (sect_name
, ".reg-ppc-vsx") == 0)
560 return &ppc32_linux_vsxregset
;
565 ppc_linux_sigtramp_cache (struct frame_info
*this_frame
,
566 struct trad_frame_cache
*this_cache
,
567 CORE_ADDR func
, LONGEST offset
,
575 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
576 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
577 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
579 base
= get_frame_register_unsigned (this_frame
,
580 gdbarch_sp_regnum (gdbarch
));
581 if (bias
> 0 && get_frame_pc (this_frame
) != func
)
582 /* See below, some signal trampolines increment the stack as their
583 first instruction, need to compensate for that. */
586 /* Find the address of the register buffer pointer. */
587 regs
= base
+ offset
;
588 /* Use that to find the address of the corresponding register
590 gpregs
= read_memory_unsigned_integer (regs
, tdep
->wordsize
, byte_order
);
591 fpregs
= gpregs
+ 48 * tdep
->wordsize
;
593 /* General purpose. */
594 for (i
= 0; i
< 32; i
++)
596 int regnum
= i
+ tdep
->ppc_gp0_regnum
;
597 trad_frame_set_reg_addr (this_cache
,
598 regnum
, gpregs
+ i
* tdep
->wordsize
);
600 trad_frame_set_reg_addr (this_cache
,
601 gdbarch_pc_regnum (gdbarch
),
602 gpregs
+ 32 * tdep
->wordsize
);
603 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_ctr_regnum
,
604 gpregs
+ 35 * tdep
->wordsize
);
605 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_lr_regnum
,
606 gpregs
+ 36 * tdep
->wordsize
);
607 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_xer_regnum
,
608 gpregs
+ 37 * tdep
->wordsize
);
609 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_cr_regnum
,
610 gpregs
+ 38 * tdep
->wordsize
);
612 if (ppc_linux_trap_reg_p (gdbarch
))
614 trad_frame_set_reg_addr (this_cache
, PPC_ORIG_R3_REGNUM
,
615 gpregs
+ 34 * tdep
->wordsize
);
616 trad_frame_set_reg_addr (this_cache
, PPC_TRAP_REGNUM
,
617 gpregs
+ 40 * tdep
->wordsize
);
620 if (ppc_floating_point_unit_p (gdbarch
))
622 /* Floating point registers. */
623 for (i
= 0; i
< 32; i
++)
625 int regnum
= i
+ gdbarch_fp0_regnum (gdbarch
);
626 trad_frame_set_reg_addr (this_cache
, regnum
,
627 fpregs
+ i
* tdep
->wordsize
);
629 trad_frame_set_reg_addr (this_cache
, tdep
->ppc_fpscr_regnum
,
630 fpregs
+ 32 * tdep
->wordsize
);
632 trad_frame_set_id (this_cache
, frame_id_build (base
, func
));
636 ppc32_linux_sigaction_cache_init (const struct tramp_frame
*self
,
637 struct frame_info
*this_frame
,
638 struct trad_frame_cache
*this_cache
,
641 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
642 0xd0 /* Offset to ucontext_t. */
643 + 0x30 /* Offset to .reg. */,
648 ppc64_linux_sigaction_cache_init (const struct tramp_frame
*self
,
649 struct frame_info
*this_frame
,
650 struct trad_frame_cache
*this_cache
,
653 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
654 0x80 /* Offset to ucontext_t. */
655 + 0xe0 /* Offset to .reg. */,
660 ppc32_linux_sighandler_cache_init (const struct tramp_frame
*self
,
661 struct frame_info
*this_frame
,
662 struct trad_frame_cache
*this_cache
,
665 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
666 0x40 /* Offset to ucontext_t. */
667 + 0x1c /* Offset to .reg. */,
672 ppc64_linux_sighandler_cache_init (const struct tramp_frame
*self
,
673 struct frame_info
*this_frame
,
674 struct trad_frame_cache
*this_cache
,
677 ppc_linux_sigtramp_cache (this_frame
, this_cache
, func
,
678 0x80 /* Offset to struct sigcontext. */
679 + 0x38 /* Offset to .reg. */,
683 static struct tramp_frame ppc32_linux_sigaction_tramp_frame
= {
687 { 0x380000ac, -1 }, /* li r0, 172 */
688 { 0x44000002, -1 }, /* sc */
689 { TRAMP_SENTINEL_INSN
},
691 ppc32_linux_sigaction_cache_init
693 static struct tramp_frame ppc64_linux_sigaction_tramp_frame
= {
697 { 0x38210080, -1 }, /* addi r1,r1,128 */
698 { 0x380000ac, -1 }, /* li r0, 172 */
699 { 0x44000002, -1 }, /* sc */
700 { TRAMP_SENTINEL_INSN
},
702 ppc64_linux_sigaction_cache_init
704 static struct tramp_frame ppc32_linux_sighandler_tramp_frame
= {
708 { 0x38000077, -1 }, /* li r0,119 */
709 { 0x44000002, -1 }, /* sc */
710 { TRAMP_SENTINEL_INSN
},
712 ppc32_linux_sighandler_cache_init
714 static struct tramp_frame ppc64_linux_sighandler_tramp_frame
= {
718 { 0x38210080, -1 }, /* addi r1,r1,128 */
719 { 0x38000077, -1 }, /* li r0,119 */
720 { 0x44000002, -1 }, /* sc */
721 { TRAMP_SENTINEL_INSN
},
723 ppc64_linux_sighandler_cache_init
727 /* Address to use for displaced stepping. When debugging a stand-alone
728 SPU executable, entry_point_address () will point to an SPU local-store
729 address and is thus not usable as displaced stepping location. We use
730 the auxiliary vector to determine the PowerPC-side entry point address
733 static CORE_ADDR ppc_linux_entry_point_addr
= 0;
736 ppc_linux_inferior_created (struct target_ops
*target
, int from_tty
)
738 ppc_linux_entry_point_addr
= 0;
742 ppc_linux_displaced_step_location (struct gdbarch
*gdbarch
)
744 if (ppc_linux_entry_point_addr
== 0)
748 /* Determine entry point from target auxiliary vector. */
749 if (target_auxv_search (¤t_target
, AT_ENTRY
, &addr
) <= 0)
750 error (_("Cannot find AT_ENTRY auxiliary vector entry."));
752 /* Make certain that the address points at real code, and not a
753 function descriptor. */
754 addr
= gdbarch_convert_from_func_ptr_addr (gdbarch
, addr
,
757 /* Inferior calls also use the entry point as a breakpoint location.
758 We don't want displaced stepping to interfere with those
759 breakpoints, so leave space. */
760 ppc_linux_entry_point_addr
= addr
+ 2 * PPC_INSN_SIZE
;
763 return ppc_linux_entry_point_addr
;
767 /* Return 1 if PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM are usable. */
769 ppc_linux_trap_reg_p (struct gdbarch
*gdbarch
)
771 /* If we do not have a target description with registers, then
772 the special registers will not be included in the register set. */
773 if (!tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
776 /* If we do, then it is safe to check the size. */
777 return register_size (gdbarch
, PPC_ORIG_R3_REGNUM
) > 0
778 && register_size (gdbarch
, PPC_TRAP_REGNUM
) > 0;
781 /* Return the current system call's number present in the
782 r0 register. When the function fails, it returns -1. */
784 ppc_linux_get_syscall_number (struct gdbarch
*gdbarch
,
787 struct regcache
*regcache
= get_thread_regcache (ptid
);
788 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
789 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
790 struct cleanup
*cleanbuf
;
791 /* The content of a register */
796 /* Make sure we're in a 32- or 64-bit machine */
797 gdb_assert (tdep
->wordsize
== 4 || tdep
->wordsize
== 8);
799 buf
= (gdb_byte
*) xmalloc (tdep
->wordsize
* sizeof (gdb_byte
));
801 cleanbuf
= make_cleanup (xfree
, buf
);
803 /* Getting the system call number from the register.
804 When dealing with PowerPC architecture, this information
805 is stored at 0th register. */
806 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
, buf
);
808 ret
= extract_signed_integer (buf
, tdep
->wordsize
, byte_order
);
809 do_cleanups (cleanbuf
);
815 ppc_linux_write_pc (struct regcache
*regcache
, CORE_ADDR pc
)
817 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
819 regcache_cooked_write_unsigned (regcache
, gdbarch_pc_regnum (gdbarch
), pc
);
821 /* Set special TRAP register to -1 to prevent the kernel from
822 messing with the PC we just installed, if we happen to be
823 within an interrupted system call that the kernel wants to
826 Note that after we return from the dummy call, the TRAP and
827 ORIG_R3 registers will be automatically restored, and the
828 kernel continues to restart the system call at this point. */
829 if (ppc_linux_trap_reg_p (gdbarch
))
830 regcache_cooked_write_unsigned (regcache
, PPC_TRAP_REGNUM
, -1);
834 ppc_linux_spu_section (bfd
*abfd
, asection
*asect
, void *user_data
)
836 return strncmp (bfd_section_name (abfd
, asect
), "SPU/", 4) == 0;
839 static const struct target_desc
*
840 ppc_linux_core_read_description (struct gdbarch
*gdbarch
,
841 struct target_ops
*target
,
844 asection
*cell
= bfd_sections_find_if (abfd
, ppc_linux_spu_section
, NULL
);
845 asection
*altivec
= bfd_get_section_by_name (abfd
, ".reg-ppc-vmx");
846 asection
*vsx
= bfd_get_section_by_name (abfd
, ".reg-ppc-vsx");
847 asection
*section
= bfd_get_section_by_name (abfd
, ".reg");
851 switch (bfd_section_size (abfd
, section
))
855 return tdesc_powerpc_cell32l
;
857 return tdesc_powerpc_vsx32l
;
859 return tdesc_powerpc_altivec32l
;
861 return tdesc_powerpc_32l
;
865 return tdesc_powerpc_cell64l
;
867 return tdesc_powerpc_vsx64l
;
869 return tdesc_powerpc_altivec64l
;
871 return tdesc_powerpc_64l
;
878 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
882 ppc_stap_is_single_operand (struct gdbarch
*gdbarch
, const char *s
)
884 return (*s
== 'i' /* Literal number. */
885 || (isdigit (*s
) && s
[1] == '('
886 && isdigit (s
[2])) /* Displacement. */
887 || (*s
== '(' && isdigit (s
[1])) /* Register indirection. */
888 || isdigit (*s
)); /* Register value. */
891 /* Implementation of `gdbarch_stap_parse_special_token', as defined in
895 ppc_stap_parse_special_token (struct gdbarch
*gdbarch
,
896 struct stap_parse_info
*p
)
898 if (isdigit (*p
->arg
))
900 /* This temporary pointer is needed because we have to do a lookahead.
901 We could be dealing with a register displacement, and in such case
902 we would not need to do anything. */
903 const char *s
= p
->arg
;
913 /* It is a register displacement indeed. Returning 0 means we are
914 deferring the treatment of this case to the generic parser. */
919 regname
= alloca (len
+ 2);
922 strncpy (regname
+ 1, p
->arg
, len
);
926 if (user_reg_map_name_to_regnum (gdbarch
, regname
, len
) == -1)
927 error (_("Invalid register name `%s' on expression `%s'."),
928 regname
, p
->saved_arg
);
930 write_exp_elt_opcode (OP_REGISTER
);
933 write_exp_string (str
);
934 write_exp_elt_opcode (OP_REGISTER
);
940 /* All the other tokens should be handled correctly by the generic
948 /* Cell/B.E. active SPE context tracking support. */
950 static struct objfile
*spe_context_objfile
= NULL
;
951 static CORE_ADDR spe_context_lm_addr
= 0;
952 static CORE_ADDR spe_context_offset
= 0;
954 static ptid_t spe_context_cache_ptid
;
955 static CORE_ADDR spe_context_cache_address
;
957 /* Hook into inferior_created, solib_loaded, and solib_unloaded observers
958 to track whether we've loaded a version of libspe2 (as static or dynamic
959 library) that provides the __spe_current_active_context variable. */
961 ppc_linux_spe_context_lookup (struct objfile
*objfile
)
963 struct minimal_symbol
*sym
;
967 spe_context_objfile
= NULL
;
968 spe_context_lm_addr
= 0;
969 spe_context_offset
= 0;
970 spe_context_cache_ptid
= minus_one_ptid
;
971 spe_context_cache_address
= 0;
975 sym
= lookup_minimal_symbol ("__spe_current_active_context", NULL
, objfile
);
978 spe_context_objfile
= objfile
;
979 spe_context_lm_addr
= svr4_fetch_objfile_link_map (objfile
);
980 spe_context_offset
= SYMBOL_VALUE_ADDRESS (sym
);
981 spe_context_cache_ptid
= minus_one_ptid
;
982 spe_context_cache_address
= 0;
988 ppc_linux_spe_context_inferior_created (struct target_ops
*t
, int from_tty
)
990 struct objfile
*objfile
;
992 ppc_linux_spe_context_lookup (NULL
);
993 ALL_OBJFILES (objfile
)
994 ppc_linux_spe_context_lookup (objfile
);
998 ppc_linux_spe_context_solib_loaded (struct so_list
*so
)
1000 if (strstr (so
->so_original_name
, "/libspe") != NULL
)
1002 solib_read_symbols (so
, 0);
1003 ppc_linux_spe_context_lookup (so
->objfile
);
1008 ppc_linux_spe_context_solib_unloaded (struct so_list
*so
)
1010 if (so
->objfile
== spe_context_objfile
)
1011 ppc_linux_spe_context_lookup (NULL
);
1014 /* Retrieve contents of the N'th element in the current thread's
1015 linked SPE context list into ID and NPC. Return the address of
1016 said context element, or 0 if not found. */
1018 ppc_linux_spe_context (int wordsize
, enum bfd_endian byte_order
,
1019 int n
, int *id
, unsigned int *npc
)
1021 CORE_ADDR spe_context
= 0;
1025 /* Quick exit if we have not found __spe_current_active_context. */
1026 if (!spe_context_objfile
)
1029 /* Look up cached address of thread-local variable. */
1030 if (!ptid_equal (spe_context_cache_ptid
, inferior_ptid
))
1032 struct target_ops
*target
= ¤t_target
;
1033 volatile struct gdb_exception ex
;
1035 while (target
&& !target
->to_get_thread_local_address
)
1036 target
= find_target_beneath (target
);
1040 TRY_CATCH (ex
, RETURN_MASK_ERROR
)
1042 /* We do not call target_translate_tls_address here, because
1043 svr4_fetch_objfile_link_map may invalidate the frame chain,
1044 which must not do while inside a frame sniffer.
1046 Instead, we have cached the lm_addr value, and use that to
1047 directly call the target's to_get_thread_local_address. */
1048 spe_context_cache_address
1049 = target
->to_get_thread_local_address (target
, inferior_ptid
,
1050 spe_context_lm_addr
,
1051 spe_context_offset
);
1052 spe_context_cache_ptid
= inferior_ptid
;
1059 /* Read variable value. */
1060 if (target_read_memory (spe_context_cache_address
, buf
, wordsize
) == 0)
1061 spe_context
= extract_unsigned_integer (buf
, wordsize
, byte_order
);
1063 /* Cyle through to N'th linked list element. */
1064 for (i
= 0; i
< n
&& spe_context
; i
++)
1065 if (target_read_memory (spe_context
+ align_up (12, wordsize
),
1066 buf
, wordsize
) == 0)
1067 spe_context
= extract_unsigned_integer (buf
, wordsize
, byte_order
);
1071 /* Read current context. */
1073 && target_read_memory (spe_context
, buf
, 12) != 0)
1076 /* Extract data elements. */
1080 *id
= extract_signed_integer (buf
, 4, byte_order
);
1082 *npc
= extract_unsigned_integer (buf
+ 4, 4, byte_order
);
1089 /* Cell/B.E. cross-architecture unwinder support. */
1091 struct ppu2spu_cache
1093 struct frame_id frame_id
;
1094 struct regcache
*regcache
;
1097 static struct gdbarch
*
1098 ppu2spu_prev_arch (struct frame_info
*this_frame
, void **this_cache
)
1100 struct ppu2spu_cache
*cache
= *this_cache
;
1101 return get_regcache_arch (cache
->regcache
);
1105 ppu2spu_this_id (struct frame_info
*this_frame
,
1106 void **this_cache
, struct frame_id
*this_id
)
1108 struct ppu2spu_cache
*cache
= *this_cache
;
1109 *this_id
= cache
->frame_id
;
1112 static struct value
*
1113 ppu2spu_prev_register (struct frame_info
*this_frame
,
1114 void **this_cache
, int regnum
)
1116 struct ppu2spu_cache
*cache
= *this_cache
;
1117 struct gdbarch
*gdbarch
= get_regcache_arch (cache
->regcache
);
1120 buf
= alloca (register_size (gdbarch
, regnum
));
1122 if (regnum
< gdbarch_num_regs (gdbarch
))
1123 regcache_raw_read (cache
->regcache
, regnum
, buf
);
1125 gdbarch_pseudo_register_read (gdbarch
, cache
->regcache
, regnum
, buf
);
1127 return frame_unwind_got_bytes (this_frame
, regnum
, buf
);
1132 struct gdbarch
*gdbarch
;
1135 gdb_byte gprs
[128*16];
1139 ppu2spu_unwind_register (void *src
, int regnum
, gdb_byte
*buf
)
1141 struct ppu2spu_data
*data
= src
;
1142 enum bfd_endian byte_order
= gdbarch_byte_order (data
->gdbarch
);
1144 if (regnum
>= 0 && regnum
< SPU_NUM_GPRS
)
1145 memcpy (buf
, data
->gprs
+ 16*regnum
, 16);
1146 else if (regnum
== SPU_ID_REGNUM
)
1147 store_unsigned_integer (buf
, 4, byte_order
, data
->id
);
1148 else if (regnum
== SPU_PC_REGNUM
)
1149 store_unsigned_integer (buf
, 4, byte_order
, data
->npc
);
1151 return REG_UNAVAILABLE
;
1157 ppu2spu_sniffer (const struct frame_unwind
*self
,
1158 struct frame_info
*this_frame
, void **this_prologue_cache
)
1160 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1161 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1162 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1163 struct ppu2spu_data data
;
1164 struct frame_info
*fi
;
1165 CORE_ADDR base
, func
, backchain
, spe_context
;
1169 /* Count the number of SPU contexts already in the frame chain. */
1170 for (fi
= get_next_frame (this_frame
); fi
; fi
= get_next_frame (fi
))
1171 if (get_frame_type (fi
) == ARCH_FRAME
1172 && gdbarch_bfd_arch_info (get_frame_arch (fi
))->arch
== bfd_arch_spu
)
1175 base
= get_frame_sp (this_frame
);
1176 func
= get_frame_pc (this_frame
);
1177 if (target_read_memory (base
, buf
, tdep
->wordsize
))
1179 backchain
= extract_unsigned_integer (buf
, tdep
->wordsize
, byte_order
);
1181 spe_context
= ppc_linux_spe_context (tdep
->wordsize
, byte_order
,
1182 n
, &data
.id
, &data
.npc
);
1183 if (spe_context
&& base
<= spe_context
&& spe_context
< backchain
)
1187 /* Find gdbarch for SPU. */
1188 struct gdbarch_info info
;
1189 gdbarch_info_init (&info
);
1190 info
.bfd_arch_info
= bfd_lookup_arch (bfd_arch_spu
, bfd_mach_spu
);
1191 info
.byte_order
= BFD_ENDIAN_BIG
;
1192 info
.osabi
= GDB_OSABI_LINUX
;
1193 info
.tdep_info
= (void *) &data
.id
;
1194 data
.gdbarch
= gdbarch_find_by_info (info
);
1198 xsnprintf (annex
, sizeof annex
, "%d/regs", data
.id
);
1199 if (target_read (¤t_target
, TARGET_OBJECT_SPU
, annex
,
1200 data
.gprs
, 0, sizeof data
.gprs
)
1201 == sizeof data
.gprs
)
1203 struct ppu2spu_cache
*cache
1204 = FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache
);
1206 struct address_space
*aspace
= get_frame_address_space (this_frame
);
1207 struct regcache
*regcache
= regcache_xmalloc (data
.gdbarch
, aspace
);
1208 struct cleanup
*cleanups
= make_cleanup_regcache_xfree (regcache
);
1209 regcache_save (regcache
, ppu2spu_unwind_register
, &data
);
1210 discard_cleanups (cleanups
);
1212 cache
->frame_id
= frame_id_build (base
, func
);
1213 cache
->regcache
= regcache
;
1214 *this_prologue_cache
= cache
;
1223 ppu2spu_dealloc_cache (struct frame_info
*self
, void *this_cache
)
1225 struct ppu2spu_cache
*cache
= this_cache
;
1226 regcache_xfree (cache
->regcache
);
1229 static const struct frame_unwind ppu2spu_unwind
= {
1231 default_frame_unwind_stop_reason
,
1233 ppu2spu_prev_register
,
1236 ppu2spu_dealloc_cache
,
1242 ppc_linux_init_abi (struct gdbarch_info info
,
1243 struct gdbarch
*gdbarch
)
1245 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1246 struct tdesc_arch_data
*tdesc_data
= (void *) info
.tdep_info
;
1248 linux_init_abi (info
, gdbarch
);
1250 /* PPC GNU/Linux uses either 64-bit or 128-bit long doubles; where
1251 128-bit, they are IBM long double, not IEEE quad long double as
1252 in the System V ABI PowerPC Processor Supplement. We can safely
1253 let them default to 128-bit, since the debug info will give the
1254 size of type actually used in each case. */
1255 set_gdbarch_long_double_bit (gdbarch
, 16 * TARGET_CHAR_BIT
);
1256 set_gdbarch_long_double_format (gdbarch
, floatformats_ibm_long_double
);
1258 /* Handle inferior calls during interrupted system calls. */
1259 set_gdbarch_write_pc (gdbarch
, ppc_linux_write_pc
);
1261 /* Get the syscall number from the arch's register. */
1262 set_gdbarch_get_syscall_number (gdbarch
, ppc_linux_get_syscall_number
);
1264 /* SystemTap functions. */
1265 set_gdbarch_stap_integer_prefix (gdbarch
, "i");
1266 set_gdbarch_stap_register_indirection_prefix (gdbarch
, "(");
1267 set_gdbarch_stap_register_indirection_suffix (gdbarch
, ")");
1268 set_gdbarch_stap_gdb_register_prefix (gdbarch
, "r");
1269 set_gdbarch_stap_is_single_operand (gdbarch
, ppc_stap_is_single_operand
);
1270 set_gdbarch_stap_parse_special_token (gdbarch
,
1271 ppc_stap_parse_special_token
);
1273 if (tdep
->wordsize
== 4)
1275 /* Until November 2001, gcc did not comply with the 32 bit SysV
1276 R4 ABI requirement that structures less than or equal to 8
1277 bytes should be returned in registers. Instead GCC was using
1278 the AIX/PowerOpen ABI - everything returned in memory
1279 (well ignoring vectors that is). When this was corrected, it
1280 wasn't fixed for GNU/Linux native platform. Use the
1281 PowerOpen struct convention. */
1282 set_gdbarch_return_value (gdbarch
, ppc_linux_return_value
);
1284 set_gdbarch_memory_remove_breakpoint (gdbarch
,
1285 ppc_linux_memory_remove_breakpoint
);
1287 /* Shared library handling. */
1288 set_gdbarch_skip_trampoline_code (gdbarch
, ppc_skip_trampoline_code
);
1289 set_solib_svr4_fetch_link_map_offsets
1290 (gdbarch
, svr4_ilp32_fetch_link_map_offsets
);
1292 /* Setting the correct XML syscall filename. */
1293 set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC
);
1296 tramp_frame_prepend_unwinder (gdbarch
,
1297 &ppc32_linux_sigaction_tramp_frame
);
1298 tramp_frame_prepend_unwinder (gdbarch
,
1299 &ppc32_linux_sighandler_tramp_frame
);
1301 /* BFD target for core files. */
1302 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_LITTLE
)
1303 set_gdbarch_gcore_bfd_target (gdbarch
, "elf32-powerpcle");
1305 set_gdbarch_gcore_bfd_target (gdbarch
, "elf32-powerpc");
1307 /* Supported register sections. */
1308 if (tdesc_find_feature (info
.target_desc
,
1309 "org.gnu.gdb.power.vsx"))
1310 set_gdbarch_core_regset_sections (gdbarch
,
1311 ppc_linux_vsx_regset_sections
);
1312 else if (tdesc_find_feature (info
.target_desc
,
1313 "org.gnu.gdb.power.altivec"))
1314 set_gdbarch_core_regset_sections (gdbarch
,
1315 ppc_linux_vmx_regset_sections
);
1317 set_gdbarch_core_regset_sections (gdbarch
,
1318 ppc_linux_fp_regset_sections
);
1320 if (powerpc_so_ops
.in_dynsym_resolve_code
== NULL
)
1322 powerpc_so_ops
= svr4_so_ops
;
1323 /* Override dynamic resolve function. */
1324 powerpc_so_ops
.in_dynsym_resolve_code
=
1325 powerpc_linux_in_dynsym_resolve_code
;
1327 set_solib_ops (gdbarch
, &powerpc_so_ops
);
1329 set_gdbarch_skip_solib_resolver (gdbarch
, glibc_skip_solib_resolver
);
1332 if (tdep
->wordsize
== 8)
1334 /* Handle PPC GNU/Linux 64-bit function pointers (which are really
1335 function descriptors). */
1336 set_gdbarch_convert_from_func_ptr_addr
1337 (gdbarch
, ppc64_convert_from_func_ptr_addr
);
1339 set_gdbarch_elf_make_msymbol_special (gdbarch
,
1340 ppc64_elf_make_msymbol_special
);
1342 /* Shared library handling. */
1343 set_gdbarch_skip_trampoline_code (gdbarch
, ppc64_skip_trampoline_code
);
1344 set_solib_svr4_fetch_link_map_offsets
1345 (gdbarch
, svr4_lp64_fetch_link_map_offsets
);
1347 /* Setting the correct XML syscall filename. */
1348 set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC64
);
1351 tramp_frame_prepend_unwinder (gdbarch
,
1352 &ppc64_linux_sigaction_tramp_frame
);
1353 tramp_frame_prepend_unwinder (gdbarch
,
1354 &ppc64_linux_sighandler_tramp_frame
);
1356 /* BFD target for core files. */
1357 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_LITTLE
)
1358 set_gdbarch_gcore_bfd_target (gdbarch
, "elf64-powerpcle");
1360 set_gdbarch_gcore_bfd_target (gdbarch
, "elf64-powerpc");
1362 /* Supported register sections. */
1363 if (tdesc_find_feature (info
.target_desc
,
1364 "org.gnu.gdb.power.vsx"))
1365 set_gdbarch_core_regset_sections (gdbarch
,
1366 ppc64_linux_vsx_regset_sections
);
1367 else if (tdesc_find_feature (info
.target_desc
,
1368 "org.gnu.gdb.power.altivec"))
1369 set_gdbarch_core_regset_sections (gdbarch
,
1370 ppc64_linux_vmx_regset_sections
);
1372 set_gdbarch_core_regset_sections (gdbarch
,
1373 ppc64_linux_fp_regset_sections
);
1376 /* PPC32 uses a different prpsinfo32 compared to most other Linux
1378 if (tdep
->wordsize
== 4)
1379 set_gdbarch_elfcore_write_linux_prpsinfo (gdbarch
,
1380 elfcore_write_ppc_linux_prpsinfo32
);
1382 set_gdbarch_regset_from_core_section (gdbarch
,
1383 ppc_linux_regset_from_core_section
);
1384 set_gdbarch_core_read_description (gdbarch
, ppc_linux_core_read_description
);
1386 /* Enable TLS support. */
1387 set_gdbarch_fetch_tls_load_module_address (gdbarch
,
1388 svr4_fetch_objfile_link_map
);
1392 const struct tdesc_feature
*feature
;
1394 /* If we have target-described registers, then we can safely
1395 reserve a number for PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM
1396 (whether they are described or not). */
1397 gdb_assert (gdbarch_num_regs (gdbarch
) <= PPC_ORIG_R3_REGNUM
);
1398 set_gdbarch_num_regs (gdbarch
, PPC_TRAP_REGNUM
+ 1);
1400 /* If they are present, then assign them to the reserved number. */
1401 feature
= tdesc_find_feature (info
.target_desc
,
1402 "org.gnu.gdb.power.linux");
1403 if (feature
!= NULL
)
1405 tdesc_numbered_register (feature
, tdesc_data
,
1406 PPC_ORIG_R3_REGNUM
, "orig_r3");
1407 tdesc_numbered_register (feature
, tdesc_data
,
1408 PPC_TRAP_REGNUM
, "trap");
1412 /* Enable Cell/B.E. if supported by the target. */
1413 if (tdesc_compatible_p (info
.target_desc
,
1414 bfd_lookup_arch (bfd_arch_spu
, bfd_mach_spu
)))
1416 /* Cell/B.E. multi-architecture support. */
1417 set_spu_solib_ops (gdbarch
);
1419 /* Cell/B.E. cross-architecture unwinder support. */
1420 frame_unwind_prepend_unwinder (gdbarch
, &ppu2spu_unwind
);
1422 /* The default displaced_step_at_entry_point doesn't work for
1423 SPU stand-alone executables. */
1424 set_gdbarch_displaced_step_location (gdbarch
,
1425 ppc_linux_displaced_step_location
);
1428 set_gdbarch_get_siginfo_type (gdbarch
, linux_get_siginfo_type
);
1431 /* Provide a prototype to silence -Wmissing-prototypes. */
1432 extern initialize_file_ftype _initialize_ppc_linux_tdep
;
1435 _initialize_ppc_linux_tdep (void)
1437 /* Register for all sub-familes of the POWER/PowerPC: 32-bit and
1438 64-bit PowerPC, and the older rs6k. */
1439 gdbarch_register_osabi (bfd_arch_powerpc
, bfd_mach_ppc
, GDB_OSABI_LINUX
,
1440 ppc_linux_init_abi
);
1441 gdbarch_register_osabi (bfd_arch_powerpc
, bfd_mach_ppc64
, GDB_OSABI_LINUX
,
1442 ppc_linux_init_abi
);
1443 gdbarch_register_osabi (bfd_arch_rs6000
, bfd_mach_rs6k
, GDB_OSABI_LINUX
,
1444 ppc_linux_init_abi
);
1446 /* Attach to inferior_created observer. */
1447 observer_attach_inferior_created (ppc_linux_inferior_created
);
1449 /* Attach to observers to track __spe_current_active_context. */
1450 observer_attach_inferior_created (ppc_linux_spe_context_inferior_created
);
1451 observer_attach_solib_loaded (ppc_linux_spe_context_solib_loaded
);
1452 observer_attach_solib_unloaded (ppc_linux_spe_context_solib_unloaded
);
1454 /* Initialize the Linux target descriptions. */
1455 initialize_tdesc_powerpc_32l ();
1456 initialize_tdesc_powerpc_altivec32l ();
1457 initialize_tdesc_powerpc_cell32l ();
1458 initialize_tdesc_powerpc_vsx32l ();
1459 initialize_tdesc_powerpc_isa205_32l ();
1460 initialize_tdesc_powerpc_isa205_altivec32l ();
1461 initialize_tdesc_powerpc_isa205_vsx32l ();
1462 initialize_tdesc_powerpc_64l ();
1463 initialize_tdesc_powerpc_altivec64l ();
1464 initialize_tdesc_powerpc_cell64l ();
1465 initialize_tdesc_powerpc_vsx64l ();
1466 initialize_tdesc_powerpc_isa205_64l ();
1467 initialize_tdesc_powerpc_isa205_altivec64l ();
1468 initialize_tdesc_powerpc_isa205_vsx64l ();
1469 initialize_tdesc_powerpc_e500l ();