GDB (xrefs)
/tmp/gdb-8.1/gdb/sparc64-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for UltraSPARC.
2 
3  Copyright (C) 2003-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 "arch-utils.h"
22 #include "dwarf2-frame.h"
23 #include "frame.h"
24 #include "frame-base.h"
25 #include "frame-unwind.h"
26 #include "gdbcore.h"
27 #include "gdbtypes.h"
28 #include "inferior.h"
29 #include "symtab.h"
30 #include "objfiles.h"
31 #include "osabi.h"
32 #include "regcache.h"
33 #include "target-descriptions.h"
34 #include "target.h"
35 #include "value.h"
36 
37 #include "sparc64-tdep.h"
38 
39 /* This file implements the SPARC 64-bit ABI as defined by the
40  section "Low-Level System Information" of the SPARC Compliance
41  Definition (SCD) 2.4.1, which is the 64-bit System V psABI for
42  SPARC. */
43 
44 /* Please use the sparc32_-prefix for 32-bit specific code, the
45  sparc64_-prefix for 64-bit specific code and the sparc_-prefix for
46  code can handle both. */
47 
48 /* The M7 processor supports an Application Data Integrity (ADI) feature
49  that detects invalid data accesses. When software allocates memory and
50  enables ADI on the allocated memory, it chooses a 4-bit version number,
51  sets the version in the upper 4 bits of the 64-bit pointer to that data,
52  and stores the 4-bit version in every cacheline of the object. Hardware
53  saves the latter in spare bits in the cache and memory hierarchy. On each
54  load and store, the processor compares the upper 4 VA (virtual address) bits
55  to the cacheline's version. If there is a mismatch, the processor generates
56  a version mismatch trap which can be either precise or disrupting.
57  The trap is an error condition which the kernel delivers to the process
58  as a SIGSEGV signal.
59 
60  The upper 4 bits of the VA represent a version and are not part of the
61  true address. The processor clears these bits and sign extends bit 59
62  to generate the true address.
63 
64  Note that 32-bit applications cannot use ADI. */
65 
66 
67 #include <algorithm>
68 #include "cli/cli-utils.h"
69 #include "gdbcmd.h"
70 #include "auxv.h"
71 
72 #define MAX_PROC_NAME_SIZE sizeof("/proc/99999/lwp/9999/adi/lstatus")
73 
74 /* ELF Auxiliary vectors */
75 #ifndef AT_ADI_BLKSZ
76 #define AT_ADI_BLKSZ 34
77 #endif
78 #ifndef AT_ADI_NBITS
79 #define AT_ADI_NBITS 35
80 #endif
81 #ifndef AT_ADI_UEONADI
82 #define AT_ADI_UEONADI 36
83 #endif
84 
85 /* ADI command list. */
86 static struct cmd_list_element *sparc64adilist = NULL;
87 
88 /* ADI stat settings. */
89 typedef struct
90 {
91  /* The ADI block size. */
92  unsigned long blksize;
93 
94  /* Number of bits used for an ADI version tag which can be
95  used together with the shift value for an ADI version tag
96  to encode or extract the ADI version value in a pointer. */
97  unsigned long nbits;
98 
99  /* The maximum ADI version tag value supported. */
101 
102  /* ADI version tag file. */
103  int tag_fd = 0;
104 
105  /* ADI availability check has been done. */
106  bool checked_avail = false;
107 
108  /* ADI is available. */
109  bool is_avail = false;
110 
111 } adi_stat_t;
112 
113 /* Per-process ADI stat info. */
114 
115 typedef struct sparc64_adi_info
116 {
117  sparc64_adi_info (pid_t pid_)
118  : pid (pid_)
119  {}
120 
121  /* The process identifier. */
122  pid_t pid;
123 
124  /* The ADI stat. */
126 
128 
129 static std::forward_list<sparc64_adi_info> adi_proc_list;
130 
131 
132 /* Get ADI info for process PID, creating one if it doesn't exist. */
133 
134 static sparc64_adi_info *
136 {
137  auto found = std::find_if (adi_proc_list.begin (), adi_proc_list.end (),
138  [&pid] (const sparc64_adi_info &info)
139  {
140  return info.pid == pid;
141  });
142 
143  if (found == adi_proc_list.end ())
144  {
145  adi_proc_list.emplace_front (pid);
146  return &adi_proc_list.front ();
147  }
148  else
149  {
150  return &(*found);
151  }
152 }
153 
154 static adi_stat_t
156 {
158 
160  return proc->stat;
161 }
162 
163 /* Is called when GDB is no longer debugging process PID. It
164  deletes data structure that keeps track of the ADI stat. */
165 
166 void
168 {
169  int target_errno;
170 
171  for (auto pit = adi_proc_list.before_begin (),
172  it = std::next (pit);
173  it != adi_proc_list.end ();
174  )
175  {
176  if ((*it).pid == pid)
177  {
178  if ((*it).stat.tag_fd > 0)
179  target_fileio_close ((*it).stat.tag_fd, &target_errno);
180  adi_proc_list.erase_after (pit);
181  break;
182  }
183  else
184  pit = it++;
185  }
186 
187 }
188 
189 static void
190 info_adi_command (const char *args, int from_tty)
191 {
192  printf_unfiltered ("\"adi\" must be followed by \"examine\" "
193  "or \"assign\".\n");
195 }
196 
197 /* Read attributes of a maps entry in /proc/[pid]/adi/maps. */
198 
199 static void
200 read_maps_entry (const char *line,
201  ULONGEST *addr, ULONGEST *endaddr)
202 {
203  const char *p = line;
204 
205  *addr = strtoulst (p, &p, 16);
206  if (*p == '-')
207  p++;
208 
209  *endaddr = strtoulst (p, &p, 16);
210 }
211 
212 /* Check if ADI is available. */
213 
214 static bool
216 {
217  pid_t pid = ptid_get_pid (inferior_ptid);
220 
221  if (proc->stat.checked_avail)
222  return proc->stat.is_avail;
223 
224  proc->stat.checked_avail = true;
226  return false;
227  proc->stat.blksize = value;
229  proc->stat.nbits = value;
230  proc->stat.max_version = (1 << proc->stat.nbits) - 2;
231  proc->stat.is_avail = true;
232 
233  return proc->stat.is_avail;
234 }
235 
236 /* Normalize a versioned address - a VA with ADI bits (63-60) set. */
237 
238 static CORE_ADDR
240 {
242 
243  if (ast.nbits)
244  {
245  /* Clear upper bits. */
246  addr &= ((uint64_t) -1) >> ast.nbits;
247 
248  /* Sign extend. */
249  CORE_ADDR signbit = (uint64_t) 1 << (64 - ast.nbits - 1);
250  return (addr ^ signbit) - signbit;
251  }
252  return addr;
253 }
254 
255 /* Align a normalized address - a VA with bit 59 sign extended into
256  ADI bits. */
257 
258 static CORE_ADDR
260 {
262 
263  return (naddr - (naddr % ast.blksize)) / ast.blksize;
264 }
265 
266 /* Convert a byte count to count at a ratio of 1:adi_blksz. */
267 
268 static int
269 adi_convert_byte_count (CORE_ADDR naddr, int nbytes, CORE_ADDR locl)
270 {
272 
273  return ((naddr + nbytes + ast.blksize - 1) / ast.blksize) - locl;
274 }
275 
276 /* The /proc/[pid]/adi/tags file, which allows gdb to get/set ADI
277  version in a target process, maps linearly to the address space
278  of the target process at a ratio of 1:adi_blksz.
279 
280  A read (or write) at offset K in the file returns (or modifies)
281  the ADI version tag stored in the cacheline containing address
282  K * adi_blksz, encoded as 1 version tag per byte. The allowed
283  version tag values are between 0 and adi_stat.max_version. */
284 
285 static int
287 {
288  pid_t pid = ptid_get_pid (inferior_ptid);
290 
291  if (proc->stat.tag_fd != 0)
292  return proc->stat.tag_fd;
293 
294  char cl_name[MAX_PROC_NAME_SIZE];
295  snprintf (cl_name, sizeof(cl_name), "/proc/%ld/adi/tags", (long) pid);
296  int target_errno;
297  proc->stat.tag_fd = target_fileio_open (NULL, cl_name, O_RDWR|O_EXCL,
298  0, &target_errno);
299  return proc->stat.tag_fd;
300 }
301 
302 /* Check if an address set is ADI enabled, using /proc/[pid]/adi/maps
303  which was exported by the kernel and contains the currently ADI
304  mapped memory regions and their access permissions. */
305 
306 static bool
307 adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt)
308 {
309  char filename[MAX_PROC_NAME_SIZE];
310  size_t i = 0;
311 
312  pid_t pid = ptid_get_pid (inferior_ptid);
313  snprintf (filename, sizeof filename, "/proc/%ld/adi/maps", (long) pid);
315  = target_fileio_read_stralloc (NULL, filename);
316  if (data)
317  {
318  adi_stat_t adi_stat = get_adi_info (pid);
319  char *line;
320  for (line = strtok (data.get (), "\n"); line; line = strtok (NULL, "\n"))
321  {
322  ULONGEST addr, endaddr;
323 
324  read_maps_entry (line, &addr, &endaddr);
325 
326  while (((vaddr + i) * adi_stat.blksize) >= addr
327  && ((vaddr + i) * adi_stat.blksize) < endaddr)
328  {
329  if (++i == cnt)
330  return true;
331  }
332  }
333  }
334  else
335  warning (_("unable to open /proc file '%s'"), filename);
336 
337  return false;
338 }
339 
340 /* Read ADI version tag value for memory locations starting at "VADDR"
341  for "SIZE" number of bytes. */
342 
343 static int
344 adi_read_versions (CORE_ADDR vaddr, size_t size, gdb_byte *tags)
345 {
346  int fd = adi_tag_fd ();
347  if (fd == -1)
348  return -1;
349 
350  if (!adi_is_addr_mapped (vaddr, size))
351  {
353  error(_("Address at %s is not in ADI maps"),
354  paddress (target_gdbarch (), vaddr * ast.blksize));
355  }
356 
357  int target_errno;
358  return target_fileio_pread (fd, tags, size, vaddr, &target_errno);
359 }
360 
361 /* Write ADI version tag for memory locations starting at "VADDR" for
362  "SIZE" number of bytes to "TAGS". */
363 
364 static int
365 adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
366 {
367  int fd = adi_tag_fd ();
368  if (fd == -1)
369  return -1;
370 
371  if (!adi_is_addr_mapped (vaddr, size))
372  {
374  error(_("Address at %s is not in ADI maps"),
375  paddress (target_gdbarch (), vaddr * ast.blksize));
376  }
377 
378  int target_errno;
379  return target_fileio_pwrite (fd, tags, size, vaddr, &target_errno);
380 }
381 
382 /* Print ADI version tag value in "TAGS" for memory locations starting
383  at "VADDR" with number of "CNT". */
384 
385 static void
386 adi_print_versions (CORE_ADDR vaddr, size_t cnt, gdb_byte *tags)
387 {
388  int v_idx = 0;
389  const int maxelts = 8; /* # of elements per line */
390 
392 
393  while (cnt > 0)
394  {
395  QUIT;
396  printf_filtered ("%s:\t",
397  paddress (target_gdbarch (), vaddr * adi_stat.blksize));
398  for (int i = maxelts; i > 0 && cnt > 0; i--, cnt--)
399  {
400  if (tags[v_idx] == 0xff) /* no version tag */
401  printf_filtered ("-");
402  else
403  printf_filtered ("%1X", tags[v_idx]);
404  if (cnt > 1)
405  printf_filtered (" ");
406  ++v_idx;
407  }
408  printf_filtered ("\n");
410  vaddr += maxelts;
411  }
412 }
413 
414 static void
415 do_examine (CORE_ADDR start, int bcnt)
416 {
417  CORE_ADDR vaddr = adi_normalize_address (start);
418 
419  CORE_ADDR vstart = adi_align_address (vaddr);
420  int cnt = adi_convert_byte_count (vaddr, bcnt, vstart);
421  gdb::def_vector<gdb_byte> buf (cnt);
422  int read_cnt = adi_read_versions (vstart, cnt, buf.data ());
423  if (read_cnt == -1)
424  error (_("No ADI information"));
425  else if (read_cnt < cnt)
426  error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));
427 
428  adi_print_versions (vstart, cnt, buf.data ());
429 }
430 
431 static void
432 do_assign (CORE_ADDR start, size_t bcnt, int version)
433 {
434  CORE_ADDR vaddr = adi_normalize_address (start);
435 
436  CORE_ADDR vstart = adi_align_address (vaddr);
437  int cnt = adi_convert_byte_count (vaddr, bcnt, vstart);
438  std::vector<unsigned char> buf (cnt, version);
439  int set_cnt = adi_write_versions (vstart, cnt, buf.data ());
440 
441  if (set_cnt == -1)
442  error (_("No ADI information"));
443  else if (set_cnt < cnt)
444  error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));
445 
446 }
447 
448 /* ADI examine version tag command.
449 
450  Command syntax:
451 
452  adi (examine|x)/count <addr> */
453 
454 static void
455 adi_examine_command (const char *args, int from_tty)
456 {
457  /* make sure program is active and adi is available */
459  error (_("ADI command requires a live process/thread"));
460 
461  if (!adi_available ())
462  error (_("No ADI information"));
463 
464  pid_t pid = ptid_get_pid (inferior_ptid);
466  int cnt = 1;
467  const char *p = args;
468  if (p && *p == '/')
469  {
470  p++;
471  cnt = get_number (&p);
472  }
473 
475  if (p != 0 && *p != 0)
477  if (!cnt || !next_address)
478  error (_("Usage: adi examine|x[/count] <addr>"));
479 
480  do_examine (next_address, cnt);
481 }
482 
483 /* ADI assign version tag command.
484 
485  Command syntax:
486 
487  adi (assign|a)/count <addr> = <version> */
488 
489 static void
490 adi_assign_command (const char *args, int from_tty)
491 {
492  /* make sure program is active and adi is available */
494  error (_("ADI command requires a live process/thread"));
495 
496  if (!adi_available ())
497  error (_("No ADI information"));
498 
499  const char *exp = args;
500  if (exp == 0)
501  error_no_arg (_("Usage: adi assign|a[/count] <addr> = <version>"));
502 
503  char *q = (char *) strchr (exp, '=');
504  if (q)
505  *q++ = 0;
506  else
507  error (_("Usage: adi assign|a[/count] <addr> = <version>"));
508 
509  size_t cnt = 1;
510  const char *p = args;
511  if (exp && *exp == '/')
512  {
513  p = exp + 1;
514  cnt = get_number (&p);
515  }
516 
518  if (p != 0 && *p != 0)
520  else
521  error (_("Usage: adi assign|a[/count] <addr> = <version>"));
522 
523  int version = 0;
524  if (q != NULL) /* parse version tag */
525  {
528  if (version < 0 || version > ast.max_version)
529  error (_("Invalid ADI version tag %d"), version);
530  }
531 
533 }
534 
535 void
537 {
538 
540  _("ADI version related commands."),
541  &sparc64adilist, "adi ", 0, &cmdlist);
543  _("Examine ADI versions."), &sparc64adilist);
544  add_alias_cmd ("x", "examine", no_class, 1, &sparc64adilist);
546  _("Assign ADI versions."), &sparc64adilist);
547 
548 }
549 
550 
551 /* The functions on this page are intended to be used to classify
552  function arguments. */
553 
554 /* Check whether TYPE is "Integral or Pointer". */
555 
556 static int
558 {
559  switch (TYPE_CODE (type))
560  {
561  case TYPE_CODE_INT:
562  case TYPE_CODE_BOOL:
563  case TYPE_CODE_CHAR:
564  case TYPE_CODE_ENUM:
565  case TYPE_CODE_RANGE:
566  {
567  int len = TYPE_LENGTH (type);
568  gdb_assert (len == 1 || len == 2 || len == 4 || len == 8);
569  }
570  return 1;
571  case TYPE_CODE_PTR:
572  case TYPE_CODE_REF:
574  {
575  int len = TYPE_LENGTH (type);
576  gdb_assert (len == 8);
577  }
578  return 1;
579  default:
580  break;
581  }
582 
583  return 0;
584 }
585 
586 /* Check whether TYPE is "Floating". */
587 
588 static int
589 sparc64_floating_p (const struct type *type)
590 {
591  switch (TYPE_CODE (type))
592  {
593  case TYPE_CODE_FLT:
594  {
595  int len = TYPE_LENGTH (type);
596  gdb_assert (len == 4 || len == 8 || len == 16);
597  }
598  return 1;
599  default:
600  break;
601  }
602 
603  return 0;
604 }
605 
606 /* Check whether TYPE is "Complex Floating". */
607 
608 static int
610 {
611  switch (TYPE_CODE (type))
612  {
613  case TYPE_CODE_COMPLEX:
614  {
615  int len = TYPE_LENGTH (type);
616  gdb_assert (len == 8 || len == 16 || len == 32);
617  }
618  return 1;
619  default:
620  break;
621  }
622 
623  return 0;
624 }
625 
626 /* Check whether TYPE is "Structure or Union".
627 
628  In terms of Ada subprogram calls, arrays are treated the same as
629  struct and union types. So this function also returns non-zero
630  for array types. */
631 
632 static int
634 {
635  switch (TYPE_CODE (type))
636  {
637  case TYPE_CODE_STRUCT:
638  case TYPE_CODE_UNION:
639  case TYPE_CODE_ARRAY:
640  return 1;
641  default:
642  break;
643  }
644 
645  return 0;
646 }
647 
648 
649 /* Construct types for ISA-specific registers. */
650 
651 static struct type *
653 {
654  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
655 
656  if (!tdep->sparc64_pstate_type)
657  {
658  struct type *type;
659 
660  type = arch_flags_type (gdbarch, "builtin_type_sparc64_pstate", 64);
661  append_flags_type_flag (type, 0, "AG");
662  append_flags_type_flag (type, 1, "IE");
663  append_flags_type_flag (type, 2, "PRIV");
664  append_flags_type_flag (type, 3, "AM");
665  append_flags_type_flag (type, 4, "PEF");
666  append_flags_type_flag (type, 5, "RED");
667  append_flags_type_flag (type, 8, "TLE");
668  append_flags_type_flag (type, 9, "CLE");
669  append_flags_type_flag (type, 10, "PID0");
670  append_flags_type_flag (type, 11, "PID1");
671 
672  tdep->sparc64_pstate_type = type;
673  }
674 
675  return tdep->sparc64_pstate_type;
676 }
677 
678 static struct type *
680 {
681  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
682 
683  if (tdep->sparc64_ccr_type == NULL)
684  {
685  struct type *type;
686 
687  type = arch_flags_type (gdbarch, "builtin_type_sparc64_ccr", 64);
688  append_flags_type_flag (type, 0, "icc.c");
689  append_flags_type_flag (type, 1, "icc.v");
690  append_flags_type_flag (type, 2, "icc.z");
691  append_flags_type_flag (type, 3, "icc.n");
692  append_flags_type_flag (type, 4, "xcc.c");
693  append_flags_type_flag (type, 5, "xcc.v");
694  append_flags_type_flag (type, 6, "xcc.z");
695  append_flags_type_flag (type, 7, "xcc.n");
696 
697  tdep->sparc64_ccr_type = type;
698  }
699 
700  return tdep->sparc64_ccr_type;
701 }
702 
703 static struct type *
705 {
706  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
707 
708  if (!tdep->sparc64_fsr_type)
709  {
710  struct type *type;
711 
712  type = arch_flags_type (gdbarch, "builtin_type_sparc64_fsr", 64);
713  append_flags_type_flag (type, 0, "NXC");
714  append_flags_type_flag (type, 1, "DZC");
715  append_flags_type_flag (type, 2, "UFC");
716  append_flags_type_flag (type, 3, "OFC");
717  append_flags_type_flag (type, 4, "NVC");
718  append_flags_type_flag (type, 5, "NXA");
719  append_flags_type_flag (type, 6, "DZA");
720  append_flags_type_flag (type, 7, "UFA");
721  append_flags_type_flag (type, 8, "OFA");
722  append_flags_type_flag (type, 9, "NVA");
723  append_flags_type_flag (type, 22, "NS");
724  append_flags_type_flag (type, 23, "NXM");
725  append_flags_type_flag (type, 24, "DZM");
726  append_flags_type_flag (type, 25, "UFM");
727  append_flags_type_flag (type, 26, "OFM");
728  append_flags_type_flag (type, 27, "NVM");
729 
730  tdep->sparc64_fsr_type = type;
731  }
732 
733  return tdep->sparc64_fsr_type;
734 }
735 
736 static struct type *
738 {
739  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
740 
741  if (!tdep->sparc64_fprs_type)
742  {
743  struct type *type;
744 
745  type = arch_flags_type (gdbarch, "builtin_type_sparc64_fprs", 64);
746  append_flags_type_flag (type, 0, "DL");
747  append_flags_type_flag (type, 1, "DU");
748  append_flags_type_flag (type, 2, "FEF");
749 
750  tdep->sparc64_fprs_type = type;
751  }
752 
753  return tdep->sparc64_fprs_type;
754 }
755 
756 
757 /* Register information. */
758 #define SPARC64_FPU_REGISTERS \
759  "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
760  "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
761  "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
762  "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
763  "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
764  "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62"
765 #define SPARC64_CP0_REGISTERS \
766  "pc", "npc", \
767  /* FIXME: Give "state" a name until we start using register groups. */ \
768  "state", \
769  "fsr", \
770  "fprs", \
771  "y"
772 
775 
776 static const char *sparc64_register_names[] =
777 {
781 };
782 
783 /* Total number of registers. */
784 #define SPARC64_NUM_REGS ARRAY_SIZE (sparc64_register_names)
785 
786 /* We provide the aliases %d0..%d62 and %q0..%q60 for the floating
787  registers as "psuedo" registers. */
788 
789 static const char *sparc64_pseudo_register_names[] =
790 {
791  "cwp", "pstate", "asi", "ccr",
792 
793  "d0", "d2", "d4", "d6", "d8", "d10", "d12", "d14",
794  "d16", "d18", "d20", "d22", "d24", "d26", "d28", "d30",
795  "d32", "d34", "d36", "d38", "d40", "d42", "d44", "d46",
796  "d48", "d50", "d52", "d54", "d56", "d58", "d60", "d62",
797 
798  "q0", "q4", "q8", "q12", "q16", "q20", "q24", "q28",
799  "q32", "q36", "q40", "q44", "q48", "q52", "q56", "q60",
800 };
801 
802 /* Total number of pseudo registers. */
803 #define SPARC64_NUM_PSEUDO_REGS ARRAY_SIZE (sparc64_pseudo_register_names)
804 
805 /* Return the name of pseudo register REGNUM. */
806 
807 static const char *
809 {
811 
814 
815  internal_error (__FILE__, __LINE__,
816  _("sparc64_pseudo_register_name: bad register number %d"),
817  regnum);
818 }
819 
820 /* Return the name of register REGNUM. */
821 
822 static const char *
824 {
827 
828  if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch))
830 
832 }
833 
834 /* Return the GDB type object for the "standard" data type of data in
835  pseudo register REGNUM. */
836 
837 static struct type *
839 {
841 
842  if (regnum == SPARC64_CWP_REGNUM)
845  return sparc64_pstate_type (gdbarch);
846  if (regnum == SPARC64_ASI_REGNUM)
848  if (regnum == SPARC64_CCR_REGNUM)
849  return sparc64_ccr_type (gdbarch);
854 
855  internal_error (__FILE__, __LINE__,
856  _("sparc64_pseudo_register_type: bad register number %d"),
857  regnum);
858 }
859 
860 /* Return the GDB type object for the "standard" data type of data in
861  register REGNUM. */
862 
863 static struct type *
865 {
868 
869  /* Raw registers. */
880  /* This raw register contains the contents of %cwp, %pstate, %asi
881  and %ccr as laid out in a %tstate register. */
884  if (regnum == SPARC64_FSR_REGNUM)
885  return sparc64_fsr_type (gdbarch);
887  return sparc64_fprs_type (gdbarch);
888  /* "Although Y is a 64-bit register, its high-order 32 bits are
889  reserved and always read as 0." */
890  if (regnum == SPARC64_Y_REGNUM)
892 
893  /* Pseudo registers. */
896 
897  internal_error (__FILE__, __LINE__, _("invalid regnum"));
898 }
899 
900 static enum register_status
902  struct regcache *regcache,
903  int regnum, gdb_byte *buf)
904 {
905  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
906  enum register_status status;
907 
909 
911  {
914  if (status == REG_VALID)
915  status = regcache_raw_read (regcache, regnum + 1, buf + 4);
916  return status;
917  }
919  {
921  return regcache_raw_read (regcache, regnum, buf);
922  }
924  {
926 
928  if (status == REG_VALID)
929  status = regcache_raw_read (regcache, regnum + 1, buf + 4);
930  if (status == REG_VALID)
931  status = regcache_raw_read (regcache, regnum + 2, buf + 8);
932  if (status == REG_VALID)
933  status = regcache_raw_read (regcache, regnum + 3, buf + 12);
934 
935  return status;
936  }
938  {
940 
942  if (status == REG_VALID)
943  status = regcache_raw_read (regcache, regnum + 1, buf + 8);
944 
945  return status;
946  }
947  else if (regnum == SPARC64_CWP_REGNUM
951  {
952  ULONGEST state;
953 
955  if (status != REG_VALID)
956  return status;
957 
958  switch (regnum)
959  {
960  case SPARC64_CWP_REGNUM:
961  state = (state >> 0) & ((1 << 5) - 1);
962  break;
964  state = (state >> 8) & ((1 << 12) - 1);
965  break;
966  case SPARC64_ASI_REGNUM:
967  state = (state >> 24) & ((1 << 8) - 1);
968  break;
969  case SPARC64_CCR_REGNUM:
970  state = (state >> 32) & ((1 << 8) - 1);
971  break;
972  }
973  store_unsigned_integer (buf, 8, byte_order, state);
974  }
975 
976  return REG_VALID;
977 }
978 
979 static void
981  struct regcache *regcache,
982  int regnum, const gdb_byte *buf)
983 {
984  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
985 
987 
989  {
992  regcache_raw_write (regcache, regnum + 1, buf + 4);
993  }
995  {
998  }
1000  {
1003  regcache_raw_write (regcache, regnum + 1, buf + 4);
1004  regcache_raw_write (regcache, regnum + 2, buf + 8);
1005  regcache_raw_write (regcache, regnum + 3, buf + 12);
1006  }
1008  {
1011  regcache_raw_write (regcache, regnum + 1, buf + 8);
1012  }
1013  else if (regnum == SPARC64_CWP_REGNUM
1016  || regnum == SPARC64_CCR_REGNUM)
1017  {
1018  ULONGEST state, bits;
1019 
1021  bits = extract_unsigned_integer (buf, 8, byte_order);
1022  switch (regnum)
1023  {
1024  case SPARC64_CWP_REGNUM:
1025  state |= ((bits & ((1 << 5) - 1)) << 0);
1026  break;
1027  case SPARC64_PSTATE_REGNUM:
1028  state |= ((bits & ((1 << 12) - 1)) << 8);
1029  break;
1030  case SPARC64_ASI_REGNUM:
1031  state |= ((bits & ((1 << 8) - 1)) << 24);
1032  break;
1033  case SPARC64_CCR_REGNUM:
1034  state |= ((bits & ((1 << 8) - 1)) << 32);
1035  break;
1036  }
1038  }
1039 }
1040 
1041 
1042 /* Return PC of first real instruction of the function starting at
1043  START_PC. */
1044 
1045 static CORE_ADDR
1047 {
1048  struct symtab_and_line sal;
1049  CORE_ADDR func_start, func_end;
1050  struct sparc_frame_cache cache;
1051 
1052  /* This is the preferred method, find the end of the prologue by
1053  using the debugging information. */
1054  if (find_pc_partial_function (start_pc, NULL, &func_start, &func_end))
1055  {
1056  sal = find_pc_line (func_start, 0);
1057 
1058  if (sal.end < func_end
1059  && start_pc <= sal.end)
1060  return sal.end;
1061  }
1062 
1063  return sparc_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffULL,
1064  &cache);
1065 }
1066 
1067 /* Normal frames. */
1068 
1069 static struct sparc_frame_cache *
1070 sparc64_frame_cache (struct frame_info *this_frame, void **this_cache)
1071 {
1072  return sparc_frame_cache (this_frame, this_cache);
1073 }
1074 
1075 static void
1076 sparc64_frame_this_id (struct frame_info *this_frame, void **this_cache,
1077  struct frame_id *this_id)
1078 {
1079  struct sparc_frame_cache *cache =
1080  sparc64_frame_cache (this_frame, this_cache);
1081 
1082  /* This marks the outermost frame. */
1083  if (cache->base == 0)
1084  return;
1085 
1086  (*this_id) = frame_id_build (cache->base, cache->pc);
1087 }
1088 
1089 static struct value *
1090 sparc64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
1091  int regnum)
1092 {
1093  struct gdbarch *gdbarch = get_frame_arch (this_frame);
1094  struct sparc_frame_cache *cache =
1095  sparc64_frame_cache (this_frame, this_cache);
1096 
1098  {
1099  CORE_ADDR pc = (regnum == SPARC64_NPC_REGNUM) ? 4 : 0;
1100 
1101  regnum =
1102  (cache->copied_regs_mask & 0x80) ? SPARC_I7_REGNUM : SPARC_O7_REGNUM;
1103  pc += get_frame_register_unsigned (this_frame, regnum) + 8;
1104  return frame_unwind_got_constant (this_frame, regnum, pc);
1105  }
1106 
1107  /* Handle StackGhost. */
1108  {
1109  ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
1110 
1111  if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
1112  {
1113  CORE_ADDR addr = cache->base + (regnum - SPARC_L0_REGNUM) * 8;
1114  ULONGEST i7;
1115 
1116  /* Read the value in from memory. */
1117  i7 = get_frame_memory_unsigned (this_frame, addr, 8);
1118  return frame_unwind_got_constant (this_frame, regnum, i7 ^ wcookie);
1119  }
1120  }
1121 
1122  /* The previous frame's `local' and `in' registers may have been saved
1123  in the register save area. */
1125  && (cache->saved_regs_mask & (1 << (regnum - SPARC_L0_REGNUM))))
1126  {
1127  CORE_ADDR addr = cache->base + (regnum - SPARC_L0_REGNUM) * 8;
1128 
1129  return frame_unwind_got_memory (this_frame, regnum, addr);
1130  }
1131 
1132  /* The previous frame's `out' registers may be accessible as the current
1133  frame's `in' registers. */
1135  && (cache->copied_regs_mask & (1 << (regnum - SPARC_O0_REGNUM))))
1137 
1138  return frame_unwind_got_register (this_frame, regnum, regnum);
1139 }
1140 
1141 static const struct frame_unwind sparc64_frame_unwind =
1142 {
1143  NORMAL_FRAME,
1147  NULL,
1149 };
1150 
1151 
1152 static CORE_ADDR
1153 sparc64_frame_base_address (struct frame_info *this_frame, void **this_cache)
1154 {
1155  struct sparc_frame_cache *cache =
1156  sparc64_frame_cache (this_frame, this_cache);
1157 
1158  return cache->base;
1159 }
1160 
1161 static const struct frame_base sparc64_frame_base =
1162 {
1167 };
1168 
1169 /* Check whether TYPE must be 16-byte aligned. */
1170 
1171 static int
1173 {
1174  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
1175  {
1176  struct type *t = check_typedef (TYPE_TARGET_TYPE (type));
1177 
1178  if (sparc64_floating_p (t))
1179  return 1;
1180  }
1181  if (sparc64_floating_p (type) && TYPE_LENGTH (type) == 16)
1182  return 1;
1183 
1185  {
1186  int i;
1187 
1188  for (i = 0; i < TYPE_NFIELDS (type); i++)
1189  {
1190  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
1191 
1192  if (sparc64_16_byte_align_p (subtype))
1193  return 1;
1194  }
1195  }
1196 
1197  return 0;
1198 }
1199 
1200 /* Store floating fields of element ELEMENT of an "parameter array"
1201  that has type TYPE and is stored at BITPOS in VALBUF in the
1202  apropriate registers of REGCACHE. This function can be called
1203  recursively and therefore handles floating types in addition to
1204  structures. */
1205 
1206 static void
1208  const gdb_byte *valbuf, int element, int bitpos)
1209 {
1210  struct gdbarch *gdbarch = regcache->arch ();
1211  int len = TYPE_LENGTH (type);
1212 
1213  gdb_assert (element < 16);
1214 
1215  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
1216  {
1217  gdb_byte buf[8];
1218  int regnum = SPARC_F0_REGNUM + element * 2 + bitpos / 32;
1219 
1220  valbuf += bitpos / 8;
1221  if (len < 8)
1222  {
1223  memset (buf, 0, 8 - len);
1224  memcpy (buf + 8 - len, valbuf, len);
1225  valbuf = buf;
1226  len = 8;
1227  }
1228  for (int n = 0; n < (len + 3) / 4; n++)
1229  regcache_cooked_write (regcache, regnum + n, valbuf + n * 4);
1230  }
1231  else if (sparc64_floating_p (type)
1232  || (sparc64_complex_floating_p (type) && len <= 16))
1233  {
1234  int regnum;
1235 
1236  if (len == 16)
1237  {
1238  gdb_assert (bitpos == 0);
1239  gdb_assert ((element % 2) == 0);
1240 
1241  regnum = gdbarch_num_regs (gdbarch) + SPARC64_Q0_REGNUM + element / 2;
1243  }
1244  else if (len == 8)
1245  {
1246  gdb_assert (bitpos == 0 || bitpos == 64);
1247 
1249  + element + bitpos / 64;
1250  regcache_cooked_write (regcache, regnum, valbuf + (bitpos / 8));
1251  }
1252  else
1253  {
1254  gdb_assert (len == 4);
1255  gdb_assert (bitpos % 32 == 0 && bitpos >= 0 && bitpos < 128);
1256 
1257  regnum = SPARC_F0_REGNUM + element * 2 + bitpos / 32;
1258  regcache_cooked_write (regcache, regnum, valbuf + (bitpos / 8));
1259  }
1260  }
1262  {
1263  int i;
1264 
1265  for (i = 0; i < TYPE_NFIELDS (type); i++)
1266  {
1267  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
1268  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
1269 
1270  sparc64_store_floating_fields (regcache, subtype, valbuf,
1271  element, subpos);
1272  }
1273 
1274  /* GCC has an interesting bug. If TYPE is a structure that has
1275  a single `float' member, GCC doesn't treat it as a structure
1276  at all, but rather as an ordinary `float' argument. This
1277  argument will be stored in %f1, as required by the psABI.
1278  However, as a member of a structure the psABI requires it to
1279  be stored in %f0. This bug is present in GCC 3.3.2, but
1280  probably in older releases to. To appease GCC, if a
1281  structure has only a single `float' member, we store its
1282  value in %f1 too (we already have stored in %f0). */
1283  if (TYPE_NFIELDS (type) == 1)
1284  {
1285  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, 0));
1286 
1287  if (sparc64_floating_p (subtype) && TYPE_LENGTH (subtype) == 4)
1289  }
1290  }
1291 }
1292 
1293 /* Fetch floating fields from a variable of type TYPE from the
1294  appropriate registers for BITPOS in REGCACHE and store it at BITPOS
1295  in VALBUF. This function can be called recursively and therefore
1296  handles floating types in addition to structures. */
1297 
1298 static void
1300  gdb_byte *valbuf, int bitpos)
1301 {
1302  struct gdbarch *gdbarch = regcache->arch ();
1303 
1304  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
1305  {
1306  int len = TYPE_LENGTH (type);
1307  int regnum = SPARC_F0_REGNUM + bitpos / 32;
1308 
1309  valbuf += bitpos / 8;
1310  if (len < 4)
1311  {
1312  gdb_byte buf[4];
1314  memcpy (valbuf, buf + 4 - len, len);
1315  }
1316  else
1317  for (int i = 0; i < (len + 3) / 4; i++)
1318  regcache_cooked_read (regcache, regnum + i, valbuf + i * 4);
1319  }
1320  else if (sparc64_floating_p (type))
1321  {
1322  int len = TYPE_LENGTH (type);
1323  int regnum;
1324 
1325  if (len == 16)
1326  {
1327  gdb_assert (bitpos == 0 || bitpos == 128);
1328 
1330  + bitpos / 128;
1331  regcache_cooked_read (regcache, regnum, valbuf + (bitpos / 8));
1332  }
1333  else if (len == 8)
1334  {
1335  gdb_assert (bitpos % 64 == 0 && bitpos >= 0 && bitpos < 256);
1336 
1337  regnum = gdbarch_num_regs (gdbarch) + SPARC64_D0_REGNUM + bitpos / 64;
1338  regcache_cooked_read (regcache, regnum, valbuf + (bitpos / 8));
1339  }
1340  else
1341  {
1342  gdb_assert (len == 4);
1343  gdb_assert (bitpos % 32 == 0 && bitpos >= 0 && bitpos < 256);
1344 
1345  regnum = SPARC_F0_REGNUM + bitpos / 32;
1346  regcache_cooked_read (regcache, regnum, valbuf + (bitpos / 8));
1347  }
1348  }
1350  {
1351  int i;
1352 
1353  for (i = 0; i < TYPE_NFIELDS (type); i++)
1354  {
1355  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
1356  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
1357 
1358  sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos);
1359  }
1360  }
1361 }
1362 
1363 /* Store the NARGS arguments ARGS and STRUCT_ADDR (if STRUCT_RETURN is
1364  non-zero) in REGCACHE and on the stack (starting from address SP). */
1365 
1366 static CORE_ADDR
1368  struct value **args, CORE_ADDR sp,
1369  int struct_return, CORE_ADDR struct_addr)
1370 {
1371  struct gdbarch *gdbarch = regcache->arch ();
1372  /* Number of extended words in the "parameter array". */
1373  int num_elements = 0;
1374  int element = 0;
1375  int i;
1376 
1377  /* Take BIAS into account. */
1378  sp += BIAS;
1379 
1380  /* First we calculate the number of extended words in the "parameter
1381  array". While doing so we also convert some of the arguments. */
1382 
1383  if (struct_return)
1384  num_elements++;
1385 
1386  for (i = 0; i < nargs; i++)
1387  {
1388  struct type *type = value_type (args[i]);
1389  int len = TYPE_LENGTH (type);
1390 
1392  || (sparc64_complex_floating_p (type) && len == 32))
1393  {
1394  /* Structure or Union arguments. */
1395  if (len <= 16)
1396  {
1397  if (num_elements % 2 && sparc64_16_byte_align_p (type))
1398  num_elements++;
1399  num_elements += ((len + 7) / 8);
1400  }
1401  else
1402  {
1403  /* The psABI says that "Structures or unions larger than
1404  sixteen bytes are copied by the caller and passed
1405  indirectly; the caller will pass the address of a
1406  correctly aligned structure value. This sixty-four
1407  bit address will occupy one word in the parameter
1408  array, and may be promoted to an %o register like any
1409  other pointer value." Allocate memory for these
1410  values on the stack. */
1411  sp -= len;
1412 
1413  /* Use 16-byte alignment for these values. That's
1414  always correct, and wasting a few bytes shouldn't be
1415  a problem. */
1416  sp &= ~0xf;
1417 
1418  write_memory (sp, value_contents (args[i]), len);
1419  args[i] = value_from_pointer (lookup_pointer_type (type), sp);
1420  num_elements++;
1421  }
1422  }
1424  {
1425  /* Floating arguments. */
1426  if (len == 16)
1427  {
1428  /* The psABI says that "Each quad-precision parameter
1429  value will be assigned to two extended words in the
1430  parameter array. */
1431  num_elements += 2;
1432 
1433  /* The psABI says that "Long doubles must be
1434  quad-aligned, and thus a hole might be introduced
1435  into the parameter array to force alignment." Skip
1436  an element if necessary. */
1437  if ((num_elements % 2) && sparc64_16_byte_align_p (type))
1438  num_elements++;
1439  }
1440  else
1441  num_elements++;
1442  }
1443  else
1444  {
1445  /* Integral and pointer arguments. */
1447 
1448  /* The psABI says that "Each argument value of integral type
1449  smaller than an extended word will be widened by the
1450  caller to an extended word according to the signed-ness
1451  of the argument type." */
1452  if (len < 8)
1453  args[i] = value_cast (builtin_type (gdbarch)->builtin_int64,
1454  args[i]);
1455  num_elements++;
1456  }
1457  }
1458 
1459  /* Allocate the "parameter array". */
1460  sp -= num_elements * 8;
1461 
1462  /* The psABI says that "Every stack frame must be 16-byte aligned." */
1463  sp &= ~0xf;
1464 
1465  /* Now we store the arguments in to the "paramater array". Some
1466  Integer or Pointer arguments and Structure or Union arguments
1467  will be passed in %o registers. Some Floating arguments and
1468  floating members of structures are passed in floating-point
1469  registers. However, for functions with variable arguments,
1470  floating arguments are stored in an %0 register, and for
1471  functions without a prototype floating arguments are stored in
1472  both a floating-point and an %o registers, or a floating-point
1473  register and memory. To simplify the logic here we always pass
1474  arguments in memory, an %o register, and a floating-point
1475  register if appropriate. This should be no problem since the
1476  contents of any unused memory or registers in the "parameter
1477  array" are undefined. */
1478 
1479  if (struct_return)
1480  {
1482  element++;
1483  }
1484 
1485  for (i = 0; i < nargs; i++)
1486  {
1487  const gdb_byte *valbuf = value_contents (args[i]);
1488  struct type *type = value_type (args[i]);
1489  int len = TYPE_LENGTH (type);
1490  int regnum = -1;
1491  gdb_byte buf[16];
1492 
1494  || (sparc64_complex_floating_p (type) && len == 32))
1495  {
1496  /* Structure, Union or long double Complex arguments. */
1497  gdb_assert (len <= 16);
1498  memset (buf, 0, sizeof (buf));
1499  memcpy (buf, valbuf, len);
1500  valbuf = buf;
1501 
1502  if (element % 2 && sparc64_16_byte_align_p (type))
1503  element++;
1504 
1505  if (element < 6)
1506  {
1507  regnum = SPARC_O0_REGNUM + element;
1508  if (len > 8 && element < 5)
1509  regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
1510  }
1511 
1512  if (element < 16)
1513  sparc64_store_floating_fields (regcache, type, valbuf, element, 0);
1514  }
1515  else if (sparc64_complex_floating_p (type))
1516  {
1517  /* Float Complex or double Complex arguments. */
1518  if (element < 16)
1519  {
1521 
1522  if (len == 16)
1523  {
1525  regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
1528  SPARC_O0_REGNUM + element + 1,
1529  valbuf + 8);
1530  }
1531  }
1532  }
1533  else if (sparc64_floating_p (type))
1534  {
1535  /* Floating arguments. */
1536  if (len == 16)
1537  {
1538  if (element % 2)
1539  element++;
1540  if (element < 16)
1542  + element / 2;
1543  }
1544  else if (len == 8)
1545  {
1546  if (element < 16)
1548  + element;
1549  }
1550  else if (len == 4)
1551  {
1552  /* The psABI says "Each single-precision parameter value
1553  will be assigned to one extended word in the
1554  parameter array, and right-justified within that
1555  word; the left half (even float register) is
1556  undefined." Even though the psABI says that "the
1557  left half is undefined", set it to zero here. */
1558  memset (buf, 0, 4);
1559  memcpy (buf + 4, valbuf, 4);
1560  valbuf = buf;
1561  len = 8;
1562  if (element < 16)
1564  + element;
1565  }
1566  }
1567  else
1568  {
1569  /* Integral and pointer arguments. */
1570  gdb_assert (len == 8);
1571  if (element < 6)
1572  regnum = SPARC_O0_REGNUM + element;
1573  }
1574 
1575  if (regnum != -1)
1576  {
1578 
1579  /* If we're storing the value in a floating-point register,
1580  also store it in the corresponding %0 register(s). */
1581  if (regnum >= gdbarch_num_regs (gdbarch))
1582  {
1584 
1586  {
1587  gdb_assert (element < 6);
1588  regnum = SPARC_O0_REGNUM + element;
1590  }
1592  {
1593  gdb_assert (element < 5);
1594  regnum = SPARC_O0_REGNUM + element;
1596  regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
1597  }
1598  }
1599  }
1600 
1601  /* Always store the argument in memory. */
1602  write_memory (sp + element * 8, valbuf, len);
1603  element += ((len + 7) / 8);
1604  }
1605 
1606  gdb_assert (element == num_elements);
1607 
1608  /* Take BIAS into account. */
1609  sp -= BIAS;
1610  return sp;
1611 }
1612 
1613 static CORE_ADDR
1615 {
1616  /* The ABI requires 16-byte alignment. */
1617  return address & ~0xf;
1618 }
1619 
1620 static CORE_ADDR
1621 sparc64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
1622  struct regcache *regcache, CORE_ADDR bp_addr,
1623  int nargs, struct value **args, CORE_ADDR sp,
1624  int struct_return, CORE_ADDR struct_addr)
1625 {
1626  /* Set return address. */
1628 
1629  /* Set up function arguments. */
1630  sp = sparc64_store_arguments (regcache, nargs, args, sp,
1631  struct_return, struct_addr);
1632 
1633  /* Allocate the register save area. */
1634  sp -= 16 * 8;
1635 
1636  /* Stack should be 16-byte aligned at this point. */
1637  gdb_assert ((sp + BIAS) % 16 == 0);
1638 
1639  /* Finally, update the stack pointer. */
1641 
1642  return sp + BIAS;
1643 }
1644 
1645 
1646 /* Extract from an array REGBUF containing the (raw) register state, a
1647  function return value of TYPE, and copy that into VALBUF. */
1648 
1649 static void
1651  gdb_byte *valbuf)
1652 {
1653  int len = TYPE_LENGTH (type);
1654  gdb_byte buf[32];
1655  int i;
1656 
1658  {
1659  /* Structure or Union return values. */
1660  gdb_assert (len <= 32);
1661 
1662  for (i = 0; i < ((len + 7) / 8); i++)
1663  regcache_cooked_read (regcache, SPARC_O0_REGNUM + i, buf + i * 8);
1664  if (TYPE_CODE (type) != TYPE_CODE_UNION)
1666  memcpy (valbuf, buf, len);
1667  }
1669  {
1670  /* Floating return values. */
1671  for (i = 0; i < len / 4; i++)
1672  regcache_cooked_read (regcache, SPARC_F0_REGNUM + i, buf + i * 4);
1673  memcpy (valbuf, buf, len);
1674  }
1675  else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
1676  {
1677  /* Small arrays are returned the same way as small structures. */
1678  gdb_assert (len <= 32);
1679 
1680  for (i = 0; i < ((len + 7) / 8); i++)
1681  regcache_cooked_read (regcache, SPARC_O0_REGNUM + i, buf + i * 8);
1682  memcpy (valbuf, buf, len);
1683  }
1684  else
1685  {
1686  /* Integral and pointer return values. */
1688 
1689  /* Just stripping off any unused bytes should preserve the
1690  signed-ness just fine. */
1692  memcpy (valbuf, buf + 8 - len, len);
1693  }
1694 }
1695 
1696 /* Write into the appropriate registers a function return value stored
1697  in VALBUF of type TYPE. */
1698 
1699 static void
1701  const gdb_byte *valbuf)
1702 {
1703  int len = TYPE_LENGTH (type);
1704  gdb_byte buf[16];
1705  int i;
1706 
1708  {
1709  /* Structure or Union return values. */
1710  gdb_assert (len <= 32);
1711 
1712  /* Simplify matters by storing the complete value (including
1713  floating members) into %o0 and %o1. Floating members are
1714  also store in the appropriate floating-point registers. */
1715  memset (buf, 0, sizeof (buf));
1716  memcpy (buf, valbuf, len);
1717  for (i = 0; i < ((len + 7) / 8); i++)
1718  regcache_cooked_write (regcache, SPARC_O0_REGNUM + i, buf + i * 8);
1719  if (TYPE_CODE (type) != TYPE_CODE_UNION)
1721  }
1723  {
1724  /* Floating return values. */
1725  memcpy (buf, valbuf, len);
1726  for (i = 0; i < len / 4; i++)
1727  regcache_cooked_write (regcache, SPARC_F0_REGNUM + i, buf + i * 4);
1728  }
1729  else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
1730  {
1731  /* Small arrays are returned the same way as small structures. */
1732  gdb_assert (len <= 32);
1733 
1734  memset (buf, 0, sizeof (buf));
1735  memcpy (buf, valbuf, len);
1736  for (i = 0; i < ((len + 7) / 8); i++)
1737  regcache_cooked_write (regcache, SPARC_O0_REGNUM + i, buf + i * 8);
1738  }
1739  else
1740  {
1741  /* Integral and pointer return values. */
1743 
1744  /* ??? Do we need to do any sign-extension here? */
1745  memset (buf, 0, 8);
1746  memcpy (buf + 8 - len, valbuf, len);
1748  }
1749 }
1750 
1751 static enum return_value_convention
1752 sparc64_return_value (struct gdbarch *gdbarch, struct value *function,
1753  struct type *type, struct regcache *regcache,
1754  gdb_byte *readbuf, const gdb_byte *writebuf)
1755 {
1756  if (TYPE_LENGTH (type) > 32)
1758 
1759  if (readbuf)
1761  if (writebuf)
1763 
1765 }
1766 
1767 
1768 static void
1770  struct dwarf2_frame_state_reg *reg,
1771  struct frame_info *this_frame)
1772 {
1773  switch (regnum)
1774  {
1775  case SPARC_G0_REGNUM:
1776  /* Since %g0 is always zero, there is no point in saving it, and
1777  people will be inclined omit it from the CFI. Make sure we
1778  don't warn about that. */
1780  break;
1781  case SPARC_SP_REGNUM:
1782  reg->how = DWARF2_FRAME_REG_CFA;
1783  break;
1784  case SPARC64_PC_REGNUM:
1786  reg->loc.offset = 8;
1787  break;
1788  case SPARC64_NPC_REGNUM:
1790  reg->loc.offset = 12;
1791  break;
1792  }
1793 }
1794 
1795 /* sparc64_addr_bits_remove - remove useless address bits */
1796 
1797 static CORE_ADDR
1799 {
1800  return adi_normalize_address (addr);
1801 }
1802 
1803 void
1805 {
1806  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1807 
1808  tdep->pc_regnum = SPARC64_PC_REGNUM;
1811  tdep->fpu_registers_num = ARRAY_SIZE (sparc64_fpu_register_names);
1813  tdep->cp0_registers_num = ARRAY_SIZE (sparc64_cp0_register_names);
1814 
1815  /* This is what all the fuss is about. */
1819 
1822 
1831 
1832  /* Register numbers of various important registers. */
1834 
1835  /* Call dummy code. */
1840 
1844 
1847 
1848  /* Hook in the DWARF CFI frame unwinder. */
1850  /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1851  StackGhost issues have been resolved. */
1852 
1855 
1857 }
1858 
1859 
1860 /* Helper functions for dealing with register sets. */
1861 
1862 #define TSTATE_CWP 0x000000000000001fULL
1863 #define TSTATE_ICC 0x0000000f00000000ULL
1864 #define TSTATE_XCC 0x000000f000000000ULL
1865 
1866 #define PSR_S 0x00000080
1867 #ifndef PSR_ICC
1868 #define PSR_ICC 0x00f00000
1869 #endif
1870 #define PSR_VERS 0x0f000000
1871 #ifndef PSR_IMPL
1872 #define PSR_IMPL 0xf0000000
1873 #endif
1874 #define PSR_V8PLUS 0xff000000
1875 #define PSR_XCC 0x000f0000
1876 
1877 void
1879  struct regcache *regcache,
1880  int regnum, const void *gregs)
1881 {
1882  struct gdbarch *gdbarch = regcache->arch ();
1883  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1884  int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
1885  const gdb_byte *regs = (const gdb_byte *) gregs;
1886  gdb_byte zero[8] = { 0 };
1887  int i;
1888 
1889  if (sparc32)
1890  {
1891  if (regnum == SPARC32_PSR_REGNUM || regnum == -1)
1892  {
1893  int offset = gregmap->r_tstate_offset;
1894  ULONGEST tstate, psr;
1895  gdb_byte buf[4];
1896 
1897  tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
1898  psr = ((tstate & TSTATE_CWP) | PSR_S | ((tstate & TSTATE_ICC) >> 12)
1899  | ((tstate & TSTATE_XCC) >> 20) | PSR_V8PLUS);
1900  store_unsigned_integer (buf, 4, byte_order, psr);
1902  }
1903 
1904  if (regnum == SPARC32_PC_REGNUM || regnum == -1)
1906  regs + gregmap->r_pc_offset + 4);
1907 
1908  if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
1910  regs + gregmap->r_npc_offset + 4);
1911 
1912  if (regnum == SPARC32_Y_REGNUM || regnum == -1)
1913  {
1914  int offset = gregmap->r_y_offset + 8 - gregmap->r_y_size;
1916  }
1917  }
1918  else
1919  {
1920  if (regnum == SPARC64_STATE_REGNUM || regnum == -1)
1922  regs + gregmap->r_tstate_offset);
1923 
1924  if (regnum == SPARC64_PC_REGNUM || regnum == -1)
1926  regs + gregmap->r_pc_offset);
1927 
1928  if (regnum == SPARC64_NPC_REGNUM || regnum == -1)
1930  regs + gregmap->r_npc_offset);
1931 
1932  if (regnum == SPARC64_Y_REGNUM || regnum == -1)
1933  {
1934  gdb_byte buf[8];
1935 
1936  memset (buf, 0, 8);
1937  memcpy (buf + 8 - gregmap->r_y_size,
1938  regs + gregmap->r_y_offset, gregmap->r_y_size);
1940  }
1941 
1942  if ((regnum == SPARC64_FPRS_REGNUM || regnum == -1)
1943  && gregmap->r_fprs_offset != -1)
1945  regs + gregmap->r_fprs_offset);
1946  }
1947 
1948  if (regnum == SPARC_G0_REGNUM || regnum == -1)
1950 
1951  if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
1952  {
1953  int offset = gregmap->r_g1_offset;
1954 
1955  if (sparc32)
1956  offset += 4;
1957 
1958  for (i = SPARC_G1_REGNUM; i <= SPARC_O7_REGNUM; i++)
1959  {
1960  if (regnum == i || regnum == -1)
1961  regcache_raw_supply (regcache, i, regs + offset);
1962  offset += 8;
1963  }
1964  }
1965 
1966  if ((regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) || regnum == -1)
1967  {
1968  /* Not all of the register set variants include Locals and
1969  Inputs. For those that don't, we read them off the stack. */
1970  if (gregmap->r_l0_offset == -1)
1971  {
1972  ULONGEST sp;
1973 
1976  }
1977  else
1978  {
1979  int offset = gregmap->r_l0_offset;
1980 
1981  if (sparc32)
1982  offset += 4;
1983 
1984  for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
1985  {
1986  if (regnum == i || regnum == -1)
1987  regcache_raw_supply (regcache, i, regs + offset);
1988  offset += 8;
1989  }
1990  }
1991  }
1992 }
1993 
1994 void
1996  const struct regcache *regcache,
1997  int regnum, void *gregs)
1998 {
1999  struct gdbarch *gdbarch = regcache->arch ();
2000  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2001  int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
2002  gdb_byte *regs = (gdb_byte *) gregs;
2003  int i;
2004 
2005  if (sparc32)
2006  {
2007  if (regnum == SPARC32_PSR_REGNUM || regnum == -1)
2008  {
2009  int offset = gregmap->r_tstate_offset;
2010  ULONGEST tstate, psr;
2011  gdb_byte buf[8];
2012 
2013  tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
2015  psr = extract_unsigned_integer (buf, 4, byte_order);
2016  tstate |= (psr & PSR_ICC) << 12;
2017  if ((psr & (PSR_VERS | PSR_IMPL)) == PSR_V8PLUS)
2018  tstate |= (psr & PSR_XCC) << 20;
2019  store_unsigned_integer (buf, 8, byte_order, tstate);
2020  memcpy (regs + offset, buf, 8);
2021  }
2022 
2023  if (regnum == SPARC32_PC_REGNUM || regnum == -1)
2025  regs + gregmap->r_pc_offset + 4);
2026 
2027  if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
2029  regs + gregmap->r_npc_offset + 4);
2030 
2031  if (regnum == SPARC32_Y_REGNUM || regnum == -1)
2032  {
2033  int offset = gregmap->r_y_offset + 8 - gregmap->r_y_size;
2035  }
2036  }
2037  else
2038  {
2039  if (regnum == SPARC64_STATE_REGNUM || regnum == -1)
2041  regs + gregmap->r_tstate_offset);
2042 
2043  if (regnum == SPARC64_PC_REGNUM || regnum == -1)
2045  regs + gregmap->r_pc_offset);
2046 
2047  if (regnum == SPARC64_NPC_REGNUM || regnum == -1)
2049  regs + gregmap->r_npc_offset);
2050 
2051  if (regnum == SPARC64_Y_REGNUM || regnum == -1)
2052  {
2053  gdb_byte buf[8];
2054 
2056  memcpy (regs + gregmap->r_y_offset,
2057  buf + 8 - gregmap->r_y_size, gregmap->r_y_size);
2058  }
2059 
2060  if ((regnum == SPARC64_FPRS_REGNUM || regnum == -1)
2061  && gregmap->r_fprs_offset != -1)
2063  regs + gregmap->r_fprs_offset);
2064 
2065  }
2066 
2067  if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
2068  {
2069  int offset = gregmap->r_g1_offset;
2070 
2071  if (sparc32)
2072  offset += 4;
2073 
2074  /* %g0 is always zero. */
2075  for (i = SPARC_G1_REGNUM; i <= SPARC_O7_REGNUM; i++)
2076  {
2077  if (regnum == i || regnum == -1)
2078  regcache_raw_collect (regcache, i, regs + offset);
2079  offset += 8;
2080  }
2081  }
2082 
2083  if ((regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) || regnum == -1)
2084  {
2085  /* Not all of the register set variants include Locals and
2086  Inputs. For those that don't, we read them off the stack. */
2087  if (gregmap->r_l0_offset != -1)
2088  {
2089  int offset = gregmap->r_l0_offset;
2090 
2091  if (sparc32)
2092  offset += 4;
2093 
2094  for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
2095  {
2096  if (regnum == i || regnum == -1)
2097  regcache_raw_collect (regcache, i, regs + offset);
2098  offset += 8;
2099  }
2100  }
2101  }
2102 }
2103 
2104 void
2105 sparc64_supply_fpregset (const struct sparc_fpregmap *fpregmap,
2106  struct regcache *regcache,
2107  int regnum, const void *fpregs)
2108 {
2109  int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
2110  const gdb_byte *regs = (const gdb_byte *) fpregs;
2111  int i;
2112 
2113  for (i = 0; i < 32; i++)
2114  {
2115  if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1)
2117  regs + fpregmap->r_f0_offset + (i * 4));
2118  }
2119 
2120  if (sparc32)
2121  {
2122  if (regnum == SPARC32_FSR_REGNUM || regnum == -1)
2124  regs + fpregmap->r_fsr_offset);
2125  }
2126  else
2127  {
2128  for (i = 0; i < 16; i++)
2129  {
2130  if (regnum == (SPARC64_F32_REGNUM + i) || regnum == -1)
2132  (regs + fpregmap->r_f0_offset
2133  + (32 * 4) + (i * 8)));
2134  }
2135 
2136  if (regnum == SPARC64_FSR_REGNUM || regnum == -1)
2138  regs + fpregmap->r_fsr_offset);
2139  }
2140 }
2141 
2142 void
2144  const struct regcache *regcache,
2145  int regnum, void *fpregs)
2146 {
2147  int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
2148  gdb_byte *regs = (gdb_byte *) fpregs;
2149  int i;
2150 
2151  for (i = 0; i < 32; i++)
2152  {
2153  if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1)
2155  regs + fpregmap->r_f0_offset + (i * 4));
2156  }
2157 
2158  if (sparc32)
2159  {
2160  if (regnum == SPARC32_FSR_REGNUM || regnum == -1)
2162  regs + fpregmap->r_fsr_offset);
2163  }
2164  else
2165  {
2166  for (i = 0; i < 16; i++)
2167  {
2168  if (regnum == (SPARC64_F32_REGNUM + i) || regnum == -1)
2170  (regs + fpregmap->r_f0_offset
2171  + (32 * 4) + (i * 8)));
2172  }
2173 
2174  if (regnum == SPARC64_FSR_REGNUM || regnum == -1)
2176  regs + fpregmap->r_fsr_offset);
2177  }
2178 }
2179 
2181 {
2182  0 * 8, /* %f0 */
2183  32 * 8, /* %fsr */
2184 };
void error_no_arg(const char *why)
Definition: cli-cmds.c:185
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition: gdbarch.c:2050
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype frame_align)
Definition: gdbarch.c:3151
void sparc64_collect_fpregset(const struct sparc_fpregmap *fpregmap, const struct regcache *regcache, int regnum, void *fpregs)
void sparc64_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static void sparc64_dwarf2_frame_init_reg(struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame)
#define SPARC_CORE_REGISTERS
Definition: sparc-tdep.h:23
static void sparc64_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
#define TSTATE_ICC
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:624
static std::forward_list< sparc64_adi_info > adi_proc_list
Definition: sparc64-tdep.c:129
int sparc_stack_frame_destroyed_p(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: sparc-tdep.c:537
struct type * builtin_func_ptr
Definition: gdbtypes.h:1565
void set_tdesc_pseudo_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name)
struct type * builtin_long_double
Definition: gdbtypes.h:1512
bfd_vma CORE_ADDR
Definition: common-types.h:41
int ptid_get_pid(const ptid_t &ptid)
Definition: ptid.c:47
static void info_adi_command(const char *args, int from_tty)
Definition: sparc64-tdep.c:190
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition: gnu-nat.c:1824
static void read_maps_entry(const char *line, ULONGEST *addr, ULONGEST *endaddr)
Definition: sparc64-tdep.c:200
void set_gdbarch_wchar_bit(struct gdbarch *gdbarch, int wchar_bit)
Definition: gdbarch.c:1789
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
Definition: frame-unwind.c:233
const char ** fpu_register_names
Definition: sparc-tdep.h:67
void set_tdesc_pseudo_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type)
static sparc64_adi_info * get_adi_info_proc(pid_t pid)
Definition: sparc64-tdep.c:135
void warning(const char *fmt,...)
Definition: errors.c:26
CORE_ADDR end
Definition: symtab.h:1760
static CORE_ADDR sparc64_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
void set_gdbarch_addr_bits_remove(struct gdbarch *gdbarch, gdbarch_addr_bits_remove_ftype addr_bits_remove)
Definition: gdbarch.c:3218
struct sparc64_adi_info sparc64_adi_info
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1831
struct sparc_frame_cache * sparc_frame_cache(struct frame_info *this_frame, void **this_cache)
Definition: sparc-tdep.c:1174
std::vector< T, gdb::default_init_allocator< T > > def_vector
Definition: def-vector.h:32
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition: gdbtypes.c:5217
#define BIAS
Definition: sparc-tdep.c:72
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
Definition: errors.c:50
static struct type * sparc64_pseudo_register_type(struct gdbarch *gdbarch, int regnum)
Definition: sparc64-tdep.c:838
const char * tdesc_register_name(struct gdbarch *gdbarch, int regno)
return_value_convention
Definition: defs.h:247
void _initialize_sparc64_adi_tdep(void)
Definition: sparc64-tdep.c:536
static struct type * sparc64_ccr_type(struct gdbarch *gdbarch)
Definition: sparc64-tdep.c:679
size_t cp0_registers_num
Definition: sparc-tdep.h:70
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition: cli-decode.c:262
void set_gdbarch_stabs_argument_has_addr(struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype stabs_argument_has_addr)
Definition: gdbarch.c:3168
register_status
struct cmd_list_element * cmdlist
Definition: cli-cmds.c:79
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:2039
static enum register_status sparc64_pseudo_register_read(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, gdb_byte *buf)
Definition: sparc64-tdep.c:901
#define _(String)
Definition: gdb_locale.h:35
#define SPARC64_NUM_PSEUDO_REGS
Definition: sparc64-tdep.c:803
ULONGEST get_frame_memory_unsigned(struct frame_info *this_frame, CORE_ADDR addr, int len)
Definition: frame.c:2671
int target_fileio_pwrite(int fd, const gdb_byte *write_buf, int len, ULONGEST offset, int *target_errno)
Definition: target.c:2847
void sparc64_forget_process(pid_t pid)
Definition: sparc64-tdep.c:167
int npc_regnum
Definition: sparc-tdep.h:64
static CORE_ADDR sparc64_store_arguments(struct regcache *regcache, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
void sparc64_collect_gregset(const struct sparc_gregmap *gregmap, const struct regcache *regcache, int regnum, void *gregs)
static const char * sparc64_register_name(struct gdbarch *gdbarch, int regnum)
Definition: sparc64-tdep.c:823
static const struct frame_unwind sparc64_frame_unwind
static void sparc64_store_floating_fields(struct regcache *regcache, struct type *type, const gdb_byte *valbuf, int element, int bitpos)
void sparc64_supply_gregset(const struct sparc_gregmap *gregmap, struct regcache *regcache, int regnum, const void *gregs)
#define bits(obj, st, fn)
Definition: aarch64-tdep.c:64
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1491
void sparc_supply_rwindow(struct regcache *regcache, CORE_ADDR sp, int regnum)
Definition: sparc-tdep.c:1925
#define TYPE_FIELD_TYPE(thistype, n)
Definition: gdbtypes.h:1371
#define SPARC64_CP0_REGISTERS
Definition: sparc64-tdep.c:765
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
Definition: frame-unwind.c:79
static struct type * sparc64_pstate_type(struct gdbarch *gdbarch)
Definition: sparc64-tdep.c:652
static adi_stat_t get_adi_info(pid_t pid)
Definition: sparc64-tdep.c:155
int target_fileio_close(int fd, int *target_errno)
Definition: target.c:2915
void set_gdbarch_wchar_signed(struct gdbarch *gdbarch, int wchar_signed)
Definition: gdbarch.c:1807
#define AT_ADI_BLKSZ
Definition: sparc64-tdep.c:76
void printf_filtered(const char *format,...)
Definition: utils.c:2045
static void adi_assign_command(const char *args, int from_tty)
Definition: sparc64-tdep.c:490
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2745
static CORE_ADDR next_address
Definition: printcmd.c:68
struct value * frame_unwind_got_constant(struct frame_info *frame, int regnum, ULONGEST val)
Definition: frame-unwind.c:246
ULONGEST sparc_fetch_wcookie(struct gdbarch *gdbarch)
Definition: sparc-tdep.c:189
adi_stat_t stat
Definition: sparc64-tdep.c:125
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
Definition: cli-decode.c:367
static const struct frame_base sparc64_frame_base
#define TSTATE_XCC
static const char * sparc64_pseudo_register_names[]
Definition: sparc64-tdep.c:789
unsigned long nbits
Definition: sparc64-tdep.c:97
const struct sparc_fpregmap sparc64_bsd_fpregmap
#define PSR_S
#define PSR_IMPL
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
Definition: frame-base.c:95
#define AT_ENTRY_POINT
Definition: inferior.h:264
void set_gdbarch_pseudo_register_write(struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype pseudo_register_write)
Definition: gdbarch.c:2032
struct type * sparc64_ccr_type
Definition: sparc-tdep.h:91
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
Definition: gdbarch.c:2316
struct type * arch_flags_type(struct gdbarch *gdbarch, const char *name, int bit)
Definition: gdbtypes.c:5076
struct type * check_typedef(struct type *type)
Definition: gdbtypes.c:2421
const gdb_byte * value_contents(struct value *value)
Definition: value.c:1407
static int adi_write_versions(CORE_ADDR vaddr, size_t size, unsigned char *tags)
Definition: sparc64-tdep.c:365
static const char * sparc64_pseudo_register_name(struct gdbarch *gdbarch, int regnum)
Definition: sparc64-tdep.c:808
Definition: gnu-nat.h:42
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
struct target_ops current_target
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition: symtab.c:3288
unsigned short int saved_regs_mask
Definition: sparc-tdep.h:180
void set_gdbarch_stack_frame_destroyed_p(struct gdbarch *gdbarch, gdbarch_stack_frame_destroyed_p_ftype stack_frame_destroyed_p)
Definition: gdbarch.c:3367
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
Definition: defs.h:577
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition: regcache.c:777
struct type * sparc64_fprs_type
Definition: sparc-tdep.h:94
#define PSR_ICC
static struct cmd_list_element * sparc64adilist
Definition: sparc64-tdep.c:86
static void do_assign(CORE_ADDR start, size_t bcnt, int version)
Definition: sparc64-tdep.c:432
CORE_ADDR base
Definition: sparc-tdep.h:170
void sparc64_supply_fpregset(const struct sparc_fpregmap *fpregmap, struct regcache *regcache, int regnum, const void *fpregs)
int target_auxv_search(struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp)
Definition: auxv.c:375
static const char * sparc64_cp0_register_names[]
Definition: sparc64-tdep.c:774
struct_return
Definition: arm-tdep.h:88
static struct type * sparc64_fprs_type(struct gdbarch *gdbarch)
Definition: sparc64-tdep.c:737
#define SPARC64_NUM_REGS
Definition: sparc64-tdep.c:784
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1509
static CORE_ADDR sparc64_addr_bits_remove(struct gdbarch *gdbarch, CORE_ADDR addr)
const char version[]
Definition: version.c:2
static int adi_convert_byte_count(CORE_ADDR naddr, int nbytes, CORE_ADDR locl)
Definition: sparc64-tdep.c:269
const char ** cp0_register_names
Definition: sparc-tdep.h:69
Definition: gdbtypes.h:749
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
Definition: blockframe.c:320
static void do_examine(CORE_ADDR start, int bcnt)
Definition: sparc64-tdep.c:415
static void sparc64_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
Definition: frame-unwind.c:174
static int adi_tag_fd(void)
Definition: sparc64-tdep.c:286
static const char * type
Definition: language.c:113
static bool adi_is_addr_mapped(CORE_ADDR vaddr, size_t cnt)
Definition: sparc64-tdep.c:307
void append_flags_type_flag(struct type *type, int bitpos, const char *name)
Definition: gdbtypes.c:5119
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
Definition: gnu-nat.c:1822
struct value * value_cast(struct type *type, struct value *arg2)
Definition: valops.c:351
static bool adi_available(void)
Definition: sparc64-tdep.c:215
#define target_has_execution
Definition: target.h:1756
ULONGEST strtoulst(const char *num, const char **trailer, int base)
Definition: common-utils.c:266
int regnum
Definition: aarch64-tdep.c:77
static CORE_ADDR sparc64_frame_align(struct gdbarch *gdbarch, CORE_ADDR address)
void printf_unfiltered(const char *format,...)
Definition: utils.c:2056
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1308
unsigned long * gregmap
Definition: xtensa-tdep.h:220
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
Definition: gdbarch.c:1623
#define TYPE_FIELD_BITPOS(thistype, n)
Definition: gdbtypes.h:1374
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition: cli-decode.c:306
#define SPARC64_FPU_REGISTERS
Definition: sparc64-tdep.c:758
Definition: regdef.h:22
#define gdb_assert(expr)
Definition: gdb_assert.h:32
Definition: value.c:169
struct type * sparc64_fsr_type
Definition: sparc-tdep.h:93
static void sparc64_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
#define PSR_VERS
static struct type * sparc64_register_type(struct gdbarch *gdbarch, int regnum)
Definition: sparc64-tdep.c:864
CORE_ADDR sparc_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct sparc_frame_cache *cache)
Definition: sparc-tdep.c:965
void set_gdbarch_push_dummy_code(struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype push_dummy_code)
Definition: gdbarch.c:2422
static const char * sparc64_fpu_register_names[]
Definition: sparc64-tdep.c:773
#define PSR_V8PLUS
bfd_byte gdb_byte
Definition: common-types.h:38
#define MAX_PROC_NAME_SIZE
Definition: sparc64-tdep.c:72
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
Definition: cli-decode.c:1071
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
Definition: value.c:3560
void set_gdbarch_pseudo_register_read(struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype pseudo_register_read)
Definition: gdbarch.c:1984
static int adi_read_versions(CORE_ADDR vaddr, size_t size, gdb_byte *tags)
Definition: sparc64-tdep.c:344
int r_npc_offset
Definition: sparc-tdep.h:41
#define TYPE_TARGET_TYPE(thistype)
Definition: gdbtypes.h:1226
struct type * builtin_double
Definition: gdbtypes.h:1511
static CORE_ADDR sparc64_frame_base_address(struct frame_info *this_frame, void **this_cache)
static int sparc64_complex_floating_p(const struct type *type)
Definition: sparc64-tdep.c:609
gdb::unique_xmalloc_ptr< char > target_fileio_read_stralloc(struct inferior *inf, const char *filename)
Definition: target.c:3082
static int sparc64_16_byte_align_p(struct type *type)
CORE_ADDR parse_and_eval_address(const char *exp)
Definition: eval.c:101
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1238
unsigned char copied_regs_mask
Definition: sparc-tdep.h:183
enum register_status regcache_raw_read(struct regcache *regcache, int regnum, gdb_byte *buf)
Definition: regcache.c:565
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition: regcache.c:806
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
Definition: frame-unwind.c:223
ptid_t inferior_ptid
Definition: infcmd.c:94
struct type * builtin_data_ptr
Definition: gdbtypes.h:1554
struct type * sparc64_pstate_type
Definition: sparc-tdep.h:92
struct type * tdesc_register_type(struct gdbarch *gdbarch, int regno)
#define TSTATE_CWP
int offset
Definition: agent.c:65
#define PSR_XCC
void regcache_raw_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition: regcache.c:640
#define TYPE_NFIELDS(thistype)
Definition: gdbtypes.h:1239
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
Definition: gdbarch.c:2067
static struct sparc_frame_cache * sparc64_frame_cache(struct frame_info *this_frame, void **this_cache)
static CORE_ADDR sparc64_push_dummy_call(struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
sparc64_adi_info(pid_t pid_)
Definition: sparc64-tdep.c:117
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 void sparc64_extract_floating_fields(struct regcache *regcache, struct type *type, gdb_byte *valbuf, int bitpos)
size_t fpu_registers_num
Definition: sparc-tdep.h:68
static int sparc64_floating_p(const struct type *type)
Definition: sparc64-tdep.c:589
static struct value * sparc64_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
#define AT_ADI_NBITS
Definition: sparc64-tdep.c:79
int offset
Definition: regdef.h:33
static void sparc64_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf)
Definition: sparc64-tdep.c:980
static const char * sparc64_register_names[]
Definition: sparc64-tdep.c:776
int target_fileio_pread(int fd, gdb_byte *read_buf, int len, ULONGEST offset, int *target_errno)
Definition: target.c:2871
static enum return_value_convention sparc64_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
Definition: regcache.c:1004
static struct type * sparc64_fsr_type(struct gdbarch *gdbarch)
Definition: sparc64-tdep.c:704
void set_gdbarch_call_dummy_location(struct gdbarch *gdbarch, int call_dummy_location)
Definition: gdbarch.c:2398
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:184
struct type * value_type(const struct value *value)
Definition: value.c:1095
struct type * builtin_int64
Definition: gdbtypes.h:1540
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
Definition: gdbarch.c:1606
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
Definition: gdbarch.c:2738
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
Definition: regcache.c:1085
void dwarf2_frame_set_init_reg(struct gdbarch *gdbarch, void(*init_reg)(struct gdbarch *, int, struct dwarf2_frame_state_reg *, struct frame_info *))
Definition: dwarf2-frame.c:743
int default_stabs_argument_has_addr(struct gdbarch *gdbarch, struct type *type)
Definition: arch-utils.c:262
#define TYPE_LENGTH(thistype)
Definition: gdbtypes.h:1235
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
Definition: gdbarch.c:1841
int target_fileio_open(struct inferior *inf, const char *filename, int flags, int mode, int *target_errno)
Definition: target.c:2826
enum register_status regcache_raw_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition: regcache.c:612
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype push_dummy_call)
Definition: gdbarch.c:2381
static void adi_print_versions(CORE_ADDR vaddr, size_t cnt, gdb_byte *tags)
Definition: sparc64-tdep.c:386
void gdb_flush(struct ui_file *file)
Definition: ui-file.c:93
#define QUIT
Definition: defs.h:179
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition: corefile.c:394
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype skip_prologue)
Definition: gdbarch.c:2772
static CORE_ADDR adi_normalize_address(CORE_ADDR addr)
Definition: sparc64-tdep.c:239
static void adi_examine_command(const char *args, int from_tty)
Definition: sparc64-tdep.c:455
enum bfd_endian byte_order
Definition: gdbarch.c:137
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
Definition: gdbarch.c:2173
int tdesc_has_registers(const struct target_desc *target_desc)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
Definition: gdbarch.c:2292
void error(const char *fmt,...)
Definition: errors.c:38
static CORE_ADDR adi_align_address(CORE_ADDR naddr)
Definition: sparc64-tdep.c:259
size_t size
Definition: go32-nat.c:242
static int sparc64_structure_or_union_p(const struct type *type)
Definition: sparc64-tdep.c:633
int get_number(const char **pp)
Definition: cli-utils.c:110
static int sparc64_integral_or_pointer_p(const struct type *type)
Definition: sparc64-tdep.c:557
struct type * lookup_pointer_type(struct type *type)
Definition: gdbtypes.c:381
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2691
void regcache_cooked_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
Definition: regcache.c:873
struct type * builtin_float
Definition: gdbtypes.h:1510
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition: defs.h:604
const struct target_desc * gdbarch_target_desc(struct gdbarch *gdbarch)
Definition: gdbarch.c:1536
#define gdb_stdout
Definition: utils.h:340
void regcache_raw_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
Definition: regcache.c:831
unsigned long blksize
Definition: sparc64-tdep.c:92
LONGEST parse_and_eval_long(const char *exp)
Definition: eval.c:111