Commit | Line | Data |
---|---|---|
c877c8e6 | 1 | /* Target-dependent code for GDB, the GNU debugger. |
4e052eda | 2 | |
ecd75fc8 | 3 | Copyright (C) 1986-2014 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" | |
591a12a1 | 47 | #include "elf/ppc64.h" |
cc5f0d61 UW |
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 | { |
0d5ed153 | 213 | CORE_ADDR addr = bp_tgt->reqstd_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 | ||
5d853008 | 259 | /* PLT stub in executable. */ |
d78489bf | 260 | static struct ppc_insn_pattern powerpc32_plt_stub[] = |
5d853008 ME |
261 | { |
262 | { 0xffff0000, 0x3d600000, 0 }, /* lis r11, xxxx */ | |
263 | { 0xffff0000, 0x816b0000, 0 }, /* lwz r11, xxxx(r11) */ | |
264 | { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */ | |
265 | { 0xffffffff, 0x4e800420, 0 }, /* bctr */ | |
266 | { 0, 0, 0 } | |
267 | }; | |
268 | ||
269 | /* PLT stub in shared library. */ | |
d78489bf | 270 | static struct ppc_insn_pattern powerpc32_plt_stub_so[] = |
5d853008 ME |
271 | { |
272 | { 0xffff0000, 0x817e0000, 0 }, /* lwz r11, xxxx(r30) */ | |
273 | { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */ | |
274 | { 0xffffffff, 0x4e800420, 0 }, /* bctr */ | |
275 | { 0xffffffff, 0x60000000, 0 }, /* nop */ | |
276 | { 0, 0, 0 } | |
277 | }; | |
278 | #define POWERPC32_PLT_STUB_LEN ARRAY_SIZE (powerpc32_plt_stub) | |
279 | ||
280 | /* Check if PC is in PLT stub. For non-secure PLT, stub is in .plt | |
281 | section. For secure PLT, stub is in .text and we need to check | |
282 | instruction patterns. */ | |
283 | ||
284 | static int | |
285 | powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc) | |
286 | { | |
7cbd4a93 | 287 | struct bound_minimal_symbol sym; |
5d853008 ME |
288 | |
289 | /* Check whether PC is in the dynamic linker. This also checks | |
290 | whether it is in the .plt section, used by non-PIC executables. */ | |
291 | if (svr4_in_dynsym_resolve_code (pc)) | |
292 | return 1; | |
293 | ||
294 | /* Check if we are in the resolver. */ | |
295 | sym = lookup_minimal_symbol_by_pc (pc); | |
7cbd4a93 | 296 | if (sym.minsym != NULL |
efd66ac6 TT |
297 | && (strcmp (MSYMBOL_LINKAGE_NAME (sym.minsym), "__glink") == 0 |
298 | || strcmp (MSYMBOL_LINKAGE_NAME (sym.minsym), | |
7cbd4a93 | 299 | "__glink_PLTresolve") == 0)) |
5d853008 ME |
300 | return 1; |
301 | ||
302 | return 0; | |
303 | } | |
304 | ||
305 | /* Follow PLT stub to actual routine. */ | |
306 | ||
307 | static CORE_ADDR | |
308 | ppc_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) | |
309 | { | |
463920bf | 310 | unsigned int insnbuf[POWERPC32_PLT_STUB_LEN]; |
5d853008 ME |
311 | struct gdbarch *gdbarch = get_frame_arch (frame); |
312 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
313 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
314 | CORE_ADDR target = 0; | |
315 | ||
845d4708 | 316 | if (ppc_insns_match_pattern (frame, pc, powerpc32_plt_stub, insnbuf)) |
5d853008 ME |
317 | { |
318 | /* Insn pattern is | |
319 | lis r11, xxxx | |
320 | lwz r11, xxxx(r11) | |
321 | Branch target is in r11. */ | |
322 | ||
d78489bf AT |
323 | target = (ppc_insn_d_field (insnbuf[0]) << 16) |
324 | | ppc_insn_d_field (insnbuf[1]); | |
5d853008 ME |
325 | target = read_memory_unsigned_integer (target, 4, byte_order); |
326 | } | |
327 | ||
845d4708 | 328 | if (ppc_insns_match_pattern (frame, pc, powerpc32_plt_stub_so, insnbuf)) |
5d853008 ME |
329 | { |
330 | /* Insn pattern is | |
331 | lwz r11, xxxx(r30) | |
332 | Branch target is in r11. */ | |
333 | ||
334 | target = get_frame_register_unsigned (frame, tdep->ppc_gp0_regnum + 30) | |
d78489bf | 335 | + ppc_insn_d_field (insnbuf[0]); |
5d853008 ME |
336 | target = read_memory_unsigned_integer (target, 4, byte_order); |
337 | } | |
338 | ||
339 | return target; | |
340 | } | |
f470a70a | 341 | |
7284e1be UW |
342 | /* Wrappers to handle Linux-only registers. */ |
343 | ||
344 | static void | |
345 | ppc_linux_supply_gregset (const struct regset *regset, | |
346 | struct regcache *regcache, | |
347 | int regnum, const void *gregs, size_t len) | |
348 | { | |
7fefa8d7 | 349 | const struct ppc_reg_offsets *offsets = regset->regmap; |
7284e1be UW |
350 | |
351 | ppc_supply_gregset (regset, regcache, regnum, gregs, len); | |
352 | ||
353 | if (ppc_linux_trap_reg_p (get_regcache_arch (regcache))) | |
354 | { | |
355 | /* "orig_r3" is stored 2 slots after "pc". */ | |
356 | if (regnum == -1 || regnum == PPC_ORIG_R3_REGNUM) | |
357 | ppc_supply_reg (regcache, PPC_ORIG_R3_REGNUM, gregs, | |
358 | offsets->pc_offset + 2 * offsets->gpr_size, | |
359 | offsets->gpr_size); | |
360 | ||
361 | /* "trap" is stored 8 slots after "pc". */ | |
362 | if (regnum == -1 || regnum == PPC_TRAP_REGNUM) | |
363 | ppc_supply_reg (regcache, PPC_TRAP_REGNUM, gregs, | |
364 | offsets->pc_offset + 8 * offsets->gpr_size, | |
365 | offsets->gpr_size); | |
366 | } | |
367 | } | |
f2db237a | 368 | |
f9be684a | 369 | static void |
f2db237a AM |
370 | ppc_linux_collect_gregset (const struct regset *regset, |
371 | const struct regcache *regcache, | |
372 | int regnum, void *gregs, size_t len) | |
f9be684a | 373 | { |
7fefa8d7 | 374 | const struct ppc_reg_offsets *offsets = regset->regmap; |
7284e1be UW |
375 | |
376 | /* Clear areas in the linux gregset not written elsewhere. */ | |
f2db237a AM |
377 | if (regnum == -1) |
378 | memset (gregs, 0, len); | |
7284e1be | 379 | |
f2db237a | 380 | ppc_collect_gregset (regset, regcache, regnum, gregs, len); |
7284e1be UW |
381 | |
382 | if (ppc_linux_trap_reg_p (get_regcache_arch (regcache))) | |
383 | { | |
384 | /* "orig_r3" is stored 2 slots after "pc". */ | |
385 | if (regnum == -1 || regnum == PPC_ORIG_R3_REGNUM) | |
386 | ppc_collect_reg (regcache, PPC_ORIG_R3_REGNUM, gregs, | |
387 | offsets->pc_offset + 2 * offsets->gpr_size, | |
388 | offsets->gpr_size); | |
389 | ||
390 | /* "trap" is stored 8 slots after "pc". */ | |
391 | if (regnum == -1 || regnum == PPC_TRAP_REGNUM) | |
392 | ppc_collect_reg (regcache, PPC_TRAP_REGNUM, gregs, | |
393 | offsets->pc_offset + 8 * offsets->gpr_size, | |
394 | offsets->gpr_size); | |
395 | } | |
f9be684a AC |
396 | } |
397 | ||
f2db237a AM |
398 | /* Regset descriptions. */ |
399 | static const struct ppc_reg_offsets ppc32_linux_reg_offsets = | |
400 | { | |
401 | /* General-purpose registers. */ | |
402 | /* .r0_offset = */ 0, | |
403 | /* .gpr_size = */ 4, | |
404 | /* .xr_size = */ 4, | |
405 | /* .pc_offset = */ 128, | |
406 | /* .ps_offset = */ 132, | |
407 | /* .cr_offset = */ 152, | |
408 | /* .lr_offset = */ 144, | |
409 | /* .ctr_offset = */ 140, | |
410 | /* .xer_offset = */ 148, | |
411 | /* .mq_offset = */ 156, | |
412 | ||
413 | /* Floating-point registers. */ | |
414 | /* .f0_offset = */ 0, | |
415 | /* .fpscr_offset = */ 256, | |
416 | /* .fpscr_size = */ 8, | |
417 | ||
418 | /* AltiVec registers. */ | |
419 | /* .vr0_offset = */ 0, | |
06caf7d2 CES |
420 | /* .vscr_offset = */ 512 + 12, |
421 | /* .vrsave_offset = */ 528 | |
f2db237a | 422 | }; |
f9be684a | 423 | |
f2db237a AM |
424 | static const struct ppc_reg_offsets ppc64_linux_reg_offsets = |
425 | { | |
426 | /* General-purpose registers. */ | |
427 | /* .r0_offset = */ 0, | |
428 | /* .gpr_size = */ 8, | |
429 | /* .xr_size = */ 8, | |
430 | /* .pc_offset = */ 256, | |
431 | /* .ps_offset = */ 264, | |
432 | /* .cr_offset = */ 304, | |
433 | /* .lr_offset = */ 288, | |
434 | /* .ctr_offset = */ 280, | |
435 | /* .xer_offset = */ 296, | |
436 | /* .mq_offset = */ 312, | |
437 | ||
438 | /* Floating-point registers. */ | |
439 | /* .f0_offset = */ 0, | |
440 | /* .fpscr_offset = */ 256, | |
441 | /* .fpscr_size = */ 8, | |
442 | ||
443 | /* AltiVec registers. */ | |
444 | /* .vr0_offset = */ 0, | |
06caf7d2 CES |
445 | /* .vscr_offset = */ 512 + 12, |
446 | /* .vrsave_offset = */ 528 | |
f2db237a | 447 | }; |
2fda4977 | 448 | |
f2db237a AM |
449 | static const struct regset ppc32_linux_gregset = { |
450 | &ppc32_linux_reg_offsets, | |
7284e1be | 451 | ppc_linux_supply_gregset, |
09424cff | 452 | ppc_linux_collect_gregset |
f9be684a AC |
453 | }; |
454 | ||
f2db237a AM |
455 | static const struct regset ppc64_linux_gregset = { |
456 | &ppc64_linux_reg_offsets, | |
7284e1be | 457 | ppc_linux_supply_gregset, |
09424cff | 458 | ppc_linux_collect_gregset |
f2db237a | 459 | }; |
f9be684a | 460 | |
f2db237a AM |
461 | static const struct regset ppc32_linux_fpregset = { |
462 | &ppc32_linux_reg_offsets, | |
463 | ppc_supply_fpregset, | |
09424cff | 464 | ppc_collect_fpregset |
f9be684a AC |
465 | }; |
466 | ||
06caf7d2 CES |
467 | static const struct regset ppc32_linux_vrregset = { |
468 | &ppc32_linux_reg_offsets, | |
469 | ppc_supply_vrregset, | |
09424cff | 470 | ppc_collect_vrregset |
06caf7d2 CES |
471 | }; |
472 | ||
604c2f83 LM |
473 | static const struct regset ppc32_linux_vsxregset = { |
474 | &ppc32_linux_reg_offsets, | |
475 | ppc_supply_vsxregset, | |
09424cff | 476 | ppc_collect_vsxregset |
604c2f83 LM |
477 | }; |
478 | ||
f2db237a AM |
479 | const struct regset * |
480 | ppc_linux_gregset (int wordsize) | |
2fda4977 | 481 | { |
f2db237a | 482 | return wordsize == 8 ? &ppc64_linux_gregset : &ppc32_linux_gregset; |
2fda4977 DJ |
483 | } |
484 | ||
f2db237a AM |
485 | const struct regset * |
486 | ppc_linux_fpregset (void) | |
487 | { | |
488 | return &ppc32_linux_fpregset; | |
489 | } | |
2fda4977 | 490 | |
5aa82d05 AA |
491 | /* Iterate over supported core file register note sections. */ |
492 | ||
493 | static void | |
494 | ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, | |
495 | iterate_over_regset_sections_cb *cb, | |
496 | void *cb_data, | |
497 | const struct regcache *regcache) | |
498 | { | |
499 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
500 | int have_altivec = tdep->ppc_vr0_regnum != -1; | |
501 | int have_vsx = tdep->ppc_vsr0_upper_regnum != -1; | |
502 | ||
8f0435f7 AA |
503 | if (tdep->wordsize == 4) |
504 | cb (".reg", 48 * 4, &ppc32_linux_gregset, NULL, cb_data); | |
505 | else | |
506 | cb (".reg", 48 * 8, &ppc64_linux_gregset, NULL, cb_data); | |
507 | ||
508 | cb (".reg2", 264, &ppc32_linux_fpregset, NULL, cb_data); | |
5aa82d05 AA |
509 | |
510 | if (have_altivec) | |
8f0435f7 | 511 | cb (".reg-ppc-vmx", 544, &ppc32_linux_vrregset, "ppc Altivec", cb_data); |
5aa82d05 AA |
512 | |
513 | if (have_vsx) | |
8f0435f7 | 514 | cb (".reg-ppc-vsx", 256, &ppc32_linux_vsxregset, "POWER7 VSX", cb_data); |
5aa82d05 AA |
515 | } |
516 | ||
a8f60bfc | 517 | static void |
5366653e | 518 | ppc_linux_sigtramp_cache (struct frame_info *this_frame, |
a8f60bfc AC |
519 | struct trad_frame_cache *this_cache, |
520 | CORE_ADDR func, LONGEST offset, | |
521 | int bias) | |
522 | { | |
523 | CORE_ADDR base; | |
524 | CORE_ADDR regs; | |
525 | CORE_ADDR gpregs; | |
526 | CORE_ADDR fpregs; | |
527 | int i; | |
5366653e | 528 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
a8f60bfc | 529 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
e17a4113 | 530 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
a8f60bfc | 531 | |
5366653e DJ |
532 | base = get_frame_register_unsigned (this_frame, |
533 | gdbarch_sp_regnum (gdbarch)); | |
534 | if (bias > 0 && get_frame_pc (this_frame) != func) | |
a8f60bfc AC |
535 | /* See below, some signal trampolines increment the stack as their |
536 | first instruction, need to compensate for that. */ | |
537 | base -= bias; | |
538 | ||
539 | /* Find the address of the register buffer pointer. */ | |
540 | regs = base + offset; | |
541 | /* Use that to find the address of the corresponding register | |
542 | buffers. */ | |
e17a4113 | 543 | gpregs = read_memory_unsigned_integer (regs, tdep->wordsize, byte_order); |
a8f60bfc AC |
544 | fpregs = gpregs + 48 * tdep->wordsize; |
545 | ||
546 | /* General purpose. */ | |
547 | for (i = 0; i < 32; i++) | |
548 | { | |
549 | int regnum = i + tdep->ppc_gp0_regnum; | |
0df8b418 MS |
550 | trad_frame_set_reg_addr (this_cache, |
551 | regnum, gpregs + i * tdep->wordsize); | |
a8f60bfc | 552 | } |
3e8c568d | 553 | trad_frame_set_reg_addr (this_cache, |
40a6adc1 | 554 | gdbarch_pc_regnum (gdbarch), |
3e8c568d | 555 | gpregs + 32 * tdep->wordsize); |
a8f60bfc AC |
556 | trad_frame_set_reg_addr (this_cache, tdep->ppc_ctr_regnum, |
557 | gpregs + 35 * tdep->wordsize); | |
558 | trad_frame_set_reg_addr (this_cache, tdep->ppc_lr_regnum, | |
559 | gpregs + 36 * tdep->wordsize); | |
560 | trad_frame_set_reg_addr (this_cache, tdep->ppc_xer_regnum, | |
561 | gpregs + 37 * tdep->wordsize); | |
562 | trad_frame_set_reg_addr (this_cache, tdep->ppc_cr_regnum, | |
563 | gpregs + 38 * tdep->wordsize); | |
564 | ||
7284e1be UW |
565 | if (ppc_linux_trap_reg_p (gdbarch)) |
566 | { | |
567 | trad_frame_set_reg_addr (this_cache, PPC_ORIG_R3_REGNUM, | |
568 | gpregs + 34 * tdep->wordsize); | |
569 | trad_frame_set_reg_addr (this_cache, PPC_TRAP_REGNUM, | |
570 | gpregs + 40 * tdep->wordsize); | |
571 | } | |
572 | ||
60f140f9 PG |
573 | if (ppc_floating_point_unit_p (gdbarch)) |
574 | { | |
575 | /* Floating point registers. */ | |
576 | for (i = 0; i < 32; i++) | |
577 | { | |
40a6adc1 | 578 | int regnum = i + gdbarch_fp0_regnum (gdbarch); |
60f140f9 PG |
579 | trad_frame_set_reg_addr (this_cache, regnum, |
580 | fpregs + i * tdep->wordsize); | |
581 | } | |
582 | trad_frame_set_reg_addr (this_cache, tdep->ppc_fpscr_regnum, | |
4019046a | 583 | fpregs + 32 * tdep->wordsize); |
60f140f9 | 584 | } |
a8f60bfc AC |
585 | trad_frame_set_id (this_cache, frame_id_build (base, func)); |
586 | } | |
587 | ||
588 | static void | |
589 | ppc32_linux_sigaction_cache_init (const struct tramp_frame *self, | |
5366653e | 590 | struct frame_info *this_frame, |
a8f60bfc AC |
591 | struct trad_frame_cache *this_cache, |
592 | CORE_ADDR func) | |
593 | { | |
5366653e | 594 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
595 | 0xd0 /* Offset to ucontext_t. */ |
596 | + 0x30 /* Offset to .reg. */, | |
597 | 0); | |
598 | } | |
599 | ||
600 | static void | |
601 | ppc64_linux_sigaction_cache_init (const struct tramp_frame *self, | |
5366653e | 602 | struct frame_info *this_frame, |
a8f60bfc AC |
603 | struct trad_frame_cache *this_cache, |
604 | CORE_ADDR func) | |
605 | { | |
5366653e | 606 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
607 | 0x80 /* Offset to ucontext_t. */ |
608 | + 0xe0 /* Offset to .reg. */, | |
609 | 128); | |
610 | } | |
611 | ||
612 | static void | |
613 | ppc32_linux_sighandler_cache_init (const struct tramp_frame *self, | |
5366653e | 614 | struct frame_info *this_frame, |
a8f60bfc AC |
615 | struct trad_frame_cache *this_cache, |
616 | CORE_ADDR func) | |
617 | { | |
5366653e | 618 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
619 | 0x40 /* Offset to ucontext_t. */ |
620 | + 0x1c /* Offset to .reg. */, | |
621 | 0); | |
622 | } | |
623 | ||
624 | static void | |
625 | ppc64_linux_sighandler_cache_init (const struct tramp_frame *self, | |
5366653e | 626 | struct frame_info *this_frame, |
a8f60bfc AC |
627 | struct trad_frame_cache *this_cache, |
628 | CORE_ADDR func) | |
629 | { | |
5366653e | 630 | ppc_linux_sigtramp_cache (this_frame, this_cache, func, |
a8f60bfc AC |
631 | 0x80 /* Offset to struct sigcontext. */ |
632 | + 0x38 /* Offset to .reg. */, | |
633 | 128); | |
634 | } | |
635 | ||
636 | static struct tramp_frame ppc32_linux_sigaction_tramp_frame = { | |
637 | SIGTRAMP_FRAME, | |
638 | 4, | |
639 | { | |
640 | { 0x380000ac, -1 }, /* li r0, 172 */ | |
641 | { 0x44000002, -1 }, /* sc */ | |
642 | { TRAMP_SENTINEL_INSN }, | |
643 | }, | |
644 | ppc32_linux_sigaction_cache_init | |
645 | }; | |
646 | static struct tramp_frame ppc64_linux_sigaction_tramp_frame = { | |
647 | SIGTRAMP_FRAME, | |
648 | 4, | |
649 | { | |
650 | { 0x38210080, -1 }, /* addi r1,r1,128 */ | |
651 | { 0x380000ac, -1 }, /* li r0, 172 */ | |
652 | { 0x44000002, -1 }, /* sc */ | |
653 | { TRAMP_SENTINEL_INSN }, | |
654 | }, | |
655 | ppc64_linux_sigaction_cache_init | |
656 | }; | |
657 | static struct tramp_frame ppc32_linux_sighandler_tramp_frame = { | |
658 | SIGTRAMP_FRAME, | |
659 | 4, | |
660 | { | |
661 | { 0x38000077, -1 }, /* li r0,119 */ | |
662 | { 0x44000002, -1 }, /* sc */ | |
663 | { TRAMP_SENTINEL_INSN }, | |
664 | }, | |
665 | ppc32_linux_sighandler_cache_init | |
666 | }; | |
667 | static struct tramp_frame ppc64_linux_sighandler_tramp_frame = { | |
668 | SIGTRAMP_FRAME, | |
669 | 4, | |
670 | { | |
671 | { 0x38210080, -1 }, /* addi r1,r1,128 */ | |
672 | { 0x38000077, -1 }, /* li r0,119 */ | |
673 | { 0x44000002, -1 }, /* sc */ | |
674 | { TRAMP_SENTINEL_INSN }, | |
675 | }, | |
676 | ppc64_linux_sighandler_cache_init | |
677 | }; | |
678 | ||
7284e1be | 679 | |
85e747d2 UW |
680 | /* Address to use for displaced stepping. When debugging a stand-alone |
681 | SPU executable, entry_point_address () will point to an SPU local-store | |
682 | address and is thus not usable as displaced stepping location. We use | |
683 | the auxiliary vector to determine the PowerPC-side entry point address | |
684 | instead. */ | |
685 | ||
686 | static CORE_ADDR ppc_linux_entry_point_addr = 0; | |
687 | ||
688 | static void | |
689 | ppc_linux_inferior_created (struct target_ops *target, int from_tty) | |
690 | { | |
691 | ppc_linux_entry_point_addr = 0; | |
692 | } | |
693 | ||
694 | static CORE_ADDR | |
695 | ppc_linux_displaced_step_location (struct gdbarch *gdbarch) | |
696 | { | |
697 | if (ppc_linux_entry_point_addr == 0) | |
698 | { | |
699 | CORE_ADDR addr; | |
700 | ||
701 | /* Determine entry point from target auxiliary vector. */ | |
702 | if (target_auxv_search (¤t_target, AT_ENTRY, &addr) <= 0) | |
703 | error (_("Cannot find AT_ENTRY auxiliary vector entry.")); | |
704 | ||
705 | /* Make certain that the address points at real code, and not a | |
706 | function descriptor. */ | |
707 | addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, | |
708 | ¤t_target); | |
709 | ||
710 | /* Inferior calls also use the entry point as a breakpoint location. | |
711 | We don't want displaced stepping to interfere with those | |
712 | breakpoints, so leave space. */ | |
5931a2fa | 713 | ppc_linux_entry_point_addr = addr + 2 * PPC_INSN_SIZE; |
85e747d2 UW |
714 | } |
715 | ||
716 | return ppc_linux_entry_point_addr; | |
717 | } | |
718 | ||
719 | ||
7284e1be UW |
720 | /* Return 1 if PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM are usable. */ |
721 | int | |
722 | ppc_linux_trap_reg_p (struct gdbarch *gdbarch) | |
723 | { | |
724 | /* If we do not have a target description with registers, then | |
725 | the special registers will not be included in the register set. */ | |
726 | if (!tdesc_has_registers (gdbarch_target_desc (gdbarch))) | |
727 | return 0; | |
728 | ||
729 | /* If we do, then it is safe to check the size. */ | |
730 | return register_size (gdbarch, PPC_ORIG_R3_REGNUM) > 0 | |
731 | && register_size (gdbarch, PPC_TRAP_REGNUM) > 0; | |
732 | } | |
733 | ||
a96d9b2e SDJ |
734 | /* Return the current system call's number present in the |
735 | r0 register. When the function fails, it returns -1. */ | |
736 | static LONGEST | |
737 | ppc_linux_get_syscall_number (struct gdbarch *gdbarch, | |
738 | ptid_t ptid) | |
739 | { | |
740 | struct regcache *regcache = get_thread_regcache (ptid); | |
741 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
742 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
743 | struct cleanup *cleanbuf; | |
744 | /* The content of a register */ | |
745 | gdb_byte *buf; | |
746 | /* The result */ | |
747 | LONGEST ret; | |
748 | ||
749 | /* Make sure we're in a 32- or 64-bit machine */ | |
750 | gdb_assert (tdep->wordsize == 4 || tdep->wordsize == 8); | |
751 | ||
752 | buf = (gdb_byte *) xmalloc (tdep->wordsize * sizeof (gdb_byte)); | |
753 | ||
754 | cleanbuf = make_cleanup (xfree, buf); | |
755 | ||
756 | /* Getting the system call number from the register. | |
757 | When dealing with PowerPC architecture, this information | |
758 | is stored at 0th register. */ | |
759 | regcache_cooked_read (regcache, tdep->ppc_gp0_regnum, buf); | |
760 | ||
761 | ret = extract_signed_integer (buf, tdep->wordsize, byte_order); | |
762 | do_cleanups (cleanbuf); | |
763 | ||
764 | return ret; | |
765 | } | |
766 | ||
7284e1be UW |
767 | static void |
768 | ppc_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) | |
769 | { | |
770 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
771 | ||
772 | regcache_cooked_write_unsigned (regcache, gdbarch_pc_regnum (gdbarch), pc); | |
773 | ||
774 | /* Set special TRAP register to -1 to prevent the kernel from | |
775 | messing with the PC we just installed, if we happen to be | |
776 | within an interrupted system call that the kernel wants to | |
777 | restart. | |
778 | ||
779 | Note that after we return from the dummy call, the TRAP and | |
780 | ORIG_R3 registers will be automatically restored, and the | |
781 | kernel continues to restart the system call at this point. */ | |
782 | if (ppc_linux_trap_reg_p (gdbarch)) | |
783 | regcache_cooked_write_unsigned (regcache, PPC_TRAP_REGNUM, -1); | |
784 | } | |
785 | ||
f4d9bade UW |
786 | static int |
787 | ppc_linux_spu_section (bfd *abfd, asection *asect, void *user_data) | |
788 | { | |
789 | return strncmp (bfd_section_name (abfd, asect), "SPU/", 4) == 0; | |
790 | } | |
791 | ||
7284e1be UW |
792 | static const struct target_desc * |
793 | ppc_linux_core_read_description (struct gdbarch *gdbarch, | |
794 | struct target_ops *target, | |
795 | bfd *abfd) | |
796 | { | |
f4d9bade | 797 | asection *cell = bfd_sections_find_if (abfd, ppc_linux_spu_section, NULL); |
7284e1be | 798 | asection *altivec = bfd_get_section_by_name (abfd, ".reg-ppc-vmx"); |
604c2f83 | 799 | asection *vsx = bfd_get_section_by_name (abfd, ".reg-ppc-vsx"); |
7284e1be UW |
800 | asection *section = bfd_get_section_by_name (abfd, ".reg"); |
801 | if (! section) | |
802 | return NULL; | |
803 | ||
804 | switch (bfd_section_size (abfd, section)) | |
805 | { | |
806 | case 48 * 4: | |
f4d9bade UW |
807 | if (cell) |
808 | return tdesc_powerpc_cell32l; | |
809 | else if (vsx) | |
604c2f83 LM |
810 | return tdesc_powerpc_vsx32l; |
811 | else if (altivec) | |
812 | return tdesc_powerpc_altivec32l; | |
813 | else | |
814 | return tdesc_powerpc_32l; | |
7284e1be UW |
815 | |
816 | case 48 * 8: | |
f4d9bade UW |
817 | if (cell) |
818 | return tdesc_powerpc_cell64l; | |
819 | else if (vsx) | |
604c2f83 LM |
820 | return tdesc_powerpc_vsx64l; |
821 | else if (altivec) | |
822 | return tdesc_powerpc_altivec64l; | |
823 | else | |
824 | return tdesc_powerpc_64l; | |
7284e1be UW |
825 | |
826 | default: | |
827 | return NULL; | |
828 | } | |
829 | } | |
830 | ||
591a12a1 UW |
831 | |
832 | /* Implementation of `gdbarch_elf_make_msymbol_special', as defined in | |
833 | gdbarch.h. This implementation is used for the ELFv2 ABI only. */ | |
834 | ||
835 | static void | |
836 | ppc_elfv2_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym) | |
837 | { | |
838 | elf_symbol_type *elf_sym = (elf_symbol_type *)sym; | |
839 | ||
840 | /* If the symbol is marked as having a local entry point, set a target | |
841 | flag in the msymbol. We currently only support local entry point | |
842 | offsets of 8 bytes, which is the only entry point offset ever used | |
843 | by current compilers. If/when other offsets are ever used, we will | |
844 | have to use additional target flag bits to store them. */ | |
845 | switch (PPC64_LOCAL_ENTRY_OFFSET (elf_sym->internal_elf_sym.st_other)) | |
846 | { | |
847 | default: | |
848 | break; | |
849 | case 8: | |
850 | MSYMBOL_TARGET_FLAG_1 (msym) = 1; | |
851 | break; | |
852 | } | |
853 | } | |
854 | ||
855 | /* Implementation of `gdbarch_skip_entrypoint', as defined in | |
856 | gdbarch.h. This implementation is used for the ELFv2 ABI only. */ | |
857 | ||
858 | static CORE_ADDR | |
859 | ppc_elfv2_skip_entrypoint (struct gdbarch *gdbarch, CORE_ADDR pc) | |
860 | { | |
861 | struct bound_minimal_symbol fun; | |
862 | int local_entry_offset = 0; | |
863 | ||
864 | fun = lookup_minimal_symbol_by_pc (pc); | |
865 | if (fun.minsym == NULL) | |
866 | return pc; | |
867 | ||
868 | /* See ppc_elfv2_elf_make_msymbol_special for how local entry point | |
869 | offset values are encoded. */ | |
870 | if (MSYMBOL_TARGET_FLAG_1 (fun.minsym)) | |
871 | local_entry_offset = 8; | |
872 | ||
77e371c0 TT |
873 | if (BMSYMBOL_VALUE_ADDRESS (fun) <= pc |
874 | && pc < BMSYMBOL_VALUE_ADDRESS (fun) + local_entry_offset) | |
875 | return BMSYMBOL_VALUE_ADDRESS (fun) + local_entry_offset; | |
591a12a1 UW |
876 | |
877 | return pc; | |
878 | } | |
879 | ||
55aa24fb SDJ |
880 | /* Implementation of `gdbarch_stap_is_single_operand', as defined in |
881 | gdbarch.h. */ | |
882 | ||
883 | static int | |
884 | ppc_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) | |
885 | { | |
886 | return (*s == 'i' /* Literal number. */ | |
887 | || (isdigit (*s) && s[1] == '(' | |
888 | && isdigit (s[2])) /* Displacement. */ | |
889 | || (*s == '(' && isdigit (s[1])) /* Register indirection. */ | |
890 | || isdigit (*s)); /* Register value. */ | |
891 | } | |
892 | ||
893 | /* Implementation of `gdbarch_stap_parse_special_token', as defined in | |
894 | gdbarch.h. */ | |
895 | ||
896 | static int | |
897 | ppc_stap_parse_special_token (struct gdbarch *gdbarch, | |
898 | struct stap_parse_info *p) | |
899 | { | |
900 | if (isdigit (*p->arg)) | |
901 | { | |
902 | /* This temporary pointer is needed because we have to do a lookahead. | |
903 | We could be dealing with a register displacement, and in such case | |
904 | we would not need to do anything. */ | |
905 | const char *s = p->arg; | |
906 | char *regname; | |
907 | int len; | |
908 | struct stoken str; | |
909 | ||
910 | while (isdigit (*s)) | |
911 | ++s; | |
912 | ||
913 | if (*s == '(') | |
914 | { | |
915 | /* It is a register displacement indeed. Returning 0 means we are | |
916 | deferring the treatment of this case to the generic parser. */ | |
917 | return 0; | |
918 | } | |
919 | ||
920 | len = s - p->arg; | |
921 | regname = alloca (len + 2); | |
922 | regname[0] = 'r'; | |
923 | ||
924 | strncpy (regname + 1, p->arg, len); | |
925 | ++len; | |
926 | regname[len] = '\0'; | |
927 | ||
928 | if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1) | |
929 | error (_("Invalid register name `%s' on expression `%s'."), | |
930 | regname, p->saved_arg); | |
931 | ||
410a0ff2 | 932 | write_exp_elt_opcode (&p->pstate, OP_REGISTER); |
55aa24fb SDJ |
933 | str.ptr = regname; |
934 | str.length = len; | |
410a0ff2 SDJ |
935 | write_exp_string (&p->pstate, str); |
936 | write_exp_elt_opcode (&p->pstate, OP_REGISTER); | |
55aa24fb SDJ |
937 | |
938 | p->arg = s; | |
939 | } | |
940 | else | |
941 | { | |
942 | /* All the other tokens should be handled correctly by the generic | |
943 | parser. */ | |
944 | return 0; | |
945 | } | |
946 | ||
947 | return 1; | |
948 | } | |
cc5f0d61 UW |
949 | |
950 | /* Cell/B.E. active SPE context tracking support. */ | |
951 | ||
952 | static struct objfile *spe_context_objfile = NULL; | |
953 | static CORE_ADDR spe_context_lm_addr = 0; | |
954 | static CORE_ADDR spe_context_offset = 0; | |
955 | ||
956 | static ptid_t spe_context_cache_ptid; | |
957 | static CORE_ADDR spe_context_cache_address; | |
958 | ||
959 | /* Hook into inferior_created, solib_loaded, and solib_unloaded observers | |
960 | to track whether we've loaded a version of libspe2 (as static or dynamic | |
961 | library) that provides the __spe_current_active_context variable. */ | |
962 | static void | |
963 | ppc_linux_spe_context_lookup (struct objfile *objfile) | |
964 | { | |
3b7344d5 | 965 | struct bound_minimal_symbol sym; |
cc5f0d61 UW |
966 | |
967 | if (!objfile) | |
968 | { | |
969 | spe_context_objfile = NULL; | |
970 | spe_context_lm_addr = 0; | |
971 | spe_context_offset = 0; | |
972 | spe_context_cache_ptid = minus_one_ptid; | |
973 | spe_context_cache_address = 0; | |
974 | return; | |
975 | } | |
976 | ||
977 | sym = lookup_minimal_symbol ("__spe_current_active_context", NULL, objfile); | |
3b7344d5 | 978 | if (sym.minsym) |
cc5f0d61 UW |
979 | { |
980 | spe_context_objfile = objfile; | |
981 | spe_context_lm_addr = svr4_fetch_objfile_link_map (objfile); | |
77e371c0 | 982 | spe_context_offset = BMSYMBOL_VALUE_ADDRESS (sym); |
cc5f0d61 UW |
983 | spe_context_cache_ptid = minus_one_ptid; |
984 | spe_context_cache_address = 0; | |
985 | return; | |
986 | } | |
987 | } | |
988 | ||
989 | static void | |
990 | ppc_linux_spe_context_inferior_created (struct target_ops *t, int from_tty) | |
991 | { | |
992 | struct objfile *objfile; | |
993 | ||
994 | ppc_linux_spe_context_lookup (NULL); | |
995 | ALL_OBJFILES (objfile) | |
996 | ppc_linux_spe_context_lookup (objfile); | |
997 | } | |
998 | ||
999 | static void | |
1000 | ppc_linux_spe_context_solib_loaded (struct so_list *so) | |
1001 | { | |
1002 | if (strstr (so->so_original_name, "/libspe") != NULL) | |
1003 | { | |
7e559477 | 1004 | solib_read_symbols (so, 0); |
cc5f0d61 UW |
1005 | ppc_linux_spe_context_lookup (so->objfile); |
1006 | } | |
1007 | } | |
1008 | ||
1009 | static void | |
1010 | ppc_linux_spe_context_solib_unloaded (struct so_list *so) | |
1011 | { | |
1012 | if (so->objfile == spe_context_objfile) | |
1013 | ppc_linux_spe_context_lookup (NULL); | |
1014 | } | |
1015 | ||
1016 | /* Retrieve contents of the N'th element in the current thread's | |
1017 | linked SPE context list into ID and NPC. Return the address of | |
1018 | said context element, or 0 if not found. */ | |
1019 | static CORE_ADDR | |
1020 | ppc_linux_spe_context (int wordsize, enum bfd_endian byte_order, | |
1021 | int n, int *id, unsigned int *npc) | |
1022 | { | |
1023 | CORE_ADDR spe_context = 0; | |
1024 | gdb_byte buf[16]; | |
1025 | int i; | |
1026 | ||
1027 | /* Quick exit if we have not found __spe_current_active_context. */ | |
1028 | if (!spe_context_objfile) | |
1029 | return 0; | |
1030 | ||
1031 | /* Look up cached address of thread-local variable. */ | |
1032 | if (!ptid_equal (spe_context_cache_ptid, inferior_ptid)) | |
1033 | { | |
1034 | struct target_ops *target = ¤t_target; | |
1035 | volatile struct gdb_exception ex; | |
1036 | ||
cc5f0d61 UW |
1037 | TRY_CATCH (ex, RETURN_MASK_ERROR) |
1038 | { | |
1039 | /* We do not call target_translate_tls_address here, because | |
1040 | svr4_fetch_objfile_link_map may invalidate the frame chain, | |
1041 | which must not do while inside a frame sniffer. | |
1042 | ||
1043 | Instead, we have cached the lm_addr value, and use that to | |
1044 | directly call the target's to_get_thread_local_address. */ | |
1045 | spe_context_cache_address | |
1046 | = target->to_get_thread_local_address (target, inferior_ptid, | |
1047 | spe_context_lm_addr, | |
1048 | spe_context_offset); | |
1049 | spe_context_cache_ptid = inferior_ptid; | |
1050 | } | |
1051 | ||
1052 | if (ex.reason < 0) | |
1053 | return 0; | |
1054 | } | |
1055 | ||
1056 | /* Read variable value. */ | |
1057 | if (target_read_memory (spe_context_cache_address, buf, wordsize) == 0) | |
1058 | spe_context = extract_unsigned_integer (buf, wordsize, byte_order); | |
1059 | ||
1060 | /* Cyle through to N'th linked list element. */ | |
1061 | for (i = 0; i < n && spe_context; i++) | |
1062 | if (target_read_memory (spe_context + align_up (12, wordsize), | |
1063 | buf, wordsize) == 0) | |
1064 | spe_context = extract_unsigned_integer (buf, wordsize, byte_order); | |
1065 | else | |
1066 | spe_context = 0; | |
1067 | ||
1068 | /* Read current context. */ | |
1069 | if (spe_context | |
1070 | && target_read_memory (spe_context, buf, 12) != 0) | |
1071 | spe_context = 0; | |
1072 | ||
1073 | /* Extract data elements. */ | |
1074 | if (spe_context) | |
1075 | { | |
1076 | if (id) | |
1077 | *id = extract_signed_integer (buf, 4, byte_order); | |
1078 | if (npc) | |
1079 | *npc = extract_unsigned_integer (buf + 4, 4, byte_order); | |
1080 | } | |
1081 | ||
1082 | return spe_context; | |
1083 | } | |
1084 | ||
1085 | ||
1086 | /* Cell/B.E. cross-architecture unwinder support. */ | |
1087 | ||
1088 | struct ppu2spu_cache | |
1089 | { | |
1090 | struct frame_id frame_id; | |
1091 | struct regcache *regcache; | |
1092 | }; | |
1093 | ||
1094 | static struct gdbarch * | |
1095 | ppu2spu_prev_arch (struct frame_info *this_frame, void **this_cache) | |
1096 | { | |
1097 | struct ppu2spu_cache *cache = *this_cache; | |
1098 | return get_regcache_arch (cache->regcache); | |
1099 | } | |
1100 | ||
1101 | static void | |
1102 | ppu2spu_this_id (struct frame_info *this_frame, | |
1103 | void **this_cache, struct frame_id *this_id) | |
1104 | { | |
1105 | struct ppu2spu_cache *cache = *this_cache; | |
1106 | *this_id = cache->frame_id; | |
1107 | } | |
1108 | ||
1109 | static struct value * | |
1110 | ppu2spu_prev_register (struct frame_info *this_frame, | |
1111 | void **this_cache, int regnum) | |
1112 | { | |
1113 | struct ppu2spu_cache *cache = *this_cache; | |
1114 | struct gdbarch *gdbarch = get_regcache_arch (cache->regcache); | |
1115 | gdb_byte *buf; | |
1116 | ||
1117 | buf = alloca (register_size (gdbarch, regnum)); | |
a536c6d7 UW |
1118 | |
1119 | if (regnum < gdbarch_num_regs (gdbarch)) | |
1120 | regcache_raw_read (cache->regcache, regnum, buf); | |
1121 | else | |
1122 | gdbarch_pseudo_register_read (gdbarch, cache->regcache, regnum, buf); | |
1123 | ||
cc5f0d61 UW |
1124 | return frame_unwind_got_bytes (this_frame, regnum, buf); |
1125 | } | |
1126 | ||
1127 | struct ppu2spu_data | |
1128 | { | |
1129 | struct gdbarch *gdbarch; | |
1130 | int id; | |
1131 | unsigned int npc; | |
1132 | gdb_byte gprs[128*16]; | |
1133 | }; | |
1134 | ||
1135 | static int | |
1136 | ppu2spu_unwind_register (void *src, int regnum, gdb_byte *buf) | |
1137 | { | |
1138 | struct ppu2spu_data *data = src; | |
1139 | enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch); | |
1140 | ||
1141 | if (regnum >= 0 && regnum < SPU_NUM_GPRS) | |
1142 | memcpy (buf, data->gprs + 16*regnum, 16); | |
1143 | else if (regnum == SPU_ID_REGNUM) | |
1144 | store_unsigned_integer (buf, 4, byte_order, data->id); | |
1145 | else if (regnum == SPU_PC_REGNUM) | |
1146 | store_unsigned_integer (buf, 4, byte_order, data->npc); | |
1147 | else | |
a536c6d7 | 1148 | return REG_UNAVAILABLE; |
cc5f0d61 | 1149 | |
a536c6d7 | 1150 | return REG_VALID; |
cc5f0d61 UW |
1151 | } |
1152 | ||
1153 | static int | |
1154 | ppu2spu_sniffer (const struct frame_unwind *self, | |
1155 | struct frame_info *this_frame, void **this_prologue_cache) | |
1156 | { | |
1157 | struct gdbarch *gdbarch = get_frame_arch (this_frame); | |
1158 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
1159 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
1160 | struct ppu2spu_data data; | |
1161 | struct frame_info *fi; | |
1162 | CORE_ADDR base, func, backchain, spe_context; | |
1163 | gdb_byte buf[8]; | |
1164 | int n = 0; | |
1165 | ||
1166 | /* Count the number of SPU contexts already in the frame chain. */ | |
1167 | for (fi = get_next_frame (this_frame); fi; fi = get_next_frame (fi)) | |
1168 | if (get_frame_type (fi) == ARCH_FRAME | |
1169 | && gdbarch_bfd_arch_info (get_frame_arch (fi))->arch == bfd_arch_spu) | |
1170 | n++; | |
1171 | ||
1172 | base = get_frame_sp (this_frame); | |
1173 | func = get_frame_pc (this_frame); | |
1174 | if (target_read_memory (base, buf, tdep->wordsize)) | |
1175 | return 0; | |
1176 | backchain = extract_unsigned_integer (buf, tdep->wordsize, byte_order); | |
1177 | ||
1178 | spe_context = ppc_linux_spe_context (tdep->wordsize, byte_order, | |
1179 | n, &data.id, &data.npc); | |
1180 | if (spe_context && base <= spe_context && spe_context < backchain) | |
1181 | { | |
1182 | char annex[32]; | |
1183 | ||
1184 | /* Find gdbarch for SPU. */ | |
1185 | struct gdbarch_info info; | |
1186 | gdbarch_info_init (&info); | |
1187 | info.bfd_arch_info = bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu); | |
1188 | info.byte_order = BFD_ENDIAN_BIG; | |
1189 | info.osabi = GDB_OSABI_LINUX; | |
1190 | info.tdep_info = (void *) &data.id; | |
1191 | data.gdbarch = gdbarch_find_by_info (info); | |
1192 | if (!data.gdbarch) | |
1193 | return 0; | |
1194 | ||
1195 | xsnprintf (annex, sizeof annex, "%d/regs", data.id); | |
1196 | if (target_read (¤t_target, TARGET_OBJECT_SPU, annex, | |
1197 | data.gprs, 0, sizeof data.gprs) | |
1198 | == sizeof data.gprs) | |
1199 | { | |
1200 | struct ppu2spu_cache *cache | |
1201 | = FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache); | |
1202 | ||
d37346f0 DJ |
1203 | struct address_space *aspace = get_frame_address_space (this_frame); |
1204 | struct regcache *regcache = regcache_xmalloc (data.gdbarch, aspace); | |
cc5f0d61 UW |
1205 | struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache); |
1206 | regcache_save (regcache, ppu2spu_unwind_register, &data); | |
1207 | discard_cleanups (cleanups); | |
1208 | ||
1209 | cache->frame_id = frame_id_build (base, func); | |
1210 | cache->regcache = regcache; | |
1211 | *this_prologue_cache = cache; | |
1212 | return 1; | |
1213 | } | |
1214 | } | |
1215 | ||
1216 | return 0; | |
1217 | } | |
1218 | ||
1219 | static void | |
1220 | ppu2spu_dealloc_cache (struct frame_info *self, void *this_cache) | |
1221 | { | |
1222 | struct ppu2spu_cache *cache = this_cache; | |
1223 | regcache_xfree (cache->regcache); | |
1224 | } | |
1225 | ||
1226 | static const struct frame_unwind ppu2spu_unwind = { | |
1227 | ARCH_FRAME, | |
8fbca658 | 1228 | default_frame_unwind_stop_reason, |
cc5f0d61 UW |
1229 | ppu2spu_this_id, |
1230 | ppu2spu_prev_register, | |
1231 | NULL, | |
1232 | ppu2spu_sniffer, | |
1233 | ppu2spu_dealloc_cache, | |
1234 | ppu2spu_prev_arch, | |
1235 | }; | |
1236 | ||
1237 | ||
7b112f9c JT |
1238 | static void |
1239 | ppc_linux_init_abi (struct gdbarch_info info, | |
1240 | struct gdbarch *gdbarch) | |
1241 | { | |
1242 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
7284e1be | 1243 | struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info; |
05c0465e SDJ |
1244 | static const char *const stap_integer_prefixes[] = { "i", NULL }; |
1245 | static const char *const stap_register_indirection_prefixes[] = { "(", | |
1246 | NULL }; | |
1247 | static const char *const stap_register_indirection_suffixes[] = { ")", | |
1248 | NULL }; | |
7b112f9c | 1249 | |
a5ee0f0c PA |
1250 | linux_init_abi (info, gdbarch); |
1251 | ||
b14d30e1 JM |
1252 | /* PPC GNU/Linux uses either 64-bit or 128-bit long doubles; where |
1253 | 128-bit, they are IBM long double, not IEEE quad long double as | |
1254 | in the System V ABI PowerPC Processor Supplement. We can safely | |
1255 | let them default to 128-bit, since the debug info will give the | |
1256 | size of type actually used in each case. */ | |
1257 | set_gdbarch_long_double_bit (gdbarch, 16 * TARGET_CHAR_BIT); | |
1258 | set_gdbarch_long_double_format (gdbarch, floatformats_ibm_long_double); | |
0598a43c | 1259 | |
7284e1be UW |
1260 | /* Handle inferior calls during interrupted system calls. */ |
1261 | set_gdbarch_write_pc (gdbarch, ppc_linux_write_pc); | |
1262 | ||
a96d9b2e SDJ |
1263 | /* Get the syscall number from the arch's register. */ |
1264 | set_gdbarch_get_syscall_number (gdbarch, ppc_linux_get_syscall_number); | |
1265 | ||
55aa24fb | 1266 | /* SystemTap functions. */ |
05c0465e SDJ |
1267 | set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes); |
1268 | set_gdbarch_stap_register_indirection_prefixes (gdbarch, | |
1269 | stap_register_indirection_prefixes); | |
1270 | set_gdbarch_stap_register_indirection_suffixes (gdbarch, | |
1271 | stap_register_indirection_suffixes); | |
55aa24fb SDJ |
1272 | set_gdbarch_stap_gdb_register_prefix (gdbarch, "r"); |
1273 | set_gdbarch_stap_is_single_operand (gdbarch, ppc_stap_is_single_operand); | |
1274 | set_gdbarch_stap_parse_special_token (gdbarch, | |
1275 | ppc_stap_parse_special_token); | |
1276 | ||
7b112f9c JT |
1277 | if (tdep->wordsize == 4) |
1278 | { | |
b9ff3018 AC |
1279 | /* Until November 2001, gcc did not comply with the 32 bit SysV |
1280 | R4 ABI requirement that structures less than or equal to 8 | |
1281 | bytes should be returned in registers. Instead GCC was using | |
b021a221 | 1282 | the AIX/PowerOpen ABI - everything returned in memory |
b9ff3018 AC |
1283 | (well ignoring vectors that is). When this was corrected, it |
1284 | wasn't fixed for GNU/Linux native platform. Use the | |
1285 | PowerOpen struct convention. */ | |
05580c65 | 1286 | set_gdbarch_return_value (gdbarch, ppc_linux_return_value); |
b9ff3018 | 1287 | |
7b112f9c JT |
1288 | set_gdbarch_memory_remove_breakpoint (gdbarch, |
1289 | ppc_linux_memory_remove_breakpoint); | |
61a65099 | 1290 | |
f470a70a | 1291 | /* Shared library handling. */ |
5d853008 | 1292 | set_gdbarch_skip_trampoline_code (gdbarch, ppc_skip_trampoline_code); |
7b112f9c | 1293 | set_solib_svr4_fetch_link_map_offsets |
76a9d10f | 1294 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); |
a8f60bfc | 1295 | |
a96d9b2e SDJ |
1296 | /* Setting the correct XML syscall filename. */ |
1297 | set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC); | |
1298 | ||
a8f60bfc | 1299 | /* Trampolines. */ |
0df8b418 MS |
1300 | tramp_frame_prepend_unwinder (gdbarch, |
1301 | &ppc32_linux_sigaction_tramp_frame); | |
1302 | tramp_frame_prepend_unwinder (gdbarch, | |
1303 | &ppc32_linux_sighandler_tramp_frame); | |
a78c2d62 UW |
1304 | |
1305 | /* BFD target for core files. */ | |
1306 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) | |
1307 | set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpcle"); | |
1308 | else | |
1309 | set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpc"); | |
2f2241f1 | 1310 | |
5d853008 ME |
1311 | if (powerpc_so_ops.in_dynsym_resolve_code == NULL) |
1312 | { | |
1313 | powerpc_so_ops = svr4_so_ops; | |
1314 | /* Override dynamic resolve function. */ | |
1315 | powerpc_so_ops.in_dynsym_resolve_code = | |
1316 | powerpc_linux_in_dynsym_resolve_code; | |
1317 | } | |
1318 | set_solib_ops (gdbarch, &powerpc_so_ops); | |
1319 | ||
1320 | set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver); | |
7b112f9c | 1321 | } |
f470a70a JB |
1322 | |
1323 | if (tdep->wordsize == 8) | |
1324 | { | |
d4094b6a UW |
1325 | if (tdep->elf_abi == POWERPC_ELF_V1) |
1326 | { | |
1327 | /* Handle PPC GNU/Linux 64-bit function pointers (which are really | |
1328 | function descriptors). */ | |
1329 | set_gdbarch_convert_from_func_ptr_addr | |
1330 | (gdbarch, ppc64_convert_from_func_ptr_addr); | |
00d5f93a | 1331 | |
d4094b6a UW |
1332 | set_gdbarch_elf_make_msymbol_special |
1333 | (gdbarch, ppc64_elf_make_msymbol_special); | |
1334 | } | |
591a12a1 UW |
1335 | else |
1336 | { | |
1337 | set_gdbarch_elf_make_msymbol_special | |
1338 | (gdbarch, ppc_elfv2_elf_make_msymbol_special); | |
1339 | ||
1340 | set_gdbarch_skip_entrypoint (gdbarch, ppc_elfv2_skip_entrypoint); | |
1341 | } | |
24c274a1 | 1342 | |
fb318ff7 | 1343 | /* Shared library handling. */ |
2bbe3cc1 | 1344 | set_gdbarch_skip_trampoline_code (gdbarch, ppc64_skip_trampoline_code); |
fb318ff7 DJ |
1345 | set_solib_svr4_fetch_link_map_offsets |
1346 | (gdbarch, svr4_lp64_fetch_link_map_offsets); | |
1347 | ||
a96d9b2e SDJ |
1348 | /* Setting the correct XML syscall filename. */ |
1349 | set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC64); | |
1350 | ||
a8f60bfc | 1351 | /* Trampolines. */ |
0df8b418 MS |
1352 | tramp_frame_prepend_unwinder (gdbarch, |
1353 | &ppc64_linux_sigaction_tramp_frame); | |
1354 | tramp_frame_prepend_unwinder (gdbarch, | |
1355 | &ppc64_linux_sighandler_tramp_frame); | |
a78c2d62 UW |
1356 | |
1357 | /* BFD target for core files. */ | |
1358 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) | |
1359 | set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle"); | |
1360 | else | |
1361 | set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc"); | |
f470a70a | 1362 | } |
b3ac9c77 SDJ |
1363 | |
1364 | /* PPC32 uses a different prpsinfo32 compared to most other Linux | |
1365 | archs. */ | |
1366 | if (tdep->wordsize == 4) | |
1367 | set_gdbarch_elfcore_write_linux_prpsinfo (gdbarch, | |
1368 | elfcore_write_ppc_linux_prpsinfo32); | |
1369 | ||
7284e1be | 1370 | set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description); |
5aa82d05 AA |
1371 | set_gdbarch_iterate_over_regset_sections (gdbarch, |
1372 | ppc_linux_iterate_over_regset_sections); | |
b2756930 KB |
1373 | |
1374 | /* Enable TLS support. */ | |
1375 | set_gdbarch_fetch_tls_load_module_address (gdbarch, | |
1376 | svr4_fetch_objfile_link_map); | |
7284e1be UW |
1377 | |
1378 | if (tdesc_data) | |
1379 | { | |
1380 | const struct tdesc_feature *feature; | |
1381 | ||
1382 | /* If we have target-described registers, then we can safely | |
1383 | reserve a number for PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM | |
1384 | (whether they are described or not). */ | |
1385 | gdb_assert (gdbarch_num_regs (gdbarch) <= PPC_ORIG_R3_REGNUM); | |
1386 | set_gdbarch_num_regs (gdbarch, PPC_TRAP_REGNUM + 1); | |
1387 | ||
1388 | /* If they are present, then assign them to the reserved number. */ | |
1389 | feature = tdesc_find_feature (info.target_desc, | |
1390 | "org.gnu.gdb.power.linux"); | |
1391 | if (feature != NULL) | |
1392 | { | |
1393 | tdesc_numbered_register (feature, tdesc_data, | |
1394 | PPC_ORIG_R3_REGNUM, "orig_r3"); | |
1395 | tdesc_numbered_register (feature, tdesc_data, | |
1396 | PPC_TRAP_REGNUM, "trap"); | |
1397 | } | |
1398 | } | |
85e747d2 UW |
1399 | |
1400 | /* Enable Cell/B.E. if supported by the target. */ | |
1401 | if (tdesc_compatible_p (info.target_desc, | |
1402 | bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu))) | |
1403 | { | |
1404 | /* Cell/B.E. multi-architecture support. */ | |
1405 | set_spu_solib_ops (gdbarch); | |
1406 | ||
cc5f0d61 UW |
1407 | /* Cell/B.E. cross-architecture unwinder support. */ |
1408 | frame_unwind_prepend_unwinder (gdbarch, &ppu2spu_unwind); | |
1409 | ||
85e747d2 UW |
1410 | /* The default displaced_step_at_entry_point doesn't work for |
1411 | SPU stand-alone executables. */ | |
1412 | set_gdbarch_displaced_step_location (gdbarch, | |
1413 | ppc_linux_displaced_step_location); | |
1414 | } | |
f782ad9b AS |
1415 | |
1416 | set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type); | |
7b112f9c JT |
1417 | } |
1418 | ||
63807e1d PA |
1419 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
1420 | extern initialize_file_ftype _initialize_ppc_linux_tdep; | |
1421 | ||
7b112f9c JT |
1422 | void |
1423 | _initialize_ppc_linux_tdep (void) | |
1424 | { | |
0a0a4ac3 AC |
1425 | /* Register for all sub-familes of the POWER/PowerPC: 32-bit and |
1426 | 64-bit PowerPC, and the older rs6k. */ | |
1427 | gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc, GDB_OSABI_LINUX, | |
1428 | ppc_linux_init_abi); | |
1429 | gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc64, GDB_OSABI_LINUX, | |
1430 | ppc_linux_init_abi); | |
1431 | gdbarch_register_osabi (bfd_arch_rs6000, bfd_mach_rs6k, GDB_OSABI_LINUX, | |
1432 | ppc_linux_init_abi); | |
7284e1be | 1433 | |
85e747d2 UW |
1434 | /* Attach to inferior_created observer. */ |
1435 | observer_attach_inferior_created (ppc_linux_inferior_created); | |
1436 | ||
cc5f0d61 UW |
1437 | /* Attach to observers to track __spe_current_active_context. */ |
1438 | observer_attach_inferior_created (ppc_linux_spe_context_inferior_created); | |
1439 | observer_attach_solib_loaded (ppc_linux_spe_context_solib_loaded); | |
1440 | observer_attach_solib_unloaded (ppc_linux_spe_context_solib_unloaded); | |
1441 | ||
7284e1be UW |
1442 | /* Initialize the Linux target descriptions. */ |
1443 | initialize_tdesc_powerpc_32l (); | |
1444 | initialize_tdesc_powerpc_altivec32l (); | |
f4d9bade | 1445 | initialize_tdesc_powerpc_cell32l (); |
604c2f83 | 1446 | initialize_tdesc_powerpc_vsx32l (); |
69abc51c TJB |
1447 | initialize_tdesc_powerpc_isa205_32l (); |
1448 | initialize_tdesc_powerpc_isa205_altivec32l (); | |
1449 | initialize_tdesc_powerpc_isa205_vsx32l (); | |
7284e1be UW |
1450 | initialize_tdesc_powerpc_64l (); |
1451 | initialize_tdesc_powerpc_altivec64l (); | |
f4d9bade | 1452 | initialize_tdesc_powerpc_cell64l (); |
604c2f83 | 1453 | initialize_tdesc_powerpc_vsx64l (); |
69abc51c TJB |
1454 | initialize_tdesc_powerpc_isa205_64l (); |
1455 | initialize_tdesc_powerpc_isa205_altivec64l (); | |
1456 | initialize_tdesc_powerpc_isa205_vsx64l (); | |
7284e1be | 1457 | initialize_tdesc_powerpc_e500l (); |
7b112f9c | 1458 | } |