GDB (xrefs)
/tmp/gdb-7.10/gdb/ppc-linux-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for GDB, the GNU debugger.
2 
3  Copyright (C) 1986-2015 Free Software Foundation, Inc.
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
9  the Free Software Foundation; either version 3 of the License, or
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
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
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"
29 #include "regcache.h"
30 #include "value.h"
31 #include "osabi.h"
32 #include "regset.h"
33 #include "solib-svr4.h"
34 #include "solib-spu.h"
35 #include "solib.h"
36 #include "solist.h"
37 #include "ppc-tdep.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"
44 #include "observer.h"
45 #include "auxv.h"
46 #include "elf/common.h"
47 #include "elf/ppc64.h"
48 #include "arch-utils.h"
49 #include "spu-tdep.h"
50 #include "xml-syscall.h"
51 #include "linux-tdep.h"
52 #include "linux-record.h"
53 #include "record-full.h"
54 #include "infrun.h"
55 
56 #include "stap-probe.h"
57 #include "ax.h"
58 #include "ax-gdb.h"
59 #include "cli/cli-utils.h"
60 #include "parser-defs.h"
61 #include "user-regs.h"
62 #include <ctype.h>
63 #include "elf-bfd.h" /* for elfcore_write_* */
64 
80 
81 /* Shared library operations for PowerPC-Linux. */
83 
84 /* The syscall's XML filename for PPC and PPC64. */
85 #define XML_SYSCALL_FILENAME_PPC "syscalls/ppc-linux.xml"
86 #define XML_SYSCALL_FILENAME_PPC64 "syscalls/ppc64-linux.xml"
87 
88 /* ppc_linux_memory_remove_breakpoints attempts to remove a breakpoint
89  in much the same fashion as memory_remove_breakpoint in mem-break.c,
90  but is careful not to write back the previous contents if the code
91  in question has changed in between inserting the breakpoint and
92  removing it.
93 
94  Here is the problem that we're trying to solve...
95 
96  Once upon a time, before introducing this function to remove
97  breakpoints from the inferior, setting a breakpoint on a shared
98  library function prior to running the program would not work
99  properly. In order to understand the problem, it is first
100  necessary to understand a little bit about dynamic linking on
101  this platform.
102 
103  A call to a shared library function is accomplished via a bl
104  (branch-and-link) instruction whose branch target is an entry
105  in the procedure linkage table (PLT). The PLT in the object
106  file is uninitialized. To gdb, prior to running the program, the
107  entries in the PLT are all zeros.
108 
109  Once the program starts running, the shared libraries are loaded
110  and the procedure linkage table is initialized, but the entries in
111  the table are not (necessarily) resolved. Once a function is
112  actually called, the code in the PLT is hit and the function is
113  resolved. In order to better illustrate this, an example is in
114  order; the following example is from the gdb testsuite.
115 
116  We start the program shmain.
117 
118  [kev@arroyo testsuite]$ ../gdb gdb.base/shmain
119  [...]
120 
121  We place two breakpoints, one on shr1 and the other on main.
122 
123  (gdb) b shr1
124  Breakpoint 1 at 0x100409d4
125  (gdb) b main
126  Breakpoint 2 at 0x100006a0: file gdb.base/shmain.c, line 44.
127 
128  Examine the instruction (and the immediatly following instruction)
129  upon which the breakpoint was placed. Note that the PLT entry
130  for shr1 contains zeros.
131 
132  (gdb) x/2i 0x100409d4
133  0x100409d4 <shr1>: .long 0x0
134  0x100409d8 <shr1+4>: .long 0x0
135 
136  Now run 'til main.
137 
138  (gdb) r
139  Starting program: gdb.base/shmain
140  Breakpoint 1 at 0xffaf790: file gdb.base/shr1.c, line 19.
141 
142  Breakpoint 2, main ()
143  at gdb.base/shmain.c:44
144  44 g = 1;
145 
146  Examine the PLT again. Note that the loading of the shared
147  library has initialized the PLT to code which loads a constant
148  (which I think is an index into the GOT) into r11 and then
149  branchs a short distance to the code which actually does the
150  resolving.
151 
152  (gdb) x/2i 0x100409d4
153  0x100409d4 <shr1>: li r11,4
154  0x100409d8 <shr1+4>: b 0x10040984 <sg+4>
155  (gdb) c
156  Continuing.
157 
158  Breakpoint 1, shr1 (x=1)
159  at gdb.base/shr1.c:19
160  19 l = 1;
161 
162  Now we've hit the breakpoint at shr1. (The breakpoint was
163  reset from the PLT entry to the actual shr1 function after the
164  shared library was loaded.) Note that the PLT entry has been
165  resolved to contain a branch that takes us directly to shr1.
166  (The real one, not the PLT entry.)
167 
168  (gdb) x/2i 0x100409d4
169  0x100409d4 <shr1>: b 0xffaf76c <shr1>
170  0x100409d8 <shr1+4>: b 0x10040984 <sg+4>
171 
172  The thing to note here is that the PLT entry for shr1 has been
173  changed twice.
174 
175  Now the problem should be obvious. GDB places a breakpoint (a
176  trap instruction) on the zero value of the PLT entry for shr1.
177  Later on, after the shared library had been loaded and the PLT
178  initialized, GDB gets a signal indicating this fact and attempts
179  (as it always does when it stops) to remove all the breakpoints.
180 
181  The breakpoint removal was causing the former contents (a zero
182  word) to be written back to the now initialized PLT entry thus
183  destroying a portion of the initialization that had occurred only a
184  short time ago. When execution continued, the zero word would be
185  executed as an instruction an illegal instruction trap was
186  generated instead. (0 is not a legal instruction.)
187 
188  The fix for this problem was fairly straightforward. The function
189  memory_remove_breakpoint from mem-break.c was copied to this file,
190  modified slightly, and renamed to ppc_linux_memory_remove_breakpoint.
191  In tm-linux.h, MEMORY_REMOVE_BREAKPOINT is defined to call this new
192  function.
193 
194  The differences between ppc_linux_memory_remove_breakpoint () and
195  memory_remove_breakpoint () are minor. All that the former does
196  that the latter does not is check to make sure that the breakpoint
197  location actually contains a breakpoint (trap instruction) prior
198  to attempting to write back the old contents. If it does contain
199  a trap instruction, we allow the old contents to be written back.
200  Otherwise, we silently do nothing.
201 
202  The big question is whether memory_remove_breakpoint () should be
203  changed to have the same functionality. The downside is that more
204  traffic is generated for remote targets since we'll have an extra
205  fetch of a memory word each time a breakpoint is removed.
206 
207  For the time being, we'll leave this self-modifying-code-friendly
208  version in ppc-linux-tdep.c, but it ought to be migrated somewhere
209  else in the event that some other platform has similar needs with
210  regard to removing breakpoints in some potentially self modifying
211  code. */
212 static int
214  struct bp_target_info *bp_tgt)
215 {
216  CORE_ADDR addr = bp_tgt->reqstd_address;
217  const unsigned char *bp;
218  int val;
219  int bplen;
220  gdb_byte old_contents[BREAKPOINT_MAX];
221  struct cleanup *cleanup;
222 
223  /* Determine appropriate breakpoint contents and size for this address. */
224  bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
225  if (bp == NULL)
226  error (_("Software breakpoints not implemented for this target."));
227 
228  /* Make sure we see the memory breakpoints. */
230  val = target_read_memory (addr, old_contents, bplen);
231 
232  /* If our breakpoint is no longer at the address, this means that the
233  program modified the code on us, so it is wrong to put back the
234  old value. */
235  if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
236  val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
237 
238  do_cleanups (cleanup);
239  return val;
240 }
241 
242 /* For historic reasons, PPC 32 GNU/Linux follows PowerOpen rather
243  than the 32 bit SYSV R4 ABI structure return convention - all
244  structures, no matter their size, are put in memory. Vectors,
245  which were added later, do get returned in a register though. */
246 
247 static enum return_value_convention
248 ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function,
249  struct type *valtype, struct regcache *regcache,
250  gdb_byte *readbuf, const gdb_byte *writebuf)
251 {
252  if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT
253  || TYPE_CODE (valtype) == TYPE_CODE_UNION)
254  && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8)
255  && TYPE_VECTOR (valtype)))
257  else
258  return ppc_sysv_abi_return_value (gdbarch, function, valtype, regcache,
259  readbuf, writebuf);
260 }
261 
262 /* PLT stub in executable. */
263 static struct ppc_insn_pattern powerpc32_plt_stub[] =
264  {
265  { 0xffff0000, 0x3d600000, 0 }, /* lis r11, xxxx */
266  { 0xffff0000, 0x816b0000, 0 }, /* lwz r11, xxxx(r11) */
267  { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */
268  { 0xffffffff, 0x4e800420, 0 }, /* bctr */
269  { 0, 0, 0 }
270  };
271 
272 /* PLT stub in shared library. */
273 static struct ppc_insn_pattern powerpc32_plt_stub_so[] =
274  {
275  { 0xffff0000, 0x817e0000, 0 }, /* lwz r11, xxxx(r30) */
276  { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */
277  { 0xffffffff, 0x4e800420, 0 }, /* bctr */
278  { 0xffffffff, 0x60000000, 0 }, /* nop */
279  { 0, 0, 0 }
280  };
281 #define POWERPC32_PLT_STUB_LEN ARRAY_SIZE (powerpc32_plt_stub)
282 
283 /* Check if PC is in PLT stub. For non-secure PLT, stub is in .plt
284  section. For secure PLT, stub is in .text and we need to check
285  instruction patterns. */
286 
287 static int
289 {
290  struct bound_minimal_symbol sym;
291 
292  /* Check whether PC is in the dynamic linker. This also checks
293  whether it is in the .plt section, used by non-PIC executables. */
295  return 1;
296 
297  /* Check if we are in the resolver. */
298  sym = lookup_minimal_symbol_by_pc (pc);
299  if (sym.minsym != NULL
300  && (strcmp (MSYMBOL_LINKAGE_NAME (sym.minsym), "__glink") == 0
301  || strcmp (MSYMBOL_LINKAGE_NAME (sym.minsym),
302  "__glink_PLTresolve") == 0))
303  return 1;
304 
305  return 0;
306 }
307 
308 /* Follow PLT stub to actual routine.
309 
310  When the execution direction is EXEC_REVERSE, scan backward to
311  check whether we are in the middle of a PLT stub. Currently,
312  we only look-behind at most 4 instructions (the max length of PLT
313  stub sequence. */
314 
315 static CORE_ADDR
317 {
318  unsigned int insnbuf[POWERPC32_PLT_STUB_LEN];
319  struct gdbarch *gdbarch = get_frame_arch (frame);
320  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
321  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
322  CORE_ADDR target = 0;
323  int scan_limit, i;
324 
325  scan_limit = 1;
326  /* When reverse-debugging, scan backward to check whether we are
327  in the middle of trampoline code. */
329  scan_limit = 4; /* At more 4 instructions. */
330 
331  for (i = 0; i < scan_limit; i++)
332  {
333  if (ppc_insns_match_pattern (frame, pc, powerpc32_plt_stub, insnbuf))
334  {
335  /* Insn pattern is
336  lis r11, xxxx
337  lwz r11, xxxx(r11)
338  Branch target is in r11. */
339 
340  target = (ppc_insn_d_field (insnbuf[0]) << 16)
341  | ppc_insn_d_field (insnbuf[1]);
342  target = read_memory_unsigned_integer (target, 4, byte_order);
343  }
344  else if (ppc_insns_match_pattern (frame, pc, powerpc32_plt_stub_so,
345  insnbuf))
346  {
347  /* Insn pattern is
348  lwz r11, xxxx(r30)
349  Branch target is in r11. */
350 
351  target = get_frame_register_unsigned (frame,
352  tdep->ppc_gp0_regnum + 30)
353  + ppc_insn_d_field (insnbuf[0]);
354  target = read_memory_unsigned_integer (target, 4, byte_order);
355  }
356  else
357  {
358  /* Scan backward one more instructions if doesn't match. */
359  pc -= 4;
360  continue;
361  }
362 
363  return target;
364  }
365 
366  return 0;
367 }
368 
369 /* Wrappers to handle Linux-only registers. */
370 
371 static void
373  struct regcache *regcache,
374  int regnum, const void *gregs, size_t len)
375 {
376  const struct ppc_reg_offsets *offsets = regset->regmap;
377 
378  ppc_supply_gregset (regset, regcache, regnum, gregs, len);
379 
380  if (ppc_linux_trap_reg_p (get_regcache_arch (regcache)))
381  {
382  /* "orig_r3" is stored 2 slots after "pc". */
383  if (regnum == -1 || regnum == PPC_ORIG_R3_REGNUM)
384  ppc_supply_reg (regcache, PPC_ORIG_R3_REGNUM, gregs,
385  offsets->pc_offset + 2 * offsets->gpr_size,
386  offsets->gpr_size);
387 
388  /* "trap" is stored 8 slots after "pc". */
389  if (regnum == -1 || regnum == PPC_TRAP_REGNUM)
390  ppc_supply_reg (regcache, PPC_TRAP_REGNUM, gregs,
391  offsets->pc_offset + 8 * offsets->gpr_size,
392  offsets->gpr_size);
393  }
394 }
395 
396 static void
398  const struct regcache *regcache,
399  int regnum, void *gregs, size_t len)
400 {
401  const struct ppc_reg_offsets *offsets = regset->regmap;
402 
403  /* Clear areas in the linux gregset not written elsewhere. */
404  if (regnum == -1)
405  memset (gregs, 0, len);
406 
407  ppc_collect_gregset (regset, regcache, regnum, gregs, len);
408 
409  if (ppc_linux_trap_reg_p (get_regcache_arch (regcache)))
410  {
411  /* "orig_r3" is stored 2 slots after "pc". */
412  if (regnum == -1 || regnum == PPC_ORIG_R3_REGNUM)
413  ppc_collect_reg (regcache, PPC_ORIG_R3_REGNUM, gregs,
414  offsets->pc_offset + 2 * offsets->gpr_size,
415  offsets->gpr_size);
416 
417  /* "trap" is stored 8 slots after "pc". */
418  if (regnum == -1 || regnum == PPC_TRAP_REGNUM)
419  ppc_collect_reg (regcache, PPC_TRAP_REGNUM, gregs,
420  offsets->pc_offset + 8 * offsets->gpr_size,
421  offsets->gpr_size);
422  }
423 }
424 
425 /* Regset descriptions. */
426 static const struct ppc_reg_offsets ppc32_linux_reg_offsets =
427  {
428  /* General-purpose registers. */
429  /* .r0_offset = */ 0,
430  /* .gpr_size = */ 4,
431  /* .xr_size = */ 4,
432  /* .pc_offset = */ 128,
433  /* .ps_offset = */ 132,
434  /* .cr_offset = */ 152,
435  /* .lr_offset = */ 144,
436  /* .ctr_offset = */ 140,
437  /* .xer_offset = */ 148,
438  /* .mq_offset = */ 156,
439 
440  /* Floating-point registers. */
441  /* .f0_offset = */ 0,
442  /* .fpscr_offset = */ 256,
443  /* .fpscr_size = */ 8,
444 
445  /* AltiVec registers. */
446  /* .vr0_offset = */ 0,
447  /* .vscr_offset = */ 512 + 12,
448  /* .vrsave_offset = */ 528
449  };
450 
451 static const struct ppc_reg_offsets ppc64_linux_reg_offsets =
452  {
453  /* General-purpose registers. */
454  /* .r0_offset = */ 0,
455  /* .gpr_size = */ 8,
456  /* .xr_size = */ 8,
457  /* .pc_offset = */ 256,
458  /* .ps_offset = */ 264,
459  /* .cr_offset = */ 304,
460  /* .lr_offset = */ 288,
461  /* .ctr_offset = */ 280,
462  /* .xer_offset = */ 296,
463  /* .mq_offset = */ 312,
464 
465  /* Floating-point registers. */
466  /* .f0_offset = */ 0,
467  /* .fpscr_offset = */ 256,
468  /* .fpscr_size = */ 8,
469 
470  /* AltiVec registers. */
471  /* .vr0_offset = */ 0,
472  /* .vscr_offset = */ 512 + 12,
473  /* .vrsave_offset = */ 528
474  };
475 
476 static const struct regset ppc32_linux_gregset = {
480 };
481 
482 static const struct regset ppc64_linux_gregset = {
486 };
487 
488 static const struct regset ppc32_linux_fpregset = {
492 };
493 
494 static const struct regset ppc32_linux_vrregset = {
498 };
499 
500 static const struct regset ppc32_linux_vsxregset = {
504 };
505 
506 const struct regset *
508 {
509  return wordsize == 8 ? &ppc64_linux_gregset : &ppc32_linux_gregset;
510 }
511 
512 const struct regset *
514 {
515  return &ppc32_linux_fpregset;
516 }
517 
518 /* Iterate over supported core file register note sections. */
519 
520 static void
523  void *cb_data,
524  const struct regcache *regcache)
525 {
526  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
527  int have_altivec = tdep->ppc_vr0_regnum != -1;
528  int have_vsx = tdep->ppc_vsr0_upper_regnum != -1;
529 
530  if (tdep->wordsize == 4)
531  cb (".reg", 48 * 4, &ppc32_linux_gregset, NULL, cb_data);
532  else
533  cb (".reg", 48 * 8, &ppc64_linux_gregset, NULL, cb_data);
534 
535  cb (".reg2", 264, &ppc32_linux_fpregset, NULL, cb_data);
536 
537  if (have_altivec)
538  cb (".reg-ppc-vmx", 544, &ppc32_linux_vrregset, "ppc Altivec", cb_data);
539 
540  if (have_vsx)
541  cb (".reg-ppc-vsx", 256, &ppc32_linux_vsxregset, "POWER7 VSX", cb_data);
542 }
543 
544 static void
546  struct trad_frame_cache *this_cache,
548  int bias)
549 {
550  CORE_ADDR base;
551  CORE_ADDR regs;
552  CORE_ADDR gpregs;
553  CORE_ADDR fpregs;
554  int i;
555  struct gdbarch *gdbarch = get_frame_arch (this_frame);
556  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
557  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
558 
559  base = get_frame_register_unsigned (this_frame,
560  gdbarch_sp_regnum (gdbarch));
561  if (bias > 0 && get_frame_pc (this_frame) != func)
562  /* See below, some signal trampolines increment the stack as their
563  first instruction, need to compensate for that. */
564  base -= bias;
565 
566  /* Find the address of the register buffer pointer. */
567  regs = base + offset;
568  /* Use that to find the address of the corresponding register
569  buffers. */
570  gpregs = read_memory_unsigned_integer (regs, tdep->wordsize, byte_order);
571  fpregs = gpregs + 48 * tdep->wordsize;
572 
573  /* General purpose. */
574  for (i = 0; i < 32; i++)
575  {
576  int regnum = i + tdep->ppc_gp0_regnum;
577  trad_frame_set_reg_addr (this_cache,
578  regnum, gpregs + i * tdep->wordsize);
579  }
580  trad_frame_set_reg_addr (this_cache,
581  gdbarch_pc_regnum (gdbarch),
582  gpregs + 32 * tdep->wordsize);
583  trad_frame_set_reg_addr (this_cache, tdep->ppc_ctr_regnum,
584  gpregs + 35 * tdep->wordsize);
585  trad_frame_set_reg_addr (this_cache, tdep->ppc_lr_regnum,
586  gpregs + 36 * tdep->wordsize);
587  trad_frame_set_reg_addr (this_cache, tdep->ppc_xer_regnum,
588  gpregs + 37 * tdep->wordsize);
589  trad_frame_set_reg_addr (this_cache, tdep->ppc_cr_regnum,
590  gpregs + 38 * tdep->wordsize);
591 
592  if (ppc_linux_trap_reg_p (gdbarch))
593  {
595  gpregs + 34 * tdep->wordsize);
597  gpregs + 40 * tdep->wordsize);
598  }
599 
600  if (ppc_floating_point_unit_p (gdbarch))
601  {
602  /* Floating point registers. */
603  for (i = 0; i < 32; i++)
604  {
605  int regnum = i + gdbarch_fp0_regnum (gdbarch);
606  trad_frame_set_reg_addr (this_cache, regnum,
607  fpregs + i * tdep->wordsize);
608  }
609  trad_frame_set_reg_addr (this_cache, tdep->ppc_fpscr_regnum,
610  fpregs + 32 * tdep->wordsize);
611  }
612  trad_frame_set_id (this_cache, frame_id_build (base, func));
613 }
614 
615 static void
617  struct frame_info *this_frame,
618  struct trad_frame_cache *this_cache,
619  CORE_ADDR func)
620 {
621  ppc_linux_sigtramp_cache (this_frame, this_cache, func,
622  0xd0 /* Offset to ucontext_t. */
623  + 0x30 /* Offset to .reg. */,
624  0);
625 }
626 
627 static void
629  struct frame_info *this_frame,
630  struct trad_frame_cache *this_cache,
631  CORE_ADDR func)
632 {
633  ppc_linux_sigtramp_cache (this_frame, this_cache, func,
634  0x80 /* Offset to ucontext_t. */
635  + 0xe0 /* Offset to .reg. */,
636  128);
637 }
638 
639 static void
641  struct frame_info *this_frame,
642  struct trad_frame_cache *this_cache,
643  CORE_ADDR func)
644 {
645  ppc_linux_sigtramp_cache (this_frame, this_cache, func,
646  0x40 /* Offset to ucontext_t. */
647  + 0x1c /* Offset to .reg. */,
648  0);
649 }
650 
651 static void
653  struct frame_info *this_frame,
654  struct trad_frame_cache *this_cache,
655  CORE_ADDR func)
656 {
657  ppc_linux_sigtramp_cache (this_frame, this_cache, func,
658  0x80 /* Offset to struct sigcontext. */
659  + 0x38 /* Offset to .reg. */,
660  128);
661 }
662 
663 static struct tramp_frame ppc32_linux_sigaction_tramp_frame = {
665  4,
666  {
667  { 0x380000ac, -1 }, /* li r0, 172 */
668  { 0x44000002, -1 }, /* sc */
670  },
672 };
673 static struct tramp_frame ppc64_linux_sigaction_tramp_frame = {
675  4,
676  {
677  { 0x38210080, -1 }, /* addi r1,r1,128 */
678  { 0x380000ac, -1 }, /* li r0, 172 */
679  { 0x44000002, -1 }, /* sc */
681  },
683 };
684 static struct tramp_frame ppc32_linux_sighandler_tramp_frame = {
686  4,
687  {
688  { 0x38000077, -1 }, /* li r0,119 */
689  { 0x44000002, -1 }, /* sc */
691  },
693 };
694 static struct tramp_frame ppc64_linux_sighandler_tramp_frame = {
696  4,
697  {
698  { 0x38210080, -1 }, /* addi r1,r1,128 */
699  { 0x38000077, -1 }, /* li r0,119 */
700  { 0x44000002, -1 }, /* sc */
702  },
704 };
705 
706 /* Return 1 if PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM are usable. */
707 int
709 {
710  /* If we do not have a target description with registers, then
711  the special registers will not be included in the register set. */
712  if (!tdesc_has_registers (gdbarch_target_desc (gdbarch)))
713  return 0;
714 
715  /* If we do, then it is safe to check the size. */
716  return register_size (gdbarch, PPC_ORIG_R3_REGNUM) > 0
717  && register_size (gdbarch, PPC_TRAP_REGNUM) > 0;
718 }
719 
720 /* Return the current system call's number present in the
721  r0 register. When the function fails, it returns -1. */
722 static LONGEST
724  ptid_t ptid)
725 {
726  struct regcache *regcache = get_thread_regcache (ptid);
727  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
728  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
729  struct cleanup *cleanbuf;
730  /* The content of a register */
731  gdb_byte *buf;
732  /* The result */
733  LONGEST ret;
734 
735  /* Make sure we're in a 32- or 64-bit machine */
736  gdb_assert (tdep->wordsize == 4 || tdep->wordsize == 8);
737 
738  buf = (gdb_byte *) xmalloc (tdep->wordsize * sizeof (gdb_byte));
739 
740  cleanbuf = make_cleanup (xfree, buf);
741 
742  /* Getting the system call number from the register.
743  When dealing with PowerPC architecture, this information
744  is stored at 0th register. */
745  regcache_cooked_read (regcache, tdep->ppc_gp0_regnum, buf);
746 
747  ret = extract_signed_integer (buf, tdep->wordsize, byte_order);
748  do_cleanups (cleanbuf);
749 
750  return ret;
751 }
752 
753 /* PPC process record-replay */
754 
757 
758 /* ppc_canonicalize_syscall maps from the native PowerPC Linux set of
759  syscall ids into a canonical set of syscall ids used by process
760  record. (See arch/powerpc/include/uapi/asm/unistd.h in kernel tree.)
761  Return -1 if this system call is not supported by process record.
762  Otherwise, return the syscall number for preocess reocrd of given
763  SYSCALL. */
764 
765 static enum gdb_syscall
767 {
768  if (syscall <= 165)
769  return syscall;
770  else if (syscall >= 167 && syscall <= 190) /* Skip query_module 166 */
771  return syscall + 1;
772  else if (syscall >= 192 && syscall <= 197) /* mmap2 */
773  return syscall;
774  else if (syscall == 208) /* tkill */
775  return gdb_sys_tkill;
776  else if (syscall >= 207 && syscall <= 220) /* gettid */
777  return syscall + 224 - 207;
778  else if (syscall >= 234 && syscall <= 239) /* exit_group */
779  return syscall + 252 - 234;
780  else if (syscall >= 240 && syscall <=248) /* timer_create */
781  return syscall += 259 - 240;
782  else if (syscall >= 250 && syscall <=251) /* tgkill */
783  return syscall + 270 - 250;
784  else if (syscall == 336)
785  return gdb_sys_recv;
786  else if (syscall == 337)
787  return gdb_sys_recvfrom;
788  else if (syscall == 342)
789  return gdb_sys_recvmsg;
790  return -1;
791 }
792 
793 /* Record registers which might be clobbered during system call.
794  Return 0 if successful. */
795 
796 static int
798 {
799  struct gdbarch *gdbarch = get_regcache_arch (regcache);
800  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
801  ULONGEST scnum;
802  enum gdb_syscall syscall_gdb;
803  int ret;
804  int i;
805 
806  regcache_raw_read_unsigned (regcache, tdep->ppc_gp0_regnum, &scnum);
807  syscall_gdb = ppc_canonicalize_syscall (scnum);
808 
809  if (syscall_gdb < 0)
810  {
811  printf_unfiltered (_("Process record and replay target doesn't "
812  "support syscall number %d\n"), (int) scnum);
813  return 0;
814  }
815 
816  if (syscall_gdb == gdb_sys_sigreturn
817  || syscall_gdb == gdb_sys_rt_sigreturn)
818  {
819  int i, j;
820  int regsets[] = { tdep->ppc_gp0_regnum,
821  tdep->ppc_fp0_regnum,
822  tdep->ppc_vr0_regnum,
823  tdep->ppc_vsr0_upper_regnum };
824 
825  for (j = 0; j < 4; j++)
826  {
827  if (regsets[j] == -1)
828  continue;
829  for (i = 0; i < 32; i++)
830  {
831  if (record_full_arch_list_add_reg (regcache, regsets[j] + i))
832  return -1;
833  }
834  }
835 
836  if (record_full_arch_list_add_reg (regcache, tdep->ppc_cr_regnum))
837  return -1;
838  if (record_full_arch_list_add_reg (regcache, tdep->ppc_ctr_regnum))
839  return -1;
840  if (record_full_arch_list_add_reg (regcache, tdep->ppc_lr_regnum))
841  return -1;
842  if (record_full_arch_list_add_reg (regcache, tdep->ppc_xer_regnum))
843  return -1;
844 
845  return 0;
846  }
847 
848  if (tdep->wordsize == 8)
849  ret = record_linux_system_call (syscall_gdb, regcache,
851  else
852  ret = record_linux_system_call (syscall_gdb, regcache,
854 
855  if (ret != 0)
856  return ret;
857 
858  /* Record registers clobbered during syscall. */
859  for (i = 3; i <= 12; i++)
860  {
861  if (record_full_arch_list_add_reg (regcache, tdep->ppc_gp0_regnum + i))
862  return -1;
863  }
864  if (record_full_arch_list_add_reg (regcache, tdep->ppc_gp0_regnum + 0))
865  return -1;
866  if (record_full_arch_list_add_reg (regcache, tdep->ppc_cr_regnum))
867  return -1;
868  if (record_full_arch_list_add_reg (regcache, tdep->ppc_ctr_regnum))
869  return -1;
870  if (record_full_arch_list_add_reg (regcache, tdep->ppc_lr_regnum))
871  return -1;
872 
873  return 0;
874 }
875 
876 /* Record registers which might be clobbered during signal handling.
877  Return 0 if successful. */
878 
879 static int
881  enum gdb_signal signal)
882 {
883  /* See handle_rt_signal64 in arch/powerpc/kernel/signal_64.c
884  handle_rt_signal32 in arch/powerpc/kernel/signal_32.c
885  arch/powerpc/include/asm/ptrace.h
886  for details. */
887  const int SIGNAL_FRAMESIZE = 128;
888  const int sizeof_rt_sigframe = 1440 * 2 + 8 * 2 + 4 * 6 + 8 + 8 + 128 + 512;
889  ULONGEST sp;
890  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
891  int i;
892 
893  for (i = 3; i <= 12; i++)
894  {
895  if (record_full_arch_list_add_reg (regcache, tdep->ppc_gp0_regnum + i))
896  return -1;
897  }
898 
899  if (record_full_arch_list_add_reg (regcache, tdep->ppc_lr_regnum))
900  return -1;
901  if (record_full_arch_list_add_reg (regcache, tdep->ppc_cr_regnum))
902  return -1;
903  if (record_full_arch_list_add_reg (regcache, tdep->ppc_ctr_regnum))
904  return -1;
905  if (record_full_arch_list_add_reg (regcache, gdbarch_pc_regnum (gdbarch)))
906  return -1;
907  if (record_full_arch_list_add_reg (regcache, gdbarch_sp_regnum (gdbarch)))
908  return -1;
909 
910  /* Record the change in the stack.
911  frame-size = sizeof (struct rt_sigframe) + SIGNAL_FRAMESIZE */
912  regcache_raw_read_unsigned (regcache, gdbarch_sp_regnum (gdbarch), &sp);
913  sp -= SIGNAL_FRAMESIZE;
914  sp -= sizeof_rt_sigframe;
915 
916  if (record_full_arch_list_add_mem (sp, SIGNAL_FRAMESIZE + sizeof_rt_sigframe))
917  return -1;
918 
920  return -1;
921 
922  return 0;
923 }
924 
925 static void
927 {
928  struct gdbarch *gdbarch = get_regcache_arch (regcache);
929 
930  regcache_cooked_write_unsigned (regcache, gdbarch_pc_regnum (gdbarch), pc);
931 
932  /* Set special TRAP register to -1 to prevent the kernel from
933  messing with the PC we just installed, if we happen to be
934  within an interrupted system call that the kernel wants to
935  restart.
936 
937  Note that after we return from the dummy call, the TRAP and
938  ORIG_R3 registers will be automatically restored, and the
939  kernel continues to restart the system call at this point. */
940  if (ppc_linux_trap_reg_p (gdbarch))
942 }
943 
944 static int
945 ppc_linux_spu_section (bfd *abfd, asection *asect, void *user_data)
946 {
947  return startswith (bfd_section_name (abfd, asect), "SPU/");
948 }
949 
950 static const struct target_desc *
952  struct target_ops *target,
953  bfd *abfd)
954 {
955  asection *cell = bfd_sections_find_if (abfd, ppc_linux_spu_section, NULL);
956  asection *altivec = bfd_get_section_by_name (abfd, ".reg-ppc-vmx");
957  asection *vsx = bfd_get_section_by_name (abfd, ".reg-ppc-vsx");
958  asection *section = bfd_get_section_by_name (abfd, ".reg");
959  if (! section)
960  return NULL;
961 
962  switch (bfd_section_size (abfd, section))
963  {
964  case 48 * 4:
965  if (cell)
966  return tdesc_powerpc_cell32l;
967  else if (vsx)
968  return tdesc_powerpc_vsx32l;
969  else if (altivec)
971  else
972  return tdesc_powerpc_32l;
973 
974  case 48 * 8:
975  if (cell)
976  return tdesc_powerpc_cell64l;
977  else if (vsx)
978  return tdesc_powerpc_vsx64l;
979  else if (altivec)
981  else
982  return tdesc_powerpc_64l;
983 
984  default:
985  return NULL;
986  }
987 }
988 
989 
990 /* Implementation of `gdbarch_elf_make_msymbol_special', as defined in
991  gdbarch.h. This implementation is used for the ELFv2 ABI only. */
992 
993 static void
995 {
996  elf_symbol_type *elf_sym = (elf_symbol_type *)sym;
997 
998  /* If the symbol is marked as having a local entry point, set a target
999  flag in the msymbol. We currently only support local entry point
1000  offsets of 8 bytes, which is the only entry point offset ever used
1001  by current compilers. If/when other offsets are ever used, we will
1002  have to use additional target flag bits to store them. */
1003  switch (PPC64_LOCAL_ENTRY_OFFSET (elf_sym->internal_elf_sym.st_other))
1004  {
1005  default:
1006  break;
1007  case 8:
1008  MSYMBOL_TARGET_FLAG_1 (msym) = 1;
1009  break;
1010  }
1011 }
1012 
1013 /* Implementation of `gdbarch_skip_entrypoint', as defined in
1014  gdbarch.h. This implementation is used for the ELFv2 ABI only. */
1015 
1016 static CORE_ADDR
1018 {
1019  struct bound_minimal_symbol fun;
1020  int local_entry_offset = 0;
1021 
1022  fun = lookup_minimal_symbol_by_pc (pc);
1023  if (fun.minsym == NULL)
1024  return pc;
1025 
1026  /* See ppc_elfv2_elf_make_msymbol_special for how local entry point
1027  offset values are encoded. */
1028  if (MSYMBOL_TARGET_FLAG_1 (fun.minsym))
1029  local_entry_offset = 8;
1030 
1031  if (BMSYMBOL_VALUE_ADDRESS (fun) <= pc
1032  && pc < BMSYMBOL_VALUE_ADDRESS (fun) + local_entry_offset)
1033  return BMSYMBOL_VALUE_ADDRESS (fun) + local_entry_offset;
1034 
1035  return pc;
1036 }
1037 
1038 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
1039  gdbarch.h. */
1040 
1041 static int
1043 {
1044  return (*s == 'i' /* Literal number. */
1045  || (isdigit (*s) && s[1] == '('
1046  && isdigit (s[2])) /* Displacement. */
1047  || (*s == '(' && isdigit (s[1])) /* Register indirection. */
1048  || isdigit (*s)); /* Register value. */
1049 }
1050 
1051 /* Implementation of `gdbarch_stap_parse_special_token', as defined in
1052  gdbarch.h. */
1053 
1054 static int
1056  struct stap_parse_info *p)
1057 {
1058  if (isdigit (*p->arg))
1059  {
1060  /* This temporary pointer is needed because we have to do a lookahead.
1061  We could be dealing with a register displacement, and in such case
1062  we would not need to do anything. */
1063  const char *s = p->arg;
1064  char *regname;
1065  int len;
1066  struct stoken str;
1067 
1068  while (isdigit (*s))
1069  ++s;
1070 
1071  if (*s == '(')
1072  {
1073  /* It is a register displacement indeed. Returning 0 means we are
1074  deferring the treatment of this case to the generic parser. */
1075  return 0;
1076  }
1077 
1078  len = s - p->arg;
1079  regname = alloca (len + 2);
1080  regname[0] = 'r';
1081 
1082  strncpy (regname + 1, p->arg, len);
1083  ++len;
1084  regname[len] = '\0';
1085 
1086  if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1)
1087  error (_("Invalid register name `%s' on expression `%s'."),
1088  regname, p->saved_arg);
1089 
1090  write_exp_elt_opcode (&p->pstate, OP_REGISTER);
1091  str.ptr = regname;
1092  str.length = len;
1093  write_exp_string (&p->pstate, str);
1094  write_exp_elt_opcode (&p->pstate, OP_REGISTER);
1095 
1096  p->arg = s;
1097  }
1098  else
1099  {
1100  /* All the other tokens should be handled correctly by the generic
1101  parser. */
1102  return 0;
1103  }
1104 
1105  return 1;
1106 }
1107 
1108 /* Cell/B.E. active SPE context tracking support. */
1109 
1110 static struct objfile *spe_context_objfile = NULL;
1113 
1116 
1117 /* Hook into inferior_created, solib_loaded, and solib_unloaded observers
1118  to track whether we've loaded a version of libspe2 (as static or dynamic
1119  library) that provides the __spe_current_active_context variable. */
1120 static void
1122 {
1123  struct bound_minimal_symbol sym;
1124 
1125  if (!objfile)
1126  {
1127  spe_context_objfile = NULL;
1128  spe_context_lm_addr = 0;
1129  spe_context_offset = 0;
1130  spe_context_cache_ptid = minus_one_ptid;
1131  spe_context_cache_address = 0;
1132  return;
1133  }
1134 
1135  sym = lookup_minimal_symbol ("__spe_current_active_context", NULL, objfile);
1136  if (sym.minsym)
1137  {
1138  spe_context_objfile = objfile;
1139  spe_context_lm_addr = svr4_fetch_objfile_link_map (objfile);
1140  spe_context_offset = BMSYMBOL_VALUE_ADDRESS (sym);
1141  spe_context_cache_ptid = minus_one_ptid;
1142  spe_context_cache_address = 0;
1143  return;
1144  }
1145 }
1146 
1147 static void
1149 {
1150  struct objfile *objfile;
1151 
1153  ALL_OBJFILES (objfile)
1154  ppc_linux_spe_context_lookup (objfile);
1155 }
1156 
1157 static void
1159 {
1160  if (strstr (so->so_original_name, "/libspe") != NULL)
1161  {
1162  solib_read_symbols (so, 0);
1164  }
1165 }
1166 
1167 static void
1169 {
1170  if (so->objfile == spe_context_objfile)
1172 }
1173 
1174 /* Retrieve contents of the N'th element in the current thread's
1175  linked SPE context list into ID and NPC. Return the address of
1176  said context element, or 0 if not found. */
1177 static CORE_ADDR
1178 ppc_linux_spe_context (int wordsize, enum bfd_endian byte_order,
1179  int n, int *id, unsigned int *npc)
1180 {
1181  CORE_ADDR spe_context = 0;
1182  gdb_byte buf[16];
1183  int i;
1184 
1185  /* Quick exit if we have not found __spe_current_active_context. */
1186  if (!spe_context_objfile)
1187  return 0;
1188 
1189  /* Look up cached address of thread-local variable. */
1190  if (!ptid_equal (spe_context_cache_ptid, inferior_ptid))
1191  {
1192  struct target_ops *target = &current_target;
1193 
1194  TRY
1195  {
1196  /* We do not call target_translate_tls_address here, because
1197  svr4_fetch_objfile_link_map may invalidate the frame chain,
1198  which must not do while inside a frame sniffer.
1199 
1200  Instead, we have cached the lm_addr value, and use that to
1201  directly call the target's to_get_thread_local_address. */
1202  spe_context_cache_address
1203  = target->to_get_thread_local_address (target, inferior_ptid,
1204  spe_context_lm_addr,
1205  spe_context_offset);
1206  spe_context_cache_ptid = inferior_ptid;
1207  }
1208 
1209  CATCH (ex, RETURN_MASK_ERROR)
1210  {
1211  return 0;
1212  }
1213  END_CATCH
1214  }
1215 
1216  /* Read variable value. */
1217  if (target_read_memory (spe_context_cache_address, buf, wordsize) == 0)
1218  spe_context = extract_unsigned_integer (buf, wordsize, byte_order);
1219 
1220  /* Cyle through to N'th linked list element. */
1221  for (i = 0; i < n && spe_context; i++)
1222  if (target_read_memory (spe_context + align_up (12, wordsize),
1223  buf, wordsize) == 0)
1224  spe_context = extract_unsigned_integer (buf, wordsize, byte_order);
1225  else
1226  spe_context = 0;
1227 
1228  /* Read current context. */
1229  if (spe_context
1230  && target_read_memory (spe_context, buf, 12) != 0)
1231  spe_context = 0;
1232 
1233  /* Extract data elements. */
1234  if (spe_context)
1235  {
1236  if (id)
1237  *id = extract_signed_integer (buf, 4, byte_order);
1238  if (npc)
1239  *npc = extract_unsigned_integer (buf + 4, 4, byte_order);
1240  }
1241 
1242  return spe_context;
1243 }
1244 
1245 
1246 /* Cell/B.E. cross-architecture unwinder support. */
1247 
1249 {
1252 };
1253 
1254 static struct gdbarch *
1255 ppu2spu_prev_arch (struct frame_info *this_frame, void **this_cache)
1256 {
1257  struct ppu2spu_cache *cache = *this_cache;
1258  return get_regcache_arch (cache->regcache);
1259 }
1260 
1261 static void
1262 ppu2spu_this_id (struct frame_info *this_frame,
1263  void **this_cache, struct frame_id *this_id)
1264 {
1265  struct ppu2spu_cache *cache = *this_cache;
1266  *this_id = cache->frame_id;
1267 }
1268 
1269 static struct value *
1270 ppu2spu_prev_register (struct frame_info *this_frame,
1271  void **this_cache, int regnum)
1272 {
1273  struct ppu2spu_cache *cache = *this_cache;
1274  struct gdbarch *gdbarch = get_regcache_arch (cache->regcache);
1275  gdb_byte *buf;
1276 
1277  buf = alloca (register_size (gdbarch, regnum));
1278 
1279  if (regnum < gdbarch_num_regs (gdbarch))
1280  regcache_raw_read (cache->regcache, regnum, buf);
1281  else
1282  gdbarch_pseudo_register_read (gdbarch, cache->regcache, regnum, buf);
1283 
1284  return frame_unwind_got_bytes (this_frame, regnum, buf);
1285 }
1286 
1288 {
1289  struct gdbarch *gdbarch;
1290  int id;
1291  unsigned int npc;
1292  gdb_byte gprs[128*16];
1293 };
1294 
1295 static int
1297 {
1298  struct ppu2spu_data *data = src;
1299  enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
1300 
1301  if (regnum >= 0 && regnum < SPU_NUM_GPRS)
1302  memcpy (buf, data->gprs + 16*regnum, 16);
1303  else if (regnum == SPU_ID_REGNUM)
1304  store_unsigned_integer (buf, 4, byte_order, data->id);
1305  else if (regnum == SPU_PC_REGNUM)
1306  store_unsigned_integer (buf, 4, byte_order, data->npc);
1307  else
1308  return REG_UNAVAILABLE;
1309 
1310  return REG_VALID;
1311 }
1312 
1313 static int
1314 ppu2spu_sniffer (const struct frame_unwind *self,
1315  struct frame_info *this_frame, void **this_prologue_cache)
1316 {
1317  struct gdbarch *gdbarch = get_frame_arch (this_frame);
1318  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1319  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1320  struct ppu2spu_data data;
1321  struct frame_info *fi;
1322  CORE_ADDR base, func, backchain, spe_context;
1323  gdb_byte buf[8];
1324  int n = 0;
1325 
1326  /* Count the number of SPU contexts already in the frame chain. */
1327  for (fi = get_next_frame (this_frame); fi; fi = get_next_frame (fi))
1328  if (get_frame_type (fi) == ARCH_FRAME
1329  && gdbarch_bfd_arch_info (get_frame_arch (fi))->arch == bfd_arch_spu)
1330  n++;
1331 
1332  base = get_frame_sp (this_frame);
1333  func = get_frame_pc (this_frame);
1334  if (target_read_memory (base, buf, tdep->wordsize))
1335  return 0;
1336  backchain = extract_unsigned_integer (buf, tdep->wordsize, byte_order);
1337 
1338  spe_context = ppc_linux_spe_context (tdep->wordsize, byte_order,
1339  n, &data.id, &data.npc);
1340  if (spe_context && base <= spe_context && spe_context < backchain)
1341  {
1342  char annex[32];
1343 
1344  /* Find gdbarch for SPU. */
1345  struct gdbarch_info info;
1346  gdbarch_info_init (&info);
1347  info.bfd_arch_info = bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu);
1348  info.byte_order = BFD_ENDIAN_BIG;
1349  info.osabi = GDB_OSABI_LINUX;
1350  info.tdep_info = (void *) &data.id;
1351  data.gdbarch = gdbarch_find_by_info (info);
1352  if (!data.gdbarch)
1353  return 0;
1354 
1355  xsnprintf (annex, sizeof annex, "%d/regs", data.id);
1357  data.gprs, 0, sizeof data.gprs)
1358  == sizeof data.gprs)
1359  {
1360  struct ppu2spu_cache *cache
1361  = FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache);
1362 
1363  struct address_space *aspace = get_frame_address_space (this_frame);
1364  struct regcache *regcache = regcache_xmalloc (data.gdbarch, aspace);
1365  struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
1366  regcache_save (regcache, ppu2spu_unwind_register, &data);
1367  discard_cleanups (cleanups);
1368 
1369  cache->frame_id = frame_id_build (base, func);
1370  cache->regcache = regcache;
1371  *this_prologue_cache = cache;
1372  return 1;
1373  }
1374  }
1375 
1376  return 0;
1377 }
1378 
1379 static void
1380 ppu2spu_dealloc_cache (struct frame_info *self, void *this_cache)
1381 {
1382  struct ppu2spu_cache *cache = this_cache;
1383  regcache_xfree (cache->regcache);
1384 }
1385 
1386 static const struct frame_unwind ppu2spu_unwind = {
1387  ARCH_FRAME,
1391  NULL,
1395 };
1396 
1397 /* Initialize linux_record_tdep if not initialized yet.
1398  WORDSIZE is 4 or 8 for 32- or 64-bit PowerPC Linux respectively.
1399  Sizes of data structures are initialized accordingly. */
1400 
1401 static void
1403  int wordsize)
1404 {
1405  /* Simply return if it had been initialized. */
1406  if (record_tdep->size_pointer != 0)
1407  return;
1408 
1409  /* These values are the size of the type that will be used in a system
1410  call. They are obtained from Linux Kernel source. */
1411 
1412  if (wordsize == 8)
1413  {
1414  record_tdep->size_pointer = 8;
1415  record_tdep->size__old_kernel_stat = 32;
1416  record_tdep->size_tms = 32;
1417  record_tdep->size_loff_t = 8;
1418  record_tdep->size_flock = 32;
1419  record_tdep->size_oldold_utsname = 45;
1420  record_tdep->size_ustat = 32;
1421  record_tdep->size_old_sigaction = 152;
1422  record_tdep->size_old_sigset_t = 128;
1423  record_tdep->size_rlimit = 16;
1424  record_tdep->size_rusage = 144;
1425  record_tdep->size_timeval = 16;
1426  record_tdep->size_timezone = 8;
1427  record_tdep->size_old_gid_t = 4;
1428  record_tdep->size_old_uid_t = 4;
1429  record_tdep->size_fd_set = 128;
1430  record_tdep->size_dirent = 280;
1431  record_tdep->size_dirent64 = 280;
1432  record_tdep->size_statfs = 120;
1433  record_tdep->size_statfs64 = 120;
1434  record_tdep->size_sockaddr = 16;
1435  record_tdep->size_int = 4;
1436  record_tdep->size_long = 8;
1437  record_tdep->size_ulong = 8;
1438  record_tdep->size_msghdr = 56;
1439  record_tdep->size_itimerval = 32;
1440  record_tdep->size_stat = 144;
1441  record_tdep->size_old_utsname = 325;
1442  record_tdep->size_sysinfo = 112;
1443  record_tdep->size_msqid_ds = 120;
1444  record_tdep->size_shmid_ds = 112;
1445  record_tdep->size_new_utsname = 390;
1446  record_tdep->size_timex = 208;
1447  record_tdep->size_mem_dqinfo = 24;
1448  record_tdep->size_if_dqblk = 72;
1449  record_tdep->size_fs_quota_stat = 80;
1450  record_tdep->size_timespec = 16;
1451  record_tdep->size_pollfd = 8;
1452  record_tdep->size_NFS_FHSIZE = 32;
1453  record_tdep->size_knfsd_fh = 132;
1454  record_tdep->size_TASK_COMM_LEN = 32;
1455  record_tdep->size_sigaction = 152;
1456  record_tdep->size_sigset_t = 128;
1457  record_tdep->size_siginfo_t = 128;
1458  record_tdep->size_cap_user_data_t = 8;
1459  record_tdep->size_stack_t = 24;
1460  record_tdep->size_off_t = 8;
1461  record_tdep->size_stat64 = 104;
1462  record_tdep->size_gid_t = 4;
1463  record_tdep->size_uid_t = 4;
1464  record_tdep->size_PAGE_SIZE = 0x10000; /* 64KB */
1465  record_tdep->size_flock64 = 32;
1466  record_tdep->size_io_event = 32;
1467  record_tdep->size_iocb = 64;
1468  record_tdep->size_epoll_event = 16;
1469  record_tdep->size_itimerspec = 32;
1470  record_tdep->size_mq_attr = 64;
1471  record_tdep->size_siginfo = 128;
1472  record_tdep->size_termios = 44;
1473  record_tdep->size_pid_t = 4;
1474  record_tdep->size_winsize = 8;
1475  record_tdep->size_serial_struct = 72;
1476  record_tdep->size_serial_icounter_struct = 80;
1477  record_tdep->size_size_t = 8;
1478  record_tdep->size_iovec = 16;
1479  }
1480  else if (wordsize == 4)
1481  {
1482  record_tdep->size_pointer = 4;
1483  record_tdep->size__old_kernel_stat = 32;
1484  record_tdep->size_tms = 16;
1485  record_tdep->size_loff_t = 8;
1486  record_tdep->size_flock = 16;
1487  record_tdep->size_oldold_utsname = 45;
1488  record_tdep->size_ustat = 20;
1489  record_tdep->size_old_sigaction = 152;
1490  record_tdep->size_old_sigset_t = 128;
1491  record_tdep->size_rlimit = 8;
1492  record_tdep->size_rusage = 72;
1493  record_tdep->size_timeval = 8;
1494  record_tdep->size_timezone = 8;
1495  record_tdep->size_old_gid_t = 4;
1496  record_tdep->size_old_uid_t = 4;
1497  record_tdep->size_fd_set = 128;
1498  record_tdep->size_dirent = 268;
1499  record_tdep->size_dirent64 = 280;
1500  record_tdep->size_statfs = 64;
1501  record_tdep->size_statfs64 = 88;
1502  record_tdep->size_sockaddr = 16;
1503  record_tdep->size_int = 4;
1504  record_tdep->size_long = 4;
1505  record_tdep->size_ulong = 4;
1506  record_tdep->size_msghdr = 28;
1507  record_tdep->size_itimerval = 16;
1508  record_tdep->size_stat = 88;
1509  record_tdep->size_old_utsname = 325;
1510  record_tdep->size_sysinfo = 64;
1511  record_tdep->size_msqid_ds = 68;
1512  record_tdep->size_shmid_ds = 60;
1513  record_tdep->size_new_utsname = 390;
1514  record_tdep->size_timex = 128;
1515  record_tdep->size_mem_dqinfo = 24;
1516  record_tdep->size_if_dqblk = 72;
1517  record_tdep->size_fs_quota_stat = 80;
1518  record_tdep->size_timespec = 8;
1519  record_tdep->size_pollfd = 8;
1520  record_tdep->size_NFS_FHSIZE = 32;
1521  record_tdep->size_knfsd_fh = 132;
1522  record_tdep->size_TASK_COMM_LEN = 32;
1523  record_tdep->size_sigaction = 140;
1524  record_tdep->size_sigset_t = 128;
1525  record_tdep->size_siginfo_t = 128;
1526  record_tdep->size_cap_user_data_t = 4;
1527  record_tdep->size_stack_t = 12;
1528  record_tdep->size_off_t = 4;
1529  record_tdep->size_stat64 = 104;
1530  record_tdep->size_gid_t = 4;
1531  record_tdep->size_uid_t = 4;
1532  record_tdep->size_PAGE_SIZE = 0x10000; /* 64KB */
1533  record_tdep->size_flock64 = 32;
1534  record_tdep->size_io_event = 32;
1535  record_tdep->size_iocb = 64;
1536  record_tdep->size_epoll_event = 16;
1537  record_tdep->size_itimerspec = 16;
1538  record_tdep->size_mq_attr = 32;
1539  record_tdep->size_siginfo = 128;
1540  record_tdep->size_termios = 44;
1541  record_tdep->size_pid_t = 4;
1542  record_tdep->size_winsize = 8;
1543  record_tdep->size_serial_struct = 60;
1544  record_tdep->size_serial_icounter_struct = 80;
1545  record_tdep->size_size_t = 4;
1546  record_tdep->size_iovec = 8;
1547  }
1548  else
1549  internal_error (__FILE__, __LINE__, _("unexpected wordsize"));
1550 
1551  /* These values are the second argument of system call "sys_fcntl"
1552  and "sys_fcntl64". They are obtained from Linux Kernel source. */
1553  record_tdep->fcntl_F_GETLK = 5;
1554  record_tdep->fcntl_F_GETLK64 = 12;
1555  record_tdep->fcntl_F_SETLK64 = 13;
1556  record_tdep->fcntl_F_SETLKW64 = 14;
1557 
1558  record_tdep->arg1 = PPC_R0_REGNUM + 3;
1559  record_tdep->arg2 = PPC_R0_REGNUM + 4;
1560  record_tdep->arg3 = PPC_R0_REGNUM + 5;
1561  record_tdep->arg4 = PPC_R0_REGNUM + 6;
1562  record_tdep->arg5 = PPC_R0_REGNUM + 7;
1563  record_tdep->arg6 = PPC_R0_REGNUM + 8;
1564 
1565  /* These values are the second argument of system call "sys_ioctl".
1566  They are obtained from Linux Kernel source.
1567  See arch/powerpc/include/uapi/asm/ioctls.h. */
1568  record_tdep->ioctl_TCGETS = 0x403c7413;
1569  record_tdep->ioctl_TCSETS = 0x803c7414;
1570  record_tdep->ioctl_TCSETSW = 0x803c7415;
1571  record_tdep->ioctl_TCSETSF = 0x803c7416;
1572  record_tdep->ioctl_TCGETA = 0x40147417;
1573  record_tdep->ioctl_TCSETA = 0x80147418;
1574  record_tdep->ioctl_TCSETAW = 0x80147419;
1575  record_tdep->ioctl_TCSETAF = 0x8014741c;
1576  record_tdep->ioctl_TCSBRK = 0x2000741d;
1577  record_tdep->ioctl_TCXONC = 0x2000741e;
1578  record_tdep->ioctl_TCFLSH = 0x2000741f;
1579  record_tdep->ioctl_TIOCEXCL = 0x540c;
1580  record_tdep->ioctl_TIOCNXCL = 0x540d;
1581  record_tdep->ioctl_TIOCSCTTY = 0x540e;
1582  record_tdep->ioctl_TIOCGPGRP = 0x40047477;
1583  record_tdep->ioctl_TIOCSPGRP = 0x80047476;
1584  record_tdep->ioctl_TIOCOUTQ = 0x40047473;
1585  record_tdep->ioctl_TIOCSTI = 0x5412;
1586  record_tdep->ioctl_TIOCGWINSZ = 0x40087468;
1587  record_tdep->ioctl_TIOCSWINSZ = 0x80087467;
1588  record_tdep->ioctl_TIOCMGET = 0x5415;
1589  record_tdep->ioctl_TIOCMBIS = 0x5416;
1590  record_tdep->ioctl_TIOCMBIC = 0x5417;
1591  record_tdep->ioctl_TIOCMSET = 0x5418;
1592  record_tdep->ioctl_TIOCGSOFTCAR = 0x5419;
1593  record_tdep->ioctl_TIOCSSOFTCAR = 0x541a;
1594  record_tdep->ioctl_FIONREAD = 0x4004667f;
1595  record_tdep->ioctl_TIOCINQ = 0x4004667f;
1596  record_tdep->ioctl_TIOCLINUX = 0x541c;
1597  record_tdep->ioctl_TIOCCONS = 0x541d;
1598  record_tdep->ioctl_TIOCGSERIAL = 0x541e;
1599  record_tdep->ioctl_TIOCSSERIAL = 0x541f;
1600  record_tdep->ioctl_TIOCPKT = 0x5420;
1601  record_tdep->ioctl_FIONBIO = 0x8004667e;
1602  record_tdep->ioctl_TIOCNOTTY = 0x5422;
1603  record_tdep->ioctl_TIOCSETD = 0x5423;
1604  record_tdep->ioctl_TIOCGETD = 0x5424;
1605  record_tdep->ioctl_TCSBRKP = 0x5425;
1606  record_tdep->ioctl_TIOCSBRK = 0x5427;
1607  record_tdep->ioctl_TIOCCBRK = 0x5428;
1608  record_tdep->ioctl_TIOCGSID = 0x5429;
1609  record_tdep->ioctl_TIOCGPTN = 0x40045430;
1610  record_tdep->ioctl_TIOCSPTLCK = 0x80045431;
1611  record_tdep->ioctl_FIONCLEX = 0x20006602;
1612  record_tdep->ioctl_FIOCLEX = 0x20006601;
1613  record_tdep->ioctl_FIOASYNC = 0x8004667d;
1614  record_tdep->ioctl_TIOCSERCONFIG = 0x5453;
1615  record_tdep->ioctl_TIOCSERGWILD = 0x5454;
1616  record_tdep->ioctl_TIOCSERSWILD = 0x5455;
1617  record_tdep->ioctl_TIOCGLCKTRMIOS = 0x5456;
1618  record_tdep->ioctl_TIOCSLCKTRMIOS = 0x5457;
1619  record_tdep->ioctl_TIOCSERGSTRUCT = 0x5458;
1620  record_tdep->ioctl_TIOCSERGETLSR = 0x5459;
1621  record_tdep->ioctl_TIOCSERGETMULTI = 0x545a;
1622  record_tdep->ioctl_TIOCSERSETMULTI = 0x545b;
1623  record_tdep->ioctl_TIOCMIWAIT = 0x545c;
1624  record_tdep->ioctl_TIOCGICOUNT = 0x545d;
1625  record_tdep->ioctl_FIOQSIZE = 0x40086680;
1626 }
1627 
1628 static void
1630  struct gdbarch *gdbarch)
1631 {
1632  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1633  struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info;
1634  static const char *const stap_integer_prefixes[] = { "i", NULL };
1635  static const char *const stap_register_indirection_prefixes[] = { "(",
1636  NULL };
1637  static const char *const stap_register_indirection_suffixes[] = { ")",
1638  NULL };
1639 
1640  linux_init_abi (info, gdbarch);
1641 
1642  /* PPC GNU/Linux uses either 64-bit or 128-bit long doubles; where
1643  128-bit, they are IBM long double, not IEEE quad long double as
1644  in the System V ABI PowerPC Processor Supplement. We can safely
1645  let them default to 128-bit, since the debug info will give the
1646  size of type actually used in each case. */
1649 
1650  /* Handle inferior calls during interrupted system calls. */
1652 
1653  /* Get the syscall number from the arch's register. */
1655 
1656  /* SystemTap functions. */
1657  set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes);
1659  stap_register_indirection_prefixes);
1661  stap_register_indirection_suffixes);
1666 
1667  if (tdep->wordsize == 4)
1668  {
1669  /* Until November 2001, gcc did not comply with the 32 bit SysV
1670  R4 ABI requirement that structures less than or equal to 8
1671  bytes should be returned in registers. Instead GCC was using
1672  the AIX/PowerOpen ABI - everything returned in memory
1673  (well ignoring vectors that is). When this was corrected, it
1674  wasn't fixed for GNU/Linux native platform. Use the
1675  PowerOpen struct convention. */
1677 
1680 
1681  /* Shared library handling. */
1685 
1686  /* Setting the correct XML syscall filename. */
1688 
1689  /* Trampolines. */
1691  &ppc32_linux_sigaction_tramp_frame);
1693  &ppc32_linux_sighandler_tramp_frame);
1694 
1695  /* BFD target for core files. */
1696  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
1697  set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpcle");
1698  else
1699  set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpc");
1700 
1702  {
1704  /* Override dynamic resolve function. */
1707  }
1709 
1711  }
1712 
1713  if (tdep->wordsize == 8)
1714  {
1715  if (tdep->elf_abi == POWERPC_ELF_V1)
1716  {
1717  /* Handle PPC GNU/Linux 64-bit function pointers (which are really
1718  function descriptors). */
1721 
1724  }
1725  else
1726  {
1729 
1731  }
1732 
1733  /* Shared library handling. */
1737 
1738  /* Setting the correct XML syscall filename. */
1740 
1741  /* Trampolines. */
1743  &ppc64_linux_sigaction_tramp_frame);
1745  &ppc64_linux_sighandler_tramp_frame);
1746 
1747  /* BFD target for core files. */
1748  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
1749  set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle");
1750  else
1751  set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc");
1752  }
1753 
1754  /* PPC32 uses a different prpsinfo32 compared to most other Linux
1755  archs. */
1756  if (tdep->wordsize == 4)
1758  elfcore_write_ppc_linux_prpsinfo32);
1759 
1763 
1764  /* Enable TLS support. */
1767 
1768  if (tdesc_data)
1769  {
1770  const struct tdesc_feature *feature;
1771 
1772  /* If we have target-described registers, then we can safely
1773  reserve a number for PPC_ORIG_R3_REGNUM and PPC_TRAP_REGNUM
1774  (whether they are described or not). */
1777 
1778  /* If they are present, then assign them to the reserved number. */
1779  feature = tdesc_find_feature (info.target_desc,
1780  "org.gnu.gdb.power.linux");
1781  if (feature != NULL)
1782  {
1784  PPC_ORIG_R3_REGNUM, "orig_r3");
1786  PPC_TRAP_REGNUM, "trap");
1787  }
1788  }
1789 
1790  /* Enable Cell/B.E. if supported by the target. */
1791  if (tdesc_compatible_p (info.target_desc,
1792  bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu)))
1793  {
1794  /* Cell/B.E. multi-architecture support. */
1796 
1797  /* Cell/B.E. cross-architecture unwinder support. */
1798  frame_unwind_prepend_unwinder (gdbarch, &ppu2spu_unwind);
1799  }
1800 
1803 
1804  /* Support reverse debugging. */
1807  tdep->ppc_syscall_record = ppc_linux_syscall_record;
1808 
1811 }
1812 
1813 /* Provide a prototype to silence -Wmissing-prototypes. */
1815 
1816 void
1818 {
1819  /* Register for all sub-familes of the POWER/PowerPC: 32-bit and
1820  64-bit PowerPC, and the older rs6k. */
1821  gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc, GDB_OSABI_LINUX,
1823  gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc64, GDB_OSABI_LINUX,
1825  gdbarch_register_osabi (bfd_arch_rs6000, bfd_mach_rs6k, GDB_OSABI_LINUX,
1827 
1828  /* Attach to observers to track __spe_current_active_context. */
1832 
1833  /* Initialize the Linux target descriptions. */
1849 }
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition: gdbarch.c:1909
struct regcache * regcache
CORE_ADDR reqstd_address
Definition: breakpoint.h:235
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
Definition: findvar.c:84
static void initialize_tdesc_powerpc_cell32l(void)
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
Definition: trad-frame.c:119
struct cleanup * make_show_memory_breakpoints_cleanup(int show)
Definition: target.c:1269
int size_serial_icounter_struct
Definition: linux-record.h:90
static void initialize_tdesc_powerpc_32l(void)
Definition: powerpc-32l.c:10
static void ppc_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:554
#define XML_SYSCALL_FILENAME_PPC
struct value * frame_unwind_got_bytes(struct frame_info *frame, int regnum, gdb_byte *buf)
Definition: frame-unwind.c:255
static void ppc_linux_supply_gregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
static CORE_ADDR ppc_elfv2_skip_entrypoint(struct gdbarch *gdbarch, CORE_ADDR pc)
static int ppu2spu_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
static void ppc_linux_sigtramp_cache(struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func, LONGEST offset, int bias)
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2217
#define MSYMBOL_LINKAGE_NAME(symbol)
Definition: symtab.h:409
static void initialize_tdesc_powerpc_isa205_64l(void)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
Definition: ptid.c:76
Definition: target.h:98
bfd_vma CORE_ADDR
Definition: common-types.h:41
static const struct ppc_reg_offsets ppc64_linux_reg_offsets
void set_gdbarch_fetch_tls_load_module_address(struct gdbarch *gdbarch, gdbarch_fetch_tls_load_module_address_ftype fetch_tls_load_module_address)
Definition: gdbarch.c:2822
#define TRAMP_SENTINEL_INSN
Definition: tramp-frame.h:44
static const struct regset ppc32_linux_fpregset
static void initialize_tdesc_powerpc_isa205_altivec32l(void)
struct link_map_offsets * svr4_lp64_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3180
struct regcache * get_thread_regcache(ptid_t ptid)
Definition: regcache.c:529
const char * ptr
Definition: parser-defs.h:79
void set_gdbarch_stap_parse_special_token(struct gdbarch *gdbarch, gdbarch_stap_parse_special_token_ftype stap_parse_special_token)
Definition: gdbarch.c:4243
void xfree(void *)
Definition: common-utils.c:97
static void initialize_tdesc_powerpc_vsx32l(void)
static void ppc32_linux_sigaction_cache_init(const struct tramp_frame *self, struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
int record_full_arch_list_add_reg(struct regcache *regcache, int regnum)
Definition: record-full.c:466
int ppc_lr_regnum
Definition: ppc-tdep.h:218
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
Definition: regcache.c:297
void(* func)(char *)
void set_solib_ops(struct gdbarch *gdbarch, const struct target_so_ops *new_ops)
Definition: solib.c:76
#define BMSYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:393
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype skip_trampoline_code)
Definition: gdbarch.c:3084
void ppc_supply_fpregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len)
Definition: rs6000-tdep.c:550
CORE_ADDR glibc_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: glibc-tdep.c:38
static void ppc_linux_write_pc(struct regcache *regcache, CORE_ADDR pc)
int tdesc_compatible_p(const struct target_desc *target_desc, const struct bfd_arch_info *arch)
struct frame_id frame_id
int svr4_in_dynsym_resolve_code(CORE_ADDR pc)
Definition: solib-svr4.c:1618
void set_gdbarch_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype write_pc)
Definition: gdbarch.c:1802
void set_gdbarch_displaced_step_location(struct gdbarch *gdbarch, gdbarch_displaced_step_location_ftype displaced_step_location)
Definition: gdbarch.c:3743
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
Definition: trad-frame.c:164
int ppc_fpscr_regnum
Definition: ppc-tdep.h:228
void set_gdbarch_process_record_signal(struct gdbarch *gdbarch, gdbarch_process_record_signal_ftype process_record_signal)
Definition: gdbarch.c:3905
CORE_ADDR get_frame_sp(struct frame_info *this_frame)
Definition: frame.c:2577
struct gdbarch * gdbarch_find_by_info(struct gdbarch_info info)
Definition: gdbarch.c:5008
static void initialize_tdesc_powerpc_altivec64l(void)
void internal_error(const char *file, int line, const char *fmt,...)
Definition: errors.c:50
int ppc_process_record(struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr)
Definition: rs6000-tdep.c:5056
struct m32c_reg * pc
Definition: m32c-tdep.c:111
return_value_convention
Definition: defs.h:206
const char * arg
Definition: stap-probe.h:32
struct regcache * regcache_xmalloc(struct gdbarch *gdbarch, struct address_space *aspace)
Definition: regcache.c:241
void ppc_supply_reg(struct regcache *regcache, int regnum, const gdb_byte *regs, size_t offset, int regsize)
Definition: rs6000-tdep.c:383
void linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: linux-tdep.c:2427
static void ppc_init_linux_record_tdep(struct linux_record_tdep *record_tdep, int wordsize)
static CORE_ADDR ppc_skip_trampoline_code(struct frame_info *frame, CORE_ADDR pc)
static struct linux_record_tdep ppc64_linux_record_tdep
struct target_desc * tdesc_powerpc_32l
Definition: powerpc-32l.c:8
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3149
void set_gdbarch_elfcore_write_linux_prpsinfo(struct gdbarch *gdbarch, gdbarch_elfcore_write_linux_prpsinfo_ftype elfcore_write_linux_prpsinfo)
Definition: gdbarch.c:3446
Definition: solist.h:30
const struct regset * ppc_linux_gregset(int wordsize)
struct address_space * get_frame_address_space(struct frame_info *frame)
Definition: frame.c:2490
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:1898
#define _(String)
Definition: gdb_locale.h:40
const struct bfd_arch_info * bfd_arch_info
Definition: gdbarch.h:1549
#define MSYMBOL_TARGET_FLAG_1(msymbol)
Definition: symtab.h:372
struct gdbarch_tdep_info * tdep_info
Definition: gdbarch.h:1560
int ppc_cr_regnum
Definition: ppc-tdep.h:217
unsigned int npc
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1402
#define XML_SYSCALL_FILENAME_PPC64
#define END_CATCH
struct target_desc * tdesc_powerpc_cell32l
CORE_ADDR ppc64_skip_trampoline_code(struct frame_info *frame, CORE_ADDR pc)
Definition: ppc64-tdep.c:458
void frame_unwind_prepend_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
Definition: frame-unwind.c:64
static void initialize_tdesc_powerpc_isa205_32l(void)
void set_gdbarch_process_record(struct gdbarch *gdbarch, gdbarch_process_record_ftype process_record)
Definition: gdbarch.c:3881
void set_gdbarch_elf_make_msymbol_special(struct gdbarch *gdbarch, gdbarch_elf_make_msymbol_special_ftype elf_make_msymbol_special)
Definition: gdbarch.c:3159
static void ppc_linux_spe_context_solib_loaded(struct so_list *so)
static enum gdb_syscall ppc_canonicalize_syscall(int syscall)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
Definition: findvar.c:212
void set_gdbarch_stap_register_indirection_suffixes(struct gdbarch *gdbarch, const char *const *stap_register_indirection_suffixes)
Definition: gdbarch.c:4161
Definition: ptid.h:35
CORE_ADDR svr4_fetch_objfile_link_map(struct objfile *objfile)
Definition: solib-svr4.c:1573
struct target_desc * tdesc_powerpc_64l
Definition: powerpc-64l.c:8
Definition: regset.h:34
struct observer * observer_attach_inferior_created(observer_inferior_created_ftype *f)
#define TRY
void set_gdbarch_stap_integer_prefixes(struct gdbarch *gdbarch, const char *const *stap_integer_prefixes)
Definition: gdbarch.c:4076
void set_gdbarch_stap_gdb_register_prefix(struct gdbarch *gdbarch, const char *stap_gdb_register_prefix)
Definition: gdbarch.c:4178
struct parser_state pstate
Definition: stap-probe.h:35
static void ppc_linux_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
static void initialize_tdesc_powerpc_vsx64l(void)
int tdesc_numbered_register(const struct tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *name)
static void initialize_tdesc_powerpc_isa205_vsx32l(void)
#define ALL_OBJFILES(obj)
Definition: objfiles.h:579
enum frame_type get_frame_type(struct frame_info *frame)
Definition: frame.c:2463
static void initialize_tdesc_powerpc_64l(void)
Definition: powerpc-64l.c:10
int(* in_dynsym_resolve_code)(CORE_ADDR pc)
Definition: solist.h:127
void ppc_collect_gregset(const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len)
Definition: rs6000-tdep.c:663
#define CATCH(EXCEPTION, MASK)
int ppc_vsr0_upper_regnum
Definition: ppc-tdep.h:235
struct target_desc * tdesc_powerpc_cell64l
static int ppc_stap_is_single_operand(struct gdbarch *gdbarch, const char *s)
static void ppu2spu_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
static void initialize_tdesc_powerpc_cell64l(void)
struct target_ops current_target
void initialize_file_ftype(void)
Definition: defs.h:281
static void ppc64_linux_sighandler_cache_init(const struct tramp_frame *self, struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
Definition: gdbarch.c:1981
struct target_desc * tdesc_powerpc_altivec32l
int record_linux_system_call(enum gdb_syscall syscall, struct regcache *regcache, struct linux_record_tdep *tdep)
Definition: linux-record.c:227
static int powerpc_linux_in_dynsym_resolve_code(CORE_ADDR pc)
static CORE_ADDR spe_context_offset
static int ppc_linux_spu_section(bfd *abfd, asection *asect, void *user_data)
void ppc_collect_reg(const struct regcache *regcache, int regnum, gdb_byte *regs, size_t offset, int regsize)
Definition: rs6000-tdep.c:404
static void initialize_tdesc_powerpc_e500l(void)
Definition: powerpc-e500l.c:10
void ppc_collect_vrregset(const struct regset *regset, const struct regcache *regcache, int regnum, void *vrregs, size_t len)
Definition: rs6000-tdep.c:783
static int ppc_linux_syscall_record(struct regcache *regcache)
int ppc_gp0_regnum
Definition: ppc-tdep.h:214
int ppc_linux_trap_reg_p(struct gdbarch *gdbarch)
static enum return_value_convention ppc_linux_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
#define TYPE_VECTOR(t)
Definition: gdbtypes.h:287
struct observer * observer_attach_solib_unloaded(observer_solib_unloaded_ftype *f)
#define BREAKPOINT_MAX
Definition: breakpoint.h:46
gdb_byte shadow_contents[BREAKPOINT_MAX]
Definition: breakpoint.h:245
char so_original_name[SO_NAME_MAX_PATH_SIZE]
Definition: solist.h:49
int solib_read_symbols(struct so_list *so, int flags)
Definition: solib.c:669
static int ppu2spu_unwind_register(void *src, int regnum, gdb_byte *buf)
CORE_ADDR(* to_get_thread_local_address)(struct target_ops *ops, ptid_t ptid, CORE_ADDR load_module_addr, CORE_ADDR offset) TARGET_DEFAULT_NORETURN(generic_tls_error())
Definition: target.h:689
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1420
int target_write_raw_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
Definition: target.c:1492
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:117
CORE_ADDR ppc64_convert_from_func_ptr_addr(struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
Definition: ppc64-tdep.c:560
#define TARGET_CHAR_BIT
Definition: host-defs.h:29
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
Definition: solib-svr4.c:3108
void set_gdbarch_gcore_bfd_target(struct gdbarch *gdbarch, const char *gcore_bfd_target)
Definition: gdbarch.c:3567
void set_gdbarch_stap_register_indirection_prefixes(struct gdbarch *gdbarch, const char *const *stap_register_indirection_prefixes)
Definition: gdbarch.c:4144
enum gdb_osabi osabi
Definition: gdbarch.h:1563
Definition: gdbtypes.h:749
#define SPU_NUM_GPRS
Definition: spu-tdep.h:25
static void initialize_tdesc_powerpc_isa205_altivec64l(void)
initialize_file_ftype _initialize_ppc_linux_tdep
static struct gdbarch * ppu2spu_prev_arch(struct frame_info *this_frame, void **this_cache)
const struct floatformat * floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN]
Definition: gdbtypes.c:110
static int ppc_linux_memory_remove_breakpoint(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
#define gdb_assert(expr)
Definition: gdb_assert.h:33
void ppc_collect_fpregset(const struct regset *regset, const struct regcache *regcache, int regnum, void *fpregs, size_t len)
Definition: rs6000-tdep.c:710
const char * saved_arg
Definition: stap-probe.h:40
static int startswith(const char *string, const char *pattern)
Definition: common-utils.h:75
static void ppc64_linux_sigaction_cache_init(const struct tramp_frame *self, struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
enum register_status regcache_raw_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition: regcache.c:690
static int ppc_stap_parse_special_token(struct gdbarch *gdbarch, struct stap_parse_info *p)
void ppc_supply_vrregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *vrregs, size_t len)
Definition: rs6000-tdep.c:618
gdb_byte gprs[128 *16]
void set_gdbarch_convert_from_func_ptr_addr(struct gdbarch *gdbarch, gdbarch_convert_from_func_ptr_addr_ftype convert_from_func_ptr_addr)
Definition: gdbarch.c:2985
int regnum
Definition: aarch64-tdep.c:69
void set_xml_syscall_file_name(struct gdbarch *gdbarch, const char *name)
Definition: xml-syscall.c:392
void printf_unfiltered(const char *format,...)
Definition: utils.c:2399
void( iterate_over_regset_sections_cb)(const char *sect_name, int size, const struct regset *regset, const char *human_name, void *cb_data)
Definition: gdbarch.h:98
int user_reg_map_name_to_regnum(struct gdbarch *gdbarch, const char *name, int len)
Definition: user-regs.c:129
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1194
void set_spu_solib_ops(struct gdbarch *gdbarch)
Definition: solib-spu.c:507
void * xmalloc(YYSIZE_T)
CORE_ADDR linux_displaced_step_location(struct gdbarch *gdbarch)
Definition: linux-tdep.c:2384
static const struct target_desc * ppc_linux_core_read_description(struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd)
int ppc_insns_match_pattern(struct frame_info *frame, CORE_ADDR pc, struct ppc_insn_pattern *pattern, unsigned int *insns)
Definition: rs6000-tdep.c:6112
void ppc64_elf_make_msymbol_special(asymbol *sym, struct minimal_symbol *msym)
Definition: ppc64-tdep.c:609
gdb_syscall
Definition: linux-record.h:184
int record_full_arch_list_add_mem(CORE_ADDR addr, int len)
Definition: record-full.c:489
Definition: value.c:172
static const struct ppc_reg_offsets ppc32_linux_reg_offsets
static void ppc_elfv2_elf_make_msymbol_special(asymbol *sym, struct minimal_symbol *msym)
const struct regset * ppc_linux_fpregset(void)
static void ppc32_linux_sighandler_cache_init(const struct tramp_frame *self, struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
void write_exp_elt_opcode(struct parser_state *ps, enum exp_opcode expelt)
Definition: parse.c:236
bfd_byte gdb_byte
Definition: common-types.h:38
static CORE_ADDR spe_context_lm_addr
int ppc_ctr_regnum
Definition: ppc-tdep.h:219
struct frame_info * get_next_frame(struct frame_info *this_frame)
Definition: frame.c:1668
int ppc_vr0_regnum
Definition: ppc-tdep.h:239
struct target_so_ops svr4_so_ops
Definition: solib-svr4.c:3208
void discard_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:213
ULONGEST align_up(ULONGEST v, int n)
Definition: utils.c:2963
#define POWERPC32_PLT_STUB_LEN
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
Definition: minsyms.c:801
void ppc_collect_vsxregset(const struct regset *regset, const struct regcache *regcache, int regnum, void *vsxregs, size_t len)
Definition: rs6000-tdep.c:749
static LONGEST ppc_linux_get_syscall_number(struct gdbarch *gdbarch, ptid_t ptid)
CORE_ADDR ppc_insn_d_field(unsigned int insn)
Definition: rs6000-tdep.c:6141
int gdbarch_fp0_regnum(struct gdbarch *gdbarch)
Definition: gdbarch.c:2032
enum register_status gdbarch_pseudo_register_read(struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, gdb_byte *buf)
Definition: gdbarch.c:1833
static void ppc_linux_spe_context_inferior_created(struct target_ops *t, int from_tty)
int xsnprintf(char *str, size_t size, const char *format,...)
Definition: common-utils.c:134
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1240
enum register_status regcache_raw_read(struct regcache *regcache, int regnum, gdb_byte *buf)
Definition: regcache.c:637
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition: regcache.c:871
void regcache_save(struct regcache *dst, regcache_cooked_read_ftype *cooked_read, void *src)
Definition: regcache.c:317
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: target.c:1393
int wordsize
Definition: ppc-tdep.h:206
const gdb_byte * gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
Definition: gdbarch.c:2662
void gdbarch_info_init(struct gdbarch_info *info)
Definition: arch-utils.c:708
static int ppc_linux_record_signal(struct gdbarch *gdbarch, struct regcache *regcache, enum gdb_signal signal)
ptid_t inferior_ptid
Definition: infcmd.c:124
struct minimal_symbol * minsym
Definition: minsyms.h:32
void set_gdbarch_stap_is_single_operand(struct gdbarch *gdbarch, gdbarch_stap_is_single_operand_ftype stap_is_single_operand)
Definition: gdbarch.c:4219
int offset
Definition: agent.c:65
void set_gdbarch_get_syscall_number(struct gdbarch *gdbarch, gdbarch_get_syscall_number_ftype get_syscall_number)
Definition: gdbarch.c:4025
void tramp_frame_prepend_unwinder(struct gdbarch *gdbarch, const struct tramp_frame *tramp_frame)
Definition: tramp-frame.c:145
int ppc_xer_regnum
Definition: ppc-tdep.h:220
enum register_status regcache_cooked_read(struct regcache *regcache, int regnum, gdb_byte *buf)
Definition: regcache.c:737
static const struct regset ppc32_linux_gregset
struct gdbarch * gdbarch
struct m32c_reg regs[M32C_MAX_NUM_REGS]
Definition: m32c-tdep.c:105
struct cleanup * make_cleanup_regcache_xfree(struct regcache *regcache)
Definition: regcache.c:263
static void initialize_tdesc_powerpc_isa205_vsx64l(void)
struct m32c_reg * sp
Definition: m32c-tdep.c:114
void regcache_xfree(struct regcache *regcache)
Definition: regcache.c:247
void set_gdbarch_memory_remove_breakpoint(struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype memory_remove_breakpoint)
Definition: gdbarch.c:2747
struct target_desc * tdesc_powerpc_vsx64l
Definition: powerpc-vsx64l.c:8
static void ppc_linux_spe_context_lookup(struct objfile *objfile)
const void * regmap
Definition: regset.h:39
unsigned long long ULONGEST
Definition: common-types.h:53
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
Definition: frame-unwind.c:180
const struct tdesc_feature * tdesc_find_feature(const struct target_desc *target_desc, const char *name)
int register_size(struct gdbarch *gdbarch, int regnum)
Definition: regcache.c:169
static void initialize_tdesc_powerpc_altivec32l(void)
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
Definition: gdbarch.c:1667
void set_gdbarch_skip_entrypoint(struct gdbarch *gdbarch, gdbarch_skip_entrypoint_ftype skip_entrypoint)
Definition: gdbarch.c:2638
const struct frame_base * base
Definition: frame.c:133
struct target_desc * tdesc_powerpc_vsx32l
Definition: powerpc-vsx32l.c:8
static void ppc_linux_spe_context_solib_unloaded(struct so_list *so)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
Definition: gdbarch.c:2556
LONGEST target_read(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *buf, ULONGEST offset, LONGEST len)
Definition: target.c:1590
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
Definition: gdbarch.c:1411
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
Definition: gdbarch.c:1998
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
Definition: gdbarch.c:1683
#define TYPE_LENGTH(thistype)
Definition: gdbtypes.h:1237
struct objfile * objfile
Definition: minsyms.h:37
int execution_direction
Definition: infrun.c:7561
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:321
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype iterate_over_regset_sections)
Definition: gdbarch.c:3398
static struct linux_record_tdep ppc_linux_record_tdep
LONGEST extract_signed_integer(const gdb_byte *, int, enum bfd_endian)
Definition: findvar.c:49
static struct value * ppu2spu_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
static struct gdbarch_data * tdesc_data
void ppc_supply_vsxregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *vsxregs, size_t len)
Definition: rs6000-tdep.c:587
struct objfile * objfile
Definition: solist.h:69
struct target_desc * tdesc_powerpc_altivec64l
static void ppc_linux_collect_gregset(const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len)
enum bfd_endian byte_order
Definition: gdbarch.h:1552
void set_gdbarch_skip_solib_resolver(struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype skip_solib_resolver)
Definition: gdbarch.c:3101
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:163
int ppc_floating_point_unit_p(struct gdbarch *gdbarch)
Definition: rs6000-tdep.c:212
void write_exp_string(struct parser_state *ps, struct stoken str)
Definition: parse.c:349
int record_full_arch_list_add_end(void)
Definition: record-full.c:520
void set_gdbarch_core_read_description(struct gdbarch *gdbarch, gdbarch_core_read_description_ftype core_read_description)
Definition: gdbarch.c:3816
int tdesc_has_registers(const struct target_desc *target_desc)
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition: osabi.c:148
enum return_value_convention ppc_sysv_abi_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
void error(const char *fmt,...)
Definition: errors.c:38
int ppc_fp0_regnum
Definition: ppc-tdep.h:227
void ppc_supply_gregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
Definition: rs6000-tdep.c:505
ptid_t minus_one_ptid
Definition: ptid.c:26
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2535
#define FRAME_OBSTACK_CALLOC(NUMBER, TYPE)
Definition: frame.h:662
long long LONGEST
Definition: common-types.h:52
#define wordsize
static CORE_ADDR spe_context_cache_address
void do_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:175
struct observer * observer_attach_solib_loaded(observer_solib_loaded_ftype *f)
static void ppu2spu_dealloc_cache(struct frame_info *self, void *this_cache)
static struct target_so_ops powerpc_so_ops
int length
Definition: parser-defs.h:81
static CORE_ADDR ppc_linux_spe_context(int wordsize, enum bfd_endian byte_order, int n, int *id, unsigned int *npc)
const struct target_desc * gdbarch_target_desc(struct gdbarch *gdbarch)
Definition: gdbarch.c:1447
const ULONGEST const LONGEST len
Definition: target.h:309
static ptid_t spe_context_cache_ptid