GDB (xrefs)
/tmp/gdb-8.1/gdb/mips-linux-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for GNU/Linux on MIPS processors.
2 
3  Copyright (C) 2001-2018 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 "gdbcore.h"
22 #include "target.h"
23 #include "solib-svr4.h"
24 #include "osabi.h"
25 #include "mips-tdep.h"
26 #include "frame.h"
27 #include "regcache.h"
28 #include "trad-frame.h"
29 #include "tramp-frame.h"
30 #include "gdbtypes.h"
31 #include "objfiles.h"
32 #include "solib.h"
33 #include "solist.h"
34 #include "symtab.h"
35 #include "target-descriptions.h"
36 #include "regset.h"
37 #include "mips-linux-tdep.h"
38 #include "glibc-tdep.h"
39 #include "linux-tdep.h"
40 #include "xml-syscall.h"
41 #include "gdb_signals.h"
42 
43 #include "features/mips-linux.c"
45 #include "features/mips64-linux.c"
47 
49 
50 /* This enum represents the signals' numbers on the MIPS
51  architecture. It just contains the signal definitions which are
52  different from the generic implementation.
53 
54  It is derived from the file <arch/mips/include/uapi/asm/signal.h>,
55  from the Linux kernel tree. */
56 
57 enum
58  {
80 
84  };
85 
86 /* Figure out where the longjmp will land.
87  We expect the first arg to be a pointer to the jmp_buf structure
88  from which we extract the pc (MIPS_LINUX_JB_PC) that we will land
89  at. The pc is copied into PC. This routine returns 1 on
90  success. */
91 
92 #define MIPS_LINUX_JB_ELEMENT_SIZE 4
93 #define MIPS_LINUX_JB_PC 0
94 
95 static int
97 {
98  CORE_ADDR jb_addr;
99  struct gdbarch *gdbarch = get_frame_arch (frame);
100  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
102 
103  jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
104 
105  if (target_read_memory ((jb_addr
108  return 0;
109 
110  *pc = extract_unsigned_integer (buf,
112  byte_order);
113 
114  return 1;
115 }
116 
117 /* Transform the bits comprising a 32-bit register to the right size
118  for regcache_raw_supply(). This is needed when mips_isa_regsize()
119  is 8. */
120 
121 static void
122 supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr)
123 {
124  regcache->raw_supply_integer (regnum, (const gdb_byte *) addr, 4, true);
125 }
126 
127 /* Unpack an elf_gregset_t into GDB's register cache. */
128 
129 void
131  const mips_elf_gregset_t *gregsetp)
132 {
133  int regi;
134  const mips_elf_greg_t *regp = *gregsetp;
135  struct gdbarch *gdbarch = regcache->arch ();
136 
137  for (regi = EF_REG0 + 1; regi <= EF_REG31; regi++)
138  supply_32bit_reg (regcache, regi - EF_REG0, regp + regi);
139 
142 
145 
147  regp + EF_CP0_EPC);
149  regp + EF_CP0_BADVADDR);
152  regp + EF_CP0_CAUSE);
153 
154  /* Fill the inaccessible zero register with zero. */
156 }
157 
158 static void
160  struct regcache *regcache,
161  int regnum, const void *gregs, size_t len)
162 {
163  gdb_assert (len >= sizeof (mips_elf_gregset_t));
164 
166 }
167 
168 /* Pack our registers (or one register) into an elf_gregset_t. */
169 
170 void
172  mips_elf_gregset_t *gregsetp, int regno)
173 {
174  struct gdbarch *gdbarch = regcache->arch ();
175  int regaddr, regi;
176  mips_elf_greg_t *regp = *gregsetp;
177  void *dst;
178 
179  if (regno == -1)
180  {
181  memset (regp, 0, sizeof (mips_elf_gregset_t));
182  for (regi = 1; regi < 32; regi++)
183  mips_fill_gregset (regcache, gregsetp, regi);
184  mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->lo);
185  mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->hi);
186  mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->pc);
187  mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->badvaddr);
189  mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->cause);
191  return;
192  }
193 
194  if (regno > 0 && regno < 32)
195  {
196  dst = regp + regno + EF_REG0;
197  regcache_raw_collect (regcache, regno, dst);
198  return;
199  }
200 
201  if (regno == mips_regnum (gdbarch)->lo)
202  regaddr = EF_LO;
203  else if (regno == mips_regnum (gdbarch)->hi)
204  regaddr = EF_HI;
205  else if (regno == mips_regnum (gdbarch)->pc)
206  regaddr = EF_CP0_EPC;
207  else if (regno == mips_regnum (gdbarch)->badvaddr)
208  regaddr = EF_CP0_BADVADDR;
209  else if (regno == MIPS_PS_REGNUM)
210  regaddr = EF_CP0_STATUS;
211  else if (regno == mips_regnum (gdbarch)->cause)
212  regaddr = EF_CP0_CAUSE;
214  && regno == MIPS_RESTART_REGNUM)
215  regaddr = EF_REG0;
216  else
217  regaddr = -1;
218 
219  if (regaddr != -1)
220  {
221  dst = regp + regaddr;
222  regcache_raw_collect (regcache, regno, dst);
223  }
224 }
225 
226 static void
228  const struct regcache *regcache,
229  int regnum, void *gregs, size_t len)
230 {
231  gdb_assert (len >= sizeof (mips_elf_gregset_t));
232 
234 }
235 
236 /* Likewise, unpack an elf_fpregset_t. */
237 
238 void
240  const mips_elf_fpregset_t *fpregsetp)
241 {
242  struct gdbarch *gdbarch = regcache->arch ();
243  int regi;
244 
245  for (regi = 0; regi < 32; regi++)
247  gdbarch_fp0_regnum (gdbarch) + regi,
248  *fpregsetp + regi);
249 
251  mips_regnum (gdbarch)->fp_control_status,
252  *fpregsetp + 32);
253 
254  /* FIXME: how can we supply FCRIR? The ABI doesn't tell us. */
256  (mips_regnum (gdbarch)->fp_implementation_revision);
257 }
258 
259 static void
261  struct regcache *regcache,
262  int regnum, const void *gregs, size_t len)
263 {
264  gdb_assert (len >= sizeof (mips_elf_fpregset_t));
265 
267 }
268 
269 /* Likewise, pack one or all floating point registers into an
270  elf_fpregset_t. */
271 
272 void
274  mips_elf_fpregset_t *fpregsetp, int regno)
275 {
276  struct gdbarch *gdbarch = regcache->arch ();
277  char *to;
278 
279  if ((regno >= gdbarch_fp0_regnum (gdbarch))
280  && (regno < gdbarch_fp0_regnum (gdbarch) + 32))
281  {
282  to = (char *) (*fpregsetp + regno - gdbarch_fp0_regnum (gdbarch));
283  regcache_raw_collect (regcache, regno, to);
284  }
285  else if (regno == mips_regnum (gdbarch)->fp_control_status)
286  {
287  to = (char *) (*fpregsetp + 32);
288  regcache_raw_collect (regcache, regno, to);
289  }
290  else if (regno == -1)
291  {
292  int regi;
293 
294  for (regi = 0; regi < 32; regi++)
295  mips_fill_fpregset (regcache, fpregsetp,
296  gdbarch_fp0_regnum (gdbarch) + regi);
297  mips_fill_fpregset (regcache, fpregsetp,
298  mips_regnum (gdbarch)->fp_control_status);
299  }
300 }
301 
302 static void
304  const struct regcache *regcache,
305  int regnum, void *gregs, size_t len)
306 {
307  gdb_assert (len >= sizeof (mips_elf_fpregset_t));
308 
310 }
311 
312 /* Support for 64-bit ABIs. */
313 
314 /* Figure out where the longjmp will land.
315  We expect the first arg to be a pointer to the jmp_buf structure
316  from which we extract the pc (MIPS_LINUX_JB_PC) that we will land
317  at. The pc is copied into PC. This routine returns 1 on
318  success. */
319 
320 /* Details about jmp_buf. */
321 
322 #define MIPS64_LINUX_JB_PC 0
323 
324 static int
326 {
327  CORE_ADDR jb_addr;
328  struct gdbarch *gdbarch = get_frame_arch (frame);
329  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
330  gdb_byte *buf
331  = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
332  int element_size = gdbarch_ptr_bit (gdbarch) == 32 ? 4 : 8;
333 
334  jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
335 
336  if (target_read_memory (jb_addr + MIPS64_LINUX_JB_PC * element_size,
337  buf,
339  return 0;
340 
341  *pc = extract_unsigned_integer (buf,
343  byte_order);
344 
345  return 1;
346 }
347 
348 /* Register set support functions. These operate on standard 64-bit
349  regsets, but work whether the target is 32-bit or 64-bit. A 32-bit
350  target will still use the 64-bit format for PTRACE_GETREGS. */
351 
352 /* Supply a 64-bit register. */
353 
354 static void
356  const gdb_byte *buf)
357 {
358  struct gdbarch *gdbarch = regcache->arch ();
359  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG
360  && register_size (gdbarch, regnum) == 4)
361  regcache_raw_supply (regcache, regnum, buf + 4);
362  else
364 }
365 
366 /* Unpack a 64-bit elf_gregset_t into GDB's register cache. */
367 
368 void
370  const mips64_elf_gregset_t *gregsetp)
371 {
372  int regi;
373  const mips64_elf_greg_t *regp = *gregsetp;
374  struct gdbarch *gdbarch = regcache->arch ();
375 
376  for (regi = MIPS64_EF_REG0 + 1; regi <= MIPS64_EF_REG31; regi++)
378  (const gdb_byte *) (regp + regi));
379 
382  (const gdb_byte *) (regp + MIPS64_EF_REG0));
383 
385  (const gdb_byte *) (regp + MIPS64_EF_LO));
387  (const gdb_byte *) (regp + MIPS64_EF_HI));
388 
390  (const gdb_byte *) (regp + MIPS64_EF_CP0_EPC));
392  (const gdb_byte *) (regp + MIPS64_EF_CP0_BADVADDR));
394  (const gdb_byte *) (regp + MIPS64_EF_CP0_STATUS));
396  (const gdb_byte *) (regp + MIPS64_EF_CP0_CAUSE));
397 
398  /* Fill the inaccessible zero register with zero. */
400 }
401 
402 static void
404  struct regcache *regcache,
405  int regnum, const void *gregs, size_t len)
406 {
407  gdb_assert (len >= sizeof (mips64_elf_gregset_t));
408 
410 }
411 
412 /* Pack our registers (or one register) into a 64-bit elf_gregset_t. */
413 
414 void
416  mips64_elf_gregset_t *gregsetp, int regno)
417 {
418  struct gdbarch *gdbarch = regcache->arch ();
419  int regaddr, regi;
420  mips64_elf_greg_t *regp = *gregsetp;
421  void *dst;
422 
423  if (regno == -1)
424  {
425  memset (regp, 0, sizeof (mips64_elf_gregset_t));
426  for (regi = 1; regi < 32; regi++)
427  mips64_fill_gregset (regcache, gregsetp, regi);
428  mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->lo);
429  mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->hi);
430  mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->pc);
431  mips64_fill_gregset (regcache, gregsetp,
432  mips_regnum (gdbarch)->badvaddr);
434  mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->cause);
436  return;
437  }
438 
439  if (regno > 0 && regno < 32)
440  regaddr = regno + MIPS64_EF_REG0;
441  else if (regno == mips_regnum (gdbarch)->lo)
442  regaddr = MIPS64_EF_LO;
443  else if (regno == mips_regnum (gdbarch)->hi)
444  regaddr = MIPS64_EF_HI;
445  else if (regno == mips_regnum (gdbarch)->pc)
446  regaddr = MIPS64_EF_CP0_EPC;
447  else if (regno == mips_regnum (gdbarch)->badvaddr)
448  regaddr = MIPS64_EF_CP0_BADVADDR;
449  else if (regno == MIPS_PS_REGNUM)
450  regaddr = MIPS64_EF_CP0_STATUS;
451  else if (regno == mips_regnum (gdbarch)->cause)
452  regaddr = MIPS64_EF_CP0_CAUSE;
454  && regno == MIPS_RESTART_REGNUM)
455  regaddr = MIPS64_EF_REG0;
456  else
457  regaddr = -1;
458 
459  if (regaddr != -1)
460  {
461  dst = regp + regaddr;
462  regcache->raw_collect_integer (regno, (gdb_byte *) dst, 8, true);
463  }
464 }
465 
466 static void
468  const struct regcache *regcache,
469  int regnum, void *gregs, size_t len)
470 {
471  gdb_assert (len >= sizeof (mips64_elf_gregset_t));
472 
474 }
475 
476 /* Likewise, unpack an elf_fpregset_t. */
477 
478 void
480  const mips64_elf_fpregset_t *fpregsetp)
481 {
482  struct gdbarch *gdbarch = regcache->arch ();
483  int regi;
484 
485  /* See mips_linux_o32_sigframe_init for a description of the
486  peculiar FP register layout. */
488  for (regi = 0; regi < 32; regi++)
489  {
490  const gdb_byte *reg_ptr
491  = (const gdb_byte *) (*fpregsetp + (regi & ~1));
492  if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (regi & 1))
493  reg_ptr += 4;
495  gdbarch_fp0_regnum (gdbarch) + regi,
496  reg_ptr);
497  }
498  else
499  for (regi = 0; regi < 32; regi++)
501  gdbarch_fp0_regnum (gdbarch) + regi,
502  (const char *) (*fpregsetp + regi));
503 
504  supply_32bit_reg (regcache, mips_regnum (gdbarch)->fp_control_status,
505  (const gdb_byte *) (*fpregsetp + 32));
506 
507  /* The ABI doesn't tell us how to supply FCRIR, and core dumps don't
508  include it - but the result of PTRACE_GETFPREGS does. The best we
509  can do is to assume that its value is present. */
511  mips_regnum (gdbarch)->fp_implementation_revision,
512  (const gdb_byte *) (*fpregsetp + 32) + 4);
513 }
514 
515 static void
517  struct regcache *regcache,
518  int regnum, const void *gregs, size_t len)
519 {
520  gdb_assert (len >= sizeof (mips64_elf_fpregset_t));
521 
523 }
524 
525 /* Likewise, pack one or all floating point registers into an
526  elf_fpregset_t. */
527 
528 void
530  mips64_elf_fpregset_t *fpregsetp, int regno)
531 {
532  struct gdbarch *gdbarch = regcache->arch ();
533  gdb_byte *to;
534 
535  if ((regno >= gdbarch_fp0_regnum (gdbarch))
536  && (regno < gdbarch_fp0_regnum (gdbarch) + 32))
537  {
538  /* See mips_linux_o32_sigframe_init for a description of the
539  peculiar FP register layout. */
540  if (register_size (gdbarch, regno) == 4)
541  {
542  int regi = regno - gdbarch_fp0_regnum (gdbarch);
543 
544  to = (gdb_byte *) (*fpregsetp + (regi & ~1));
545  if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (regi & 1))
546  to += 4;
547  regcache_raw_collect (regcache, regno, to);
548  }
549  else
550  {
551  to = (gdb_byte *) (*fpregsetp + regno
553  regcache_raw_collect (regcache, regno, to);
554  }
555  }
556  else if (regno == mips_regnum (gdbarch)->fp_control_status)
557  {
558  to = (gdb_byte *) (*fpregsetp + 32);
559  regcache->raw_collect_integer (regno, to, 4, true);
560  }
561  else if (regno == mips_regnum (gdbarch)->fp_implementation_revision)
562  {
563  to = (gdb_byte *) (*fpregsetp + 32) + 4;
564  regcache->raw_collect_integer (regno, to, 4, true);
565  }
566  else if (regno == -1)
567  {
568  int regi;
569 
570  for (regi = 0; regi < 32; regi++)
571  mips64_fill_fpregset (regcache, fpregsetp,
572  gdbarch_fp0_regnum (gdbarch) + regi);
573  mips64_fill_fpregset (regcache, fpregsetp,
574  mips_regnum (gdbarch)->fp_control_status);
575  mips64_fill_fpregset (regcache, fpregsetp,
576  mips_regnum (gdbarch)->fp_implementation_revision);
577  }
578 }
579 
580 static void
582  const struct regcache *regcache,
583  int regnum, void *gregs, size_t len)
584 {
585  gdb_assert (len >= sizeof (mips64_elf_fpregset_t));
586 
588 }
589 
590 static const struct regset mips_linux_gregset =
591  {
593  };
594 
595 static const struct regset mips64_linux_gregset =
596  {
598  };
599 
600 static const struct regset mips_linux_fpregset =
601  {
603  };
604 
605 static const struct regset mips64_linux_fpregset =
606  {
608  };
609 
610 static void
613  void *cb_data,
614  const struct regcache *regcache)
615 {
617  {
618  cb (".reg", sizeof (mips_elf_gregset_t), &mips_linux_gregset,
619  NULL, cb_data);
620  cb (".reg2", sizeof (mips_elf_fpregset_t), &mips_linux_fpregset,
621  NULL, cb_data);
622  }
623  else
624  {
625  cb (".reg", sizeof (mips64_elf_gregset_t), &mips64_linux_gregset,
626  NULL, cb_data);
627  cb (".reg2", sizeof (mips64_elf_fpregset_t), &mips64_linux_fpregset,
628  NULL, cb_data);
629  }
630 }
631 
632 static const struct target_desc *
634  struct target_ops *target,
635  bfd *abfd)
636 {
637  asection *section = bfd_get_section_by_name (abfd, ".reg");
638  if (! section)
639  return NULL;
640 
641  switch (bfd_section_size (abfd, section))
642  {
643  case sizeof (mips_elf_gregset_t):
644  return mips_tdesc_gp32;
645 
646  case sizeof (mips64_elf_gregset_t):
647  return mips_tdesc_gp64;
648 
649  default:
650  return NULL;
651  }
652 }
653 
654 
655 /* Check the code at PC for a dynamic linker lazy resolution stub.
656  GNU ld for MIPS has put lazy resolution stubs into a ".MIPS.stubs"
657  section uniformly since version 2.15. If the pc is in that section,
658  then we are in such a stub. Before that ".stub" was used in 32-bit
659  ELF binaries, however we do not bother checking for that since we
660  have never had and that case should be extremely rare these days.
661  Instead we pattern-match on the code generated by GNU ld. They look
662  like this:
663 
664  lw t9,0x8010(gp)
665  addu t7,ra
666  jalr t9,ra
667  addiu t8,zero,INDEX
668 
669  (with the appropriate doubleword instructions for N64). As any lazy
670  resolution stubs in microMIPS binaries will always be in a
671  ".MIPS.stubs" section we only ever verify standard MIPS patterns. */
672 
673 static int
675 {
676  gdb_byte buf[28], *p;
677  ULONGEST insn, insn1;
678  int n64 = (mips_abi (target_gdbarch ()) == MIPS_ABI_N64);
679  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
680 
681  if (in_mips_stubs_section (pc))
682  return 1;
683 
684  read_memory (pc - 12, buf, 28);
685 
686  if (n64)
687  {
688  /* ld t9,0x8010(gp) */
689  insn1 = 0xdf998010;
690  }
691  else
692  {
693  /* lw t9,0x8010(gp) */
694  insn1 = 0x8f998010;
695  }
696 
697  p = buf + 12;
698  while (p >= buf)
699  {
700  insn = extract_unsigned_integer (p, 4, byte_order);
701  if (insn == insn1)
702  break;
703  p -= 4;
704  }
705  if (p < buf)
706  return 0;
707 
708  insn = extract_unsigned_integer (p + 4, 4, byte_order);
709  if (n64)
710  {
711  /* 'daddu t7,ra' or 'or t7, ra, zero'*/
712  if (insn != 0x03e0782d || insn != 0x03e07825)
713  return 0;
714 
715  }
716  else
717  {
718  /* 'addu t7,ra' or 'or t7, ra, zero'*/
719  if (insn != 0x03e07821 || insn != 0x03e07825)
720  return 0;
721 
722  }
723 
724  insn = extract_unsigned_integer (p + 8, 4, byte_order);
725  /* jalr t9,ra */
726  if (insn != 0x0320f809)
727  return 0;
728 
729  insn = extract_unsigned_integer (p + 12, 4, byte_order);
730  if (n64)
731  {
732  /* daddiu t8,zero,0 */
733  if ((insn & 0xffff0000) != 0x64180000)
734  return 0;
735  }
736  else
737  {
738  /* addiu t8,zero,0 */
739  if ((insn & 0xffff0000) != 0x24180000)
740  return 0;
741  }
742 
743  return 1;
744 }
745 
746 /* Return non-zero iff PC belongs to the dynamic linker resolution
747  code, a PLT entry, or a lazy binding stub. */
748 
749 static int
751 {
752  /* Check whether PC is in the dynamic linker. This also checks
753  whether it is in the .plt section, used by non-PIC executables. */
755  return 1;
756 
757  /* Likewise for the stubs. They live in the .MIPS.stubs section these
758  days, so we check if the PC is within, than fall back to a pattern
759  match. */
760  if (mips_linux_in_dynsym_stub (pc))
761  return 1;
762 
763  return 0;
764 }
765 
766 /* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c,
767  and glibc_skip_solib_resolver in glibc-tdep.c. The normal glibc
768  implementation of this triggers at "fixup" from the same objfile as
769  "_dl_runtime_resolve"; MIPS GNU/Linux can trigger at
770  "__dl_runtime_resolve" directly. An unresolved lazy binding
771  stub will point to _dl_runtime_resolve, which will first call
772  __dl_runtime_resolve, and then pass control to the resolved
773  function. */
774 
775 static CORE_ADDR
777 {
778  struct bound_minimal_symbol resolver;
779 
780  resolver = lookup_minimal_symbol ("__dl_runtime_resolve", NULL, NULL);
781 
782  if (resolver.minsym && BMSYMBOL_VALUE_ADDRESS (resolver) == pc)
784 
785  return glibc_skip_solib_resolver (gdbarch, pc);
786 }
787 
788 /* Signal trampoline support. There are four supported layouts for a
789  signal frame: o32 sigframe, o32 rt_sigframe, n32 rt_sigframe, and
790  n64 rt_sigframe. We handle them all independently; not the most
791  efficient way, but simplest. First, declare all the unwinders. */
792 
793 static void mips_linux_o32_sigframe_init (const struct tramp_frame *self,
794  struct frame_info *this_frame,
795  struct trad_frame_cache *this_cache,
796  CORE_ADDR func);
797 
798 static void mips_linux_n32n64_sigframe_init (const struct tramp_frame *self,
799  struct frame_info *this_frame,
800  struct trad_frame_cache *this_cache,
801  CORE_ADDR func);
802 
803 static int mips_linux_sigframe_validate (const struct tramp_frame *self,
804  struct frame_info *this_frame,
805  CORE_ADDR *pc);
806 
807 static int micromips_linux_sigframe_validate (const struct tramp_frame *self,
808  struct frame_info *this_frame,
809  CORE_ADDR *pc);
810 
811 #define MIPS_NR_LINUX 4000
812 #define MIPS_NR_N64_LINUX 5000
813 #define MIPS_NR_N32_LINUX 6000
814 
815 #define MIPS_NR_sigreturn MIPS_NR_LINUX + 119
816 #define MIPS_NR_rt_sigreturn MIPS_NR_LINUX + 193
817 #define MIPS_NR_N64_rt_sigreturn MIPS_NR_N64_LINUX + 211
818 #define MIPS_NR_N32_rt_sigreturn MIPS_NR_N32_LINUX + 211
819 
820 #define MIPS_INST_LI_V0_SIGRETURN 0x24020000 + MIPS_NR_sigreturn
821 #define MIPS_INST_LI_V0_RT_SIGRETURN 0x24020000 + MIPS_NR_rt_sigreturn
822 #define MIPS_INST_LI_V0_N64_RT_SIGRETURN 0x24020000 + MIPS_NR_N64_rt_sigreturn
823 #define MIPS_INST_LI_V0_N32_RT_SIGRETURN 0x24020000 + MIPS_NR_N32_rt_sigreturn
824 #define MIPS_INST_SYSCALL 0x0000000c
825 
826 #define MICROMIPS_INST_LI_V0 0x3040
827 #define MICROMIPS_INST_POOL32A 0x0000
828 #define MICROMIPS_INST_SYSCALL 0x8b7c
829 
830 static const struct tramp_frame mips_linux_o32_sigframe = {
832  4,
833  {
835  { MIPS_INST_SYSCALL, -1 },
836  { TRAMP_SENTINEL_INSN, -1 }
837  },
840 };
841 
844  4,
845  {
847  { MIPS_INST_SYSCALL, -1 },
848  { TRAMP_SENTINEL_INSN, -1 } },
851 };
852 
855  4,
856  {
858  { MIPS_INST_SYSCALL, -1 },
859  { TRAMP_SENTINEL_INSN, -1 }
860  },
863 };
864 
867  4,
868  {
870  { MIPS_INST_SYSCALL, -1 },
871  { TRAMP_SENTINEL_INSN, -1 }
872  },
875 };
876 
879  2,
880  {
881  { MICROMIPS_INST_LI_V0, -1 },
882  { MIPS_NR_sigreturn, -1 },
883  { MICROMIPS_INST_POOL32A, -1 },
884  { MICROMIPS_INST_SYSCALL, -1 },
885  { TRAMP_SENTINEL_INSN, -1 }
886  },
889 };
890 
893  2,
894  {
895  { MICROMIPS_INST_LI_V0, -1 },
896  { MIPS_NR_rt_sigreturn, -1 },
897  { MICROMIPS_INST_POOL32A, -1 },
898  { MICROMIPS_INST_SYSCALL, -1 },
899  { TRAMP_SENTINEL_INSN, -1 }
900  },
903 };
904 
907  2,
908  {
909  { MICROMIPS_INST_LI_V0, -1 },
910  { MIPS_NR_N32_rt_sigreturn, -1 },
911  { MICROMIPS_INST_POOL32A, -1 },
912  { MICROMIPS_INST_SYSCALL, -1 },
913  { TRAMP_SENTINEL_INSN, -1 }
914  },
917 };
918 
921  2,
922  {
923  { MICROMIPS_INST_LI_V0, -1 },
924  { MIPS_NR_N64_rt_sigreturn, -1 },
925  { MICROMIPS_INST_POOL32A, -1 },
926  { MICROMIPS_INST_SYSCALL, -1 },
927  { TRAMP_SENTINEL_INSN, -1 }
928  },
931 };
932 
933 /* *INDENT-OFF* */
934 /* The unwinder for o32 signal frames. The legacy structures look
935  like this:
936 
937  struct sigframe {
938  u32 sf_ass[4]; [argument save space for o32]
939  u32 sf_code[2]; [signal trampoline or fill]
940  struct sigcontext sf_sc;
941  sigset_t sf_mask;
942  };
943 
944  Pre-2.6.12 sigcontext:
945 
946  struct sigcontext {
947  unsigned int sc_regmask; [Unused]
948  unsigned int sc_status;
949  unsigned long long sc_pc;
950  unsigned long long sc_regs[32];
951  unsigned long long sc_fpregs[32];
952  unsigned int sc_ownedfp;
953  unsigned int sc_fpc_csr;
954  unsigned int sc_fpc_eir; [Unused]
955  unsigned int sc_used_math;
956  unsigned int sc_ssflags; [Unused]
957  [Alignment hole of four bytes]
958  unsigned long long sc_mdhi;
959  unsigned long long sc_mdlo;
960 
961  unsigned int sc_cause; [Unused]
962  unsigned int sc_badvaddr; [Unused]
963 
964  unsigned long sc_sigset[4]; [kernel's sigset_t]
965  };
966 
967  Post-2.6.12 sigcontext (SmartMIPS/DSP support added):
968 
969  struct sigcontext {
970  unsigned int sc_regmask; [Unused]
971  unsigned int sc_status; [Unused]
972  unsigned long long sc_pc;
973  unsigned long long sc_regs[32];
974  unsigned long long sc_fpregs[32];
975  unsigned int sc_acx;
976  unsigned int sc_fpc_csr;
977  unsigned int sc_fpc_eir; [Unused]
978  unsigned int sc_used_math;
979  unsigned int sc_dsp;
980  [Alignment hole of four bytes]
981  unsigned long long sc_mdhi;
982  unsigned long long sc_mdlo;
983  unsigned long sc_hi1;
984  unsigned long sc_lo1;
985  unsigned long sc_hi2;
986  unsigned long sc_lo2;
987  unsigned long sc_hi3;
988  unsigned long sc_lo3;
989  };
990 
991  The RT signal frames look like this:
992 
993  struct rt_sigframe {
994  u32 rs_ass[4]; [argument save space for o32]
995  u32 rs_code[2] [signal trampoline or fill]
996  struct siginfo rs_info;
997  struct ucontext rs_uc;
998  };
999 
1000  struct ucontext {
1001  unsigned long uc_flags;
1002  struct ucontext *uc_link;
1003  stack_t uc_stack;
1004  [Alignment hole of four bytes]
1005  struct sigcontext uc_mcontext;
1006  sigset_t uc_sigmask;
1007  }; */
1008 /* *INDENT-ON* */
1009 
1010 #define SIGFRAME_SIGCONTEXT_OFFSET (6 * 4)
1011 
1012 #define RTSIGFRAME_SIGINFO_SIZE 128
1013 #define STACK_T_SIZE (3 * 4)
1014 #define UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + STACK_T_SIZE + 4)
1015 #define RTSIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \
1016  + RTSIGFRAME_SIGINFO_SIZE \
1017  + UCONTEXT_SIGCONTEXT_OFFSET)
1018 
1019 #define SIGCONTEXT_PC (1 * 8)
1020 #define SIGCONTEXT_REGS (2 * 8)
1021 #define SIGCONTEXT_FPREGS (34 * 8)
1022 #define SIGCONTEXT_FPCSR (66 * 8 + 4)
1023 #define SIGCONTEXT_DSPCTL (68 * 8 + 0)
1024 #define SIGCONTEXT_HI (69 * 8)
1025 #define SIGCONTEXT_LO (70 * 8)
1026 #define SIGCONTEXT_CAUSE (71 * 8 + 0)
1027 #define SIGCONTEXT_BADVADDR (71 * 8 + 4)
1028 #define SIGCONTEXT_HI1 (71 * 8 + 0)
1029 #define SIGCONTEXT_LO1 (71 * 8 + 4)
1030 #define SIGCONTEXT_HI2 (72 * 8 + 0)
1031 #define SIGCONTEXT_LO2 (72 * 8 + 4)
1032 #define SIGCONTEXT_HI3 (73 * 8 + 0)
1033 #define SIGCONTEXT_LO3 (73 * 8 + 4)
1034 
1035 #define SIGCONTEXT_REG_SIZE 8
1036 
1037 static void
1039  struct frame_info *this_frame,
1040  struct trad_frame_cache *this_cache,
1041  CORE_ADDR func)
1042 {
1043  struct gdbarch *gdbarch = get_frame_arch (this_frame);
1044  int ireg;
1045  CORE_ADDR frame_sp = get_frame_sp (this_frame);
1046  CORE_ADDR sigcontext_base;
1047  const struct mips_regnum *regs = mips_regnum (gdbarch);
1048  CORE_ADDR regs_base;
1049 
1050  if (self == &mips_linux_o32_sigframe
1051  || self == &micromips_linux_o32_sigframe)
1052  sigcontext_base = frame_sp + SIGFRAME_SIGCONTEXT_OFFSET;
1053  else
1054  sigcontext_base = frame_sp + RTSIGFRAME_SIGCONTEXT_OFFSET;
1055 
1056  /* I'm not proud of this hack. Eventually we will have the
1057  infrastructure to indicate the size of saved registers on a
1058  per-frame basis, but right now we don't; the kernel saves eight
1059  bytes but we only want four. Use regs_base to access any
1060  64-bit fields. */
1061  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
1062  regs_base = sigcontext_base + 4;
1063  else
1064  regs_base = sigcontext_base;
1065 
1067  trad_frame_set_reg_addr (this_cache,
1070  regs_base + SIGCONTEXT_REGS);
1071 
1072  for (ireg = 1; ireg < 32; ireg++)
1073  trad_frame_set_reg_addr (this_cache,
1074  (ireg + MIPS_ZERO_REGNUM
1076  (regs_base + SIGCONTEXT_REGS
1077  + ireg * SIGCONTEXT_REG_SIZE));
1078 
1079  /* The way that floating point registers are saved, unfortunately,
1080  depends on the architecture the kernel is built for. For the r3000 and
1081  tx39, four bytes of each register are at the beginning of each of the
1082  32 eight byte slots. For everything else, the registers are saved
1083  using double precision; only the even-numbered slots are initialized,
1084  and the high bits are the odd-numbered register. Assume the latter
1085  layout, since we can't tell, and it's much more common. Which bits are
1086  the "high" bits depends on endianness. */
1087  for (ireg = 0; ireg < 32; ireg++)
1088  if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (ireg & 1))
1089  trad_frame_set_reg_addr (this_cache,
1090  ireg + regs->fp0 + gdbarch_num_regs (gdbarch),
1091  (sigcontext_base + SIGCONTEXT_FPREGS + 4
1092  + (ireg & ~1) * SIGCONTEXT_REG_SIZE));
1093  else
1094  trad_frame_set_reg_addr (this_cache,
1095  ireg + regs->fp0 + gdbarch_num_regs (gdbarch),
1096  (sigcontext_base + SIGCONTEXT_FPREGS
1097  + (ireg & ~1) * SIGCONTEXT_REG_SIZE));
1098 
1099  trad_frame_set_reg_addr (this_cache,
1100  regs->pc + gdbarch_num_regs (gdbarch),
1101  regs_base + SIGCONTEXT_PC);
1102 
1103  trad_frame_set_reg_addr (this_cache,
1104  (regs->fp_control_status
1106  sigcontext_base + SIGCONTEXT_FPCSR);
1107 
1108  if (regs->dspctl != -1)
1109  trad_frame_set_reg_addr (this_cache,
1110  regs->dspctl + gdbarch_num_regs (gdbarch),
1111  sigcontext_base + SIGCONTEXT_DSPCTL);
1112 
1113  trad_frame_set_reg_addr (this_cache,
1114  regs->hi + gdbarch_num_regs (gdbarch),
1115  regs_base + SIGCONTEXT_HI);
1116  trad_frame_set_reg_addr (this_cache,
1117  regs->lo + gdbarch_num_regs (gdbarch),
1118  regs_base + SIGCONTEXT_LO);
1119 
1120  if (regs->dspacc != -1)
1121  {
1122  trad_frame_set_reg_addr (this_cache,
1123  regs->dspacc + 0 + gdbarch_num_regs (gdbarch),
1124  sigcontext_base + SIGCONTEXT_HI1);
1125  trad_frame_set_reg_addr (this_cache,
1126  regs->dspacc + 1 + gdbarch_num_regs (gdbarch),
1127  sigcontext_base + SIGCONTEXT_LO1);
1128  trad_frame_set_reg_addr (this_cache,
1129  regs->dspacc + 2 + gdbarch_num_regs (gdbarch),
1130  sigcontext_base + SIGCONTEXT_HI2);
1131  trad_frame_set_reg_addr (this_cache,
1132  regs->dspacc + 3 + gdbarch_num_regs (gdbarch),
1133  sigcontext_base + SIGCONTEXT_LO2);
1134  trad_frame_set_reg_addr (this_cache,
1135  regs->dspacc + 4 + gdbarch_num_regs (gdbarch),
1136  sigcontext_base + SIGCONTEXT_HI3);
1137  trad_frame_set_reg_addr (this_cache,
1138  regs->dspacc + 5 + gdbarch_num_regs (gdbarch),
1139  sigcontext_base + SIGCONTEXT_LO3);
1140  }
1141  else
1142  {
1143  trad_frame_set_reg_addr (this_cache,
1144  regs->cause + gdbarch_num_regs (gdbarch),
1145  sigcontext_base + SIGCONTEXT_CAUSE);
1146  trad_frame_set_reg_addr (this_cache,
1147  regs->badvaddr + gdbarch_num_regs (gdbarch),
1148  sigcontext_base + SIGCONTEXT_BADVADDR);
1149  }
1150 
1151  /* Choice of the bottom of the sigframe is somewhat arbitrary. */
1152  trad_frame_set_id (this_cache, frame_id_build (frame_sp, func));
1153 }
1154 
1155 /* *INDENT-OFF* */
1156 /* For N32/N64 things look different. There is no non-rt signal frame.
1157 
1158  struct rt_sigframe_n32 {
1159  u32 rs_ass[4]; [ argument save space for o32 ]
1160  u32 rs_code[2]; [ signal trampoline or fill ]
1161  struct siginfo rs_info;
1162  struct ucontextn32 rs_uc;
1163  };
1164 
1165  struct ucontextn32 {
1166  u32 uc_flags;
1167  s32 uc_link;
1168  stack32_t uc_stack;
1169  struct sigcontext uc_mcontext;
1170  sigset_t uc_sigmask; [ mask last for extensibility ]
1171  };
1172 
1173  struct rt_sigframe {
1174  u32 rs_ass[4]; [ argument save space for o32 ]
1175  u32 rs_code[2]; [ signal trampoline ]
1176  struct siginfo rs_info;
1177  struct ucontext rs_uc;
1178  };
1179 
1180  struct ucontext {
1181  unsigned long uc_flags;
1182  struct ucontext *uc_link;
1183  stack_t uc_stack;
1184  struct sigcontext uc_mcontext;
1185  sigset_t uc_sigmask; [ mask last for extensibility ]
1186  };
1187 
1188  And the sigcontext is different (this is for both n32 and n64):
1189 
1190  struct sigcontext {
1191  unsigned long long sc_regs[32];
1192  unsigned long long sc_fpregs[32];
1193  unsigned long long sc_mdhi;
1194  unsigned long long sc_hi1;
1195  unsigned long long sc_hi2;
1196  unsigned long long sc_hi3;
1197  unsigned long long sc_mdlo;
1198  unsigned long long sc_lo1;
1199  unsigned long long sc_lo2;
1200  unsigned long long sc_lo3;
1201  unsigned long long sc_pc;
1202  unsigned int sc_fpc_csr;
1203  unsigned int sc_used_math;
1204  unsigned int sc_dsp;
1205  unsigned int sc_reserved;
1206  };
1207 
1208  That is the post-2.6.12 definition of the 64-bit sigcontext; before
1209  then, there were no hi1-hi3 or lo1-lo3. Cause and badvaddr were
1210  included too. */
1211 /* *INDENT-ON* */
1212 
1213 #define N32_STACK_T_SIZE STACK_T_SIZE
1214 #define N64_STACK_T_SIZE (2 * 8 + 4)
1215 #define N32_UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + N32_STACK_T_SIZE + 4)
1216 #define N64_UCONTEXT_SIGCONTEXT_OFFSET (2 * 8 + N64_STACK_T_SIZE + 4)
1217 #define N32_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \
1218  + RTSIGFRAME_SIGINFO_SIZE \
1219  + N32_UCONTEXT_SIGCONTEXT_OFFSET)
1220 #define N64_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \
1221  + RTSIGFRAME_SIGINFO_SIZE \
1222  + N64_UCONTEXT_SIGCONTEXT_OFFSET)
1223 
1224 #define N64_SIGCONTEXT_REGS (0 * 8)
1225 #define N64_SIGCONTEXT_FPREGS (32 * 8)
1226 #define N64_SIGCONTEXT_HI (64 * 8)
1227 #define N64_SIGCONTEXT_HI1 (65 * 8)
1228 #define N64_SIGCONTEXT_HI2 (66 * 8)
1229 #define N64_SIGCONTEXT_HI3 (67 * 8)
1230 #define N64_SIGCONTEXT_LO (68 * 8)
1231 #define N64_SIGCONTEXT_LO1 (69 * 8)
1232 #define N64_SIGCONTEXT_LO2 (70 * 8)
1233 #define N64_SIGCONTEXT_LO3 (71 * 8)
1234 #define N64_SIGCONTEXT_PC (72 * 8)
1235 #define N64_SIGCONTEXT_FPCSR (73 * 8 + 0)
1236 #define N64_SIGCONTEXT_DSPCTL (74 * 8 + 0)
1237 
1238 #define N64_SIGCONTEXT_REG_SIZE 8
1239 
1240 static void
1242  struct frame_info *this_frame,
1243  struct trad_frame_cache *this_cache,
1244  CORE_ADDR func)
1245 {
1246  struct gdbarch *gdbarch = get_frame_arch (this_frame);
1247  int ireg;
1248  CORE_ADDR frame_sp = get_frame_sp (this_frame);
1249  CORE_ADDR sigcontext_base;
1250  const struct mips_regnum *regs = mips_regnum (gdbarch);
1251 
1252  if (self == &mips_linux_n32_rt_sigframe
1253  || self == &micromips_linux_n32_rt_sigframe)
1254  sigcontext_base = frame_sp + N32_SIGFRAME_SIGCONTEXT_OFFSET;
1255  else
1256  sigcontext_base = frame_sp + N64_SIGFRAME_SIGCONTEXT_OFFSET;
1257 
1259  trad_frame_set_reg_addr (this_cache,
1262  sigcontext_base + N64_SIGCONTEXT_REGS);
1263 
1264  for (ireg = 1; ireg < 32; ireg++)
1265  trad_frame_set_reg_addr (this_cache,
1266  (ireg + MIPS_ZERO_REGNUM
1268  (sigcontext_base + N64_SIGCONTEXT_REGS
1269  + ireg * N64_SIGCONTEXT_REG_SIZE));
1270 
1271  for (ireg = 0; ireg < 32; ireg++)
1272  trad_frame_set_reg_addr (this_cache,
1273  ireg + regs->fp0 + gdbarch_num_regs (gdbarch),
1274  (sigcontext_base + N64_SIGCONTEXT_FPREGS
1275  + ireg * N64_SIGCONTEXT_REG_SIZE));
1276 
1277  trad_frame_set_reg_addr (this_cache,
1278  regs->pc + gdbarch_num_regs (gdbarch),
1279  sigcontext_base + N64_SIGCONTEXT_PC);
1280 
1281  trad_frame_set_reg_addr (this_cache,
1282  (regs->fp_control_status
1284  sigcontext_base + N64_SIGCONTEXT_FPCSR);
1285 
1286  trad_frame_set_reg_addr (this_cache,
1287  regs->hi + gdbarch_num_regs (gdbarch),
1288  sigcontext_base + N64_SIGCONTEXT_HI);
1289  trad_frame_set_reg_addr (this_cache,
1290  regs->lo + gdbarch_num_regs (gdbarch),
1291  sigcontext_base + N64_SIGCONTEXT_LO);
1292 
1293  if (regs->dspacc != -1)
1294  {
1295  trad_frame_set_reg_addr (this_cache,
1296  regs->dspacc + 0 + gdbarch_num_regs (gdbarch),
1297  sigcontext_base + N64_SIGCONTEXT_HI1);
1298  trad_frame_set_reg_addr (this_cache,
1299  regs->dspacc + 1 + gdbarch_num_regs (gdbarch),
1300  sigcontext_base + N64_SIGCONTEXT_LO1);
1301  trad_frame_set_reg_addr (this_cache,
1302  regs->dspacc + 2 + gdbarch_num_regs (gdbarch),
1303  sigcontext_base + N64_SIGCONTEXT_HI2);
1304  trad_frame_set_reg_addr (this_cache,
1305  regs->dspacc + 3 + gdbarch_num_regs (gdbarch),
1306  sigcontext_base + N64_SIGCONTEXT_LO2);
1307  trad_frame_set_reg_addr (this_cache,
1308  regs->dspacc + 4 + gdbarch_num_regs (gdbarch),
1309  sigcontext_base + N64_SIGCONTEXT_HI3);
1310  trad_frame_set_reg_addr (this_cache,
1311  regs->dspacc + 5 + gdbarch_num_regs (gdbarch),
1312  sigcontext_base + N64_SIGCONTEXT_LO3);
1313  }
1314  if (regs->dspctl != -1)
1315  trad_frame_set_reg_addr (this_cache,
1316  regs->dspctl + gdbarch_num_regs (gdbarch),
1317  sigcontext_base + N64_SIGCONTEXT_DSPCTL);
1318 
1319  /* Choice of the bottom of the sigframe is somewhat arbitrary. */
1320  trad_frame_set_id (this_cache, frame_id_build (frame_sp, func));
1321 }
1322 
1323 /* Implement struct tramp_frame's "validate" method for standard MIPS code. */
1324 
1325 static int
1327  struct frame_info *this_frame,
1328  CORE_ADDR *pc)
1329 {
1330  return mips_pc_is_mips (*pc);
1331 }
1332 
1333 /* Implement struct tramp_frame's "validate" method for microMIPS code. */
1334 
1335 static int
1337  struct frame_info *this_frame,
1338  CORE_ADDR *pc)
1339 {
1340  if (mips_pc_is_micromips (get_frame_arch (this_frame), *pc))
1341  {
1343  return 1;
1344  }
1345  else
1346  return 0;
1347 }
1348 
1349 /* Implement the "write_pc" gdbarch method. */
1350 
1351 static void
1353 {
1354  struct gdbarch *gdbarch = regcache->arch ();
1355 
1356  mips_write_pc (regcache, pc);
1357 
1358  /* Clear the syscall restart flag. */
1361 }
1362 
1363 /* Return 1 if MIPS_RESTART_REGNUM is usable. */
1364 
1365 int
1367 {
1368  /* If we do not have a target description with registers, then
1369  MIPS_RESTART_REGNUM will not be included in the register set. */
1371  return 0;
1372 
1373  /* If we do, then MIPS_RESTART_REGNUM is safe to check; it will
1374  either be GPR-sized or missing. */
1376 }
1377 
1378 /* When FRAME is at a syscall instruction, return the PC of the next
1379  instruction to be executed. */
1380 
1381 static CORE_ADDR
1383 {
1384  CORE_ADDR pc = get_frame_pc (frame);
1386 
1387  /* If we are about to make a sigreturn syscall, use the unwinder to
1388  decode the signal frame. */
1389  if (v0 == MIPS_NR_sigreturn
1390  || v0 == MIPS_NR_rt_sigreturn
1391  || v0 == MIPS_NR_N64_rt_sigreturn
1392  || v0 == MIPS_NR_N32_rt_sigreturn)
1394 
1395  return pc + 4;
1396 }
1397 
1398 /* Return the current system call's number present in the
1399  v0 register. When the function fails, it returns -1. */
1400 
1401 static LONGEST
1403  ptid_t ptid)
1404 {
1406  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1407  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1408  int regsize = register_size (gdbarch, MIPS_V0_REGNUM);
1409  /* The content of a register */
1410  gdb_byte buf[8];
1411  /* The result */
1412  LONGEST ret;
1413 
1414  /* Make sure we're in a known ABI */
1415  gdb_assert (tdep->mips_abi == MIPS_ABI_O32
1416  || tdep->mips_abi == MIPS_ABI_N32
1417  || tdep->mips_abi == MIPS_ABI_N64);
1418 
1419  gdb_assert (regsize <= sizeof (buf));
1420 
1421  /* Getting the system call number from the register.
1422  syscall number is in v0 or $2. */
1424 
1425  ret = extract_signed_integer (buf, regsize, byte_order);
1426 
1427  return ret;
1428 }
1429 
1430 /* Implementation of `gdbarch_gdb_signal_to_target', as defined in
1431  gdbarch.h. */
1432 
1433 static int
1435  enum gdb_signal signal)
1436 {
1437  switch (signal)
1438  {
1439  case GDB_SIGNAL_EMT:
1440  return MIPS_LINUX_SIGEMT;
1441 
1442  case GDB_SIGNAL_BUS:
1443  return MIPS_LINUX_SIGBUS;
1444 
1445  case GDB_SIGNAL_SYS:
1446  return MIPS_LINUX_SIGSYS;
1447 
1448  case GDB_SIGNAL_USR1:
1449  return MIPS_LINUX_SIGUSR1;
1450 
1451  case GDB_SIGNAL_USR2:
1452  return MIPS_LINUX_SIGUSR2;
1453 
1454  case GDB_SIGNAL_CHLD:
1455  return MIPS_LINUX_SIGCHLD;
1456 
1457  case GDB_SIGNAL_PWR:
1458  return MIPS_LINUX_SIGPWR;
1459 
1460  case GDB_SIGNAL_WINCH:
1461  return MIPS_LINUX_SIGWINCH;
1462 
1463  case GDB_SIGNAL_URG:
1464  return MIPS_LINUX_SIGURG;
1465 
1466  case GDB_SIGNAL_IO:
1467  return MIPS_LINUX_SIGIO;
1468 
1469  case GDB_SIGNAL_POLL:
1470  return MIPS_LINUX_SIGPOLL;
1471 
1472  case GDB_SIGNAL_STOP:
1473  return MIPS_LINUX_SIGSTOP;
1474 
1475  case GDB_SIGNAL_TSTP:
1476  return MIPS_LINUX_SIGTSTP;
1477 
1478  case GDB_SIGNAL_CONT:
1479  return MIPS_LINUX_SIGCONT;
1480 
1481  case GDB_SIGNAL_TTIN:
1482  return MIPS_LINUX_SIGTTIN;
1483 
1484  case GDB_SIGNAL_TTOU:
1485  return MIPS_LINUX_SIGTTOU;
1486 
1487  case GDB_SIGNAL_VTALRM:
1488  return MIPS_LINUX_SIGVTALRM;
1489 
1490  case GDB_SIGNAL_PROF:
1491  return MIPS_LINUX_SIGPROF;
1492 
1493  case GDB_SIGNAL_XCPU:
1494  return MIPS_LINUX_SIGXCPU;
1495 
1496  case GDB_SIGNAL_XFSZ:
1497  return MIPS_LINUX_SIGXFSZ;
1498 
1499  /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
1500  therefore we have to handle it here. */
1501  case GDB_SIGNAL_REALTIME_32:
1502  return MIPS_LINUX_SIGRTMIN;
1503  }
1504 
1505  if (signal >= GDB_SIGNAL_REALTIME_33
1506  && signal <= GDB_SIGNAL_REALTIME_63)
1507  {
1508  int offset = signal - GDB_SIGNAL_REALTIME_33;
1509 
1510  return MIPS_LINUX_SIGRTMIN + 1 + offset;
1511  }
1512  else if (signal >= GDB_SIGNAL_REALTIME_64
1513  && signal <= GDB_SIGNAL_REALTIME_127)
1514  {
1515  int offset = signal - GDB_SIGNAL_REALTIME_64;
1516 
1517  return MIPS_LINUX_SIGRT64 + offset;
1518  }
1519 
1520  return linux_gdb_signal_to_target (gdbarch, signal);
1521 }
1522 
1523 /* Translate signals based on MIPS signal values.
1524  Adapted from gdb/common/signals.c. */
1525 
1526 static enum gdb_signal
1528 {
1529  switch (signal)
1530  {
1531  case MIPS_LINUX_SIGEMT:
1532  return GDB_SIGNAL_EMT;
1533 
1534  case MIPS_LINUX_SIGBUS:
1535  return GDB_SIGNAL_BUS;
1536 
1537  case MIPS_LINUX_SIGSYS:
1538  return GDB_SIGNAL_SYS;
1539 
1540  case MIPS_LINUX_SIGUSR1:
1541  return GDB_SIGNAL_USR1;
1542 
1543  case MIPS_LINUX_SIGUSR2:
1544  return GDB_SIGNAL_USR2;
1545 
1546  case MIPS_LINUX_SIGCHLD:
1547  return GDB_SIGNAL_CHLD;
1548 
1549  case MIPS_LINUX_SIGPWR:
1550  return GDB_SIGNAL_PWR;
1551 
1552  case MIPS_LINUX_SIGWINCH:
1553  return GDB_SIGNAL_WINCH;
1554 
1555  case MIPS_LINUX_SIGURG:
1556  return GDB_SIGNAL_URG;
1557 
1558  /* No way to differentiate between SIGIO and SIGPOLL.
1559  Therefore, we just handle the first one. */
1560  case MIPS_LINUX_SIGIO:
1561  return GDB_SIGNAL_IO;
1562 
1563  case MIPS_LINUX_SIGSTOP:
1564  return GDB_SIGNAL_STOP;
1565 
1566  case MIPS_LINUX_SIGTSTP:
1567  return GDB_SIGNAL_TSTP;
1568 
1569  case MIPS_LINUX_SIGCONT:
1570  return GDB_SIGNAL_CONT;
1571 
1572  case MIPS_LINUX_SIGTTIN:
1573  return GDB_SIGNAL_TTIN;
1574 
1575  case MIPS_LINUX_SIGTTOU:
1576  return GDB_SIGNAL_TTOU;
1577 
1578  case MIPS_LINUX_SIGVTALRM:
1579  return GDB_SIGNAL_VTALRM;
1580 
1581  case MIPS_LINUX_SIGPROF:
1582  return GDB_SIGNAL_PROF;
1583 
1584  case MIPS_LINUX_SIGXCPU:
1585  return GDB_SIGNAL_XCPU;
1586 
1587  case MIPS_LINUX_SIGXFSZ:
1588  return GDB_SIGNAL_XFSZ;
1589  }
1590 
1591  if (signal >= MIPS_LINUX_SIGRTMIN && signal <= MIPS_LINUX_SIGRTMAX)
1592  {
1593  /* GDB_SIGNAL_REALTIME values are not contiguous, map parts of
1594  the MIPS block to the respective GDB_SIGNAL_REALTIME blocks. */
1595  int offset = signal - MIPS_LINUX_SIGRTMIN;
1596 
1597  if (offset == 0)
1598  return GDB_SIGNAL_REALTIME_32;
1599  else if (offset < 32)
1600  return (enum gdb_signal) (offset - 1
1601  + (int) GDB_SIGNAL_REALTIME_33);
1602  else
1603  return (enum gdb_signal) (offset - 32
1604  + (int) GDB_SIGNAL_REALTIME_64);
1605  }
1606 
1607  return linux_gdb_signal_from_target (gdbarch, signal);
1608 }
1609 
1610 /* Initialize one of the GNU/Linux OS ABIs. */
1611 
1612 static void
1614  struct gdbarch *gdbarch)
1615 {
1616  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1617  enum mips_abi abi = mips_abi (gdbarch);
1618  struct tdesc_arch_data *tdesc_data = info.tdesc_data;
1619 
1620  linux_init_abi (info, gdbarch);
1621 
1622  /* Get the syscall number from the arch's register. */
1624 
1625  switch (abi)
1626  {
1627  case MIPS_ABI_O32:
1637  set_xml_syscall_file_name (gdbarch, "syscalls/mips-o32-linux.xml");
1638  break;
1639  case MIPS_ABI_N32:
1645  /* These floatformats should probably be renamed. MIPS uses
1646  the same 128-bit IEEE floating point format that IA-64 uses,
1647  except that the quiet/signalling NaN bit is reversed (GDB
1648  does not distinguish between quiet and signalling NaNs). */
1653  set_xml_syscall_file_name (gdbarch, "syscalls/mips-n32-linux.xml");
1654  break;
1655  case MIPS_ABI_N64:
1661  /* These floatformats should probably be renamed. MIPS uses
1662  the same 128-bit IEEE floating point format that IA-64 uses,
1663  except that the quiet/signalling NaN bit is reversed (GDB
1664  does not distinguish between quiet and signalling NaNs). */
1669  set_xml_syscall_file_name (gdbarch, "syscalls/mips-n64-linux.xml");
1670  break;
1671  default:
1672  break;
1673  }
1674 
1676 
1678 
1679  /* Enable TLS support. */
1682 
1683  /* Initialize this lazily, to avoid an initialization order
1684  dependency on solib-svr4.c's _initialize routine. */
1686  {
1690  }
1692 
1694 
1697 
1700 
1703 
1706 
1708 
1709  if (tdesc_data)
1710  {
1711  const struct tdesc_feature *feature;
1712 
1713  /* If we have target-described registers, then we can safely
1714  reserve a number for MIPS_RESTART_REGNUM (whether it is
1715  described or not). */
1719 
1720  /* If it's present, then assign it to the reserved number. */
1721  feature = tdesc_find_feature (info.target_desc,
1722  "org.gnu.gdb.mips.linux");
1723  if (feature != NULL)
1725  "restart");
1726  }
1727 }
1728 
1729 void
1731 {
1732  const struct bfd_arch_info *arch_info;
1733 
1734  for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
1735  arch_info != NULL;
1736  arch_info = arch_info->next)
1737  {
1738  gdbarch_register_osabi (bfd_arch_mips, arch_info->mach,
1741  }
1742 
1743  /* Initialize the standard target descriptions. */
1748 }
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition: gdbarch.c:2050
#define SIGCONTEXT_REG_SIZE
CORE_ADDR(* syscall_next_pc)(struct frame_info *frame)
Definition: mips-tdep.h:118
#define SIGCONTEXT_LO2
static void mips_linux_n32n64_sigframe_init(const struct tramp_frame *self, struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
int mips_pc_is_micromips(struct gdbarch *gdbarch, CORE_ADDR memaddr)
Definition: mips-tdep.c:1212
#define MIPS_INST_LI_V0_N32_RT_SIGRETURN
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
Definition: trad-frame.c:126
static void mips_fill_fpregset_wrapper(const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:624
void set_gdbarch_get_longjmp_target(struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype get_longjmp_target)
Definition: gdbarch.c:2572
#define N64_SIGCONTEXT_REG_SIZE
#define SIGFRAME_SIGCONTEXT_OFFSET
#define N64_SIGFRAME_SIGCONTEXT_OFFSET
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2376
void set_gdbarch_gdb_signal_to_target(struct gdbarch *gdbarch, gdbarch_gdb_signal_to_target_ftype gdb_signal_to_target)
Definition: gdbarch.c:4209
struct frame_info * get_current_frame(void)
Definition: frame.c:1563
bfd_vma CORE_ADDR
Definition: common-types.h:41
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:3038
#define TRAMP_SENTINEL_INSN
Definition: tramp-frame.h:44
struct link_map_offsets * svr4_lp64_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3214
#define EF_LO
struct regcache * get_thread_regcache(ptid_t ptid)
Definition: regcache.c:434
CORE_ADDR mips_unmake_compact_addr(CORE_ADDR addr)
Definition: mips-tdep.c:372
CORE_ADDR frame_unwind_caller_pc(struct frame_info *this_frame)
Definition: frame.c:944
void(* func)(char *)
void set_solib_ops(struct gdbarch *gdbarch, const struct target_so_ops *new_ops)
Definition: solib.c:77
#define BMSYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:691
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:99
static const struct regset mips64_linux_gregset
static const struct tramp_frame mips_linux_n32_rt_sigframe
CORE_ADDR glibc_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: glibc-tdep.c:38
#define MIPS_INST_LI_V0_RT_SIGRETURN
int svr4_in_dynsym_resolve_code(CORE_ADDR pc)
Definition: solib-svr4.c:1628
void set_gdbarch_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype write_pc)
Definition: gdbarch.c:1943
#define SIGCONTEXT_FPREGS
static void mips64_supply_fpregset_wrapper(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1831
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
Definition: trad-frame.c:171
CORE_ADDR get_frame_sp(struct frame_info *this_frame)
Definition: frame.c:2782
void * memset(T *s, int c, size_t n)=delete
#define SIGCONTEXT_REGS
#define MIPS64_EF_LO
static CORE_ADDR mips_linux_skip_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
static void mips_linux_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
void set_gdbarch_gdb_signal_from_target(struct gdbarch *gdbarch, gdbarch_gdb_signal_from_target_ftype gdb_signal_from_target)
Definition: gdbarch.c:4185
void linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: linux-tdep.c:2492
#define MIPS_INST_LI_V0_SIGRETURN
#define MIPS64_EF_CP0_BADVADDR
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3183
#define MIPS64_EF_CP0_CAUSE
const struct floatformat * floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN]
Definition: gdbtypes.c:100
void mips64_fill_gregset(const struct regcache *regcache, mips64_elf_gregset_t *gregsetp, int regno)
static const struct tramp_frame micromips_linux_o32_rt_sigframe
#define N32_SIGFRAME_SIGCONTEXT_OFFSET
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:2039
#define N64_SIGCONTEXT_FPREGS
#define SIGCONTEXT_LO3
static void mips_supply_fpregset_wrapper(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
const struct mips_regnum * mips_regnum(struct gdbarch *gdbarch)
Definition: mips-tdep.c:218
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1491
#define EF_REG31
static const struct regset mips_linux_fpregset
unsigned char mips_elf_greg_t[4]
void mips_write_pc(struct regcache *regcache, CORE_ADDR pc)
Definition: mips-tdep.c:1421
#define MIPS_NR_rt_sigreturn
#define N64_SIGCONTEXT_LO
static const struct regset mips_linux_gregset
static void initialize_tdesc_mips_linux(void)
Definition: mips-linux.c:10
static enum gdb_signal mips_gdb_signal_from_target(struct gdbarch *gdbarch, int signal)
void raw_supply_integer(int regnum, const gdb_byte *addr, int addr_len, bool is_signed)
Definition: regcache.c:1044
#define MIPS_INST_LI_V0_N64_RT_SIGRETURN
#define N64_SIGCONTEXT_LO3
#define SIGCONTEXT_HI
CORE_ADDR svr4_fetch_objfile_link_map(struct objfile *objfile)
Definition: solib-svr4.c:1579
Definition: regset.h:34
int tdesc_numbered_register(const struct tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *name)
#define MIPS64_EF_REG0
#define MICROMIPS_INST_POOL32A
#define MIPS_NR_N64_rt_sigreturn
int(* in_dynsym_resolve_code)(CORE_ADDR pc)
Definition: solist.h:129
void mips_fill_gregset(const struct regcache *regcache, mips_elf_gregset_t *gregsetp, int regno)
static const struct regset mips64_linux_fpregset
#define N64_SIGCONTEXT_HI1
static const struct tramp_frame micromips_linux_n32_rt_sigframe
#define SIGCONTEXT_BADVADDR
mips64_elf_greg_t mips64_elf_gregset_t[MIPS64_ELF_NGREG]
enum gdb_signal linux_gdb_signal_from_target(struct gdbarch *gdbarch, int signal)
Definition: linux-tdep.c:2003
#define MIPS64_EF_REG31
#define SIGCONTEXT_HI3
#define MIPS64_LINUX_JB_PC
struct target_desc * mips_tdesc_gp64
Definition: mips-tdep.c:215
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
Definition: defs.h:577
Definition: ptid.h:35
static void supply_32bit_reg(struct regcache *regcache, int regnum, const void *addr)
#define EF_CP0_EPC
#define MIPS_LINUX_JB_PC
static void mips64_supply_gregset_wrapper(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
static void initialize_tdesc_mips64_dsp_linux(void)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1509
#define EF_CP0_STATUS
#define SIGCONTEXT_HI2
#define N64_SIGCONTEXT_HI3
#define SIGCONTEXT_FPCSR
#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:3137
int badvaddr
Definition: mips-tdep.h:66
void raw_collect_integer(int regnum, gdb_byte *addr, int addr_len, bool is_signed) const
Definition: regcache.c:1116
#define MIPS64_EF_CP0_STATUS
int mips_linux_restart_reg_p(struct gdbarch *gdbarch)
static int mips_linux_get_longjmp_target(struct frame_info *frame, CORE_ADDR *pc)
static void initialize_tdesc_mips_dsp_linux(void)
void mips64_supply_gregset(struct regcache *regcache, const mips64_elf_gregset_t *gregsetp)
#define MIPS64_EF_CP0_EPC
#define MIPS_INST_SYSCALL
void raw_supply_zeroed(int regnum)
Definition: regcache.c:1067
#define MIPS_NR_N32_rt_sigreturn
int regnum
Definition: aarch64-tdep.c:77
void set_xml_syscall_file_name(struct gdbarch *gdbarch, const char *name)
Definition: xml-syscall.c:513
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:258
#define N64_SIGCONTEXT_LO2
#define MIPS64_EF_HI
static const struct tramp_frame micromips_linux_o32_sigframe
#define EF_REG0
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1308
int mips_pc_is_mips(CORE_ADDR memaddr)
Definition: mips-tdep.c:1176
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:143
#define N64_SIGCONTEXT_HI
static int mips_linux_sigframe_validate(const struct tramp_frame *self, struct frame_info *this_frame, CORE_ADDR *pc)
#define SIGCONTEXT_DSPCTL
void mips64_fill_fpregset(const struct regcache *regcache, mips64_elf_fpregset_t *fpregsetp, int regno)
#define SIGCONTEXT_LO
enum mips_abi mips_abi
Definition: mips-tdep.h:92
#define MIPS_LINUX_JB_ELEMENT_SIZE
#define gdb_assert(expr)
Definition: gdb_assert.h:32
#define MIPS_NR_sigreturn
const struct target_desc * target_desc
Definition: gdbarch.h:1660
static CORE_ADDR mips_linux_syscall_next_pc(struct frame_info *frame)
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype software_single_step)
Definition: gdbarch.c:3258
#define SIGCONTEXT_LO1
static const struct tramp_frame mips_linux_o32_sigframe
static const struct target_desc * mips_linux_core_read_description(struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd)
static int mips64_linux_get_longjmp_target(struct frame_info *frame, CORE_ADDR *pc)
static void mips_linux_o32_sigframe_init(const struct tramp_frame *self, struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
bfd_byte gdb_byte
Definition: common-types.h:38
unsigned char mips64_elf_greg_t[8]
struct target_so_ops svr4_so_ops
Definition: solib-svr4.c:3242
static void initialize_tdesc_mips64_linux(void)
Definition: mips64-linux.c:10
#define MICROMIPS_INST_LI_V0
static void mips_linux_write_pc(struct regcache *regcache, CORE_ADDR pc)
int linux_gdb_signal_to_target(struct gdbarch *gdbarch, enum gdb_signal signal)
Definition: linux-tdep.c:2126
static void mips64_fill_gregset_wrapper(const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len)
int gdbarch_fp0_regnum(struct gdbarch *gdbarch)
Definition: gdbarch.c:2197
#define SIGCONTEXT_CAUSE
mips_abi
Definition: mips-tdep.h:28
#define N64_SIGCONTEXT_PC
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition: regcache.c:806
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: target.c:1370
#define RTSIGFRAME_SIGCONTEXT_OFFSET
mips_elf_fpreg_t mips_elf_fpregset_t[ELF_NFPREG]
void mips_supply_fpregset(struct regcache *regcache, const mips_elf_fpregset_t *fpregsetp)
int dspctl
Definition: mips-tdep.h:71
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:4281
static int mips_linux_in_dynsym_stub(CORE_ADDR pc)
void tramp_frame_prepend_unwinder(struct gdbarch *gdbarch, const struct tramp_frame *tramp_frame)
Definition: tramp-frame.c:146
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
Definition: gdbarch.c:2067
gdbarch * arch() const
Definition: regcache.c:221
enum register_status regcache_cooked_read(struct regcache *regcache, int regnum, gdb_byte *buf)
Definition: regcache.c:661
static LONGEST extract_signed_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
Definition: defs.h:570
void mips_supply_gregset(struct regcache *regcache, const mips_elf_gregset_t *gregsetp)
#define SIGCONTEXT_HI1
#define N64_SIGCONTEXT_LO1
static int mips_linux_in_dynsym_resolve_code(CORE_ADDR pc)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
Definition: regcache.c:1004
#define SIGCONTEXT_PC
static int mips_gdb_signal_to_target(struct gdbarch *gdbarch, enum gdb_signal signal)
unsigned long long ULONGEST
Definition: common-types.h:53
const struct tdesc_feature * tdesc_find_feature(const struct target_desc *target_desc, const char *name)
void mips64_supply_fpregset(struct regcache *regcache, const mips64_elf_fpregset_t *fpregsetp)
int register_size(struct gdbarch *gdbarch, int regnum)
Definition: regcache.c:164
#define N64_SIGCONTEXT_HI2
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
Definition: gdbarch.c:1756
static void mips_fill_gregset_wrapper(const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len)
static void mips_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
Definition: regcache.c:1085
struct target_desc * mips_tdesc_gp32
Definition: mips-tdep.c:214
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
Definition: gdbarch.c:1772
#define EF_HI
#define N64_SIGCONTEXT_DSPCTL
static const struct tramp_frame micromips_linux_n64_rt_sigframe
static void mips64_fill_fpregset_wrapper(const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len)
static LONGEST mips_linux_get_syscall_number(struct gdbarch *gdbarch, ptid_t ptid)
void mips_fill_fpregset(const struct regcache *regcache, mips_elf_fpregset_t *fpregsetp, int regno)
static int micromips_linux_sigframe_validate(const struct tramp_frame *self, struct frame_info *this_frame, CORE_ADDR *pc)
mips_elf_greg_t mips_elf_gregset_t[ELF_NGREG]
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype iterate_over_regset_sections)
Definition: gdbarch.c:3647
ptid_t ptid() const
Definition: regcache.h:325
std::vector< CORE_ADDR > mips_software_single_step(struct regcache *regcache)
Definition: mips-tdep.c:4155
static const struct tramp_frame mips_linux_n64_rt_sigframe
#define EF_CP0_BADVADDR
#define N64_SIGCONTEXT_REGS
static struct gdbarch_data * tdesc_data
int fp_control_status
Definition: mips-tdep.h:65
mips64_elf_fpreg_t mips64_elf_fpregset_t[MIPS64_ELF_NFPREG]
void set_gdbarch_skip_solib_resolver(struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype skip_solib_resolver)
Definition: gdbarch.c:3333
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:311
struct tdesc_arch_data * tdesc_data
Definition: gdbarch.h:1648
enum s390_abi_kind abi
static const struct tramp_frame mips_linux_o32_rt_sigframe
enum bfd_endian byte_order
Definition: gdbarch.c:137
static void mips_supply_gregset_wrapper(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
void set_gdbarch_core_read_description(struct gdbarch *gdbarch, gdbarch_core_read_description_ftype core_read_description)
Definition: gdbarch.c:4072
int tdesc_has_registers(const struct target_desc *target_desc)
#define EF_CP0_CAUSE
int dspacc
Definition: mips-tdep.h:70
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2691
long long LONGEST
Definition: common-types.h:52
#define MICROMIPS_INST_SYSCALL
#define N64_SIGCONTEXT_FPCSR
static struct target_so_ops mips_svr4_so_ops
const struct target_desc * gdbarch_target_desc(struct gdbarch *gdbarch)
Definition: gdbarch.c:1536
static void supply_64bit_reg(struct regcache *regcache, int regnum, const gdb_byte *buf)
static int in_mips_stubs_section(CORE_ADDR pc)
Definition: mips-tdep.h:189
void _initialize_mips_linux_tdep(void)