GDB (xrefs)
Loading...
Searching...
No Matches
sparc64-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for UltraSPARC.
2
3 Copyright (C) 2003-2023 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#include "sparc64-tdep.h"
37#include <forward_list>
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. */
86static struct cmd_list_element *sparc64adilist = NULL;
87
88/* ADI stat settings. */
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};
112
113/* Per-process ADI stat info. */
114
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
127};
128
129static 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
134static 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
154static 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
166void
168{
169 fileio_error 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/* Read attributes of a maps entry in /proc/[pid]/adi/maps. */
190
191static void
192read_maps_entry (const char *line,
193 ULONGEST *addr, ULONGEST *endaddr)
194{
195 const char *p = line;
196
197 *addr = strtoulst (p, &p, 16);
198 if (*p == '-')
199 p++;
200
201 *endaddr = strtoulst (p, &p, 16);
202}
203
204/* Check if ADI is available. */
205
206static bool
208{
209 pid_t pid = inferior_ptid.pid ();
211 CORE_ADDR value;
212
213 if (proc->stat.checked_avail)
214 return proc->stat.is_avail;
215
216 proc->stat.checked_avail = true;
218 return false;
219 proc->stat.blksize = value;
221 proc->stat.nbits = value;
222 proc->stat.max_version = (1 << proc->stat.nbits) - 2;
223 proc->stat.is_avail = true;
224
225 return proc->stat.is_avail;
226}
227
228/* Normalize a versioned address - a VA with ADI bits (63-60) set. */
229
230static CORE_ADDR
231adi_normalize_address (CORE_ADDR addr)
232{
234
235 if (ast.nbits)
236 {
237 /* Clear upper bits. */
238 addr &= ((uint64_t) -1) >> ast.nbits;
239
240 /* Sign extend. */
241 CORE_ADDR signbit = (uint64_t) 1 << (64 - ast.nbits - 1);
242 return (addr ^ signbit) - signbit;
243 }
244 return addr;
245}
246
247/* Align a normalized address - a VA with bit 59 sign extended into
248 ADI bits. */
249
250static CORE_ADDR
251adi_align_address (CORE_ADDR naddr)
252{
254
255 return (naddr - (naddr % ast.blksize)) / ast.blksize;
256}
257
258/* Convert a byte count to count at a ratio of 1:adi_blksz. */
259
260static int
261adi_convert_byte_count (CORE_ADDR naddr, int nbytes, CORE_ADDR locl)
262{
264
265 return ((naddr + nbytes + ast.blksize - 1) / ast.blksize) - locl;
266}
267
268/* The /proc/[pid]/adi/tags file, which allows gdb to get/set ADI
269 version in a target process, maps linearly to the address space
270 of the target process at a ratio of 1:adi_blksz.
271
272 A read (or write) at offset K in the file returns (or modifies)
273 the ADI version tag stored in the cacheline containing address
274 K * adi_blksz, encoded as 1 version tag per byte. The allowed
275 version tag values are between 0 and adi_stat.max_version. */
276
277static int
279{
280 pid_t pid = inferior_ptid.pid ();
282
283 if (proc->stat.tag_fd != 0)
284 return proc->stat.tag_fd;
285
286 char cl_name[MAX_PROC_NAME_SIZE];
287 snprintf (cl_name, sizeof(cl_name), "/proc/%ld/adi/tags", (long) pid);
288 fileio_error target_errno;
289 proc->stat.tag_fd = target_fileio_open (NULL, cl_name, O_RDWR|O_EXCL,
290 false, 0, &target_errno);
291 return proc->stat.tag_fd;
292}
293
294/* Check if an address set is ADI enabled, using /proc/[pid]/adi/maps
295 which was exported by the kernel and contains the currently ADI
296 mapped memory regions and their access permissions. */
297
298static bool
299adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt)
300{
301 char filename[MAX_PROC_NAME_SIZE];
302 size_t i = 0;
303
304 pid_t pid = inferior_ptid.pid ();
305 snprintf (filename, sizeof filename, "/proc/%ld/adi/maps", (long) pid);
306 gdb::unique_xmalloc_ptr<char> data
307 = target_fileio_read_stralloc (NULL, filename);
308 if (data)
309 {
310 adi_stat_t adi_stat = get_adi_info (pid);
311 char *saveptr;
312 for (char *line = strtok_r (data.get (), "\n", &saveptr);
313 line;
314 line = strtok_r (NULL, "\n", &saveptr))
315 {
316 ULONGEST addr, endaddr;
317
318 read_maps_entry (line, &addr, &endaddr);
319
320 while (((vaddr + i) * adi_stat.blksize) >= addr
321 && ((vaddr + i) * adi_stat.blksize) < endaddr)
322 {
323 if (++i == cnt)
324 return true;
325 }
326 }
327 }
328 else
329 warning (_("unable to open /proc file '%s'"), filename);
330
331 return false;
332}
333
334/* Read ADI version tag value for memory locations starting at "VADDR"
335 for "SIZE" number of bytes. */
336
337static int
338adi_read_versions (CORE_ADDR vaddr, size_t size, gdb_byte *tags)
339{
340 int fd = adi_tag_fd ();
341 if (fd == -1)
342 return -1;
343
344 if (!adi_is_addr_mapped (vaddr, size))
345 {
347 error(_("Address at %s is not in ADI maps"),
348 paddress (target_gdbarch (), vaddr * ast.blksize));
349 }
350
351 fileio_error target_errno;
352 return target_fileio_pread (fd, tags, size, vaddr, &target_errno);
353}
354
355/* Write ADI version tag for memory locations starting at "VADDR" for
356 "SIZE" number of bytes to "TAGS". */
357
358static int
359adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
360{
361 int fd = adi_tag_fd ();
362 if (fd == -1)
363 return -1;
364
365 if (!adi_is_addr_mapped (vaddr, size))
366 {
368 error(_("Address at %s is not in ADI maps"),
369 paddress (target_gdbarch (), vaddr * ast.blksize));
370 }
371
372 fileio_error target_errno;
373 return target_fileio_pwrite (fd, tags, size, vaddr, &target_errno);
374}
375
376/* Print ADI version tag value in "TAGS" for memory locations starting
377 at "VADDR" with number of "CNT". */
378
379static void
380adi_print_versions (CORE_ADDR vaddr, size_t cnt, gdb_byte *tags)
381{
382 int v_idx = 0;
383 const int maxelts = 8; /* # of elements per line */
384
385 adi_stat_t adi_stat = get_adi_info (inferior_ptid.pid ());
386
387 while (cnt > 0)
388 {
389 QUIT;
390 gdb_printf ("%s:\t",
391 paddress (target_gdbarch (), vaddr * adi_stat.blksize));
392 for (int i = maxelts; i > 0 && cnt > 0; i--, cnt--)
393 {
394 if (tags[v_idx] == 0xff) /* no version tag */
395 gdb_printf ("-");
396 else
397 gdb_printf ("%1X", tags[v_idx]);
398 if (cnt > 1)
399 gdb_printf (" ");
400 ++v_idx;
401 }
402 gdb_printf ("\n");
403 vaddr += maxelts;
404 }
405}
406
407static void
408do_examine (CORE_ADDR start, int bcnt)
409{
410 CORE_ADDR vaddr = adi_normalize_address (start);
411
412 CORE_ADDR vstart = adi_align_address (vaddr);
413 int cnt = adi_convert_byte_count (vaddr, bcnt, vstart);
414 gdb::def_vector<gdb_byte> buf (cnt);
415 int read_cnt = adi_read_versions (vstart, cnt, buf.data ());
416 if (read_cnt == -1)
417 error (_("No ADI information"));
418 else if (read_cnt < cnt)
419 error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));
420
421 adi_print_versions (vstart, cnt, buf.data ());
422}
423
424static void
425do_assign (CORE_ADDR start, size_t bcnt, int version)
426{
427 CORE_ADDR vaddr = adi_normalize_address (start);
428
429 CORE_ADDR vstart = adi_align_address (vaddr);
430 int cnt = adi_convert_byte_count (vaddr, bcnt, vstart);
431 std::vector<unsigned char> buf (cnt, version);
432 int set_cnt = adi_write_versions (vstart, cnt, buf.data ());
433
434 if (set_cnt == -1)
435 error (_("No ADI information"));
436 else if (set_cnt < cnt)
437 error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));
438
439}
440
441/* ADI examine version tag command.
442
443 Command syntax:
444
445 adi (examine|x)[/COUNT] [ADDR] */
446
447static void
448adi_examine_command (const char *args, int from_tty)
449{
450 /* make sure program is active and adi is available */
451 if (!target_has_execution ())
452 error (_("ADI command requires a live process/thread"));
453
454 if (!adi_available ())
455 error (_("No ADI information"));
456
457 int cnt = 1;
458 const char *p = args;
459 if (p && *p == '/')
460 {
461 p++;
462 cnt = get_number (&p);
463 }
464
465 CORE_ADDR next_address = 0;
466 if (p != 0 && *p != 0)
468 if (!cnt || !next_address)
469 error (_("Usage: adi examine|x[/COUNT] [ADDR]"));
470
472}
473
474/* ADI assign version tag command.
475
476 Command syntax:
477
478 adi (assign|a)[/COUNT] ADDR = VERSION */
479
480static void
481adi_assign_command (const char *args, int from_tty)
482{
483 static const char *adi_usage
484 = N_("Usage: adi assign|a[/COUNT] ADDR = VERSION");
485
486 /* make sure program is active and adi is available */
487 if (!target_has_execution ())
488 error (_("ADI command requires a live process/thread"));
489
490 if (!adi_available ())
491 error (_("No ADI information"));
492
493 const char *exp = args;
494 if (exp == 0)
495 error_no_arg (_(adi_usage));
496
497 char *q = (char *) strchr (exp, '=');
498 if (q)
499 *q++ = 0;
500 else
501 error ("%s", _(adi_usage));
502
503 size_t cnt = 1;
504 const char *p = args;
505 if (exp && *exp == '/')
506 {
507 p = exp + 1;
508 cnt = get_number (&p);
509 }
510
511 CORE_ADDR next_address = 0;
512 if (p != 0 && *p != 0)
514 else
515 error ("%s", _(adi_usage));
516
517 int version = 0;
518 if (q != NULL) /* parse version tag */
519 {
522 if (version < 0 || version > ast.max_version)
523 error (_("Invalid ADI version tag %d"), version);
524 }
525
527}
528
530void
532{
534 _("ADI version related commands."),
535 &sparc64adilist, 0, &cmdlist);
536 cmd_list_element *adi_examine_cmd
538 _("Examine ADI versions."), &sparc64adilist);
539 add_alias_cmd ("x", adi_examine_cmd, no_class, 1, &sparc64adilist);
541 _("Assign ADI versions."), &sparc64adilist);
542
543}
544
545
546/* The functions on this page are intended to be used to classify
547 function arguments. */
548
549/* Check whether TYPE is "Integral or Pointer". */
550
551static int
553{
554 switch (type->code ())
555 {
556 case TYPE_CODE_INT:
557 case TYPE_CODE_BOOL:
558 case TYPE_CODE_CHAR:
559 case TYPE_CODE_ENUM:
560 case TYPE_CODE_RANGE:
561 {
562 int len = type->length ();
563 gdb_assert (len == 1 || len == 2 || len == 4 || len == 8);
564 }
565 return 1;
566 case TYPE_CODE_PTR:
567 case TYPE_CODE_REF:
568 case TYPE_CODE_RVALUE_REF:
569 {
570 int len = type->length ();
571 gdb_assert (len == 8);
572 }
573 return 1;
574 default:
575 break;
576 }
577
578 return 0;
579}
580
581/* Check whether TYPE is "Floating". */
582
583static int
585{
586 switch (type->code ())
587 {
588 case TYPE_CODE_FLT:
589 {
590 int len = type->length ();
591 gdb_assert (len == 4 || len == 8 || len == 16);
592 }
593 return 1;
594 default:
595 break;
596 }
597
598 return 0;
599}
600
601/* Check whether TYPE is "Complex Floating". */
602
603static int
605{
606 switch (type->code ())
607 {
608 case TYPE_CODE_COMPLEX:
609 {
610 int len = type->length ();
611 gdb_assert (len == 8 || len == 16 || len == 32);
612 }
613 return 1;
614 default:
615 break;
616 }
617
618 return 0;
619}
620
621/* Check whether TYPE is "Structure or Union".
622
623 In terms of Ada subprogram calls, arrays are treated the same as
624 struct and union types. So this function also returns non-zero
625 for array types. */
626
627static int
629{
630 switch (type->code ())
631 {
632 case TYPE_CODE_STRUCT:
633 case TYPE_CODE_UNION:
634 case TYPE_CODE_ARRAY:
635 return 1;
636 default:
637 break;
638 }
639
640 return 0;
641}
642
643
644/* Construct types for ISA-specific registers. */
645
646static struct type *
648{
649 sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
650
651 if (!tdep->sparc64_pstate_type)
652 {
653 struct type *type;
654
655 type = arch_flags_type (gdbarch, "builtin_type_sparc64_pstate", 64);
656 append_flags_type_flag (type, 0, "AG");
657 append_flags_type_flag (type, 1, "IE");
658 append_flags_type_flag (type, 2, "PRIV");
659 append_flags_type_flag (type, 3, "AM");
660 append_flags_type_flag (type, 4, "PEF");
661 append_flags_type_flag (type, 5, "RED");
662 append_flags_type_flag (type, 8, "TLE");
663 append_flags_type_flag (type, 9, "CLE");
664 append_flags_type_flag (type, 10, "PID0");
665 append_flags_type_flag (type, 11, "PID1");
666
668 }
669
670 return tdep->sparc64_pstate_type;
671}
672
673static struct type *
675{
676 sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
677
678 if (tdep->sparc64_ccr_type == NULL)
679 {
680 struct type *type;
681
682 type = arch_flags_type (gdbarch, "builtin_type_sparc64_ccr", 64);
683 append_flags_type_flag (type, 0, "icc.c");
684 append_flags_type_flag (type, 1, "icc.v");
685 append_flags_type_flag (type, 2, "icc.z");
686 append_flags_type_flag (type, 3, "icc.n");
687 append_flags_type_flag (type, 4, "xcc.c");
688 append_flags_type_flag (type, 5, "xcc.v");
689 append_flags_type_flag (type, 6, "xcc.z");
690 append_flags_type_flag (type, 7, "xcc.n");
691
692 tdep->sparc64_ccr_type = type;
693 }
694
695 return tdep->sparc64_ccr_type;
696}
697
698static struct type *
700{
701 sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
702
703 if (!tdep->sparc64_fsr_type)
704 {
705 struct type *type;
706
707 type = arch_flags_type (gdbarch, "builtin_type_sparc64_fsr", 64);
708 append_flags_type_flag (type, 0, "NXC");
709 append_flags_type_flag (type, 1, "DZC");
710 append_flags_type_flag (type, 2, "UFC");
711 append_flags_type_flag (type, 3, "OFC");
712 append_flags_type_flag (type, 4, "NVC");
713 append_flags_type_flag (type, 5, "NXA");
714 append_flags_type_flag (type, 6, "DZA");
715 append_flags_type_flag (type, 7, "UFA");
716 append_flags_type_flag (type, 8, "OFA");
717 append_flags_type_flag (type, 9, "NVA");
718 append_flags_type_flag (type, 22, "NS");
719 append_flags_type_flag (type, 23, "NXM");
720 append_flags_type_flag (type, 24, "DZM");
721 append_flags_type_flag (type, 25, "UFM");
722 append_flags_type_flag (type, 26, "OFM");
723 append_flags_type_flag (type, 27, "NVM");
724
725 tdep->sparc64_fsr_type = type;
726 }
727
728 return tdep->sparc64_fsr_type;
729}
730
731static struct type *
733{
734 sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
735
736 if (!tdep->sparc64_fprs_type)
737 {
738 struct type *type;
739
740 type = arch_flags_type (gdbarch, "builtin_type_sparc64_fprs", 64);
741 append_flags_type_flag (type, 0, "DL");
742 append_flags_type_flag (type, 1, "DU");
743 append_flags_type_flag (type, 2, "FEF");
744
745 tdep->sparc64_fprs_type = type;
746 }
747
748 return tdep->sparc64_fprs_type;
749}
750
751
752/* Register information. */
753#define SPARC64_FPU_REGISTERS \
754 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
755 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
756 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
757 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
758 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
759 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62"
760#define SPARC64_CP0_REGISTERS \
761 "pc", "npc", \
762 /* FIXME: Give "state" a name until we start using register groups. */ \
763 "state", \
764 "fsr", \
765 "fprs", \
766 "y"
767
768static const char * const sparc64_fpu_register_names[] = {
770};
771static const char * const sparc64_cp0_register_names[] = {
773};
774
775static const char * const sparc64_register_names[] =
776{
780};
781
782/* Total number of registers. */
783#define SPARC64_NUM_REGS ARRAY_SIZE (sparc64_register_names)
784
785/* We provide the aliases %d0..%d62 and %q0..%q60 for the floating
786 registers as "psuedo" registers. */
787
788static const char * const sparc64_pseudo_register_names[] =
789{
790 "cwp", "pstate", "asi", "ccr",
791
792 "d0", "d2", "d4", "d6", "d8", "d10", "d12", "d14",
793 "d16", "d18", "d20", "d22", "d24", "d26", "d28", "d30",
794 "d32", "d34", "d36", "d38", "d40", "d42", "d44", "d46",
795 "d48", "d50", "d52", "d54", "d56", "d58", "d60", "d62",
796
797 "q0", "q4", "q8", "q12", "q16", "q20", "q24", "q28",
798 "q32", "q36", "q40", "q44", "q48", "q52", "q56", "q60",
799};
800
801/* Total number of pseudo registers. */
802#define SPARC64_NUM_PSEUDO_REGS ARRAY_SIZE (sparc64_pseudo_register_names)
803
804/* Return the name of pseudo register REGNUM. */
805
806static const char *
814
815/* Return the name of register REGNUM. */
816
817static const char *
828
829/* Return the GDB type object for the "standard" data type of data in
830 pseudo register REGNUM. */
831
832static struct type *
834{
836
844 return sparc64_ccr_type (gdbarch);
849
850 internal_error (_("sparc64_pseudo_register_type: bad register number %d"),
851 regnum);
852}
853
854/* Return the GDB type object for the "standard" data type of data in
855 register REGNUM. */
856
857static struct type *
859{
862
863 /* Raw registers. */
874 /* This raw register contains the contents of %cwp, %pstate, %asi
875 and %ccr as laid out in a %tstate register. */
879 return sparc64_fsr_type (gdbarch);
881 return sparc64_fprs_type (gdbarch);
882 /* "Although Y is a 64-bit register, its high-order 32 bits are
883 reserved and always read as 0." */
886
887 /* Pseudo registers. */
890
891 internal_error (_("invalid regnum"));
892}
893
894static enum register_status
897 int regnum, gdb_byte *buf)
898{
899 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
900 enum register_status status;
901
903
905 {
907 status = regcache->raw_read (regnum, buf);
908 if (status == REG_VALID)
909 status = regcache->raw_read (regnum + 1, buf + 4);
910 return status;
911 }
913 {
915 return regcache->raw_read (regnum, buf);
916 }
918 {
920
921 status = regcache->raw_read (regnum, buf);
922 if (status == REG_VALID)
923 status = regcache->raw_read (regnum + 1, buf + 4);
924 if (status == REG_VALID)
925 status = regcache->raw_read (regnum + 2, buf + 8);
926 if (status == REG_VALID)
927 status = regcache->raw_read (regnum + 3, buf + 12);
928
929 return status;
930 }
932 {
934
935 status = regcache->raw_read (regnum, buf);
936 if (status == REG_VALID)
937 status = regcache->raw_read (regnum + 1, buf + 8);
938
939 return status;
940 }
941 else if (regnum == SPARC64_CWP_REGNUM
945 {
946 ULONGEST state;
947
949 if (status != REG_VALID)
950 return status;
951
952 switch (regnum)
953 {
955 state = (state >> 0) & ((1 << 5) - 1);
956 break;
958 state = (state >> 8) & ((1 << 12) - 1);
959 break;
961 state = (state >> 24) & ((1 << 8) - 1);
962 break;
964 state = (state >> 32) & ((1 << 8) - 1);
965 break;
966 }
967 store_unsigned_integer (buf, 8, byte_order, state);
968 }
969
970 return REG_VALID;
971}
972
973static void
975 struct regcache *regcache,
976 int regnum, const gdb_byte *buf)
977{
978 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
979
981
983 {
985 regcache->raw_write (regnum, buf);
986 regcache->raw_write (regnum + 1, buf + 4);
987 }
989 {
991 regcache->raw_write (regnum, buf);
992 }
994 {
996 regcache->raw_write (regnum, buf);
997 regcache->raw_write (regnum + 1, buf + 4);
998 regcache->raw_write (regnum + 2, buf + 8);
999 regcache->raw_write (regnum + 3, buf + 12);
1000 }
1002 {
1004 regcache->raw_write (regnum, buf);
1005 regcache->raw_write (regnum + 1, buf + 8);
1006 }
1007 else if (regnum == SPARC64_CWP_REGNUM
1011 {
1012 ULONGEST state, bits;
1013
1015 bits = extract_unsigned_integer (buf, 8, byte_order);
1016 switch (regnum)
1017 {
1018 case SPARC64_CWP_REGNUM:
1019 state |= ((bits & ((1 << 5) - 1)) << 0);
1020 break;
1022 state |= ((bits & ((1 << 12) - 1)) << 8);
1023 break;
1024 case SPARC64_ASI_REGNUM:
1025 state |= ((bits & ((1 << 8) - 1)) << 24);
1026 break;
1027 case SPARC64_CCR_REGNUM:
1028 state |= ((bits & ((1 << 8) - 1)) << 32);
1029 break;
1030 }
1032 }
1033}
1034
1035
1036/* Return PC of first real instruction of the function starting at
1037 START_PC. */
1038
1039static CORE_ADDR
1040sparc64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
1041{
1042 struct symtab_and_line sal;
1043 CORE_ADDR func_start, func_end;
1044 struct sparc_frame_cache cache;
1045
1046 /* This is the preferred method, find the end of the prologue by
1047 using the debugging information. */
1048 if (find_pc_partial_function (start_pc, NULL, &func_start, &func_end))
1049 {
1050 sal = find_pc_line (func_start, 0);
1051
1052 if (sal.end < func_end
1053 && start_pc <= sal.end)
1054 return sal.end;
1055 }
1056
1057 return sparc_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffULL,
1058 &cache);
1059}
1060
1061/* Normal frames. */
1062
1063static struct sparc_frame_cache *
1064sparc64_frame_cache (frame_info_ptr this_frame, void **this_cache)
1065{
1066 return sparc_frame_cache (this_frame, this_cache);
1067}
1068
1069static void
1070sparc64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
1071 struct frame_id *this_id)
1072{
1073 struct sparc_frame_cache *cache =
1074 sparc64_frame_cache (this_frame, this_cache);
1075
1076 /* This marks the outermost frame. */
1077 if (cache->base == 0)
1078 return;
1079
1080 (*this_id) = frame_id_build (cache->base, cache->pc);
1081}
1082
1083static struct value *
1084sparc64_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
1085 int regnum)
1086{
1087 struct gdbarch *gdbarch = get_frame_arch (this_frame);
1088 struct sparc_frame_cache *cache =
1089 sparc64_frame_cache (this_frame, this_cache);
1090
1092 {
1093 CORE_ADDR pc = (regnum == SPARC64_NPC_REGNUM) ? 4 : 0;
1094
1095 regnum =
1097 pc += get_frame_register_unsigned (this_frame, regnum) + 8;
1098 return frame_unwind_got_constant (this_frame, regnum, pc);
1099 }
1100
1101 /* Handle StackGhost. */
1102 {
1103 ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
1104
1105 if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
1106 {
1107 CORE_ADDR addr = cache->base + (regnum - SPARC_L0_REGNUM) * 8;
1108 ULONGEST i7;
1109
1110 /* Read the value in from memory. */
1111 i7 = get_frame_memory_unsigned (this_frame, addr, 8);
1112 return frame_unwind_got_constant (this_frame, regnum, i7 ^ wcookie);
1113 }
1114 }
1115
1116 /* The previous frame's `local' and `in' registers may have been saved
1117 in the register save area. */
1119 && (cache->saved_regs_mask & (1 << (regnum - SPARC_L0_REGNUM))))
1120 {
1121 CORE_ADDR addr = cache->base + (regnum - SPARC_L0_REGNUM) * 8;
1122
1123 return frame_unwind_got_memory (this_frame, regnum, addr);
1124 }
1125
1126 /* The previous frame's `out' registers may be accessible as the current
1127 frame's `in' registers. */
1129 && (cache->copied_regs_mask & (1 << (regnum - SPARC_O0_REGNUM))))
1131
1132 return frame_unwind_got_register (this_frame, regnum, regnum);
1133}
1134
1136{
1137 "sparc64 prologue",
1142 NULL,
1144};
1145
1146
1147static CORE_ADDR
1148sparc64_frame_base_address (frame_info_ptr this_frame, void **this_cache)
1149{
1150 struct sparc_frame_cache *cache =
1151 sparc64_frame_cache (this_frame, this_cache);
1152
1153 return cache->base;
1154}
1155
1163
1164/* Check whether TYPE must be 16-byte aligned. */
1165
1166static int
1168{
1169 if (type->code () == TYPE_CODE_ARRAY)
1170 {
1171 struct type *t = check_typedef (type->target_type ());
1172
1173 if (sparc64_floating_p (t))
1174 return 1;
1175 }
1176 if (sparc64_floating_p (type) && type->length () == 16)
1177 return 1;
1178
1180 {
1181 int i;
1182
1183 for (i = 0; i < type->num_fields (); i++)
1184 {
1185 struct type *subtype = check_typedef (type->field (i).type ());
1186
1187 if (sparc64_16_byte_align_p (subtype))
1188 return 1;
1189 }
1190 }
1191
1192 return 0;
1193}
1194
1195/* Store floating fields of element ELEMENT of an "parameter array"
1196 that has type TYPE and is stored at BITPOS in VALBUF in the
1197 appropriate registers of REGCACHE. This function can be called
1198 recursively and therefore handles floating types in addition to
1199 structures. */
1200
1201static void
1203 const gdb_byte *valbuf, int element, int bitpos)
1204{
1205 struct gdbarch *gdbarch = regcache->arch ();
1206 int len = type->length ();
1207
1208 gdb_assert (element < 16);
1209
1210 if (type->code () == TYPE_CODE_ARRAY)
1211 {
1212 gdb_byte buf[8];
1213 int regnum = SPARC_F0_REGNUM + element * 2 + bitpos / 32;
1214
1215 valbuf += bitpos / 8;
1216 if (len < 8)
1217 {
1218 memset (buf, 0, 8 - len);
1219 memcpy (buf + 8 - len, valbuf, len);
1220 valbuf = buf;
1221 len = 8;
1222 }
1223 for (int n = 0; n < (len + 3) / 4; n++)
1224 regcache->cooked_write (regnum + n, valbuf + n * 4);
1225 }
1226 else if (sparc64_floating_p (type)
1227 || (sparc64_complex_floating_p (type) && len <= 16))
1228 {
1229 int regnum;
1230
1231 if (len == 16)
1232 {
1233 gdb_assert (bitpos == 0);
1234 gdb_assert ((element % 2) == 0);
1235
1237 regcache->cooked_write (regnum, valbuf);
1238 }
1239 else if (len == 8)
1240 {
1241 gdb_assert (bitpos == 0 || bitpos == 64);
1242
1244 + element + bitpos / 64;
1245 regcache->cooked_write (regnum, valbuf + (bitpos / 8));
1246 }
1247 else
1248 {
1249 gdb_assert (len == 4);
1250 gdb_assert (bitpos % 32 == 0 && bitpos >= 0 && bitpos < 128);
1251
1252 regnum = SPARC_F0_REGNUM + element * 2 + bitpos / 32;
1253 regcache->cooked_write (regnum, valbuf + (bitpos / 8));
1254 }
1255 }
1257 {
1258 int i;
1259
1260 for (i = 0; i < type->num_fields (); i++)
1261 {
1262 struct type *subtype = check_typedef (type->field (i).type ());
1263 int subpos = bitpos + type->field (i).loc_bitpos ();
1264
1265 sparc64_store_floating_fields (regcache, subtype, valbuf,
1266 element, subpos);
1267 }
1268
1269 /* GCC has an interesting bug. If TYPE is a structure that has
1270 a single `float' member, GCC doesn't treat it as a structure
1271 at all, but rather as an ordinary `float' argument. This
1272 argument will be stored in %f1, as required by the psABI.
1273 However, as a member of a structure the psABI requires it to
1274 be stored in %f0. This bug is present in GCC 3.3.2, but
1275 probably in older releases to. To appease GCC, if a
1276 structure has only a single `float' member, we store its
1277 value in %f1 too (we already have stored in %f0). */
1278 if (type->num_fields () == 1)
1279 {
1280 struct type *subtype = check_typedef (type->field (0).type ());
1281
1282 if (sparc64_floating_p (subtype) && subtype->length () == 4)
1284 }
1285 }
1286}
1287
1288/* Fetch floating fields from a variable of type TYPE from the
1289 appropriate registers for BITPOS in REGCACHE and store it at BITPOS
1290 in VALBUF. This function can be called recursively and therefore
1291 handles floating types in addition to structures. */
1292
1293static void
1295 gdb_byte *valbuf, int bitpos)
1296{
1297 struct gdbarch *gdbarch = regcache->arch ();
1298
1299 if (type->code () == TYPE_CODE_ARRAY)
1300 {
1301 int len = type->length ();
1302 int regnum = SPARC_F0_REGNUM + bitpos / 32;
1303
1304 valbuf += bitpos / 8;
1305 if (len < 4)
1306 {
1307 gdb_byte buf[4];
1308 regcache->cooked_read (regnum, buf);
1309 memcpy (valbuf, buf + 4 - len, len);
1310 }
1311 else
1312 for (int i = 0; i < (len + 3) / 4; i++)
1313 regcache->cooked_read (regnum + i, valbuf + i * 4);
1314 }
1315 else if (sparc64_floating_p (type))
1316 {
1317 int len = type->length ();
1318 int regnum;
1319
1320 if (len == 16)
1321 {
1322 gdb_assert (bitpos == 0 || bitpos == 128);
1323
1325 + bitpos / 128;
1326 regcache->cooked_read (regnum, valbuf + (bitpos / 8));
1327 }
1328 else if (len == 8)
1329 {
1330 gdb_assert (bitpos % 64 == 0 && bitpos >= 0 && bitpos < 256);
1331
1333 regcache->cooked_read (regnum, valbuf + (bitpos / 8));
1334 }
1335 else
1336 {
1337 gdb_assert (len == 4);
1338 gdb_assert (bitpos % 32 == 0 && bitpos >= 0 && bitpos < 256);
1339
1340 regnum = SPARC_F0_REGNUM + bitpos / 32;
1341 regcache->cooked_read (regnum, valbuf + (bitpos / 8));
1342 }
1343 }
1345 {
1346 int i;
1347
1348 for (i = 0; i < type->num_fields (); i++)
1349 {
1350 struct type *subtype = check_typedef (type->field (i).type ());
1351 int subpos = bitpos + type->field (i).loc_bitpos ();
1352
1353 sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos);
1354 }
1355 }
1356}
1357
1358/* Store the NARGS arguments ARGS and STRUCT_ADDR (if STRUCT_RETURN is
1359 non-zero) in REGCACHE and on the stack (starting from address SP). */
1360
1361static CORE_ADDR
1363 struct value **args, CORE_ADDR sp,
1364 function_call_return_method return_method,
1365 CORE_ADDR struct_addr)
1366{
1367 struct gdbarch *gdbarch = regcache->arch ();
1368 /* Number of extended words in the "parameter array". */
1369 int num_elements = 0;
1370 int element = 0;
1371 int i;
1372
1373 /* Take BIAS into account. */
1374 sp += BIAS;
1375
1376 /* First we calculate the number of extended words in the "parameter
1377 array". While doing so we also convert some of the arguments. */
1378
1379 if (return_method == return_method_struct)
1380 num_elements++;
1381
1382 for (i = 0; i < nargs; i++)
1383 {
1384 struct type *type = args[i]->type ();
1385 int len = type->length ();
1386
1388 || (sparc64_complex_floating_p (type) && len == 32))
1389 {
1390 /* Structure or Union arguments. */
1391 if (len <= 16)
1392 {
1393 if (num_elements % 2 && sparc64_16_byte_align_p (type))
1394 num_elements++;
1395 num_elements += ((len + 7) / 8);
1396 }
1397 else
1398 {
1399 /* The psABI says that "Structures or unions larger than
1400 sixteen bytes are copied by the caller and passed
1401 indirectly; the caller will pass the address of a
1402 correctly aligned structure value. This sixty-four
1403 bit address will occupy one word in the parameter
1404 array, and may be promoted to an %o register like any
1405 other pointer value." Allocate memory for these
1406 values on the stack. */
1407 sp -= len;
1408
1409 /* Use 16-byte alignment for these values. That's
1410 always correct, and wasting a few bytes shouldn't be
1411 a problem. */
1412 sp &= ~0xf;
1413
1414 write_memory (sp, args[i]->contents ().data (), len);
1416 num_elements++;
1417 }
1418 }
1420 {
1421 /* Floating arguments. */
1422 if (len == 16)
1423 {
1424 /* The psABI says that "Each quad-precision parameter
1425 value will be assigned to two extended words in the
1426 parameter array. */
1427 num_elements += 2;
1428
1429 /* The psABI says that "Long doubles must be
1430 quad-aligned, and thus a hole might be introduced
1431 into the parameter array to force alignment." Skip
1432 an element if necessary. */
1433 if ((num_elements % 2) && sparc64_16_byte_align_p (type))
1434 num_elements++;
1435 }
1436 else
1437 num_elements++;
1438 }
1439 else
1440 {
1441 /* Integral and pointer arguments. */
1442 gdb_assert (sparc64_integral_or_pointer_p (type));
1443
1444 /* The psABI says that "Each argument value of integral type
1445 smaller than an extended word will be widened by the
1446 caller to an extended word according to the signed-ness
1447 of the argument type." */
1448 if (len < 8)
1449 args[i] = value_cast (builtin_type (gdbarch)->builtin_int64,
1450 args[i]);
1451 num_elements++;
1452 }
1453 }
1454
1455 /* Allocate the "parameter array". */
1456 sp -= num_elements * 8;
1457
1458 /* The psABI says that "Every stack frame must be 16-byte aligned." */
1459 sp &= ~0xf;
1460
1461 /* Now we store the arguments in to the "parameter array". Some
1462 Integer or Pointer arguments and Structure or Union arguments
1463 will be passed in %o registers. Some Floating arguments and
1464 floating members of structures are passed in floating-point
1465 registers. However, for functions with variable arguments,
1466 floating arguments are stored in an %0 register, and for
1467 functions without a prototype floating arguments are stored in
1468 both a floating-point and an %o registers, or a floating-point
1469 register and memory. To simplify the logic here we always pass
1470 arguments in memory, an %o register, and a floating-point
1471 register if appropriate. This should be no problem since the
1472 contents of any unused memory or registers in the "parameter
1473 array" are undefined. */
1474
1475 if (return_method == return_method_struct)
1476 {
1478 element++;
1479 }
1480
1481 for (i = 0; i < nargs; i++)
1482 {
1483 const gdb_byte *valbuf = args[i]->contents ().data ();
1484 struct type *type = args[i]->type ();
1485 int len = type->length ();
1486 int regnum = -1;
1487 gdb_byte buf[16];
1488
1490 || (sparc64_complex_floating_p (type) && len == 32))
1491 {
1492 /* Structure, Union or long double Complex arguments. */
1493 gdb_assert (len <= 16);
1494 memset (buf, 0, sizeof (buf));
1495 memcpy (buf, valbuf, len);
1496 valbuf = buf;
1497
1498 if (element % 2 && sparc64_16_byte_align_p (type))
1499 element++;
1500
1501 if (element < 6)
1502 {
1503 regnum = SPARC_O0_REGNUM + element;
1504 if (len > 8 && element < 5)
1505 regcache->cooked_write (regnum + 1, valbuf + 8);
1506 }
1507
1508 if (element < 16)
1509 sparc64_store_floating_fields (regcache, type, valbuf, element, 0);
1510 }
1512 {
1513 /* Float Complex or double Complex arguments. */
1514 if (element < 16)
1515 {
1517
1518 if (len == 16)
1519 {
1521 regcache->cooked_write (regnum + 1, valbuf + 8);
1523 regcache->cooked_write (SPARC_O0_REGNUM + element + 1,
1524 valbuf + 8);
1525 }
1526 }
1527 }
1528 else if (sparc64_floating_p (type))
1529 {
1530 /* Floating arguments. */
1531 if (len == 16)
1532 {
1533 if (element % 2)
1534 element++;
1535 if (element < 16)
1537 + element / 2;
1538 }
1539 else if (len == 8)
1540 {
1541 if (element < 16)
1543 + element;
1544 }
1545 else if (len == 4)
1546 {
1547 /* The psABI says "Each single-precision parameter value
1548 will be assigned to one extended word in the
1549 parameter array, and right-justified within that
1550 word; the left half (even float register) is
1551 undefined." Even though the psABI says that "the
1552 left half is undefined", set it to zero here. */
1553 memset (buf, 0, 4);
1554 memcpy (buf + 4, valbuf, 4);
1555 valbuf = buf;
1556 len = 8;
1557 if (element < 16)
1559 + element;
1560 }
1561 }
1562 else
1563 {
1564 /* Integral and pointer arguments. */
1565 gdb_assert (len == 8);
1566 if (element < 6)
1567 regnum = SPARC_O0_REGNUM + element;
1568 }
1569
1570 if (regnum != -1)
1571 {
1572 regcache->cooked_write (regnum, valbuf);
1573
1574 /* If we're storing the value in a floating-point register,
1575 also store it in the corresponding %0 register(s). */
1577 {
1579
1581 {
1582 gdb_assert (element < 6);
1583 regnum = SPARC_O0_REGNUM + element;
1584 regcache->cooked_write (regnum, valbuf);
1585 }
1587 {
1588 gdb_assert (element < 5);
1589 regnum = SPARC_O0_REGNUM + element;
1590 regcache->cooked_write (regnum, valbuf);
1591 regcache->cooked_write (regnum + 1, valbuf + 8);
1592 }
1593 }
1594 }
1595
1596 /* Always store the argument in memory. */
1597 write_memory (sp + element * 8, valbuf, len);
1598 element += ((len + 7) / 8);
1599 }
1600
1601 gdb_assert (element == num_elements);
1602
1603 /* Take BIAS into account. */
1604 sp -= BIAS;
1605 return sp;
1606}
1607
1608static CORE_ADDR
1609sparc64_frame_align (struct gdbarch *gdbarch, CORE_ADDR address)
1610{
1611 /* The ABI requires 16-byte alignment. */
1612 return address & ~0xf;
1613}
1614
1615static CORE_ADDR
1617 struct regcache *regcache, CORE_ADDR bp_addr,
1618 int nargs, struct value **args, CORE_ADDR sp,
1619 function_call_return_method return_method,
1620 CORE_ADDR struct_addr)
1621{
1622 /* Set return address. */
1624
1625 /* Set up function arguments. */
1626 sp = sparc64_store_arguments (regcache, nargs, args, sp, return_method,
1627 struct_addr);
1628
1629 /* Allocate the register save area. */
1630 sp -= 16 * 8;
1631
1632 /* Stack should be 16-byte aligned at this point. */
1633 gdb_assert ((sp + BIAS) % 16 == 0);
1634
1635 /* Finally, update the stack pointer. */
1637
1638 return sp + BIAS;
1639}
1640
1641
1642/* Extract from an array REGBUF containing the (raw) register state, a
1643 function return value of TYPE, and copy that into VALBUF. */
1644
1645static void
1647 gdb_byte *valbuf)
1648{
1649 int len = type->length ();
1650 gdb_byte buf[32];
1651 int i;
1652
1654 {
1655 /* Structure or Union return values. */
1656 gdb_assert (len <= 32);
1657
1658 for (i = 0; i < ((len + 7) / 8); i++)
1659 regcache->cooked_read (SPARC_O0_REGNUM + i, buf + i * 8);
1660 if (type->code () != TYPE_CODE_UNION)
1662 memcpy (valbuf, buf, len);
1663 }
1665 {
1666 /* Floating return values. */
1667 for (i = 0; i < len / 4; i++)
1668 regcache->cooked_read (SPARC_F0_REGNUM + i, buf + i * 4);
1669 memcpy (valbuf, buf, len);
1670 }
1671 else if (type->code () == TYPE_CODE_ARRAY)
1672 {
1673 /* Small arrays are returned the same way as small structures. */
1674 gdb_assert (len <= 32);
1675
1676 for (i = 0; i < ((len + 7) / 8); i++)
1677 regcache->cooked_read (SPARC_O0_REGNUM + i, buf + i * 8);
1678 memcpy (valbuf, buf, len);
1679 }
1680 else
1681 {
1682 /* Integral and pointer return values. */
1683 gdb_assert (sparc64_integral_or_pointer_p (type));
1684
1685 /* Just stripping off any unused bytes should preserve the
1686 signed-ness just fine. */
1688 memcpy (valbuf, buf + 8 - len, len);
1689 }
1690}
1691
1692/* Write into the appropriate registers a function return value stored
1693 in VALBUF of type TYPE. */
1694
1695static void
1697 const gdb_byte *valbuf)
1698{
1699 int len = type->length ();
1700 gdb_byte buf[16];
1701 int i;
1702
1704 {
1705 /* Structure or Union return values. */
1706 gdb_assert (len <= 32);
1707
1708 /* Simplify matters by storing the complete value (including
1709 floating members) into %o0 and %o1. Floating members are
1710 also store in the appropriate floating-point registers. */
1711 memset (buf, 0, sizeof (buf));
1712 memcpy (buf, valbuf, len);
1713 for (i = 0; i < ((len + 7) / 8); i++)
1714 regcache->cooked_write (SPARC_O0_REGNUM + i, buf + i * 8);
1715 if (type->code () != TYPE_CODE_UNION)
1717 }
1719 {
1720 /* Floating return values. */
1721 memcpy (buf, valbuf, len);
1722 for (i = 0; i < len / 4; i++)
1723 regcache->cooked_write (SPARC_F0_REGNUM + i, buf + i * 4);
1724 }
1725 else if (type->code () == TYPE_CODE_ARRAY)
1726 {
1727 /* Small arrays are returned the same way as small structures. */
1728 gdb_assert (len <= 32);
1729
1730 memset (buf, 0, sizeof (buf));
1731 memcpy (buf, valbuf, len);
1732 for (i = 0; i < ((len + 7) / 8); i++)
1733 regcache->cooked_write (SPARC_O0_REGNUM + i, buf + i * 8);
1734 }
1735 else
1736 {
1737 /* Integral and pointer return values. */
1738 gdb_assert (sparc64_integral_or_pointer_p (type));
1739
1740 /* ??? Do we need to do any sign-extension here? */
1741 memset (buf, 0, 8);
1742 memcpy (buf + 8 - len, valbuf, len);
1744 }
1745}
1746
1747static enum return_value_convention
1748sparc64_return_value (struct gdbarch *gdbarch, struct value *function,
1749 struct type *type, struct regcache *regcache,
1750 gdb_byte *readbuf, const gdb_byte *writebuf)
1751{
1752 if (type->length () > 32)
1754
1755 if (readbuf)
1757 if (writebuf)
1759
1761}
1762
1763
1764static void
1766 struct dwarf2_frame_state_reg *reg,
1767 frame_info_ptr this_frame)
1768{
1769 switch (regnum)
1770 {
1771 case SPARC_G0_REGNUM:
1772 /* Since %g0 is always zero, there is no point in saving it, and
1773 people will be inclined omit it from the CFI. Make sure we
1774 don't warn about that. */
1776 break;
1777 case SPARC_SP_REGNUM:
1779 break;
1780 case SPARC64_PC_REGNUM:
1782 reg->loc.offset = 8;
1783 break;
1784 case SPARC64_NPC_REGNUM:
1786 reg->loc.offset = 12;
1787 break;
1788 }
1789}
1790
1791/* sparc64_addr_bits_remove - remove useless address bits */
1792
1793static CORE_ADDR
1795{
1796 return adi_normalize_address (addr);
1797}
1798
1799void
1801{
1802 sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
1803
1807 tdep->fpu_registers_num = ARRAY_SIZE (sparc64_fpu_register_names);
1809 tdep->cp0_registers_num = ARRAY_SIZE (sparc64_cp0_register_names);
1810
1811 /* This is what all the fuss is about. */
1815
1818
1827
1828 /* Register numbers of various important registers. */
1830
1831 /* Call dummy code. */
1836
1841
1844
1845 /* Hook in the DWARF CFI frame unwinder. */
1847 /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1848 StackGhost issues have been resolved. */
1849
1852
1854}
1855
1856
1857/* Helper functions for dealing with register sets. */
1858
1859#define TSTATE_CWP 0x000000000000001fULL
1860#define TSTATE_ICC 0x0000000f00000000ULL
1861#define TSTATE_XCC 0x000000f000000000ULL
1862
1863#define PSR_S 0x00000080
1864#ifndef PSR_ICC
1865#define PSR_ICC 0x00f00000
1866#endif
1867#define PSR_VERS 0x0f000000
1868#ifndef PSR_IMPL
1869#define PSR_IMPL 0xf0000000
1870#endif
1871#define PSR_V8PLUS 0xff000000
1872#define PSR_XCC 0x000f0000
1873
1874void
1876 struct regcache *regcache,
1877 int regnum, const void *gregs)
1878{
1879 struct gdbarch *gdbarch = regcache->arch ();
1880 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1881 int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
1882 const gdb_byte *regs = (const gdb_byte *) gregs;
1883 gdb_byte zero[8] = { 0 };
1884 int i;
1885
1886 if (sparc32)
1887 {
1888 if (regnum == SPARC32_PSR_REGNUM || regnum == -1)
1889 {
1890 int offset = gregmap->r_tstate_offset;
1891 ULONGEST tstate, psr;
1892 gdb_byte buf[4];
1893
1894 tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
1895 psr = ((tstate & TSTATE_CWP) | PSR_S | ((tstate & TSTATE_ICC) >> 12)
1896 | ((tstate & TSTATE_XCC) >> 20) | PSR_V8PLUS);
1897 store_unsigned_integer (buf, 4, byte_order, psr);
1899 }
1900
1901 if (regnum == SPARC32_PC_REGNUM || regnum == -1)
1903 regs + gregmap->r_pc_offset + 4);
1904
1905 if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
1907 regs + gregmap->r_npc_offset + 4);
1908
1909 if (regnum == SPARC32_Y_REGNUM || regnum == -1)
1910 {
1911 int offset = gregmap->r_y_offset + 8 - gregmap->r_y_size;
1912 regcache->raw_supply (SPARC32_Y_REGNUM, regs + offset);
1913 }
1914 }
1915 else
1916 {
1917 if (regnum == SPARC64_STATE_REGNUM || regnum == -1)
1919 regs + gregmap->r_tstate_offset);
1920
1921 if (regnum == SPARC64_PC_REGNUM || regnum == -1)
1923 regs + gregmap->r_pc_offset);
1924
1925 if (regnum == SPARC64_NPC_REGNUM || regnum == -1)
1927 regs + gregmap->r_npc_offset);
1928
1929 if (regnum == SPARC64_Y_REGNUM || regnum == -1)
1930 {
1931 gdb_byte buf[8];
1932
1933 memset (buf, 0, 8);
1934 memcpy (buf + 8 - gregmap->r_y_size,
1935 regs + gregmap->r_y_offset, gregmap->r_y_size);
1937 }
1938
1939 if ((regnum == SPARC64_FPRS_REGNUM || regnum == -1)
1940 && gregmap->r_fprs_offset != -1)
1942 regs + gregmap->r_fprs_offset);
1943 }
1944
1945 if (regnum == SPARC_G0_REGNUM || regnum == -1)
1947
1948 if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
1949 {
1950 int offset = gregmap->r_g1_offset;
1951
1952 if (sparc32)
1953 offset += 4;
1954
1955 for (i = SPARC_G1_REGNUM; i <= SPARC_O7_REGNUM; i++)
1956 {
1957 if (regnum == i || regnum == -1)
1958 regcache->raw_supply (i, regs + offset);
1959 offset += 8;
1960 }
1961 }
1962
1963 if ((regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) || regnum == -1)
1964 {
1965 /* Not all of the register set variants include Locals and
1966 Inputs. For those that don't, we read them off the stack. */
1967 if (gregmap->r_l0_offset == -1)
1968 {
1969 ULONGEST sp;
1970
1973 }
1974 else
1975 {
1976 int offset = gregmap->r_l0_offset;
1977
1978 if (sparc32)
1979 offset += 4;
1980
1981 for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
1982 {
1983 if (regnum == i || regnum == -1)
1984 regcache->raw_supply (i, regs + offset);
1985 offset += 8;
1986 }
1987 }
1988 }
1989}
1990
1991void
1993 const struct regcache *regcache,
1994 int regnum, void *gregs)
1995{
1996 struct gdbarch *gdbarch = regcache->arch ();
1997 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1998 int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
1999 gdb_byte *regs = (gdb_byte *) gregs;
2000 int i;
2001
2002 if (sparc32)
2003 {
2004 if (regnum == SPARC32_PSR_REGNUM || regnum == -1)
2005 {
2006 int offset = gregmap->r_tstate_offset;
2007 ULONGEST tstate, psr;
2008 gdb_byte buf[8];
2009
2010 tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
2012 psr = extract_unsigned_integer (buf, 4, byte_order);
2013 tstate |= (psr & PSR_ICC) << 12;
2014 if ((psr & (PSR_VERS | PSR_IMPL)) == PSR_V8PLUS)
2015 tstate |= (psr & PSR_XCC) << 20;
2016 store_unsigned_integer (buf, 8, byte_order, tstate);
2017 memcpy (regs + offset, buf, 8);
2018 }
2019
2020 if (regnum == SPARC32_PC_REGNUM || regnum == -1)
2022 regs + gregmap->r_pc_offset + 4);
2023
2024 if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
2026 regs + gregmap->r_npc_offset + 4);
2027
2028 if (regnum == SPARC32_Y_REGNUM || regnum == -1)
2029 {
2030 int offset = gregmap->r_y_offset + 8 - gregmap->r_y_size;
2031 regcache->raw_collect (SPARC32_Y_REGNUM, regs + offset);
2032 }
2033 }
2034 else
2035 {
2036 if (regnum == SPARC64_STATE_REGNUM || regnum == -1)
2038 regs + gregmap->r_tstate_offset);
2039
2040 if (regnum == SPARC64_PC_REGNUM || regnum == -1)
2042 regs + gregmap->r_pc_offset);
2043
2044 if (regnum == SPARC64_NPC_REGNUM || regnum == -1)
2046 regs + gregmap->r_npc_offset);
2047
2048 if (regnum == SPARC64_Y_REGNUM || regnum == -1)
2049 {
2050 gdb_byte buf[8];
2051
2053 memcpy (regs + gregmap->r_y_offset,
2054 buf + 8 - gregmap->r_y_size, gregmap->r_y_size);
2055 }
2056
2057 if ((regnum == SPARC64_FPRS_REGNUM || regnum == -1)
2058 && gregmap->r_fprs_offset != -1)
2060 regs + gregmap->r_fprs_offset);
2061
2062 }
2063
2064 if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
2065 {
2066 int offset = gregmap->r_g1_offset;
2067
2068 if (sparc32)
2069 offset += 4;
2070
2071 /* %g0 is always zero. */
2072 for (i = SPARC_G1_REGNUM; i <= SPARC_O7_REGNUM; i++)
2073 {
2074 if (regnum == i || regnum == -1)
2075 regcache->raw_collect (i, regs + offset);
2076 offset += 8;
2077 }
2078 }
2079
2080 if ((regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) || regnum == -1)
2081 {
2082 /* Not all of the register set variants include Locals and
2083 Inputs. For those that don't, we read them off the stack. */
2084 if (gregmap->r_l0_offset != -1)
2085 {
2086 int offset = gregmap->r_l0_offset;
2087
2088 if (sparc32)
2089 offset += 4;
2090
2091 for (i = SPARC_L0_REGNUM; i <= SPARC_I7_REGNUM; i++)
2092 {
2093 if (regnum == i || regnum == -1)
2094 regcache->raw_collect (i, regs + offset);
2095 offset += 8;
2096 }
2097 }
2098 }
2099}
2100
2101void
2103 struct regcache *regcache,
2104 int regnum, const void *fpregs)
2105{
2106 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
2107 const gdb_byte *regs = (const gdb_byte *) fpregs;
2108 int i;
2109
2110 for (i = 0; i < 32; i++)
2111 {
2112 if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1)
2114 regs + fpregmap->r_f0_offset + (i * 4));
2115 }
2116
2117 if (sparc32)
2118 {
2119 if (regnum == SPARC32_FSR_REGNUM || regnum == -1)
2121 regs + fpregmap->r_fsr_offset);
2122 }
2123 else
2124 {
2125 for (i = 0; i < 16; i++)
2126 {
2127 if (regnum == (SPARC64_F32_REGNUM + i) || regnum == -1)
2129 (SPARC64_F32_REGNUM + i,
2130 regs + fpregmap->r_f0_offset + (32 * 4) + (i * 8));
2131 }
2132
2133 if (regnum == SPARC64_FSR_REGNUM || regnum == -1)
2135 regs + fpregmap->r_fsr_offset);
2136 }
2137}
2138
2139void
2141 const struct regcache *regcache,
2142 int regnum, void *fpregs)
2143{
2144 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
2145 gdb_byte *regs = (gdb_byte *) fpregs;
2146 int i;
2147
2148 for (i = 0; i < 32; i++)
2149 {
2150 if (regnum == (SPARC_F0_REGNUM + i) || regnum == -1)
2152 regs + fpregmap->r_f0_offset + (i * 4));
2153 }
2154
2155 if (sparc32)
2156 {
2157 if (regnum == SPARC32_FSR_REGNUM || regnum == -1)
2159 regs + fpregmap->r_fsr_offset);
2160 }
2161 else
2162 {
2163 for (i = 0; i < 16; i++)
2164 {
2165 if (regnum == (SPARC64_F32_REGNUM + i) || regnum == -1)
2167 (regs + fpregmap->r_f0_offset
2168 + (32 * 4) + (i * 8)));
2169 }
2170
2171 if (regnum == SPARC64_FSR_REGNUM || regnum == -1)
2173 regs + fpregmap->r_fsr_offset);
2174 }
2175}
2176
2178{
2179 0 * 8, /* %f0 */
2180 32 * 8, /* %fsr */
2181};
#define bits(obj, st, fn)
int regnum
struct gdbarch * target_gdbarch(void)
int default_stabs_argument_has_addr(struct gdbarch *gdbarch, struct type *type)
Definition arch-utils.c:327
enum return_value_convention default_gdbarch_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, struct value **read_value, const gdb_byte *writebuf)
int target_auxv_search(const gdb::byte_vector &auxv, target_ops *ops, gdbarch *gdbarch, CORE_ADDR match, CORE_ADDR *valp)
Definition auxv.c:385
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
Definition blockframe.c:373
enum register_status raw_read(int regnum, gdb_byte *buf)
Definition regcache.c:611
enum register_status cooked_read(int regnum, gdb_byte *buf)
Definition regcache.c:698
gdbarch * arch() const
Definition regcache.c:231
void raw_collect(int regnum, void *buf) const override
Definition regcache.c:1127
void raw_supply(int regnum, const void *buf) override
Definition regcache.c:1062
void cooked_write(int regnum, const gdb_byte *buf)
Definition regcache.c:870
void raw_write(int regnum, const gdb_byte *buf)
Definition regcache.c:833
void error_no_arg(const char *why)
Definition cli-cmds.c:206
struct cmd_list_element * cmdlist
Definition cli-cmds.c:87
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition cli-decode.c:294
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:233
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
Definition cli-decode.c:391
int get_number(const char **pp)
Definition cli-utils.c:163
@ class_support
Definition command.h:58
@ no_class
Definition command.h:53
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition corefile.c:347
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition defs.h:515
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:480
#define QUIT
Definition defs.h:187
return_value_convention
Definition defs.h:257
@ RETURN_VALUE_REGISTER_CONVENTION
Definition defs.h:260
@ RETURN_VALUE_STRUCT_CONVENTION
Definition defs.h:267
void dwarf2_frame_set_init_reg(struct gdbarch *gdbarch, void(*init_reg)(struct gdbarch *, int, struct dwarf2_frame_state_reg *, frame_info_ptr))
Definition frame.c:666
@ DWARF2_FRAME_REG_RA_OFFSET
Definition frame.h:62
@ DWARF2_FRAME_REG_SAME_VALUE
Definition frame.h:52
@ DWARF2_FRAME_REG_CFA
Definition frame.h:63
LONGEST parse_and_eval_long(const char *exp)
Definition eval.c:62
CORE_ADDR parse_and_eval_address(const char *exp)
Definition eval.c:52
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
Definition frame-base.c:93
int default_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **this_prologue_cache)
struct value * frame_unwind_got_memory(frame_info_ptr frame, int regnum, CORE_ADDR addr)
struct value * frame_unwind_got_register(frame_info_ptr frame, int regnum, int new_regnum)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
struct value * frame_unwind_got_constant(frame_info_ptr frame, int regnum, ULONGEST val)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
ULONGEST get_frame_register_unsigned(frame_info_ptr frame, int regnum)
Definition frame.c:1399
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:736
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
ULONGEST get_frame_memory_unsigned(frame_info_ptr this_frame, CORE_ADDR addr, int len)
Definition frame.c:3007
@ NORMAL_FRAME
Definition frame.h:187
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
Definition gdbarch.c:1493
void set_gdbarch_return_value_as_value(struct gdbarch *gdbarch, gdbarch_return_value_as_value_ftype *return_value_as_value)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1396
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue)
void set_gdbarch_addr_bits_remove(struct gdbarch *gdbarch, gdbarch_addr_bits_remove_ftype *addr_bits_remove)
void set_gdbarch_wchar_bit(struct gdbarch *gdbarch, int wchar_bit)
Definition gdbarch.c:1680
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name)
void set_gdbarch_push_dummy_code(struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype *push_dummy_code)
void set_gdbarch_stabs_argument_has_addr(struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value)
void set_gdbarch_wchar_signed(struct gdbarch *gdbarch, int wchar_signed)
Definition gdbarch.c:1698
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition gdbarch.c:1930
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
Definition gdbarch.c:2064
void set_gdbarch_call_dummy_location(struct gdbarch *gdbarch, enum call_dummy_location_type call_dummy_location)
Definition gdbarch.c:2279
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type)
const struct target_desc * gdbarch_target_desc(struct gdbarch *gdbarch)
Definition gdbarch.c:1423
void set_gdbarch_stack_frame_destroyed_p(struct gdbarch *gdbarch, gdbarch_stack_frame_destroyed_p_ftype *stack_frame_destroyed_p)
void set_gdbarch_pseudo_register_write(struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype *pseudo_register_write)
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
Definition gdbarch.c:1958
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
Definition gdbarch.c:1476
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
Definition gdbarch.c:1732
void set_gdbarch_pseudo_register_read(struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype *pseudo_register_read)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition gdbarch.c:1941
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1722
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call)
@ AT_ENTRY_POINT
Definition gdbarch.h:158
function_call_return_method
Definition gdbarch.h:114
@ return_method_struct
Definition gdbarch.h:126
struct type * lookup_pointer_type(struct type *type)
Definition gdbtypes.c:430
void append_flags_type_flag(struct type *type, int bitpos, const char *name)
Definition gdbtypes.c:5723
struct type * arch_flags_type(struct gdbarch *gdbarch, const char *name, int bit)
Definition gdbtypes.c:5681
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition gdbtypes.c:6168
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:2966
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:1791
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
Definition gnu-nat.c:1790
size_t size
Definition go32-nat.c:239
ptid_t inferior_ptid
Definition infcmd.c:74
static CORE_ADDR next_address
Definition printcmd.c:82
int value
Definition py-param.c:79
enum register_status regcache_raw_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition regcache.c:649
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition regcache.c:796
void regcache_raw_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition regcache.c:677
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition regcache.c:825
enum var_types type
Definition scm-param.c:142
void sparc_supply_rwindow(struct regcache *regcache, CORE_ADDR sp, int regnum)
struct sparc_frame_cache * sparc_frame_cache(frame_info_ptr this_frame, void **this_cache)
CORE_ADDR sparc_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct sparc_frame_cache *cache)
Definition sparc-tdep.c:983
int sparc_stack_frame_destroyed_p(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition sparc-tdep.c:554
ULONGEST sparc_fetch_wcookie(struct gdbarch *gdbarch)
Definition sparc-tdep.c:185
#define BIAS
Definition sparc-tdep.c:68
@ SPARC32_NPC_REGNUM
Definition sparc-tdep.h:156
@ SPARC32_FSR_REGNUM
Definition sparc-tdep.h:157
@ SPARC32_PSR_REGNUM
Definition sparc-tdep.h:152
@ SPARC32_PC_REGNUM
Definition sparc-tdep.h:155
@ SPARC32_Y_REGNUM
Definition sparc-tdep.h:150
@ SPARC_FP_REGNUM
Definition sparc-tdep.h:134
@ SPARC_O0_REGNUM
Definition sparc-tdep.h:112
@ SPARC_G0_REGNUM
Definition sparc-tdep.h:104
@ SPARC_G1_REGNUM
Definition sparc-tdep.h:105
@ SPARC_L0_REGNUM
Definition sparc-tdep.h:120
@ SPARC_I0_REGNUM
Definition sparc-tdep.h:128
@ SPARC_F0_REGNUM
Definition sparc-tdep.h:136
@ SPARC_I7_REGNUM
Definition sparc-tdep.h:135
@ SPARC_F1_REGNUM
Definition sparc-tdep.h:137
@ SPARC_F31_REGNUM
Definition sparc-tdep.h:144
@ SPARC_O7_REGNUM
Definition sparc-tdep.h:119
@ SPARC_SP_REGNUM
Definition sparc-tdep.h:118
#define SPARC_CORE_REGISTERS
Definition sparc-tdep.h:25
#define PSR_XCC
static int sparc64_integral_or_pointer_p(const struct type *type)
static const struct frame_unwind sparc64_frame_unwind
static CORE_ADDR sparc64_store_arguments(struct regcache *regcache, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr)
static void sparc64_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
#define AT_ADI_BLKSZ
static int adi_convert_byte_count(CORE_ADDR naddr, int nbytes, CORE_ADDR locl)
static CORE_ADDR adi_align_address(CORE_ADDR naddr)
static void adi_examine_command(const char *args, int from_tty)
static const char *const sparc64_pseudo_register_names[]
void sparc64_supply_gregset(const struct sparc_gregmap *gregmap, struct regcache *regcache, int regnum, const void *gregs)
void _initialize_sparc64_adi_tdep()
static void adi_assign_command(const char *args, int from_tty)
void sparc64_supply_fpregset(const struct sparc_fpregmap *fpregmap, struct regcache *regcache, int regnum, const void *fpregs)
#define PSR_IMPL
#define AT_ADI_NBITS
static struct type * sparc64_ccr_type(struct gdbarch *gdbarch)
static void do_examine(CORE_ADDR start, int bcnt)
static struct sparc_frame_cache * sparc64_frame_cache(frame_info_ptr this_frame, void **this_cache)
void sparc64_collect_fpregset(const struct sparc_fpregmap *fpregmap, const struct regcache *regcache, int regnum, void *fpregs)
static void read_maps_entry(const char *line, ULONGEST *addr, ULONGEST *endaddr)
static const char *const sparc64_cp0_register_names[]
static struct type * sparc64_fprs_type(struct gdbarch *gdbarch)
#define MAX_PROC_NAME_SIZE
static void sparc64_store_floating_fields(struct regcache *regcache, struct type *type, const gdb_byte *valbuf, int element, int bitpos)
void sparc64_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static const char * sparc64_pseudo_register_name(struct gdbarch *gdbarch, int regnum)
static void sparc64_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
const struct sparc_fpregmap sparc64_bsd_fpregmap
static int sparc64_complex_floating_p(const struct type *type)
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, function_call_return_method return_method, CORE_ADDR struct_addr)
static CORE_ADDR adi_normalize_address(CORE_ADDR addr)
static CORE_ADDR sparc64_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
static int adi_read_versions(CORE_ADDR vaddr, size_t size, gdb_byte *tags)
static void do_assign(CORE_ADDR start, size_t bcnt, int version)
static const char *const sparc64_fpu_register_names[]
static const char *const sparc64_register_names[]
#define PSR_VERS
#define TSTATE_CWP
static struct type * sparc64_pseudo_register_type(struct gdbarch *gdbarch, int regnum)
static int sparc64_structure_or_union_p(const struct type *type)
static const char * sparc64_register_name(struct gdbarch *gdbarch, int regnum)
static void sparc64_frame_this_id(frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id)
static enum register_status sparc64_pseudo_register_read(struct gdbarch *gdbarch, readable_regcache *regcache, int regnum, gdb_byte *buf)
static void sparc64_extract_floating_fields(struct regcache *regcache, struct type *type, gdb_byte *valbuf, int bitpos)
#define SPARC64_NUM_REGS
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)
static int adi_write_versions(CORE_ADDR vaddr, size_t size, unsigned char *tags)
static struct type * sparc64_fsr_type(struct gdbarch *gdbarch)
#define TSTATE_ICC
static CORE_ADDR sparc64_frame_align(struct gdbarch *gdbarch, CORE_ADDR address)
static CORE_ADDR sparc64_addr_bits_remove(struct gdbarch *gdbarch, CORE_ADDR addr)
static struct value * sparc64_frame_prev_register(frame_info_ptr this_frame, void **this_cache, int regnum)
#define PSR_ICC
static const struct frame_base sparc64_frame_base
#define SPARC64_CP0_REGISTERS
static int sparc64_floating_p(const struct type *type)
static void sparc64_dwarf2_frame_init_reg(struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, frame_info_ptr this_frame)
#define SPARC64_FPU_REGISTERS
static bool adi_is_addr_mapped(CORE_ADDR vaddr, size_t cnt)
static struct cmd_list_element * sparc64adilist
#define SPARC64_NUM_PSEUDO_REGS
static struct type * sparc64_pstate_type(struct gdbarch *gdbarch)
static CORE_ADDR sparc64_frame_base_address(frame_info_ptr this_frame, void **this_cache)
#define PSR_S
static std::forward_list< sparc64_adi_info > adi_proc_list
static int sparc64_16_byte_align_p(struct type *type)
static sparc64_adi_info * get_adi_info_proc(pid_t pid)
#define PSR_V8PLUS
static adi_stat_t get_adi_info(pid_t pid)
void sparc64_forget_process(pid_t pid)
#define TSTATE_XCC
static void sparc64_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf)
static bool adi_available(void)
static void adi_print_versions(CORE_ADDR vaddr, size_t cnt, gdb_byte *tags)
static struct type * sparc64_register_type(struct gdbarch *gdbarch, int regnum)
static int adi_tag_fd(void)
void sparc64_collect_gregset(const struct sparc_gregmap *gregmap, const struct regcache *regcache, int regnum, void *gregs)
@ SPARC64_D30_REGNUM
@ SPARC64_CWP_REGNUM
@ SPARC64_D10_REGNUM
@ SPARC64_ASI_REGNUM
@ SPARC64_Q60_REGNUM
@ SPARC64_Q28_REGNUM
@ SPARC64_Q8_REGNUM
@ SPARC64_CCR_REGNUM
@ SPARC64_Q32_REGNUM
@ SPARC64_Q0_REGNUM
@ SPARC64_D0_REGNUM
@ SPARC64_D32_REGNUM
@ SPARC64_D62_REGNUM
@ SPARC64_PSTATE_REGNUM
@ SPARC64_FSR_REGNUM
@ SPARC64_Y_REGNUM
@ SPARC64_PC_REGNUM
@ SPARC64_F32_REGNUM
@ SPARC64_FPRS_REGNUM
@ SPARC64_NPC_REGNUM
@ SPARC64_STATE_REGNUM
@ SPARC64_F62_REGNUM
bool checked_avail
unsigned long nbits
unsigned long blksize
struct type * builtin_double
Definition gdbtypes.h:2090
struct type * builtin_func_ptr
Definition gdbtypes.h:2146
struct type * builtin_data_ptr
Definition gdbtypes.h:2135
struct type * builtin_long_double
Definition gdbtypes.h:2091
struct type * builtin_int64
Definition gdbtypes.h:2121
struct type * builtin_float
Definition gdbtypes.h:2089
union dwarf2_frame_state_reg::@46 loc
enum dwarf2_frame_reg_rule how
Definition frame.h:86
LONGEST loc_bitpos() const
Definition gdbtypes.h:611
struct type * type() const
Definition gdbtypes.h:547
Definition gnu-nat.h:58
sparc64_adi_info(pid_t pid_)
unsigned char copied_regs_mask
Definition sparc-tdep.h:186
unsigned short int saved_regs_mask
Definition sparc-tdep.h:183
size_t fpu_registers_num
Definition sparc-tdep.h:70
struct type * sparc64_fprs_type
Definition sparc-tdep.h:97
const char *const * fpu_register_names
Definition sparc-tdep.h:69
size_t cp0_registers_num
Definition sparc-tdep.h:72
const char *const * cp0_register_names
Definition sparc-tdep.h:71
struct type * sparc64_pstate_type
Definition sparc-tdep.h:95
struct type * sparc64_ccr_type
Definition sparc-tdep.h:94
struct type * sparc64_fsr_type
Definition sparc-tdep.h:96
CORE_ADDR end
Definition symtab.h:2338
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
struct field & field(int idx) const
Definition gdbtypes.h:1012
unsigned int num_fields() const
Definition gdbtypes.h:994
Definition value.h:130
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition symtab.c:3295
void set_tdesc_pseudo_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name)
int tdesc_has_registers(const struct target_desc *target_desc)
void set_tdesc_pseudo_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type)
struct type * tdesc_register_type(struct gdbarch *gdbarch, int regno)
const char * tdesc_register_name(struct gdbarch *gdbarch, int regno)
int target_fileio_pwrite(int fd, const gdb_byte *write_buf, int len, ULONGEST offset, fileio_error *target_errno)
Definition target.c:3294
gdb::unique_xmalloc_ptr< char > target_fileio_read_stralloc(struct inferior *inf, const char *filename)
Definition target.c:3550
int target_fileio_open(struct inferior *inf, const char *filename, int flags, int mode, bool warn_if_slow, fileio_error *target_errno)
Definition target.c:3260
int target_fileio_close(int fd, fileio_error *target_errno)
Definition target.c:3368
int target_fileio_pread(int fd, gdb_byte *read_buf, int len, ULONGEST offset, fileio_error *target_errno)
Definition target.c:3320
bool target_has_execution(inferior *inf)
Definition target.c:201
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition utils.c:3166
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
struct value * value_cast(struct type *type, struct value *arg2)
Definition valops.c:403
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
Definition value.c:3500
const char version[]
Definition version.c:2