1 /* Target-dependent code for UltraSPARC.
3 Copyright (C) 2003-2017 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
21 #include "arch-utils.h"
22 #include "dwarf2-frame.h"
24 #include "frame-base.h"
25 #include "frame-unwind.h"
33 #include "target-descriptions.h"
37 #include "sparc64-tdep.h"
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
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. */
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
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.
64 Note that 32-bit applications cannot use ADI. */
68 #include "cli/cli-utils.h"
72 #define MAX_PROC_NAME_SIZE sizeof("/proc/99999/lwp/9999/adi/lstatus")
74 /* ELF Auxiliary vectors */
76 #define AT_ADI_BLKSZ 34
79 #define AT_ADI_NBITS 35
81 #ifndef AT_ADI_UEONADI
82 #define AT_ADI_UEONADI 36
85 /* ADI command list. */
86 static struct cmd_list_element
*sparc64adilist
= NULL
;
88 /* ADI stat settings. */
91 /* The ADI block size. */
92 unsigned long blksize
;
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. */
99 /* The maximum ADI version tag value supported. */
102 /* ADI version tag file. */
105 /* ADI availability check has been done. */
106 bool checked_avail
= false;
108 /* ADI is available. */
109 bool is_avail
= false;
113 /* Per-process ADI stat info. */
115 typedef struct sparc64_adi_info
117 sparc64_adi_info (pid_t pid_
)
121 /* The process identifier. */
125 adi_stat_t stat
= {};
129 static std::forward_list
<sparc64_adi_info
> adi_proc_list
;
132 /* Get ADI info for process PID, creating one if it doesn't exist. */
134 static sparc64_adi_info
*
135 get_adi_info_proc (pid_t pid
)
137 auto found
= std::find_if (adi_proc_list
.begin (), adi_proc_list
.end (),
138 [&pid
] (const sparc64_adi_info
&info
)
140 return info
.pid
== pid
;
143 if (found
== adi_proc_list
.end ())
145 adi_proc_list
.emplace_front (pid
);
146 return &adi_proc_list
.front ();
155 get_adi_info (pid_t pid
)
157 sparc64_adi_info
*proc
;
159 proc
= get_adi_info_proc (pid
);
163 /* Is called when GDB is no longer debugging process PID. It
164 deletes data structure that keeps track of the ADI stat. */
167 sparc64_forget_process (pid_t pid
)
171 for (auto pit
= adi_proc_list
.before_begin (),
172 it
= std::next (pit
);
173 it
!= adi_proc_list
.end ();
176 if ((*it
).pid
== pid
)
178 if ((*it
).stat
.tag_fd
> 0)
179 target_fileio_close ((*it
).stat
.tag_fd
, &target_errno
);
180 adi_proc_list
.erase_after (pit
);
190 info_adi_command (const char *args
, int from_tty
)
192 printf_unfiltered ("\"adi\" must be followed by \"examine\" "
194 help_list (sparc64adilist
, "adi ", all_commands
, gdb_stdout
);
197 /* Read attributes of a maps entry in /proc/[pid]/adi/maps. */
200 read_maps_entry (const char *line
,
201 ULONGEST
*addr
, ULONGEST
*endaddr
)
203 const char *p
= line
;
205 *addr
= strtoulst (p
, &p
, 16);
209 *endaddr
= strtoulst (p
, &p
, 16);
212 /* Check if ADI is available. */
217 pid_t pid
= ptid_get_pid (inferior_ptid
);
218 sparc64_adi_info
*proc
= get_adi_info_proc (pid
);
221 if (proc
->stat
.checked_avail
)
222 return proc
->stat
.is_avail
;
224 proc
->stat
.checked_avail
= true;
225 if (target_auxv_search (¤t_target
, AT_ADI_BLKSZ
, &value
) <= 0)
227 proc
->stat
.blksize
= value
;
228 target_auxv_search (¤t_target
, AT_ADI_NBITS
, &value
);
229 proc
->stat
.nbits
= value
;
230 proc
->stat
.max_version
= (1 << proc
->stat
.nbits
) - 2;
231 proc
->stat
.is_avail
= true;
233 return proc
->stat
.is_avail
;
236 /* Normalize a versioned address - a VA with ADI bits (63-60) set. */
239 adi_normalize_address (CORE_ADDR addr
)
241 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
245 /* Clear upper bits. */
246 addr
&= ((uint64_t) -1) >> ast
.nbits
;
249 CORE_ADDR signbit
= (uint64_t) 1 << (64 - ast
.nbits
- 1);
250 return (addr
^ signbit
) - signbit
;
255 /* Align a normalized address - a VA with bit 59 sign extended into
259 adi_align_address (CORE_ADDR naddr
)
261 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
263 return (naddr
- (naddr
% ast
.blksize
)) / ast
.blksize
;
266 /* Convert a byte count to count at a ratio of 1:adi_blksz. */
269 adi_convert_byte_count (CORE_ADDR naddr
, int nbytes
, CORE_ADDR locl
)
271 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
273 return ((naddr
+ nbytes
+ ast
.blksize
- 1) / ast
.blksize
) - locl
;
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.
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. */
288 pid_t pid
= ptid_get_pid (inferior_ptid
);
289 sparc64_adi_info
*proc
= get_adi_info_proc (pid
);
291 if (proc
->stat
.tag_fd
!= 0)
292 return proc
->stat
.tag_fd
;
294 char cl_name
[MAX_PROC_NAME_SIZE
];
295 snprintf (cl_name
, sizeof(cl_name
), "/proc/%ld/adi/tags", (long) pid
);
297 proc
->stat
.tag_fd
= target_fileio_open (NULL
, cl_name
, O_RDWR
|O_EXCL
,
299 return proc
->stat
.tag_fd
;
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. */
307 adi_is_addr_mapped (CORE_ADDR vaddr
, size_t cnt
)
309 char filename
[MAX_PROC_NAME_SIZE
];
312 pid_t pid
= ptid_get_pid (inferior_ptid
);
313 snprintf (filename
, sizeof filename
, "/proc/%ld/adi/maps", (long) pid
);
314 char *data
= target_fileio_read_stralloc (NULL
, filename
);
317 struct cleanup
*cleanup
= make_cleanup (xfree
, data
);
318 adi_stat_t adi_stat
= get_adi_info (pid
);
320 for (line
= strtok (data
, "\n"); line
; line
= strtok (NULL
, "\n"))
322 ULONGEST addr
, endaddr
;
324 read_maps_entry (line
, &addr
, &endaddr
);
326 while (((vaddr
+ i
) * adi_stat
.blksize
) >= addr
327 && ((vaddr
+ i
) * adi_stat
.blksize
) < endaddr
)
331 do_cleanups (cleanup
);
336 do_cleanups (cleanup
);
339 warning (_("unable to open /proc file '%s'"), filename
);
344 /* Read ADI version tag value for memory locations starting at "VADDR"
345 for "SIZE" number of bytes. */
348 adi_read_versions (CORE_ADDR vaddr
, size_t size
, unsigned char *tags
)
350 int fd
= adi_tag_fd ();
354 if (!adi_is_addr_mapped (vaddr
, size
))
356 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
357 error(_("Address at %s is not in ADI maps"),
358 paddress (target_gdbarch (), vaddr
* ast
.blksize
));
362 return target_fileio_pread (fd
, tags
, size
, vaddr
, &target_errno
);
365 /* Write ADI version tag for memory locations starting at "VADDR" for
366 "SIZE" number of bytes to "TAGS". */
369 adi_write_versions (CORE_ADDR vaddr
, size_t size
, unsigned char *tags
)
371 int fd
= adi_tag_fd ();
375 if (!adi_is_addr_mapped (vaddr
, size
))
377 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
378 error(_("Address at %s is not in ADI maps"),
379 paddress (target_gdbarch (), vaddr
* ast
.blksize
));
383 return target_fileio_pwrite (fd
, tags
, size
, vaddr
, &target_errno
);
386 /* Print ADI version tag value in "TAGS" for memory locations starting
387 at "VADDR" with number of "CNT". */
390 adi_print_versions (CORE_ADDR vaddr
, size_t cnt
, unsigned char *tags
)
393 const int maxelts
= 8; /* # of elements per line */
395 adi_stat_t adi_stat
= get_adi_info (ptid_get_pid (inferior_ptid
));
400 printf_filtered ("%s:\t",
401 paddress (target_gdbarch (), vaddr
* adi_stat
.blksize
));
402 for (int i
= maxelts
; i
> 0 && cnt
> 0; i
--, cnt
--)
404 if (tags
[v_idx
] == 0xff) /* no version tag */
405 printf_filtered ("-");
407 printf_filtered ("%1X", tags
[v_idx
]);
409 printf_filtered (" ");
412 printf_filtered ("\n");
413 gdb_flush (gdb_stdout
);
419 do_examine (CORE_ADDR start
, int bcnt
)
421 CORE_ADDR vaddr
= adi_normalize_address (start
);
422 struct cleanup
*cleanup
;
424 CORE_ADDR vstart
= adi_align_address (vaddr
);
425 int cnt
= adi_convert_byte_count (vaddr
, bcnt
, vstart
);
426 unsigned char *buf
= (unsigned char *) xmalloc (cnt
);
427 cleanup
= make_cleanup (xfree
, buf
);
428 int read_cnt
= adi_read_versions (vstart
, cnt
, buf
);
430 error (_("No ADI information"));
431 else if (read_cnt
< cnt
)
432 error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr
));
434 adi_print_versions (vstart
, cnt
, buf
);
436 do_cleanups (cleanup
);
440 do_assign (CORE_ADDR start
, size_t bcnt
, int version
)
442 CORE_ADDR vaddr
= adi_normalize_address (start
);
444 CORE_ADDR vstart
= adi_align_address (vaddr
);
445 int cnt
= adi_convert_byte_count (vaddr
, bcnt
, vstart
);
446 std::vector
<unsigned char> buf (cnt
, version
);
447 int set_cnt
= adi_write_versions (vstart
, cnt
, buf
.data ());
450 error (_("No ADI information"));
451 else if (set_cnt
< cnt
)
452 error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr
));
456 /* ADI examine version tag command.
460 adi (examine|x)/count <addr> */
463 adi_examine_command (char *args
, int from_tty
)
465 /* make sure program is active and adi is available */
466 if (!target_has_execution
)
467 error (_("ADI command requires a live process/thread"));
469 if (!adi_available ())
470 error (_("No ADI information"));
472 pid_t pid
= ptid_get_pid (inferior_ptid
);
473 sparc64_adi_info
*proc
= get_adi_info_proc (pid
);
479 cnt
= get_number (&p
);
482 CORE_ADDR next_address
= 0;
483 if (p
!= 0 && *p
!= 0)
484 next_address
= parse_and_eval_address (p
);
485 if (!cnt
|| !next_address
)
486 error (_("Usage: adi examine|x[/count] <addr>"));
488 do_examine (next_address
, cnt
);
491 /* ADI assign version tag command.
495 adi (assign|a)/count <addr> = <version> */
498 adi_assign_command (char *args
, int from_tty
)
500 /* make sure program is active and adi is available */
501 if (!target_has_execution
)
502 error (_("ADI command requires a live process/thread"));
504 if (!adi_available ())
505 error (_("No ADI information"));
509 error_no_arg (_("Usage: adi assign|a[/count] <addr> = <version>"));
511 char *q
= (char *) strchr (exp
, '=');
515 error (_("Usage: adi assign|a[/count] <addr> = <version>"));
519 if (exp
&& *exp
== '/')
522 cnt
= get_number (&p
);
525 CORE_ADDR next_address
= 0;
526 if (p
!= 0 && *p
!= 0)
527 next_address
= parse_and_eval_address (p
);
529 error (_("Usage: adi assign|a[/count] <addr> = <version>"));
532 if (q
!= NULL
) /* parse version tag */
534 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
535 version
= parse_and_eval_long (q
);
536 if (version
< 0 || version
> ast
.max_version
)
537 error (_("Invalid ADI version tag %d"), version
);
540 do_assign (next_address
, cnt
, version
);
544 _initialize_sparc64_adi_tdep (void)
547 add_prefix_cmd ("adi", class_support
, info_adi_command
,
548 _("ADI version related commands."),
549 &sparc64adilist
, "adi ", 0, &cmdlist
);
550 add_cmd ("examine", class_support
, adi_examine_command
,
551 _("Examine ADI versions."), &sparc64adilist
);
552 add_alias_cmd ("x", "examine", no_class
, 1, &sparc64adilist
);
553 add_cmd ("assign", class_support
, adi_assign_command
,
554 _("Assign ADI versions."), &sparc64adilist
);
559 /* The functions on this page are intended to be used to classify
560 function arguments. */
562 /* Check whether TYPE is "Integral or Pointer". */
565 sparc64_integral_or_pointer_p (const struct type
*type
)
567 switch (TYPE_CODE (type
))
573 case TYPE_CODE_RANGE
:
575 int len
= TYPE_LENGTH (type
);
576 gdb_assert (len
== 1 || len
== 2 || len
== 4 || len
== 8);
581 case TYPE_CODE_RVALUE_REF
:
583 int len
= TYPE_LENGTH (type
);
584 gdb_assert (len
== 8);
594 /* Check whether TYPE is "Floating". */
597 sparc64_floating_p (const struct type
*type
)
599 switch (TYPE_CODE (type
))
603 int len
= TYPE_LENGTH (type
);
604 gdb_assert (len
== 4 || len
== 8 || len
== 16);
614 /* Check whether TYPE is "Complex Floating". */
617 sparc64_complex_floating_p (const struct type
*type
)
619 switch (TYPE_CODE (type
))
621 case TYPE_CODE_COMPLEX
:
623 int len
= TYPE_LENGTH (type
);
624 gdb_assert (len
== 8 || len
== 16 || len
== 32);
634 /* Check whether TYPE is "Structure or Union".
636 In terms of Ada subprogram calls, arrays are treated the same as
637 struct and union types. So this function also returns non-zero
641 sparc64_structure_or_union_p (const struct type
*type
)
643 switch (TYPE_CODE (type
))
645 case TYPE_CODE_STRUCT
:
646 case TYPE_CODE_UNION
:
647 case TYPE_CODE_ARRAY
:
657 /* Construct types for ISA-specific registers. */
660 sparc64_pstate_type (struct gdbarch
*gdbarch
)
662 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
664 if (!tdep
->sparc64_pstate_type
)
668 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_pstate", 64);
669 append_flags_type_flag (type
, 0, "AG");
670 append_flags_type_flag (type
, 1, "IE");
671 append_flags_type_flag (type
, 2, "PRIV");
672 append_flags_type_flag (type
, 3, "AM");
673 append_flags_type_flag (type
, 4, "PEF");
674 append_flags_type_flag (type
, 5, "RED");
675 append_flags_type_flag (type
, 8, "TLE");
676 append_flags_type_flag (type
, 9, "CLE");
677 append_flags_type_flag (type
, 10, "PID0");
678 append_flags_type_flag (type
, 11, "PID1");
680 tdep
->sparc64_pstate_type
= type
;
683 return tdep
->sparc64_pstate_type
;
687 sparc64_ccr_type (struct gdbarch
*gdbarch
)
689 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
691 if (tdep
->sparc64_ccr_type
== NULL
)
695 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_ccr", 64);
696 append_flags_type_flag (type
, 0, "icc.c");
697 append_flags_type_flag (type
, 1, "icc.v");
698 append_flags_type_flag (type
, 2, "icc.z");
699 append_flags_type_flag (type
, 3, "icc.n");
700 append_flags_type_flag (type
, 4, "xcc.c");
701 append_flags_type_flag (type
, 5, "xcc.v");
702 append_flags_type_flag (type
, 6, "xcc.z");
703 append_flags_type_flag (type
, 7, "xcc.n");
705 tdep
->sparc64_ccr_type
= type
;
708 return tdep
->sparc64_ccr_type
;
712 sparc64_fsr_type (struct gdbarch
*gdbarch
)
714 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
716 if (!tdep
->sparc64_fsr_type
)
720 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_fsr", 64);
721 append_flags_type_flag (type
, 0, "NXC");
722 append_flags_type_flag (type
, 1, "DZC");
723 append_flags_type_flag (type
, 2, "UFC");
724 append_flags_type_flag (type
, 3, "OFC");
725 append_flags_type_flag (type
, 4, "NVC");
726 append_flags_type_flag (type
, 5, "NXA");
727 append_flags_type_flag (type
, 6, "DZA");
728 append_flags_type_flag (type
, 7, "UFA");
729 append_flags_type_flag (type
, 8, "OFA");
730 append_flags_type_flag (type
, 9, "NVA");
731 append_flags_type_flag (type
, 22, "NS");
732 append_flags_type_flag (type
, 23, "NXM");
733 append_flags_type_flag (type
, 24, "DZM");
734 append_flags_type_flag (type
, 25, "UFM");
735 append_flags_type_flag (type
, 26, "OFM");
736 append_flags_type_flag (type
, 27, "NVM");
738 tdep
->sparc64_fsr_type
= type
;
741 return tdep
->sparc64_fsr_type
;
745 sparc64_fprs_type (struct gdbarch
*gdbarch
)
747 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
749 if (!tdep
->sparc64_fprs_type
)
753 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_fprs", 64);
754 append_flags_type_flag (type
, 0, "DL");
755 append_flags_type_flag (type
, 1, "DU");
756 append_flags_type_flag (type
, 2, "FEF");
758 tdep
->sparc64_fprs_type
= type
;
761 return tdep
->sparc64_fprs_type
;
765 /* Register information. */
766 #define SPARC64_FPU_REGISTERS \
767 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
768 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
769 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
770 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
771 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
772 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62"
773 #define SPARC64_CP0_REGISTERS \
775 /* FIXME: Give "state" a name until we start using register groups. */ \
781 static const char *sparc64_fpu_register_names
[] = { SPARC64_FPU_REGISTERS
};
782 static const char *sparc64_cp0_register_names
[] = { SPARC64_CP0_REGISTERS
};
784 static const char *sparc64_register_names
[] =
786 SPARC_CORE_REGISTERS
,
787 SPARC64_FPU_REGISTERS
,
788 SPARC64_CP0_REGISTERS
791 /* Total number of registers. */
792 #define SPARC64_NUM_REGS ARRAY_SIZE (sparc64_register_names)
794 /* We provide the aliases %d0..%d62 and %q0..%q60 for the floating
795 registers as "psuedo" registers. */
797 static const char *sparc64_pseudo_register_names
[] =
799 "cwp", "pstate", "asi", "ccr",
801 "d0", "d2", "d4", "d6", "d8", "d10", "d12", "d14",
802 "d16", "d18", "d20", "d22", "d24", "d26", "d28", "d30",
803 "d32", "d34", "d36", "d38", "d40", "d42", "d44", "d46",
804 "d48", "d50", "d52", "d54", "d56", "d58", "d60", "d62",
806 "q0", "q4", "q8", "q12", "q16", "q20", "q24", "q28",
807 "q32", "q36", "q40", "q44", "q48", "q52", "q56", "q60",
810 /* Total number of pseudo registers. */
811 #define SPARC64_NUM_PSEUDO_REGS ARRAY_SIZE (sparc64_pseudo_register_names)
813 /* Return the name of pseudo register REGNUM. */
816 sparc64_pseudo_register_name (struct gdbarch
*gdbarch
, int regnum
)
818 regnum
-= gdbarch_num_regs (gdbarch
);
820 if (regnum
< SPARC64_NUM_PSEUDO_REGS
)
821 return sparc64_pseudo_register_names
[regnum
];
823 internal_error (__FILE__
, __LINE__
,
824 _("sparc64_pseudo_register_name: bad register number %d"),
828 /* Return the name of register REGNUM. */
831 sparc64_register_name (struct gdbarch
*gdbarch
, int regnum
)
833 if (tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
834 return tdesc_register_name (gdbarch
, regnum
);
836 if (regnum
>= 0 && regnum
< gdbarch_num_regs (gdbarch
))
837 return sparc64_register_names
[regnum
];
839 return sparc64_pseudo_register_name (gdbarch
, regnum
);
842 /* Return the GDB type object for the "standard" data type of data in
843 pseudo register REGNUM. */
846 sparc64_pseudo_register_type (struct gdbarch
*gdbarch
, int regnum
)
848 regnum
-= gdbarch_num_regs (gdbarch
);
850 if (regnum
== SPARC64_CWP_REGNUM
)
851 return builtin_type (gdbarch
)->builtin_int64
;
852 if (regnum
== SPARC64_PSTATE_REGNUM
)
853 return sparc64_pstate_type (gdbarch
);
854 if (regnum
== SPARC64_ASI_REGNUM
)
855 return builtin_type (gdbarch
)->builtin_int64
;
856 if (regnum
== SPARC64_CCR_REGNUM
)
857 return sparc64_ccr_type (gdbarch
);
858 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
859 return builtin_type (gdbarch
)->builtin_double
;
860 if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
861 return builtin_type (gdbarch
)->builtin_long_double
;
863 internal_error (__FILE__
, __LINE__
,
864 _("sparc64_pseudo_register_type: bad register number %d"),
868 /* Return the GDB type object for the "standard" data type of data in
872 sparc64_register_type (struct gdbarch
*gdbarch
, int regnum
)
874 if (tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
875 return tdesc_register_type (gdbarch
, regnum
);
878 if (regnum
== SPARC_SP_REGNUM
|| regnum
== SPARC_FP_REGNUM
)
879 return builtin_type (gdbarch
)->builtin_data_ptr
;
880 if (regnum
>= SPARC_G0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
)
881 return builtin_type (gdbarch
)->builtin_int64
;
882 if (regnum
>= SPARC_F0_REGNUM
&& regnum
<= SPARC_F31_REGNUM
)
883 return builtin_type (gdbarch
)->builtin_float
;
884 if (regnum
>= SPARC64_F32_REGNUM
&& regnum
<= SPARC64_F62_REGNUM
)
885 return builtin_type (gdbarch
)->builtin_double
;
886 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
887 return builtin_type (gdbarch
)->builtin_func_ptr
;
888 /* This raw register contains the contents of %cwp, %pstate, %asi
889 and %ccr as laid out in a %tstate register. */
890 if (regnum
== SPARC64_STATE_REGNUM
)
891 return builtin_type (gdbarch
)->builtin_int64
;
892 if (regnum
== SPARC64_FSR_REGNUM
)
893 return sparc64_fsr_type (gdbarch
);
894 if (regnum
== SPARC64_FPRS_REGNUM
)
895 return sparc64_fprs_type (gdbarch
);
896 /* "Although Y is a 64-bit register, its high-order 32 bits are
897 reserved and always read as 0." */
898 if (regnum
== SPARC64_Y_REGNUM
)
899 return builtin_type (gdbarch
)->builtin_int64
;
901 /* Pseudo registers. */
902 if (regnum
>= gdbarch_num_regs (gdbarch
))
903 return sparc64_pseudo_register_type (gdbarch
, regnum
);
905 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
908 static enum register_status
909 sparc64_pseudo_register_read (struct gdbarch
*gdbarch
,
910 struct regcache
*regcache
,
911 int regnum
, gdb_byte
*buf
)
913 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
914 enum register_status status
;
916 regnum
-= gdbarch_num_regs (gdbarch
);
918 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
920 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
921 status
= regcache_raw_read (regcache
, regnum
, buf
);
922 if (status
== REG_VALID
)
923 status
= regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
926 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
928 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
929 return regcache_raw_read (regcache
, regnum
, buf
);
931 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
933 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
935 status
= regcache_raw_read (regcache
, regnum
, buf
);
936 if (status
== REG_VALID
)
937 status
= regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
938 if (status
== REG_VALID
)
939 status
= regcache_raw_read (regcache
, regnum
+ 2, buf
+ 8);
940 if (status
== REG_VALID
)
941 status
= regcache_raw_read (regcache
, regnum
+ 3, buf
+ 12);
945 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
947 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
949 status
= regcache_raw_read (regcache
, regnum
, buf
);
950 if (status
== REG_VALID
)
951 status
= regcache_raw_read (regcache
, regnum
+ 1, buf
+ 8);
955 else if (regnum
== SPARC64_CWP_REGNUM
956 || regnum
== SPARC64_PSTATE_REGNUM
957 || regnum
== SPARC64_ASI_REGNUM
958 || regnum
== SPARC64_CCR_REGNUM
)
962 status
= regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
963 if (status
!= REG_VALID
)
968 case SPARC64_CWP_REGNUM
:
969 state
= (state
>> 0) & ((1 << 5) - 1);
971 case SPARC64_PSTATE_REGNUM
:
972 state
= (state
>> 8) & ((1 << 12) - 1);
974 case SPARC64_ASI_REGNUM
:
975 state
= (state
>> 24) & ((1 << 8) - 1);
977 case SPARC64_CCR_REGNUM
:
978 state
= (state
>> 32) & ((1 << 8) - 1);
981 store_unsigned_integer (buf
, 8, byte_order
, state
);
988 sparc64_pseudo_register_write (struct gdbarch
*gdbarch
,
989 struct regcache
*regcache
,
990 int regnum
, const gdb_byte
*buf
)
992 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
994 regnum
-= gdbarch_num_regs (gdbarch
);
996 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
998 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
999 regcache_raw_write (regcache
, regnum
, buf
);
1000 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
1002 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
1004 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
1005 regcache_raw_write (regcache
, regnum
, buf
);
1007 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
1009 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
1010 regcache_raw_write (regcache
, regnum
, buf
);
1011 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
1012 regcache_raw_write (regcache
, regnum
+ 2, buf
+ 8);
1013 regcache_raw_write (regcache
, regnum
+ 3, buf
+ 12);
1015 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
1017 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
1018 regcache_raw_write (regcache
, regnum
, buf
);
1019 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 8);
1021 else if (regnum
== SPARC64_CWP_REGNUM
1022 || regnum
== SPARC64_PSTATE_REGNUM
1023 || regnum
== SPARC64_ASI_REGNUM
1024 || regnum
== SPARC64_CCR_REGNUM
)
1026 ULONGEST state
, bits
;
1028 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
1029 bits
= extract_unsigned_integer (buf
, 8, byte_order
);
1032 case SPARC64_CWP_REGNUM
:
1033 state
|= ((bits
& ((1 << 5) - 1)) << 0);
1035 case SPARC64_PSTATE_REGNUM
:
1036 state
|= ((bits
& ((1 << 12) - 1)) << 8);
1038 case SPARC64_ASI_REGNUM
:
1039 state
|= ((bits
& ((1 << 8) - 1)) << 24);
1041 case SPARC64_CCR_REGNUM
:
1042 state
|= ((bits
& ((1 << 8) - 1)) << 32);
1045 regcache_raw_write_unsigned (regcache
, SPARC64_STATE_REGNUM
, state
);
1050 /* Return PC of first real instruction of the function starting at
1054 sparc64_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR start_pc
)
1056 struct symtab_and_line sal
;
1057 CORE_ADDR func_start
, func_end
;
1058 struct sparc_frame_cache cache
;
1060 /* This is the preferred method, find the end of the prologue by
1061 using the debugging information. */
1062 if (find_pc_partial_function (start_pc
, NULL
, &func_start
, &func_end
))
1064 sal
= find_pc_line (func_start
, 0);
1066 if (sal
.end
< func_end
1067 && start_pc
<= sal
.end
)
1071 return sparc_analyze_prologue (gdbarch
, start_pc
, 0xffffffffffffffffULL
,
1075 /* Normal frames. */
1077 static struct sparc_frame_cache
*
1078 sparc64_frame_cache (struct frame_info
*this_frame
, void **this_cache
)
1080 return sparc_frame_cache (this_frame
, this_cache
);
1084 sparc64_frame_this_id (struct frame_info
*this_frame
, void **this_cache
,
1085 struct frame_id
*this_id
)
1087 struct sparc_frame_cache
*cache
=
1088 sparc64_frame_cache (this_frame
, this_cache
);
1090 /* This marks the outermost frame. */
1091 if (cache
->base
== 0)
1094 (*this_id
) = frame_id_build (cache
->base
, cache
->pc
);
1097 static struct value
*
1098 sparc64_frame_prev_register (struct frame_info
*this_frame
, void **this_cache
,
1101 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1102 struct sparc_frame_cache
*cache
=
1103 sparc64_frame_cache (this_frame
, this_cache
);
1105 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
1107 CORE_ADDR pc
= (regnum
== SPARC64_NPC_REGNUM
) ? 4 : 0;
1110 (cache
->copied_regs_mask
& 0x80) ? SPARC_I7_REGNUM
: SPARC_O7_REGNUM
;
1111 pc
+= get_frame_register_unsigned (this_frame
, regnum
) + 8;
1112 return frame_unwind_got_constant (this_frame
, regnum
, pc
);
1115 /* Handle StackGhost. */
1117 ULONGEST wcookie
= sparc_fetch_wcookie (gdbarch
);
1119 if (wcookie
!= 0 && !cache
->frameless_p
&& regnum
== SPARC_I7_REGNUM
)
1121 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
1124 /* Read the value in from memory. */
1125 i7
= get_frame_memory_unsigned (this_frame
, addr
, 8);
1126 return frame_unwind_got_constant (this_frame
, regnum
, i7
^ wcookie
);
1130 /* The previous frame's `local' and `in' registers may have been saved
1131 in the register save area. */
1132 if (regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
1133 && (cache
->saved_regs_mask
& (1 << (regnum
- SPARC_L0_REGNUM
))))
1135 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
1137 return frame_unwind_got_memory (this_frame
, regnum
, addr
);
1140 /* The previous frame's `out' registers may be accessible as the current
1141 frame's `in' registers. */
1142 if (regnum
>= SPARC_O0_REGNUM
&& regnum
<= SPARC_O7_REGNUM
1143 && (cache
->copied_regs_mask
& (1 << (regnum
- SPARC_O0_REGNUM
))))
1144 regnum
+= (SPARC_I0_REGNUM
- SPARC_O0_REGNUM
);
1146 return frame_unwind_got_register (this_frame
, regnum
, regnum
);
1149 static const struct frame_unwind sparc64_frame_unwind
=
1152 default_frame_unwind_stop_reason
,
1153 sparc64_frame_this_id
,
1154 sparc64_frame_prev_register
,
1156 default_frame_sniffer
1161 sparc64_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
1163 struct sparc_frame_cache
*cache
=
1164 sparc64_frame_cache (this_frame
, this_cache
);
1169 static const struct frame_base sparc64_frame_base
=
1171 &sparc64_frame_unwind
,
1172 sparc64_frame_base_address
,
1173 sparc64_frame_base_address
,
1174 sparc64_frame_base_address
1177 /* Check whether TYPE must be 16-byte aligned. */
1180 sparc64_16_byte_align_p (struct type
*type
)
1182 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1184 struct type
*t
= check_typedef (TYPE_TARGET_TYPE (type
));
1186 if (sparc64_floating_p (t
))
1189 if (sparc64_floating_p (type
) && TYPE_LENGTH (type
) == 16)
1192 if (sparc64_structure_or_union_p (type
))
1196 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
1198 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
1200 if (sparc64_16_byte_align_p (subtype
))
1208 /* Store floating fields of element ELEMENT of an "parameter array"
1209 that has type TYPE and is stored at BITPOS in VALBUF in the
1210 apropriate registers of REGCACHE. This function can be called
1211 recursively and therefore handles floating types in addition to
1215 sparc64_store_floating_fields (struct regcache
*regcache
, struct type
*type
,
1216 const gdb_byte
*valbuf
, int element
, int bitpos
)
1218 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1219 int len
= TYPE_LENGTH (type
);
1221 gdb_assert (element
< 16);
1223 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1226 int regnum
= SPARC_F0_REGNUM
+ element
* 2 + bitpos
/ 32;
1228 valbuf
+= bitpos
/ 8;
1231 memset (buf
, 0, 8 - len
);
1232 memcpy (buf
+ 8 - len
, valbuf
, len
);
1236 for (int n
= 0; n
< (len
+ 3) / 4; n
++)
1237 regcache_cooked_write (regcache
, regnum
+ n
, valbuf
+ n
* 4);
1239 else if (sparc64_floating_p (type
)
1240 || (sparc64_complex_floating_p (type
) && len
<= 16))
1246 gdb_assert (bitpos
== 0);
1247 gdb_assert ((element
% 2) == 0);
1249 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_Q0_REGNUM
+ element
/ 2;
1250 regcache_cooked_write (regcache
, regnum
, valbuf
);
1254 gdb_assert (bitpos
== 0 || bitpos
== 64);
1256 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
1257 + element
+ bitpos
/ 64;
1258 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1262 gdb_assert (len
== 4);
1263 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 128);
1265 regnum
= SPARC_F0_REGNUM
+ element
* 2 + bitpos
/ 32;
1266 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1269 else if (sparc64_structure_or_union_p (type
))
1273 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
1275 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
1276 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
1278 sparc64_store_floating_fields (regcache
, subtype
, valbuf
,
1282 /* GCC has an interesting bug. If TYPE is a structure that has
1283 a single `float' member, GCC doesn't treat it as a structure
1284 at all, but rather as an ordinary `float' argument. This
1285 argument will be stored in %f1, as required by the psABI.
1286 However, as a member of a structure the psABI requires it to
1287 be stored in %f0. This bug is present in GCC 3.3.2, but
1288 probably in older releases to. To appease GCC, if a
1289 structure has only a single `float' member, we store its
1290 value in %f1 too (we already have stored in %f0). */
1291 if (TYPE_NFIELDS (type
) == 1)
1293 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
1295 if (sparc64_floating_p (subtype
) && TYPE_LENGTH (subtype
) == 4)
1296 regcache_cooked_write (regcache
, SPARC_F1_REGNUM
, valbuf
);
1301 /* Fetch floating fields from a variable of type TYPE from the
1302 appropriate registers for BITPOS in REGCACHE and store it at BITPOS
1303 in VALBUF. This function can be called recursively and therefore
1304 handles floating types in addition to structures. */
1307 sparc64_extract_floating_fields (struct regcache
*regcache
, struct type
*type
,
1308 gdb_byte
*valbuf
, int bitpos
)
1310 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1312 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1314 int len
= TYPE_LENGTH (type
);
1315 int regnum
= SPARC_F0_REGNUM
+ bitpos
/ 32;
1317 valbuf
+= bitpos
/ 8;
1321 regcache_cooked_read (regcache
, regnum
, buf
);
1322 memcpy (valbuf
, buf
+ 4 - len
, len
);
1325 for (int i
= 0; i
< (len
+ 3) / 4; i
++)
1326 regcache_cooked_read (regcache
, regnum
+ i
, valbuf
+ i
* 4);
1328 else if (sparc64_floating_p (type
))
1330 int len
= TYPE_LENGTH (type
);
1335 gdb_assert (bitpos
== 0 || bitpos
== 128);
1337 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_Q0_REGNUM
1339 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1343 gdb_assert (bitpos
% 64 == 0 && bitpos
>= 0 && bitpos
< 256);
1345 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
+ bitpos
/ 64;
1346 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1350 gdb_assert (len
== 4);
1351 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 256);
1353 regnum
= SPARC_F0_REGNUM
+ bitpos
/ 32;
1354 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1357 else if (sparc64_structure_or_union_p (type
))
1361 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
1363 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
1364 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
1366 sparc64_extract_floating_fields (regcache
, subtype
, valbuf
, subpos
);
1371 /* Store the NARGS arguments ARGS and STRUCT_ADDR (if STRUCT_RETURN is
1372 non-zero) in REGCACHE and on the stack (starting from address SP). */
1375 sparc64_store_arguments (struct regcache
*regcache
, int nargs
,
1376 struct value
**args
, CORE_ADDR sp
,
1377 int struct_return
, CORE_ADDR struct_addr
)
1379 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1380 /* Number of extended words in the "parameter array". */
1381 int num_elements
= 0;
1385 /* Take BIAS into account. */
1388 /* First we calculate the number of extended words in the "parameter
1389 array". While doing so we also convert some of the arguments. */
1394 for (i
= 0; i
< nargs
; i
++)
1396 struct type
*type
= value_type (args
[i
]);
1397 int len
= TYPE_LENGTH (type
);
1399 if (sparc64_structure_or_union_p (type
)
1400 || (sparc64_complex_floating_p (type
) && len
== 32))
1402 /* Structure or Union arguments. */
1405 if (num_elements
% 2 && sparc64_16_byte_align_p (type
))
1407 num_elements
+= ((len
+ 7) / 8);
1411 /* The psABI says that "Structures or unions larger than
1412 sixteen bytes are copied by the caller and passed
1413 indirectly; the caller will pass the address of a
1414 correctly aligned structure value. This sixty-four
1415 bit address will occupy one word in the parameter
1416 array, and may be promoted to an %o register like any
1417 other pointer value." Allocate memory for these
1418 values on the stack. */
1421 /* Use 16-byte alignment for these values. That's
1422 always correct, and wasting a few bytes shouldn't be
1426 write_memory (sp
, value_contents (args
[i
]), len
);
1427 args
[i
] = value_from_pointer (lookup_pointer_type (type
), sp
);
1431 else if (sparc64_floating_p (type
) || sparc64_complex_floating_p (type
))
1433 /* Floating arguments. */
1436 /* The psABI says that "Each quad-precision parameter
1437 value will be assigned to two extended words in the
1441 /* The psABI says that "Long doubles must be
1442 quad-aligned, and thus a hole might be introduced
1443 into the parameter array to force alignment." Skip
1444 an element if necessary. */
1445 if ((num_elements
% 2) && sparc64_16_byte_align_p (type
))
1453 /* Integral and pointer arguments. */
1454 gdb_assert (sparc64_integral_or_pointer_p (type
));
1456 /* The psABI says that "Each argument value of integral type
1457 smaller than an extended word will be widened by the
1458 caller to an extended word according to the signed-ness
1459 of the argument type." */
1461 args
[i
] = value_cast (builtin_type (gdbarch
)->builtin_int64
,
1467 /* Allocate the "parameter array". */
1468 sp
-= num_elements
* 8;
1470 /* The psABI says that "Every stack frame must be 16-byte aligned." */
1473 /* Now we store the arguments in to the "paramater array". Some
1474 Integer or Pointer arguments and Structure or Union arguments
1475 will be passed in %o registers. Some Floating arguments and
1476 floating members of structures are passed in floating-point
1477 registers. However, for functions with variable arguments,
1478 floating arguments are stored in an %0 register, and for
1479 functions without a prototype floating arguments are stored in
1480 both a floating-point and an %o registers, or a floating-point
1481 register and memory. To simplify the logic here we always pass
1482 arguments in memory, an %o register, and a floating-point
1483 register if appropriate. This should be no problem since the
1484 contents of any unused memory or registers in the "parameter
1485 array" are undefined. */
1489 regcache_cooked_write_unsigned (regcache
, SPARC_O0_REGNUM
, struct_addr
);
1493 for (i
= 0; i
< nargs
; i
++)
1495 const gdb_byte
*valbuf
= value_contents (args
[i
]);
1496 struct type
*type
= value_type (args
[i
]);
1497 int len
= TYPE_LENGTH (type
);
1501 if (sparc64_structure_or_union_p (type
)
1502 || (sparc64_complex_floating_p (type
) && len
== 32))
1504 /* Structure, Union or long double Complex arguments. */
1505 gdb_assert (len
<= 16);
1506 memset (buf
, 0, sizeof (buf
));
1507 memcpy (buf
, valbuf
, len
);
1510 if (element
% 2 && sparc64_16_byte_align_p (type
))
1515 regnum
= SPARC_O0_REGNUM
+ element
;
1516 if (len
> 8 && element
< 5)
1517 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
1521 sparc64_store_floating_fields (regcache
, type
, valbuf
, element
, 0);
1523 else if (sparc64_complex_floating_p (type
))
1525 /* Float Complex or double Complex arguments. */
1528 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
+ element
;
1532 if (regnum
< gdbarch_num_regs (gdbarch
) + SPARC64_D30_REGNUM
)
1533 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
1534 if (regnum
< gdbarch_num_regs (gdbarch
) + SPARC64_D10_REGNUM
)
1535 regcache_cooked_write (regcache
,
1536 SPARC_O0_REGNUM
+ element
+ 1,
1541 else if (sparc64_floating_p (type
))
1543 /* Floating arguments. */
1549 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_Q0_REGNUM
1555 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
1560 /* The psABI says "Each single-precision parameter value
1561 will be assigned to one extended word in the
1562 parameter array, and right-justified within that
1563 word; the left half (even float register) is
1564 undefined." Even though the psABI says that "the
1565 left half is undefined", set it to zero here. */
1567 memcpy (buf
+ 4, valbuf
, 4);
1571 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
1577 /* Integral and pointer arguments. */
1578 gdb_assert (len
== 8);
1580 regnum
= SPARC_O0_REGNUM
+ element
;
1585 regcache_cooked_write (regcache
, regnum
, valbuf
);
1587 /* If we're storing the value in a floating-point register,
1588 also store it in the corresponding %0 register(s). */
1589 if (regnum
>= gdbarch_num_regs (gdbarch
))
1591 regnum
-= gdbarch_num_regs (gdbarch
);
1593 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D10_REGNUM
)
1595 gdb_assert (element
< 6);
1596 regnum
= SPARC_O0_REGNUM
+ element
;
1597 regcache_cooked_write (regcache
, regnum
, valbuf
);
1599 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q8_REGNUM
)
1601 gdb_assert (element
< 5);
1602 regnum
= SPARC_O0_REGNUM
+ element
;
1603 regcache_cooked_write (regcache
, regnum
, valbuf
);
1604 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
1609 /* Always store the argument in memory. */
1610 write_memory (sp
+ element
* 8, valbuf
, len
);
1611 element
+= ((len
+ 7) / 8);
1614 gdb_assert (element
== num_elements
);
1616 /* Take BIAS into account. */
1622 sparc64_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR address
)
1624 /* The ABI requires 16-byte alignment. */
1625 return address
& ~0xf;
1629 sparc64_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
1630 struct regcache
*regcache
, CORE_ADDR bp_addr
,
1631 int nargs
, struct value
**args
, CORE_ADDR sp
,
1632 int struct_return
, CORE_ADDR struct_addr
)
1634 /* Set return address. */
1635 regcache_cooked_write_unsigned (regcache
, SPARC_O7_REGNUM
, bp_addr
- 8);
1637 /* Set up function arguments. */
1638 sp
= sparc64_store_arguments (regcache
, nargs
, args
, sp
,
1639 struct_return
, struct_addr
);
1641 /* Allocate the register save area. */
1644 /* Stack should be 16-byte aligned at this point. */
1645 gdb_assert ((sp
+ BIAS
) % 16 == 0);
1647 /* Finally, update the stack pointer. */
1648 regcache_cooked_write_unsigned (regcache
, SPARC_SP_REGNUM
, sp
);
1654 /* Extract from an array REGBUF containing the (raw) register state, a
1655 function return value of TYPE, and copy that into VALBUF. */
1658 sparc64_extract_return_value (struct type
*type
, struct regcache
*regcache
,
1661 int len
= TYPE_LENGTH (type
);
1665 if (sparc64_structure_or_union_p (type
))
1667 /* Structure or Union return values. */
1668 gdb_assert (len
<= 32);
1670 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1671 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1672 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1673 sparc64_extract_floating_fields (regcache
, type
, buf
, 0);
1674 memcpy (valbuf
, buf
, len
);
1676 else if (sparc64_floating_p (type
) || sparc64_complex_floating_p (type
))
1678 /* Floating return values. */
1679 for (i
= 0; i
< len
/ 4; i
++)
1680 regcache_cooked_read (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1681 memcpy (valbuf
, buf
, len
);
1683 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1685 /* Small arrays are returned the same way as small structures. */
1686 gdb_assert (len
<= 32);
1688 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1689 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1690 memcpy (valbuf
, buf
, len
);
1694 /* Integral and pointer return values. */
1695 gdb_assert (sparc64_integral_or_pointer_p (type
));
1697 /* Just stripping off any unused bytes should preserve the
1698 signed-ness just fine. */
1699 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
, buf
);
1700 memcpy (valbuf
, buf
+ 8 - len
, len
);
1704 /* Write into the appropriate registers a function return value stored
1705 in VALBUF of type TYPE. */
1708 sparc64_store_return_value (struct type
*type
, struct regcache
*regcache
,
1709 const gdb_byte
*valbuf
)
1711 int len
= TYPE_LENGTH (type
);
1715 if (sparc64_structure_or_union_p (type
))
1717 /* Structure or Union return values. */
1718 gdb_assert (len
<= 32);
1720 /* Simplify matters by storing the complete value (including
1721 floating members) into %o0 and %o1. Floating members are
1722 also store in the appropriate floating-point registers. */
1723 memset (buf
, 0, sizeof (buf
));
1724 memcpy (buf
, valbuf
, len
);
1725 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1726 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1727 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1728 sparc64_store_floating_fields (regcache
, type
, buf
, 0, 0);
1730 else if (sparc64_floating_p (type
) || sparc64_complex_floating_p (type
))
1732 /* Floating return values. */
1733 memcpy (buf
, valbuf
, len
);
1734 for (i
= 0; i
< len
/ 4; i
++)
1735 regcache_cooked_write (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1737 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1739 /* Small arrays are returned the same way as small structures. */
1740 gdb_assert (len
<= 32);
1742 memset (buf
, 0, sizeof (buf
));
1743 memcpy (buf
, valbuf
, len
);
1744 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1745 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1749 /* Integral and pointer return values. */
1750 gdb_assert (sparc64_integral_or_pointer_p (type
));
1752 /* ??? Do we need to do any sign-extension here? */
1754 memcpy (buf
+ 8 - len
, valbuf
, len
);
1755 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
, buf
);
1759 static enum return_value_convention
1760 sparc64_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
1761 struct type
*type
, struct regcache
*regcache
,
1762 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1764 if (TYPE_LENGTH (type
) > 32)
1765 return RETURN_VALUE_STRUCT_CONVENTION
;
1768 sparc64_extract_return_value (type
, regcache
, readbuf
);
1770 sparc64_store_return_value (type
, regcache
, writebuf
);
1772 return RETURN_VALUE_REGISTER_CONVENTION
;
1777 sparc64_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1778 struct dwarf2_frame_state_reg
*reg
,
1779 struct frame_info
*this_frame
)
1783 case SPARC_G0_REGNUM
:
1784 /* Since %g0 is always zero, there is no point in saving it, and
1785 people will be inclined omit it from the CFI. Make sure we
1786 don't warn about that. */
1787 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
1789 case SPARC_SP_REGNUM
:
1790 reg
->how
= DWARF2_FRAME_REG_CFA
;
1792 case SPARC64_PC_REGNUM
:
1793 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1794 reg
->loc
.offset
= 8;
1796 case SPARC64_NPC_REGNUM
:
1797 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1798 reg
->loc
.offset
= 12;
1803 /* sparc64_addr_bits_remove - remove useless address bits */
1806 sparc64_addr_bits_remove (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
1808 return adi_normalize_address (addr
);
1812 sparc64_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1814 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1816 tdep
->pc_regnum
= SPARC64_PC_REGNUM
;
1817 tdep
->npc_regnum
= SPARC64_NPC_REGNUM
;
1818 tdep
->fpu_register_names
= sparc64_fpu_register_names
;
1819 tdep
->fpu_registers_num
= ARRAY_SIZE (sparc64_fpu_register_names
);
1820 tdep
->cp0_register_names
= sparc64_cp0_register_names
;
1821 tdep
->cp0_registers_num
= ARRAY_SIZE (sparc64_cp0_register_names
);
1823 /* This is what all the fuss is about. */
1824 set_gdbarch_long_bit (gdbarch
, 64);
1825 set_gdbarch_long_long_bit (gdbarch
, 64);
1826 set_gdbarch_ptr_bit (gdbarch
, 64);
1828 set_gdbarch_wchar_bit (gdbarch
, 16);
1829 set_gdbarch_wchar_signed (gdbarch
, 0);
1831 set_gdbarch_num_regs (gdbarch
, SPARC64_NUM_REGS
);
1832 set_gdbarch_register_name (gdbarch
, sparc64_register_name
);
1833 set_gdbarch_register_type (gdbarch
, sparc64_register_type
);
1834 set_gdbarch_num_pseudo_regs (gdbarch
, SPARC64_NUM_PSEUDO_REGS
);
1835 set_tdesc_pseudo_register_name (gdbarch
, sparc64_pseudo_register_name
);
1836 set_tdesc_pseudo_register_type (gdbarch
, sparc64_pseudo_register_type
);
1837 set_gdbarch_pseudo_register_read (gdbarch
, sparc64_pseudo_register_read
);
1838 set_gdbarch_pseudo_register_write (gdbarch
, sparc64_pseudo_register_write
);
1840 /* Register numbers of various important registers. */
1841 set_gdbarch_pc_regnum (gdbarch
, SPARC64_PC_REGNUM
); /* %pc */
1843 /* Call dummy code. */
1844 set_gdbarch_frame_align (gdbarch
, sparc64_frame_align
);
1845 set_gdbarch_call_dummy_location (gdbarch
, AT_ENTRY_POINT
);
1846 set_gdbarch_push_dummy_code (gdbarch
, NULL
);
1847 set_gdbarch_push_dummy_call (gdbarch
, sparc64_push_dummy_call
);
1849 set_gdbarch_return_value (gdbarch
, sparc64_return_value
);
1850 set_gdbarch_stabs_argument_has_addr
1851 (gdbarch
, default_stabs_argument_has_addr
);
1853 set_gdbarch_skip_prologue (gdbarch
, sparc64_skip_prologue
);
1854 set_gdbarch_stack_frame_destroyed_p (gdbarch
, sparc_stack_frame_destroyed_p
);
1856 /* Hook in the DWARF CFI frame unwinder. */
1857 dwarf2_frame_set_init_reg (gdbarch
, sparc64_dwarf2_frame_init_reg
);
1858 /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1859 StackGhost issues have been resolved. */
1861 frame_unwind_append_unwinder (gdbarch
, &sparc64_frame_unwind
);
1862 frame_base_set_default (gdbarch
, &sparc64_frame_base
);
1864 set_gdbarch_addr_bits_remove (gdbarch
, sparc64_addr_bits_remove
);
1868 /* Helper functions for dealing with register sets. */
1870 #define TSTATE_CWP 0x000000000000001fULL
1871 #define TSTATE_ICC 0x0000000f00000000ULL
1872 #define TSTATE_XCC 0x000000f000000000ULL
1874 #define PSR_S 0x00000080
1876 #define PSR_ICC 0x00f00000
1878 #define PSR_VERS 0x0f000000
1880 #define PSR_IMPL 0xf0000000
1882 #define PSR_V8PLUS 0xff000000
1883 #define PSR_XCC 0x000f0000
1886 sparc64_supply_gregset (const struct sparc_gregmap
*gregmap
,
1887 struct regcache
*regcache
,
1888 int regnum
, const void *gregs
)
1890 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1891 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1892 int sparc32
= (gdbarch_ptr_bit (gdbarch
) == 32);
1893 const gdb_byte
*regs
= (const gdb_byte
*) gregs
;
1894 gdb_byte zero
[8] = { 0 };
1899 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1901 int offset
= gregmap
->r_tstate_offset
;
1902 ULONGEST tstate
, psr
;
1905 tstate
= extract_unsigned_integer (regs
+ offset
, 8, byte_order
);
1906 psr
= ((tstate
& TSTATE_CWP
) | PSR_S
| ((tstate
& TSTATE_ICC
) >> 12)
1907 | ((tstate
& TSTATE_XCC
) >> 20) | PSR_V8PLUS
);
1908 store_unsigned_integer (buf
, 4, byte_order
, psr
);
1909 regcache_raw_supply (regcache
, SPARC32_PSR_REGNUM
, buf
);
1912 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1913 regcache_raw_supply (regcache
, SPARC32_PC_REGNUM
,
1914 regs
+ gregmap
->r_pc_offset
+ 4);
1916 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1917 regcache_raw_supply (regcache
, SPARC32_NPC_REGNUM
,
1918 regs
+ gregmap
->r_npc_offset
+ 4);
1920 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1922 int offset
= gregmap
->r_y_offset
+ 8 - gregmap
->r_y_size
;
1923 regcache_raw_supply (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1928 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1929 regcache_raw_supply (regcache
, SPARC64_STATE_REGNUM
,
1930 regs
+ gregmap
->r_tstate_offset
);
1932 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1933 regcache_raw_supply (regcache
, SPARC64_PC_REGNUM
,
1934 regs
+ gregmap
->r_pc_offset
);
1936 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1937 regcache_raw_supply (regcache
, SPARC64_NPC_REGNUM
,
1938 regs
+ gregmap
->r_npc_offset
);
1940 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1945 memcpy (buf
+ 8 - gregmap
->r_y_size
,
1946 regs
+ gregmap
->r_y_offset
, gregmap
->r_y_size
);
1947 regcache_raw_supply (regcache
, SPARC64_Y_REGNUM
, buf
);
1950 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1951 && gregmap
->r_fprs_offset
!= -1)
1952 regcache_raw_supply (regcache
, SPARC64_FPRS_REGNUM
,
1953 regs
+ gregmap
->r_fprs_offset
);
1956 if (regnum
== SPARC_G0_REGNUM
|| regnum
== -1)
1957 regcache_raw_supply (regcache
, SPARC_G0_REGNUM
, &zero
);
1959 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1961 int offset
= gregmap
->r_g1_offset
;
1966 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1968 if (regnum
== i
|| regnum
== -1)
1969 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1974 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1976 /* Not all of the register set variants include Locals and
1977 Inputs. For those that don't, we read them off the stack. */
1978 if (gregmap
->r_l0_offset
== -1)
1982 regcache_cooked_read_unsigned (regcache
, SPARC_SP_REGNUM
, &sp
);
1983 sparc_supply_rwindow (regcache
, sp
, regnum
);
1987 int offset
= gregmap
->r_l0_offset
;
1992 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1994 if (regnum
== i
|| regnum
== -1)
1995 regcache_raw_supply (regcache
, i
, regs
+ offset
);
2003 sparc64_collect_gregset (const struct sparc_gregmap
*gregmap
,
2004 const struct regcache
*regcache
,
2005 int regnum
, void *gregs
)
2007 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
2008 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2009 int sparc32
= (gdbarch_ptr_bit (gdbarch
) == 32);
2010 gdb_byte
*regs
= (gdb_byte
*) gregs
;
2015 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
2017 int offset
= gregmap
->r_tstate_offset
;
2018 ULONGEST tstate
, psr
;
2021 tstate
= extract_unsigned_integer (regs
+ offset
, 8, byte_order
);
2022 regcache_raw_collect (regcache
, SPARC32_PSR_REGNUM
, buf
);
2023 psr
= extract_unsigned_integer (buf
, 4, byte_order
);
2024 tstate
|= (psr
& PSR_ICC
) << 12;
2025 if ((psr
& (PSR_VERS
| PSR_IMPL
)) == PSR_V8PLUS
)
2026 tstate
|= (psr
& PSR_XCC
) << 20;
2027 store_unsigned_integer (buf
, 8, byte_order
, tstate
);
2028 memcpy (regs
+ offset
, buf
, 8);
2031 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
2032 regcache_raw_collect (regcache
, SPARC32_PC_REGNUM
,
2033 regs
+ gregmap
->r_pc_offset
+ 4);
2035 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
2036 regcache_raw_collect (regcache
, SPARC32_NPC_REGNUM
,
2037 regs
+ gregmap
->r_npc_offset
+ 4);
2039 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
2041 int offset
= gregmap
->r_y_offset
+ 8 - gregmap
->r_y_size
;
2042 regcache_raw_collect (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
2047 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
2048 regcache_raw_collect (regcache
, SPARC64_STATE_REGNUM
,
2049 regs
+ gregmap
->r_tstate_offset
);
2051 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
2052 regcache_raw_collect (regcache
, SPARC64_PC_REGNUM
,
2053 regs
+ gregmap
->r_pc_offset
);
2055 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
2056 regcache_raw_collect (regcache
, SPARC64_NPC_REGNUM
,
2057 regs
+ gregmap
->r_npc_offset
);
2059 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
2063 regcache_raw_collect (regcache
, SPARC64_Y_REGNUM
, buf
);
2064 memcpy (regs
+ gregmap
->r_y_offset
,
2065 buf
+ 8 - gregmap
->r_y_size
, gregmap
->r_y_size
);
2068 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
2069 && gregmap
->r_fprs_offset
!= -1)
2070 regcache_raw_collect (regcache
, SPARC64_FPRS_REGNUM
,
2071 regs
+ gregmap
->r_fprs_offset
);
2075 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
2077 int offset
= gregmap
->r_g1_offset
;
2082 /* %g0 is always zero. */
2083 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
2085 if (regnum
== i
|| regnum
== -1)
2086 regcache_raw_collect (regcache
, i
, regs
+ offset
);
2091 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
2093 /* Not all of the register set variants include Locals and
2094 Inputs. For those that don't, we read them off the stack. */
2095 if (gregmap
->r_l0_offset
!= -1)
2097 int offset
= gregmap
->r_l0_offset
;
2102 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
2104 if (regnum
== i
|| regnum
== -1)
2105 regcache_raw_collect (regcache
, i
, regs
+ offset
);
2113 sparc64_supply_fpregset (const struct sparc_fpregmap
*fpregmap
,
2114 struct regcache
*regcache
,
2115 int regnum
, const void *fpregs
)
2117 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
2118 const gdb_byte
*regs
= (const gdb_byte
*) fpregs
;
2121 for (i
= 0; i
< 32; i
++)
2123 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
2124 regcache_raw_supply (regcache
, SPARC_F0_REGNUM
+ i
,
2125 regs
+ fpregmap
->r_f0_offset
+ (i
* 4));
2130 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
2131 regcache_raw_supply (regcache
, SPARC32_FSR_REGNUM
,
2132 regs
+ fpregmap
->r_fsr_offset
);
2136 for (i
= 0; i
< 16; i
++)
2138 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
2139 regcache_raw_supply (regcache
, SPARC64_F32_REGNUM
+ i
,
2140 (regs
+ fpregmap
->r_f0_offset
2141 + (32 * 4) + (i
* 8)));
2144 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
2145 regcache_raw_supply (regcache
, SPARC64_FSR_REGNUM
,
2146 regs
+ fpregmap
->r_fsr_offset
);
2151 sparc64_collect_fpregset (const struct sparc_fpregmap
*fpregmap
,
2152 const struct regcache
*regcache
,
2153 int regnum
, void *fpregs
)
2155 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
2156 gdb_byte
*regs
= (gdb_byte
*) fpregs
;
2159 for (i
= 0; i
< 32; i
++)
2161 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
2162 regcache_raw_collect (regcache
, SPARC_F0_REGNUM
+ i
,
2163 regs
+ fpregmap
->r_f0_offset
+ (i
* 4));
2168 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
2169 regcache_raw_collect (regcache
, SPARC32_FSR_REGNUM
,
2170 regs
+ fpregmap
->r_fsr_offset
);
2174 for (i
= 0; i
< 16; i
++)
2176 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
2177 regcache_raw_collect (regcache
, SPARC64_F32_REGNUM
+ i
,
2178 (regs
+ fpregmap
->r_f0_offset
2179 + (32 * 4) + (i
* 8)));
2182 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
2183 regcache_raw_collect (regcache
, SPARC64_FSR_REGNUM
,
2184 regs
+ fpregmap
->r_fsr_offset
);
2188 const struct sparc_fpregmap sparc64_bsd_fpregmap
=