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"
23 #include "floatformat.h"
25 #include "frame-base.h"
26 #include "frame-unwind.h"
34 #include "target-descriptions.h"
38 #include "sparc64-tdep.h"
40 /* This file implements the SPARC 64-bit ABI as defined by the
41 section "Low-Level System Information" of the SPARC Compliance
42 Definition (SCD) 2.4.1, which is the 64-bit System V psABI for
45 /* Please use the sparc32_-prefix for 32-bit specific code, the
46 sparc64_-prefix for 64-bit specific code and the sparc_-prefix for
47 code can handle both. */
49 /* The M7 processor supports an Application Data Integrity (ADI) feature
50 that detects invalid data accesses. When software allocates memory and
51 enables ADI on the allocated memory, it chooses a 4-bit version number,
52 sets the version in the upper 4 bits of the 64-bit pointer to that data,
53 and stores the 4-bit version in every cacheline of the object. Hardware
54 saves the latter in spare bits in the cache and memory hierarchy. On each
55 load and store, the processor compares the upper 4 VA (virtual address) bits
56 to the cacheline's version. If there is a mismatch, the processor generates
57 a version mismatch trap which can be either precise or disrupting.
58 The trap is an error condition which the kernel delivers to the process
61 The upper 4 bits of the VA represent a version and are not part of the
62 true address. The processor clears these bits and sign extends bit 59
63 to generate the true address.
65 Note that 32-bit applications cannot use ADI. */
69 #include "cli/cli-utils.h"
73 #define MAX_PROC_NAME_SIZE sizeof("/proc/99999/lwp/9999/adi/lstatus")
75 /* ELF Auxiliary vectors */
77 #define AT_ADI_BLKSZ 34
80 #define AT_ADI_NBITS 35
82 #ifndef AT_ADI_UEONADI
83 #define AT_ADI_UEONADI 36
86 /* ADI command list. */
87 static struct cmd_list_element
*sparc64adilist
= NULL
;
89 /* ADI stat settings. */
92 /* The ADI block size. */
93 unsigned long blksize
;
95 /* Number of bits used for an ADI version tag which can be
96 used together with the shift value for an ADI version tag
97 to encode or extract the ADI version value in a pointer. */
100 /* The maximum ADI version tag value supported. */
103 /* ADI version tag file. */
106 /* ADI availability check has been done. */
107 bool checked_avail
= false;
109 /* ADI is available. */
110 bool is_avail
= false;
114 /* Per-process ADI stat info. */
116 typedef struct sparc64_adi_info
118 sparc64_adi_info (pid_t pid_
)
122 /* The process identifier. */
126 adi_stat_t stat
= {};
130 static std::forward_list
<sparc64_adi_info
> adi_proc_list
;
133 /* Get ADI info for process PID, creating one if it doesn't exist. */
135 static sparc64_adi_info
*
136 get_adi_info_proc (pid_t pid
)
138 auto found
= std::find_if (adi_proc_list
.begin (), adi_proc_list
.end (),
139 [&pid
] (const sparc64_adi_info
&info
)
141 return info
.pid
== pid
;
144 if (found
== adi_proc_list
.end ())
146 adi_proc_list
.emplace_front (pid
);
147 return &adi_proc_list
.front ();
156 get_adi_info (pid_t pid
)
158 sparc64_adi_info
*proc
;
160 proc
= get_adi_info_proc (pid
);
164 /* Is called when GDB is no longer debugging process PID. It
165 deletes data structure that keeps track of the ADI stat. */
168 sparc64_forget_process (pid_t pid
)
172 for (auto pit
= adi_proc_list
.before_begin (),
173 it
= std::next (pit
);
174 it
!= adi_proc_list
.end ();
177 if ((*it
).pid
== pid
)
179 if ((*it
).stat
.tag_fd
> 0)
180 target_fileio_close ((*it
).stat
.tag_fd
, &target_errno
);
181 adi_proc_list
.erase_after (pit
);
191 info_adi_command (char *args
, int from_tty
)
193 printf_unfiltered ("\"adi\" must be followed by \"examine\" "
195 help_list (sparc64adilist
, "adi ", all_commands
, gdb_stdout
);
198 /* Read attributes of a maps entry in /proc/[pid]/adi/maps. */
201 read_maps_entry (const char *line
,
202 ULONGEST
*addr
, ULONGEST
*endaddr
)
204 const char *p
= line
;
206 *addr
= strtoulst (p
, &p
, 16);
210 *endaddr
= strtoulst (p
, &p
, 16);
213 /* Check if ADI is available. */
218 pid_t pid
= ptid_get_pid (inferior_ptid
);
219 sparc64_adi_info
*proc
= get_adi_info_proc (pid
);
222 if (proc
->stat
.checked_avail
)
223 return proc
->stat
.is_avail
;
225 proc
->stat
.checked_avail
= true;
226 if (target_auxv_search (¤t_target
, AT_ADI_BLKSZ
, &value
) <= 0)
228 proc
->stat
.blksize
= value
;
229 target_auxv_search (¤t_target
, AT_ADI_NBITS
, &value
);
230 proc
->stat
.nbits
= value
;
231 proc
->stat
.max_version
= (1 << proc
->stat
.nbits
) - 2;
232 proc
->stat
.is_avail
= true;
234 return proc
->stat
.is_avail
;
237 /* Normalize a versioned address - a VA with ADI bits (63-60) set. */
240 adi_normalize_address (CORE_ADDR addr
)
242 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
246 /* Clear upper bits. */
247 addr
&= ((uint64_t) -1) >> ast
.nbits
;
250 CORE_ADDR signbit
= (uint64_t) 1 << (64 - ast
.nbits
- 1);
251 return (addr
^ signbit
) - signbit
;
256 /* Align a normalized address - a VA with bit 59 sign extended into
260 adi_align_address (CORE_ADDR naddr
)
262 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
264 return (naddr
- (naddr
% ast
.blksize
)) / ast
.blksize
;
267 /* Convert a byte count to count at a ratio of 1:adi_blksz. */
270 adi_convert_byte_count (CORE_ADDR naddr
, int nbytes
, CORE_ADDR locl
)
272 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
274 return ((naddr
+ nbytes
+ ast
.blksize
- 1) / ast
.blksize
) - locl
;
277 /* The /proc/[pid]/adi/tags file, which allows gdb to get/set ADI
278 version in a target process, maps linearly to the address space
279 of the target process at a ratio of 1:adi_blksz.
281 A read (or write) at offset K in the file returns (or modifies)
282 the ADI version tag stored in the cacheline containing address
283 K * adi_blksz, encoded as 1 version tag per byte. The allowed
284 version tag values are between 0 and adi_stat.max_version. */
289 pid_t pid
= ptid_get_pid (inferior_ptid
);
290 sparc64_adi_info
*proc
= get_adi_info_proc (pid
);
292 if (proc
->stat
.tag_fd
!= 0)
293 return proc
->stat
.tag_fd
;
295 char cl_name
[MAX_PROC_NAME_SIZE
];
296 snprintf (cl_name
, sizeof(cl_name
), "/proc/%d/adi/tags", pid
);
298 proc
->stat
.tag_fd
= target_fileio_open (NULL
, cl_name
, O_RDWR
|O_EXCL
,
300 return proc
->stat
.tag_fd
;
303 /* Check if an address set is ADI enabled, using /proc/[pid]/adi/maps
304 which was exported by the kernel and contains the currently ADI
305 mapped memory regions and their access permissions. */
308 adi_is_addr_mapped (CORE_ADDR vaddr
, size_t cnt
)
310 char filename
[MAX_PROC_NAME_SIZE
];
313 pid_t pid
= ptid_get_pid (inferior_ptid
);
314 snprintf (filename
, sizeof filename
, "/proc/%d/adi/maps", pid
);
315 char *data
= target_fileio_read_stralloc (NULL
, filename
);
318 struct cleanup
*cleanup
= make_cleanup (xfree
, data
);
319 adi_stat_t adi_stat
= get_adi_info (pid
);
321 for (line
= strtok (data
, "\n"); line
; line
= strtok (NULL
, "\n"))
323 ULONGEST addr
, endaddr
;
325 read_maps_entry (line
, &addr
, &endaddr
);
327 while (((vaddr
+ i
) * adi_stat
.blksize
) >= addr
328 && ((vaddr
+ i
) * adi_stat
.blksize
) < endaddr
)
332 do_cleanups (cleanup
);
337 do_cleanups (cleanup
);
340 warning (_("unable to open /proc file '%s'"), filename
);
345 /* Read ADI version tag value for memory locations starting at "VADDR"
346 for "SIZE" number of bytes. */
349 adi_read_versions (CORE_ADDR vaddr
, size_t size
, unsigned char *tags
)
351 int fd
= adi_tag_fd ();
355 if (!adi_is_addr_mapped (vaddr
, size
))
357 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
358 error(_("Address at %s is not in ADI maps"),
359 paddress (target_gdbarch (), vaddr
* ast
.blksize
));
363 return target_fileio_pread (fd
, tags
, size
, vaddr
, &target_errno
);
366 /* Write ADI version tag for memory locations starting at "VADDR" for
367 "SIZE" number of bytes to "TAGS". */
370 adi_write_versions (CORE_ADDR vaddr
, size_t size
, unsigned char *tags
)
372 int fd
= adi_tag_fd ();
376 if (!adi_is_addr_mapped (vaddr
, size
))
378 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
379 error(_("Address at %s is not in ADI maps"),
380 paddress (target_gdbarch (), vaddr
* ast
.blksize
));
384 return target_fileio_pwrite (fd
, tags
, size
, vaddr
, &target_errno
);
387 /* Print ADI version tag value in "TAGS" for memory locations starting
388 at "VADDR" with number of "CNT". */
391 adi_print_versions (CORE_ADDR vaddr
, size_t cnt
, unsigned char *tags
)
394 const int maxelts
= 8; /* # of elements per line */
396 adi_stat_t adi_stat
= get_adi_info (ptid_get_pid (inferior_ptid
));
401 printf_filtered ("%s:\t",
402 paddress (target_gdbarch (), vaddr
* adi_stat
.blksize
));
403 for (int i
= maxelts
; i
> 0 && cnt
> 0; i
--, cnt
--)
405 if (tags
[v_idx
] == 0xff) /* no version tag */
406 printf_filtered ("-");
408 printf_filtered ("%1X", tags
[v_idx
]);
410 printf_filtered (" ");
413 printf_filtered ("\n");
414 gdb_flush (gdb_stdout
);
420 do_examine (CORE_ADDR start
, int bcnt
)
422 CORE_ADDR vaddr
= adi_normalize_address (start
);
423 struct cleanup
*cleanup
;
425 CORE_ADDR vstart
= adi_align_address (vaddr
);
426 int cnt
= adi_convert_byte_count (vaddr
, bcnt
, vstart
);
427 unsigned char *buf
= (unsigned char *) xmalloc (cnt
);
428 cleanup
= make_cleanup (xfree
, buf
);
429 int read_cnt
= adi_read_versions (vstart
, cnt
, buf
);
431 error (_("No ADI information"));
432 else if (read_cnt
< cnt
)
433 error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr
));
435 adi_print_versions (vstart
, cnt
, buf
);
437 do_cleanups (cleanup
);
441 do_assign (CORE_ADDR start
, size_t bcnt
, int version
)
443 CORE_ADDR vaddr
= adi_normalize_address (start
);
445 CORE_ADDR vstart
= adi_align_address (vaddr
);
446 int cnt
= adi_convert_byte_count (vaddr
, bcnt
, vstart
);
447 std::vector
<unsigned char> buf (cnt
, version
);
448 int set_cnt
= adi_write_versions (vstart
, cnt
, buf
.data ());
451 error (_("No ADI information"));
452 else if (set_cnt
< cnt
)
453 error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr
));
457 /* ADI examine version tag command.
461 adi (examine|x)/count <addr> */
464 adi_examine_command (char *args
, int from_tty
)
466 /* make sure program is active and adi is available */
467 if (!target_has_execution
)
468 error (_("ADI command requires a live process/thread"));
470 if (!adi_available ())
471 error (_("No ADI information"));
473 pid_t pid
= ptid_get_pid (inferior_ptid
);
474 sparc64_adi_info
*proc
= get_adi_info_proc (pid
);
480 cnt
= get_number (&p
);
483 CORE_ADDR next_address
= 0;
484 if (p
!= 0 && *p
!= 0)
485 next_address
= parse_and_eval_address (p
);
486 if (!cnt
|| !next_address
)
487 error (_("Usage: adi examine|x[/count] <addr>"));
489 do_examine (next_address
, cnt
);
492 /* ADI assign version tag command.
496 adi (assign|a)/count <addr> = <version> */
499 adi_assign_command (char *args
, int from_tty
)
501 /* make sure program is active and adi is available */
502 if (!target_has_execution
)
503 error (_("ADI command requires a live process/thread"));
505 if (!adi_available ())
506 error (_("No ADI information"));
510 error_no_arg (_("Usage: adi assign|a[/count] <addr> = <version>"));
512 char *q
= (char *) strchr (exp
, '=');
516 error (_("Usage: adi assign|a[/count] <addr> = <version>"));
520 if (exp
&& *exp
== '/')
523 cnt
= get_number (&p
);
526 CORE_ADDR next_address
= 0;
527 if (p
!= 0 && *p
!= 0)
528 next_address
= parse_and_eval_address (p
);
530 error (_("Usage: adi assign|a[/count] <addr> = <version>"));
533 if (q
!= NULL
) /* parse version tag */
535 adi_stat_t ast
= get_adi_info (ptid_get_pid (inferior_ptid
));
536 version
= parse_and_eval_long (q
);
537 if (version
< 0 || version
> ast
.max_version
)
538 error (_("Invalid ADI version tag %d"), version
);
541 do_assign (next_address
, cnt
, version
);
545 _initialize_sparc64_adi_tdep (void)
548 add_prefix_cmd ("adi", class_support
, info_adi_command
,
549 _("ADI version related commands."),
550 &sparc64adilist
, "adi ", 0, &cmdlist
);
551 add_cmd ("examine", class_support
, adi_examine_command
,
552 _("Examine ADI versions."), &sparc64adilist
);
553 add_alias_cmd ("x", "examine", no_class
, 1, &sparc64adilist
);
554 add_cmd ("assign", class_support
, adi_assign_command
,
555 _("Assign ADI versions."), &sparc64adilist
);
560 /* The functions on this page are intended to be used to classify
561 function arguments. */
563 /* Check whether TYPE is "Integral or Pointer". */
566 sparc64_integral_or_pointer_p (const struct type
*type
)
568 switch (TYPE_CODE (type
))
574 case TYPE_CODE_RANGE
:
576 int len
= TYPE_LENGTH (type
);
577 gdb_assert (len
== 1 || len
== 2 || len
== 4 || len
== 8);
582 case TYPE_CODE_RVALUE_REF
:
584 int len
= TYPE_LENGTH (type
);
585 gdb_assert (len
== 8);
595 /* Check whether TYPE is "Floating". */
598 sparc64_floating_p (const struct type
*type
)
600 switch (TYPE_CODE (type
))
604 int len
= TYPE_LENGTH (type
);
605 gdb_assert (len
== 4 || len
== 8 || len
== 16);
615 /* Check whether TYPE is "Complex Floating". */
618 sparc64_complex_floating_p (const struct type
*type
)
620 switch (TYPE_CODE (type
))
622 case TYPE_CODE_COMPLEX
:
624 int len
= TYPE_LENGTH (type
);
625 gdb_assert (len
== 8 || len
== 16 || len
== 32);
635 /* Check whether TYPE is "Structure or Union".
637 In terms of Ada subprogram calls, arrays are treated the same as
638 struct and union types. So this function also returns non-zero
642 sparc64_structure_or_union_p (const struct type
*type
)
644 switch (TYPE_CODE (type
))
646 case TYPE_CODE_STRUCT
:
647 case TYPE_CODE_UNION
:
648 case TYPE_CODE_ARRAY
:
658 /* Construct types for ISA-specific registers. */
661 sparc64_pstate_type (struct gdbarch
*gdbarch
)
663 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
665 if (!tdep
->sparc64_pstate_type
)
669 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_pstate", 8);
670 append_flags_type_flag (type
, 0, "AG");
671 append_flags_type_flag (type
, 1, "IE");
672 append_flags_type_flag (type
, 2, "PRIV");
673 append_flags_type_flag (type
, 3, "AM");
674 append_flags_type_flag (type
, 4, "PEF");
675 append_flags_type_flag (type
, 5, "RED");
676 append_flags_type_flag (type
, 8, "TLE");
677 append_flags_type_flag (type
, 9, "CLE");
678 append_flags_type_flag (type
, 10, "PID0");
679 append_flags_type_flag (type
, 11, "PID1");
681 tdep
->sparc64_pstate_type
= type
;
684 return tdep
->sparc64_pstate_type
;
688 sparc64_ccr_type (struct gdbarch
*gdbarch
)
690 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
692 if (tdep
->sparc64_ccr_type
== NULL
)
696 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_ccr", 8);
697 append_flags_type_flag (type
, 0, "icc.c");
698 append_flags_type_flag (type
, 1, "icc.v");
699 append_flags_type_flag (type
, 2, "icc.z");
700 append_flags_type_flag (type
, 3, "icc.n");
701 append_flags_type_flag (type
, 4, "xcc.c");
702 append_flags_type_flag (type
, 5, "xcc.v");
703 append_flags_type_flag (type
, 6, "xcc.z");
704 append_flags_type_flag (type
, 7, "xcc.n");
706 tdep
->sparc64_ccr_type
= type
;
709 return tdep
->sparc64_ccr_type
;
713 sparc64_fsr_type (struct gdbarch
*gdbarch
)
715 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
717 if (!tdep
->sparc64_fsr_type
)
721 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_fsr", 8);
722 append_flags_type_flag (type
, 0, "NXC");
723 append_flags_type_flag (type
, 1, "DZC");
724 append_flags_type_flag (type
, 2, "UFC");
725 append_flags_type_flag (type
, 3, "OFC");
726 append_flags_type_flag (type
, 4, "NVC");
727 append_flags_type_flag (type
, 5, "NXA");
728 append_flags_type_flag (type
, 6, "DZA");
729 append_flags_type_flag (type
, 7, "UFA");
730 append_flags_type_flag (type
, 8, "OFA");
731 append_flags_type_flag (type
, 9, "NVA");
732 append_flags_type_flag (type
, 22, "NS");
733 append_flags_type_flag (type
, 23, "NXM");
734 append_flags_type_flag (type
, 24, "DZM");
735 append_flags_type_flag (type
, 25, "UFM");
736 append_flags_type_flag (type
, 26, "OFM");
737 append_flags_type_flag (type
, 27, "NVM");
739 tdep
->sparc64_fsr_type
= type
;
742 return tdep
->sparc64_fsr_type
;
746 sparc64_fprs_type (struct gdbarch
*gdbarch
)
748 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
750 if (!tdep
->sparc64_fprs_type
)
754 type
= arch_flags_type (gdbarch
, "builtin_type_sparc64_fprs", 8);
755 append_flags_type_flag (type
, 0, "DL");
756 append_flags_type_flag (type
, 1, "DU");
757 append_flags_type_flag (type
, 2, "FEF");
759 tdep
->sparc64_fprs_type
= type
;
762 return tdep
->sparc64_fprs_type
;
766 /* Register information. */
767 #define SPARC64_FPU_REGISTERS \
768 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
769 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
770 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
771 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
772 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
773 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62"
774 #define SPARC64_CP0_REGISTERS \
776 /* FIXME: Give "state" a name until we start using register groups. */ \
782 static const char *sparc64_fpu_register_names
[] = { SPARC64_FPU_REGISTERS
};
783 static const char *sparc64_cp0_register_names
[] = { SPARC64_CP0_REGISTERS
};
785 static const char *sparc64_register_names
[] =
787 SPARC_CORE_REGISTERS
,
788 SPARC64_FPU_REGISTERS
,
789 SPARC64_CP0_REGISTERS
792 /* Total number of registers. */
793 #define SPARC64_NUM_REGS ARRAY_SIZE (sparc64_register_names)
795 /* We provide the aliases %d0..%d62 and %q0..%q60 for the floating
796 registers as "psuedo" registers. */
798 static const char *sparc64_pseudo_register_names
[] =
800 "cwp", "pstate", "asi", "ccr",
802 "d0", "d2", "d4", "d6", "d8", "d10", "d12", "d14",
803 "d16", "d18", "d20", "d22", "d24", "d26", "d28", "d30",
804 "d32", "d34", "d36", "d38", "d40", "d42", "d44", "d46",
805 "d48", "d50", "d52", "d54", "d56", "d58", "d60", "d62",
807 "q0", "q4", "q8", "q12", "q16", "q20", "q24", "q28",
808 "q32", "q36", "q40", "q44", "q48", "q52", "q56", "q60",
811 /* Total number of pseudo registers. */
812 #define SPARC64_NUM_PSEUDO_REGS ARRAY_SIZE (sparc64_pseudo_register_names)
814 /* Return the name of pseudo register REGNUM. */
817 sparc64_pseudo_register_name (struct gdbarch
*gdbarch
, int regnum
)
819 regnum
-= gdbarch_num_regs (gdbarch
);
821 if (regnum
< SPARC64_NUM_PSEUDO_REGS
)
822 return sparc64_pseudo_register_names
[regnum
];
824 internal_error (__FILE__
, __LINE__
,
825 _("sparc64_pseudo_register_name: bad register number %d"),
829 /* Return the name of register REGNUM. */
832 sparc64_register_name (struct gdbarch
*gdbarch
, int regnum
)
834 if (tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
835 return tdesc_register_name (gdbarch
, regnum
);
837 if (regnum
>= 0 && regnum
< gdbarch_num_regs (gdbarch
))
838 return sparc64_register_names
[regnum
];
840 return sparc64_pseudo_register_name (gdbarch
, regnum
);
843 /* Return the GDB type object for the "standard" data type of data in
844 pseudo register REGNUM. */
847 sparc64_pseudo_register_type (struct gdbarch
*gdbarch
, int regnum
)
849 regnum
-= gdbarch_num_regs (gdbarch
);
851 if (regnum
== SPARC64_CWP_REGNUM
)
852 return builtin_type (gdbarch
)->builtin_int64
;
853 if (regnum
== SPARC64_PSTATE_REGNUM
)
854 return sparc64_pstate_type (gdbarch
);
855 if (regnum
== SPARC64_ASI_REGNUM
)
856 return builtin_type (gdbarch
)->builtin_int64
;
857 if (regnum
== SPARC64_CCR_REGNUM
)
858 return sparc64_ccr_type (gdbarch
);
859 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
860 return builtin_type (gdbarch
)->builtin_double
;
861 if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
862 return builtin_type (gdbarch
)->builtin_long_double
;
864 internal_error (__FILE__
, __LINE__
,
865 _("sparc64_pseudo_register_type: bad register number %d"),
869 /* Return the GDB type object for the "standard" data type of data in
873 sparc64_register_type (struct gdbarch
*gdbarch
, int regnum
)
875 if (tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
876 return tdesc_register_type (gdbarch
, regnum
);
879 if (regnum
== SPARC_SP_REGNUM
|| regnum
== SPARC_FP_REGNUM
)
880 return builtin_type (gdbarch
)->builtin_data_ptr
;
881 if (regnum
>= SPARC_G0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
)
882 return builtin_type (gdbarch
)->builtin_int64
;
883 if (regnum
>= SPARC_F0_REGNUM
&& regnum
<= SPARC_F31_REGNUM
)
884 return builtin_type (gdbarch
)->builtin_float
;
885 if (regnum
>= SPARC64_F32_REGNUM
&& regnum
<= SPARC64_F62_REGNUM
)
886 return builtin_type (gdbarch
)->builtin_double
;
887 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
888 return builtin_type (gdbarch
)->builtin_func_ptr
;
889 /* This raw register contains the contents of %cwp, %pstate, %asi
890 and %ccr as laid out in a %tstate register. */
891 if (regnum
== SPARC64_STATE_REGNUM
)
892 return builtin_type (gdbarch
)->builtin_int64
;
893 if (regnum
== SPARC64_FSR_REGNUM
)
894 return sparc64_fsr_type (gdbarch
);
895 if (regnum
== SPARC64_FPRS_REGNUM
)
896 return sparc64_fprs_type (gdbarch
);
897 /* "Although Y is a 64-bit register, its high-order 32 bits are
898 reserved and always read as 0." */
899 if (regnum
== SPARC64_Y_REGNUM
)
900 return builtin_type (gdbarch
)->builtin_int64
;
902 /* Pseudo registers. */
903 if (regnum
>= gdbarch_num_regs (gdbarch
))
904 return sparc64_pseudo_register_type (gdbarch
, regnum
);
906 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
909 static enum register_status
910 sparc64_pseudo_register_read (struct gdbarch
*gdbarch
,
911 struct regcache
*regcache
,
912 int regnum
, gdb_byte
*buf
)
914 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
915 enum register_status status
;
917 regnum
-= gdbarch_num_regs (gdbarch
);
919 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
921 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
922 status
= regcache_raw_read (regcache
, regnum
, buf
);
923 if (status
== REG_VALID
)
924 status
= regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
927 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
929 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
930 return regcache_raw_read (regcache
, regnum
, buf
);
932 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
934 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
936 status
= regcache_raw_read (regcache
, regnum
, buf
);
937 if (status
== REG_VALID
)
938 status
= regcache_raw_read (regcache
, regnum
+ 1, buf
+ 4);
939 if (status
== REG_VALID
)
940 status
= regcache_raw_read (regcache
, regnum
+ 2, buf
+ 8);
941 if (status
== REG_VALID
)
942 status
= regcache_raw_read (regcache
, regnum
+ 3, buf
+ 12);
946 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
948 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
950 status
= regcache_raw_read (regcache
, regnum
, buf
);
951 if (status
== REG_VALID
)
952 status
= regcache_raw_read (regcache
, regnum
+ 1, buf
+ 8);
956 else if (regnum
== SPARC64_CWP_REGNUM
957 || regnum
== SPARC64_PSTATE_REGNUM
958 || regnum
== SPARC64_ASI_REGNUM
959 || regnum
== SPARC64_CCR_REGNUM
)
963 status
= regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
964 if (status
!= REG_VALID
)
969 case SPARC64_CWP_REGNUM
:
970 state
= (state
>> 0) & ((1 << 5) - 1);
972 case SPARC64_PSTATE_REGNUM
:
973 state
= (state
>> 8) & ((1 << 12) - 1);
975 case SPARC64_ASI_REGNUM
:
976 state
= (state
>> 24) & ((1 << 8) - 1);
978 case SPARC64_CCR_REGNUM
:
979 state
= (state
>> 32) & ((1 << 8) - 1);
982 store_unsigned_integer (buf
, 8, byte_order
, state
);
989 sparc64_pseudo_register_write (struct gdbarch
*gdbarch
,
990 struct regcache
*regcache
,
991 int regnum
, const gdb_byte
*buf
)
993 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
995 regnum
-= gdbarch_num_regs (gdbarch
);
997 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D30_REGNUM
)
999 regnum
= SPARC_F0_REGNUM
+ 2 * (regnum
- SPARC64_D0_REGNUM
);
1000 regcache_raw_write (regcache
, regnum
, buf
);
1001 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
1003 else if (regnum
>= SPARC64_D32_REGNUM
&& regnum
<= SPARC64_D62_REGNUM
)
1005 regnum
= SPARC64_F32_REGNUM
+ (regnum
- SPARC64_D32_REGNUM
);
1006 regcache_raw_write (regcache
, regnum
, buf
);
1008 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q28_REGNUM
)
1010 regnum
= SPARC_F0_REGNUM
+ 4 * (regnum
- SPARC64_Q0_REGNUM
);
1011 regcache_raw_write (regcache
, regnum
, buf
);
1012 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 4);
1013 regcache_raw_write (regcache
, regnum
+ 2, buf
+ 8);
1014 regcache_raw_write (regcache
, regnum
+ 3, buf
+ 12);
1016 else if (regnum
>= SPARC64_Q32_REGNUM
&& regnum
<= SPARC64_Q60_REGNUM
)
1018 regnum
= SPARC64_F32_REGNUM
+ 2 * (regnum
- SPARC64_Q32_REGNUM
);
1019 regcache_raw_write (regcache
, regnum
, buf
);
1020 regcache_raw_write (regcache
, regnum
+ 1, buf
+ 8);
1022 else if (regnum
== SPARC64_CWP_REGNUM
1023 || regnum
== SPARC64_PSTATE_REGNUM
1024 || regnum
== SPARC64_ASI_REGNUM
1025 || regnum
== SPARC64_CCR_REGNUM
)
1027 ULONGEST state
, bits
;
1029 regcache_raw_read_unsigned (regcache
, SPARC64_STATE_REGNUM
, &state
);
1030 bits
= extract_unsigned_integer (buf
, 8, byte_order
);
1033 case SPARC64_CWP_REGNUM
:
1034 state
|= ((bits
& ((1 << 5) - 1)) << 0);
1036 case SPARC64_PSTATE_REGNUM
:
1037 state
|= ((bits
& ((1 << 12) - 1)) << 8);
1039 case SPARC64_ASI_REGNUM
:
1040 state
|= ((bits
& ((1 << 8) - 1)) << 24);
1042 case SPARC64_CCR_REGNUM
:
1043 state
|= ((bits
& ((1 << 8) - 1)) << 32);
1046 regcache_raw_write_unsigned (regcache
, SPARC64_STATE_REGNUM
, state
);
1051 /* Return PC of first real instruction of the function starting at
1055 sparc64_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR start_pc
)
1057 struct symtab_and_line sal
;
1058 CORE_ADDR func_start
, func_end
;
1059 struct sparc_frame_cache cache
;
1061 /* This is the preferred method, find the end of the prologue by
1062 using the debugging information. */
1063 if (find_pc_partial_function (start_pc
, NULL
, &func_start
, &func_end
))
1065 sal
= find_pc_line (func_start
, 0);
1067 if (sal
.end
< func_end
1068 && start_pc
<= sal
.end
)
1072 return sparc_analyze_prologue (gdbarch
, start_pc
, 0xffffffffffffffffULL
,
1076 /* Normal frames. */
1078 static struct sparc_frame_cache
*
1079 sparc64_frame_cache (struct frame_info
*this_frame
, void **this_cache
)
1081 return sparc_frame_cache (this_frame
, this_cache
);
1085 sparc64_frame_this_id (struct frame_info
*this_frame
, void **this_cache
,
1086 struct frame_id
*this_id
)
1088 struct sparc_frame_cache
*cache
=
1089 sparc64_frame_cache (this_frame
, this_cache
);
1091 /* This marks the outermost frame. */
1092 if (cache
->base
== 0)
1095 (*this_id
) = frame_id_build (cache
->base
, cache
->pc
);
1098 static struct value
*
1099 sparc64_frame_prev_register (struct frame_info
*this_frame
, void **this_cache
,
1102 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1103 struct sparc_frame_cache
*cache
=
1104 sparc64_frame_cache (this_frame
, this_cache
);
1106 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== SPARC64_NPC_REGNUM
)
1108 CORE_ADDR pc
= (regnum
== SPARC64_NPC_REGNUM
) ? 4 : 0;
1111 (cache
->copied_regs_mask
& 0x80) ? SPARC_I7_REGNUM
: SPARC_O7_REGNUM
;
1112 pc
+= get_frame_register_unsigned (this_frame
, regnum
) + 8;
1113 return frame_unwind_got_constant (this_frame
, regnum
, pc
);
1116 /* Handle StackGhost. */
1118 ULONGEST wcookie
= sparc_fetch_wcookie (gdbarch
);
1120 if (wcookie
!= 0 && !cache
->frameless_p
&& regnum
== SPARC_I7_REGNUM
)
1122 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
1125 /* Read the value in from memory. */
1126 i7
= get_frame_memory_unsigned (this_frame
, addr
, 8);
1127 return frame_unwind_got_constant (this_frame
, regnum
, i7
^ wcookie
);
1131 /* The previous frame's `local' and `in' registers may have been saved
1132 in the register save area. */
1133 if (regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
1134 && (cache
->saved_regs_mask
& (1 << (regnum
- SPARC_L0_REGNUM
))))
1136 CORE_ADDR addr
= cache
->base
+ (regnum
- SPARC_L0_REGNUM
) * 8;
1138 return frame_unwind_got_memory (this_frame
, regnum
, addr
);
1141 /* The previous frame's `out' registers may be accessible as the current
1142 frame's `in' registers. */
1143 if (regnum
>= SPARC_O0_REGNUM
&& regnum
<= SPARC_O7_REGNUM
1144 && (cache
->copied_regs_mask
& (1 << (regnum
- SPARC_O0_REGNUM
))))
1145 regnum
+= (SPARC_I0_REGNUM
- SPARC_O0_REGNUM
);
1147 return frame_unwind_got_register (this_frame
, regnum
, regnum
);
1150 static const struct frame_unwind sparc64_frame_unwind
=
1153 default_frame_unwind_stop_reason
,
1154 sparc64_frame_this_id
,
1155 sparc64_frame_prev_register
,
1157 default_frame_sniffer
1162 sparc64_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
1164 struct sparc_frame_cache
*cache
=
1165 sparc64_frame_cache (this_frame
, this_cache
);
1170 static const struct frame_base sparc64_frame_base
=
1172 &sparc64_frame_unwind
,
1173 sparc64_frame_base_address
,
1174 sparc64_frame_base_address
,
1175 sparc64_frame_base_address
1178 /* Check whether TYPE must be 16-byte aligned. */
1181 sparc64_16_byte_align_p (struct type
*type
)
1183 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1185 struct type
*t
= check_typedef (TYPE_TARGET_TYPE (type
));
1187 if (sparc64_floating_p (t
))
1190 if (sparc64_floating_p (type
) && TYPE_LENGTH (type
) == 16)
1193 if (sparc64_structure_or_union_p (type
))
1197 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
1199 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
1201 if (sparc64_16_byte_align_p (subtype
))
1209 /* Store floating fields of element ELEMENT of an "parameter array"
1210 that has type TYPE and is stored at BITPOS in VALBUF in the
1211 apropriate registers of REGCACHE. This function can be called
1212 recursively and therefore handles floating types in addition to
1216 sparc64_store_floating_fields (struct regcache
*regcache
, struct type
*type
,
1217 const gdb_byte
*valbuf
, int element
, int bitpos
)
1219 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1220 int len
= TYPE_LENGTH (type
);
1222 gdb_assert (element
< 16);
1224 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1227 int regnum
= SPARC_F0_REGNUM
+ element
* 2 + bitpos
/ 32;
1229 valbuf
+= bitpos
/ 8;
1232 memset (buf
, 0, 8 - len
);
1233 memcpy (buf
+ 8 - len
, valbuf
, len
);
1237 for (int n
= 0; n
< (len
+ 3) / 4; n
++)
1238 regcache_cooked_write (regcache
, regnum
+ n
, valbuf
+ n
* 4);
1240 else if (sparc64_floating_p (type
)
1241 || (sparc64_complex_floating_p (type
) && len
<= 16))
1247 gdb_assert (bitpos
== 0);
1248 gdb_assert ((element
% 2) == 0);
1250 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_Q0_REGNUM
+ element
/ 2;
1251 regcache_cooked_write (regcache
, regnum
, valbuf
);
1255 gdb_assert (bitpos
== 0 || bitpos
== 64);
1257 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
1258 + element
+ bitpos
/ 64;
1259 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1263 gdb_assert (len
== 4);
1264 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 128);
1266 regnum
= SPARC_F0_REGNUM
+ element
* 2 + bitpos
/ 32;
1267 regcache_cooked_write (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1270 else if (sparc64_structure_or_union_p (type
))
1274 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
1276 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
1277 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
1279 sparc64_store_floating_fields (regcache
, subtype
, valbuf
,
1283 /* GCC has an interesting bug. If TYPE is a structure that has
1284 a single `float' member, GCC doesn't treat it as a structure
1285 at all, but rather as an ordinary `float' argument. This
1286 argument will be stored in %f1, as required by the psABI.
1287 However, as a member of a structure the psABI requires it to
1288 be stored in %f0. This bug is present in GCC 3.3.2, but
1289 probably in older releases to. To appease GCC, if a
1290 structure has only a single `float' member, we store its
1291 value in %f1 too (we already have stored in %f0). */
1292 if (TYPE_NFIELDS (type
) == 1)
1294 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
1296 if (sparc64_floating_p (subtype
) && TYPE_LENGTH (subtype
) == 4)
1297 regcache_cooked_write (regcache
, SPARC_F1_REGNUM
, valbuf
);
1302 /* Fetch floating fields from a variable of type TYPE from the
1303 appropriate registers for BITPOS in REGCACHE and store it at BITPOS
1304 in VALBUF. This function can be called recursively and therefore
1305 handles floating types in addition to structures. */
1308 sparc64_extract_floating_fields (struct regcache
*regcache
, struct type
*type
,
1309 gdb_byte
*valbuf
, int bitpos
)
1311 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1313 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1315 int len
= TYPE_LENGTH (type
);
1316 int regnum
= SPARC_F0_REGNUM
+ bitpos
/ 32;
1318 valbuf
+= bitpos
/ 8;
1322 regcache_cooked_read (regcache
, regnum
, buf
);
1323 memcpy (valbuf
, buf
+ 4 - len
, len
);
1326 for (int i
= 0; i
< (len
+ 3) / 4; i
++)
1327 regcache_cooked_read (regcache
, regnum
+ i
, valbuf
+ i
* 4);
1329 else if (sparc64_floating_p (type
))
1331 int len
= TYPE_LENGTH (type
);
1336 gdb_assert (bitpos
== 0 || bitpos
== 128);
1338 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_Q0_REGNUM
1340 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1344 gdb_assert (bitpos
% 64 == 0 && bitpos
>= 0 && bitpos
< 256);
1346 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
+ bitpos
/ 64;
1347 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1351 gdb_assert (len
== 4);
1352 gdb_assert (bitpos
% 32 == 0 && bitpos
>= 0 && bitpos
< 256);
1354 regnum
= SPARC_F0_REGNUM
+ bitpos
/ 32;
1355 regcache_cooked_read (regcache
, regnum
, valbuf
+ (bitpos
/ 8));
1358 else if (sparc64_structure_or_union_p (type
))
1362 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
1364 struct type
*subtype
= check_typedef (TYPE_FIELD_TYPE (type
, i
));
1365 int subpos
= bitpos
+ TYPE_FIELD_BITPOS (type
, i
);
1367 sparc64_extract_floating_fields (regcache
, subtype
, valbuf
, subpos
);
1372 /* Store the NARGS arguments ARGS and STRUCT_ADDR (if STRUCT_RETURN is
1373 non-zero) in REGCACHE and on the stack (starting from address SP). */
1376 sparc64_store_arguments (struct regcache
*regcache
, int nargs
,
1377 struct value
**args
, CORE_ADDR sp
,
1378 int struct_return
, CORE_ADDR struct_addr
)
1380 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1381 /* Number of extended words in the "parameter array". */
1382 int num_elements
= 0;
1386 /* Take BIAS into account. */
1389 /* First we calculate the number of extended words in the "parameter
1390 array". While doing so we also convert some of the arguments. */
1395 for (i
= 0; i
< nargs
; i
++)
1397 struct type
*type
= value_type (args
[i
]);
1398 int len
= TYPE_LENGTH (type
);
1400 if (sparc64_structure_or_union_p (type
)
1401 || (sparc64_complex_floating_p (type
) && len
== 32))
1403 /* Structure or Union arguments. */
1406 if (num_elements
% 2 && sparc64_16_byte_align_p (type
))
1408 num_elements
+= ((len
+ 7) / 8);
1412 /* The psABI says that "Structures or unions larger than
1413 sixteen bytes are copied by the caller and passed
1414 indirectly; the caller will pass the address of a
1415 correctly aligned structure value. This sixty-four
1416 bit address will occupy one word in the parameter
1417 array, and may be promoted to an %o register like any
1418 other pointer value." Allocate memory for these
1419 values on the stack. */
1422 /* Use 16-byte alignment for these values. That's
1423 always correct, and wasting a few bytes shouldn't be
1427 write_memory (sp
, value_contents (args
[i
]), len
);
1428 args
[i
] = value_from_pointer (lookup_pointer_type (type
), sp
);
1432 else if (sparc64_floating_p (type
) || sparc64_complex_floating_p (type
))
1434 /* Floating arguments. */
1437 /* The psABI says that "Each quad-precision parameter
1438 value will be assigned to two extended words in the
1442 /* The psABI says that "Long doubles must be
1443 quad-aligned, and thus a hole might be introduced
1444 into the parameter array to force alignment." Skip
1445 an element if necessary. */
1446 if ((num_elements
% 2) && sparc64_16_byte_align_p (type
))
1454 /* Integral and pointer arguments. */
1455 gdb_assert (sparc64_integral_or_pointer_p (type
));
1457 /* The psABI says that "Each argument value of integral type
1458 smaller than an extended word will be widened by the
1459 caller to an extended word according to the signed-ness
1460 of the argument type." */
1462 args
[i
] = value_cast (builtin_type (gdbarch
)->builtin_int64
,
1468 /* Allocate the "parameter array". */
1469 sp
-= num_elements
* 8;
1471 /* The psABI says that "Every stack frame must be 16-byte aligned." */
1474 /* Now we store the arguments in to the "paramater array". Some
1475 Integer or Pointer arguments and Structure or Union arguments
1476 will be passed in %o registers. Some Floating arguments and
1477 floating members of structures are passed in floating-point
1478 registers. However, for functions with variable arguments,
1479 floating arguments are stored in an %0 register, and for
1480 functions without a prototype floating arguments are stored in
1481 both a floating-point and an %o registers, or a floating-point
1482 register and memory. To simplify the logic here we always pass
1483 arguments in memory, an %o register, and a floating-point
1484 register if appropriate. This should be no problem since the
1485 contents of any unused memory or registers in the "parameter
1486 array" are undefined. */
1490 regcache_cooked_write_unsigned (regcache
, SPARC_O0_REGNUM
, struct_addr
);
1494 for (i
= 0; i
< nargs
; i
++)
1496 const gdb_byte
*valbuf
= value_contents (args
[i
]);
1497 struct type
*type
= value_type (args
[i
]);
1498 int len
= TYPE_LENGTH (type
);
1502 if (sparc64_structure_or_union_p (type
)
1503 || (sparc64_complex_floating_p (type
) && len
== 32))
1505 /* Structure, Union or long double Complex arguments. */
1506 gdb_assert (len
<= 16);
1507 memset (buf
, 0, sizeof (buf
));
1508 memcpy (buf
, valbuf
, len
);
1511 if (element
% 2 && sparc64_16_byte_align_p (type
))
1516 regnum
= SPARC_O0_REGNUM
+ element
;
1517 if (len
> 8 && element
< 5)
1518 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
1522 sparc64_store_floating_fields (regcache
, type
, valbuf
, element
, 0);
1524 else if (sparc64_complex_floating_p (type
))
1526 /* Float Complex or double Complex arguments. */
1529 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
+ element
;
1533 if (regnum
< gdbarch_num_regs (gdbarch
) + SPARC64_D30_REGNUM
)
1534 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
1535 if (regnum
< gdbarch_num_regs (gdbarch
) + SPARC64_D10_REGNUM
)
1536 regcache_cooked_write (regcache
,
1537 SPARC_O0_REGNUM
+ element
+ 1,
1542 else if (sparc64_floating_p (type
))
1544 /* Floating arguments. */
1550 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_Q0_REGNUM
1556 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
1561 /* The psABI says "Each single-precision parameter value
1562 will be assigned to one extended word in the
1563 parameter array, and right-justified within that
1564 word; the left half (even float register) is
1565 undefined." Even though the psABI says that "the
1566 left half is undefined", set it to zero here. */
1568 memcpy (buf
+ 4, valbuf
, 4);
1572 regnum
= gdbarch_num_regs (gdbarch
) + SPARC64_D0_REGNUM
1578 /* Integral and pointer arguments. */
1579 gdb_assert (len
== 8);
1581 regnum
= SPARC_O0_REGNUM
+ element
;
1586 regcache_cooked_write (regcache
, regnum
, valbuf
);
1588 /* If we're storing the value in a floating-point register,
1589 also store it in the corresponding %0 register(s). */
1590 if (regnum
>= gdbarch_num_regs (gdbarch
))
1592 regnum
-= gdbarch_num_regs (gdbarch
);
1594 if (regnum
>= SPARC64_D0_REGNUM
&& regnum
<= SPARC64_D10_REGNUM
)
1596 gdb_assert (element
< 6);
1597 regnum
= SPARC_O0_REGNUM
+ element
;
1598 regcache_cooked_write (regcache
, regnum
, valbuf
);
1600 else if (regnum
>= SPARC64_Q0_REGNUM
&& regnum
<= SPARC64_Q8_REGNUM
)
1602 gdb_assert (element
< 5);
1603 regnum
= SPARC_O0_REGNUM
+ element
;
1604 regcache_cooked_write (regcache
, regnum
, valbuf
);
1605 regcache_cooked_write (regcache
, regnum
+ 1, valbuf
+ 8);
1610 /* Always store the argument in memory. */
1611 write_memory (sp
+ element
* 8, valbuf
, len
);
1612 element
+= ((len
+ 7) / 8);
1615 gdb_assert (element
== num_elements
);
1617 /* Take BIAS into account. */
1623 sparc64_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR address
)
1625 /* The ABI requires 16-byte alignment. */
1626 return address
& ~0xf;
1630 sparc64_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
1631 struct regcache
*regcache
, CORE_ADDR bp_addr
,
1632 int nargs
, struct value
**args
, CORE_ADDR sp
,
1633 int struct_return
, CORE_ADDR struct_addr
)
1635 /* Set return address. */
1636 regcache_cooked_write_unsigned (regcache
, SPARC_O7_REGNUM
, bp_addr
- 8);
1638 /* Set up function arguments. */
1639 sp
= sparc64_store_arguments (regcache
, nargs
, args
, sp
,
1640 struct_return
, struct_addr
);
1642 /* Allocate the register save area. */
1645 /* Stack should be 16-byte aligned at this point. */
1646 gdb_assert ((sp
+ BIAS
) % 16 == 0);
1648 /* Finally, update the stack pointer. */
1649 regcache_cooked_write_unsigned (regcache
, SPARC_SP_REGNUM
, sp
);
1655 /* Extract from an array REGBUF containing the (raw) register state, a
1656 function return value of TYPE, and copy that into VALBUF. */
1659 sparc64_extract_return_value (struct type
*type
, struct regcache
*regcache
,
1662 int len
= TYPE_LENGTH (type
);
1666 if (sparc64_structure_or_union_p (type
))
1668 /* Structure or Union return values. */
1669 gdb_assert (len
<= 32);
1671 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1672 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1673 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1674 sparc64_extract_floating_fields (regcache
, type
, buf
, 0);
1675 memcpy (valbuf
, buf
, len
);
1677 else if (sparc64_floating_p (type
) || sparc64_complex_floating_p (type
))
1679 /* Floating return values. */
1680 for (i
= 0; i
< len
/ 4; i
++)
1681 regcache_cooked_read (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1682 memcpy (valbuf
, buf
, len
);
1684 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1686 /* Small arrays are returned the same way as small structures. */
1687 gdb_assert (len
<= 32);
1689 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1690 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1691 memcpy (valbuf
, buf
, len
);
1695 /* Integral and pointer return values. */
1696 gdb_assert (sparc64_integral_or_pointer_p (type
));
1698 /* Just stripping off any unused bytes should preserve the
1699 signed-ness just fine. */
1700 regcache_cooked_read (regcache
, SPARC_O0_REGNUM
, buf
);
1701 memcpy (valbuf
, buf
+ 8 - len
, len
);
1705 /* Write into the appropriate registers a function return value stored
1706 in VALBUF of type TYPE. */
1709 sparc64_store_return_value (struct type
*type
, struct regcache
*regcache
,
1710 const gdb_byte
*valbuf
)
1712 int len
= TYPE_LENGTH (type
);
1716 if (sparc64_structure_or_union_p (type
))
1718 /* Structure or Union return values. */
1719 gdb_assert (len
<= 32);
1721 /* Simplify matters by storing the complete value (including
1722 floating members) into %o0 and %o1. Floating members are
1723 also store in the appropriate floating-point registers. */
1724 memset (buf
, 0, sizeof (buf
));
1725 memcpy (buf
, valbuf
, len
);
1726 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1727 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1728 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
1729 sparc64_store_floating_fields (regcache
, type
, buf
, 0, 0);
1731 else if (sparc64_floating_p (type
) || sparc64_complex_floating_p (type
))
1733 /* Floating return values. */
1734 memcpy (buf
, valbuf
, len
);
1735 for (i
= 0; i
< len
/ 4; i
++)
1736 regcache_cooked_write (regcache
, SPARC_F0_REGNUM
+ i
, buf
+ i
* 4);
1738 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
)
1740 /* Small arrays are returned the same way as small structures. */
1741 gdb_assert (len
<= 32);
1743 memset (buf
, 0, sizeof (buf
));
1744 memcpy (buf
, valbuf
, len
);
1745 for (i
= 0; i
< ((len
+ 7) / 8); i
++)
1746 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
+ i
, buf
+ i
* 8);
1750 /* Integral and pointer return values. */
1751 gdb_assert (sparc64_integral_or_pointer_p (type
));
1753 /* ??? Do we need to do any sign-extension here? */
1755 memcpy (buf
+ 8 - len
, valbuf
, len
);
1756 regcache_cooked_write (regcache
, SPARC_O0_REGNUM
, buf
);
1760 static enum return_value_convention
1761 sparc64_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
1762 struct type
*type
, struct regcache
*regcache
,
1763 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1765 if (TYPE_LENGTH (type
) > 32)
1766 return RETURN_VALUE_STRUCT_CONVENTION
;
1769 sparc64_extract_return_value (type
, regcache
, readbuf
);
1771 sparc64_store_return_value (type
, regcache
, writebuf
);
1773 return RETURN_VALUE_REGISTER_CONVENTION
;
1778 sparc64_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1779 struct dwarf2_frame_state_reg
*reg
,
1780 struct frame_info
*this_frame
)
1784 case SPARC_G0_REGNUM
:
1785 /* Since %g0 is always zero, there is no point in saving it, and
1786 people will be inclined omit it from the CFI. Make sure we
1787 don't warn about that. */
1788 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
1790 case SPARC_SP_REGNUM
:
1791 reg
->how
= DWARF2_FRAME_REG_CFA
;
1793 case SPARC64_PC_REGNUM
:
1794 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1795 reg
->loc
.offset
= 8;
1797 case SPARC64_NPC_REGNUM
:
1798 reg
->how
= DWARF2_FRAME_REG_RA_OFFSET
;
1799 reg
->loc
.offset
= 12;
1804 /* sparc64_addr_bits_remove - remove useless address bits */
1807 sparc64_addr_bits_remove (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
1809 return adi_normalize_address (addr
);
1813 sparc64_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
1815 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1817 tdep
->pc_regnum
= SPARC64_PC_REGNUM
;
1818 tdep
->npc_regnum
= SPARC64_NPC_REGNUM
;
1819 tdep
->fpu_register_names
= sparc64_fpu_register_names
;
1820 tdep
->fpu_registers_num
= ARRAY_SIZE (sparc64_fpu_register_names
);
1821 tdep
->cp0_register_names
= sparc64_cp0_register_names
;
1822 tdep
->cp0_registers_num
= ARRAY_SIZE (sparc64_cp0_register_names
);
1824 /* This is what all the fuss is about. */
1825 set_gdbarch_long_bit (gdbarch
, 64);
1826 set_gdbarch_long_long_bit (gdbarch
, 64);
1827 set_gdbarch_ptr_bit (gdbarch
, 64);
1829 set_gdbarch_wchar_bit (gdbarch
, 16);
1830 set_gdbarch_wchar_signed (gdbarch
, 0);
1832 set_gdbarch_num_regs (gdbarch
, SPARC64_NUM_REGS
);
1833 set_gdbarch_register_name (gdbarch
, sparc64_register_name
);
1834 set_gdbarch_register_type (gdbarch
, sparc64_register_type
);
1835 set_gdbarch_num_pseudo_regs (gdbarch
, SPARC64_NUM_PSEUDO_REGS
);
1836 set_tdesc_pseudo_register_name (gdbarch
, sparc64_pseudo_register_name
);
1837 set_tdesc_pseudo_register_type (gdbarch
, sparc64_pseudo_register_type
);
1838 set_gdbarch_pseudo_register_read (gdbarch
, sparc64_pseudo_register_read
);
1839 set_gdbarch_pseudo_register_write (gdbarch
, sparc64_pseudo_register_write
);
1841 /* Register numbers of various important registers. */
1842 set_gdbarch_pc_regnum (gdbarch
, SPARC64_PC_REGNUM
); /* %pc */
1844 /* Call dummy code. */
1845 set_gdbarch_frame_align (gdbarch
, sparc64_frame_align
);
1846 set_gdbarch_call_dummy_location (gdbarch
, AT_ENTRY_POINT
);
1847 set_gdbarch_push_dummy_code (gdbarch
, NULL
);
1848 set_gdbarch_push_dummy_call (gdbarch
, sparc64_push_dummy_call
);
1850 set_gdbarch_return_value (gdbarch
, sparc64_return_value
);
1851 set_gdbarch_stabs_argument_has_addr
1852 (gdbarch
, default_stabs_argument_has_addr
);
1854 set_gdbarch_skip_prologue (gdbarch
, sparc64_skip_prologue
);
1855 set_gdbarch_stack_frame_destroyed_p (gdbarch
, sparc_stack_frame_destroyed_p
);
1857 /* Hook in the DWARF CFI frame unwinder. */
1858 dwarf2_frame_set_init_reg (gdbarch
, sparc64_dwarf2_frame_init_reg
);
1859 /* FIXME: kettenis/20050423: Don't enable the unwinder until the
1860 StackGhost issues have been resolved. */
1862 frame_unwind_append_unwinder (gdbarch
, &sparc64_frame_unwind
);
1863 frame_base_set_default (gdbarch
, &sparc64_frame_base
);
1865 set_gdbarch_addr_bits_remove (gdbarch
, sparc64_addr_bits_remove
);
1869 /* Helper functions for dealing with register sets. */
1871 #define TSTATE_CWP 0x000000000000001fULL
1872 #define TSTATE_ICC 0x0000000f00000000ULL
1873 #define TSTATE_XCC 0x000000f000000000ULL
1875 #define PSR_S 0x00000080
1876 #define PSR_ICC 0x00f00000
1877 #define PSR_VERS 0x0f000000
1878 #define PSR_IMPL 0xf0000000
1879 #define PSR_V8PLUS 0xff000000
1880 #define PSR_XCC 0x000f0000
1883 sparc64_supply_gregset (const struct sparc_gregmap
*gregmap
,
1884 struct regcache
*regcache
,
1885 int regnum
, const void *gregs
)
1887 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1888 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1889 int sparc32
= (gdbarch_ptr_bit (gdbarch
) == 32);
1890 const gdb_byte
*regs
= (const gdb_byte
*) gregs
;
1891 gdb_byte zero
[8] = { 0 };
1896 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
1898 int offset
= gregmap
->r_tstate_offset
;
1899 ULONGEST tstate
, psr
;
1902 tstate
= extract_unsigned_integer (regs
+ offset
, 8, byte_order
);
1903 psr
= ((tstate
& TSTATE_CWP
) | PSR_S
| ((tstate
& TSTATE_ICC
) >> 12)
1904 | ((tstate
& TSTATE_XCC
) >> 20) | PSR_V8PLUS
);
1905 store_unsigned_integer (buf
, 4, byte_order
, psr
);
1906 regcache_raw_supply (regcache
, SPARC32_PSR_REGNUM
, buf
);
1909 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
1910 regcache_raw_supply (regcache
, SPARC32_PC_REGNUM
,
1911 regs
+ gregmap
->r_pc_offset
+ 4);
1913 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
1914 regcache_raw_supply (regcache
, SPARC32_NPC_REGNUM
,
1915 regs
+ gregmap
->r_npc_offset
+ 4);
1917 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
1919 int offset
= gregmap
->r_y_offset
+ 8 - gregmap
->r_y_size
;
1920 regcache_raw_supply (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
1925 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
1926 regcache_raw_supply (regcache
, SPARC64_STATE_REGNUM
,
1927 regs
+ gregmap
->r_tstate_offset
);
1929 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
1930 regcache_raw_supply (regcache
, SPARC64_PC_REGNUM
,
1931 regs
+ gregmap
->r_pc_offset
);
1933 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
1934 regcache_raw_supply (regcache
, SPARC64_NPC_REGNUM
,
1935 regs
+ gregmap
->r_npc_offset
);
1937 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
1942 memcpy (buf
+ 8 - gregmap
->r_y_size
,
1943 regs
+ gregmap
->r_y_offset
, gregmap
->r_y_size
);
1944 regcache_raw_supply (regcache
, SPARC64_Y_REGNUM
, buf
);
1947 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
1948 && gregmap
->r_fprs_offset
!= -1)
1949 regcache_raw_supply (regcache
, SPARC64_FPRS_REGNUM
,
1950 regs
+ gregmap
->r_fprs_offset
);
1953 if (regnum
== SPARC_G0_REGNUM
|| regnum
== -1)
1954 regcache_raw_supply (regcache
, SPARC_G0_REGNUM
, &zero
);
1956 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
1958 int offset
= gregmap
->r_g1_offset
;
1963 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
1965 if (regnum
== i
|| regnum
== -1)
1966 regcache_raw_supply (regcache
, i
, regs
+ offset
);
1971 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
1973 /* Not all of the register set variants include Locals and
1974 Inputs. For those that don't, we read them off the stack. */
1975 if (gregmap
->r_l0_offset
== -1)
1979 regcache_cooked_read_unsigned (regcache
, SPARC_SP_REGNUM
, &sp
);
1980 sparc_supply_rwindow (regcache
, sp
, regnum
);
1984 int offset
= gregmap
->r_l0_offset
;
1989 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
1991 if (regnum
== i
|| regnum
== -1)
1992 regcache_raw_supply (regcache
, i
, regs
+ offset
);
2000 sparc64_collect_gregset (const struct sparc_gregmap
*gregmap
,
2001 const struct regcache
*regcache
,
2002 int regnum
, void *gregs
)
2004 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
2005 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2006 int sparc32
= (gdbarch_ptr_bit (gdbarch
) == 32);
2007 gdb_byte
*regs
= (gdb_byte
*) gregs
;
2012 if (regnum
== SPARC32_PSR_REGNUM
|| regnum
== -1)
2014 int offset
= gregmap
->r_tstate_offset
;
2015 ULONGEST tstate
, psr
;
2018 tstate
= extract_unsigned_integer (regs
+ offset
, 8, byte_order
);
2019 regcache_raw_collect (regcache
, SPARC32_PSR_REGNUM
, buf
);
2020 psr
= extract_unsigned_integer (buf
, 4, byte_order
);
2021 tstate
|= (psr
& PSR_ICC
) << 12;
2022 if ((psr
& (PSR_VERS
| PSR_IMPL
)) == PSR_V8PLUS
)
2023 tstate
|= (psr
& PSR_XCC
) << 20;
2024 store_unsigned_integer (buf
, 8, byte_order
, tstate
);
2025 memcpy (regs
+ offset
, buf
, 8);
2028 if (regnum
== SPARC32_PC_REGNUM
|| regnum
== -1)
2029 regcache_raw_collect (regcache
, SPARC32_PC_REGNUM
,
2030 regs
+ gregmap
->r_pc_offset
+ 4);
2032 if (regnum
== SPARC32_NPC_REGNUM
|| regnum
== -1)
2033 regcache_raw_collect (regcache
, SPARC32_NPC_REGNUM
,
2034 regs
+ gregmap
->r_npc_offset
+ 4);
2036 if (regnum
== SPARC32_Y_REGNUM
|| regnum
== -1)
2038 int offset
= gregmap
->r_y_offset
+ 8 - gregmap
->r_y_size
;
2039 regcache_raw_collect (regcache
, SPARC32_Y_REGNUM
, regs
+ offset
);
2044 if (regnum
== SPARC64_STATE_REGNUM
|| regnum
== -1)
2045 regcache_raw_collect (regcache
, SPARC64_STATE_REGNUM
,
2046 regs
+ gregmap
->r_tstate_offset
);
2048 if (regnum
== SPARC64_PC_REGNUM
|| regnum
== -1)
2049 regcache_raw_collect (regcache
, SPARC64_PC_REGNUM
,
2050 regs
+ gregmap
->r_pc_offset
);
2052 if (regnum
== SPARC64_NPC_REGNUM
|| regnum
== -1)
2053 regcache_raw_collect (regcache
, SPARC64_NPC_REGNUM
,
2054 regs
+ gregmap
->r_npc_offset
);
2056 if (regnum
== SPARC64_Y_REGNUM
|| regnum
== -1)
2060 regcache_raw_collect (regcache
, SPARC64_Y_REGNUM
, buf
);
2061 memcpy (regs
+ gregmap
->r_y_offset
,
2062 buf
+ 8 - gregmap
->r_y_size
, gregmap
->r_y_size
);
2065 if ((regnum
== SPARC64_FPRS_REGNUM
|| regnum
== -1)
2066 && gregmap
->r_fprs_offset
!= -1)
2067 regcache_raw_collect (regcache
, SPARC64_FPRS_REGNUM
,
2068 regs
+ gregmap
->r_fprs_offset
);
2072 if ((regnum
>= SPARC_G1_REGNUM
&& regnum
<= SPARC_O7_REGNUM
) || regnum
== -1)
2074 int offset
= gregmap
->r_g1_offset
;
2079 /* %g0 is always zero. */
2080 for (i
= SPARC_G1_REGNUM
; i
<= SPARC_O7_REGNUM
; i
++)
2082 if (regnum
== i
|| regnum
== -1)
2083 regcache_raw_collect (regcache
, i
, regs
+ offset
);
2088 if ((regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
) || regnum
== -1)
2090 /* Not all of the register set variants include Locals and
2091 Inputs. For those that don't, we read them off the stack. */
2092 if (gregmap
->r_l0_offset
!= -1)
2094 int offset
= gregmap
->r_l0_offset
;
2099 for (i
= SPARC_L0_REGNUM
; i
<= SPARC_I7_REGNUM
; i
++)
2101 if (regnum
== i
|| regnum
== -1)
2102 regcache_raw_collect (regcache
, i
, regs
+ offset
);
2110 sparc64_supply_fpregset (const struct sparc_fpregmap
*fpregmap
,
2111 struct regcache
*regcache
,
2112 int regnum
, const void *fpregs
)
2114 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
2115 const gdb_byte
*regs
= (const gdb_byte
*) fpregs
;
2118 for (i
= 0; i
< 32; i
++)
2120 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
2121 regcache_raw_supply (regcache
, SPARC_F0_REGNUM
+ i
,
2122 regs
+ fpregmap
->r_f0_offset
+ (i
* 4));
2127 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
2128 regcache_raw_supply (regcache
, SPARC32_FSR_REGNUM
,
2129 regs
+ fpregmap
->r_fsr_offset
);
2133 for (i
= 0; i
< 16; i
++)
2135 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
2136 regcache_raw_supply (regcache
, SPARC64_F32_REGNUM
+ i
,
2137 (regs
+ fpregmap
->r_f0_offset
2138 + (32 * 4) + (i
* 8)));
2141 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
2142 regcache_raw_supply (regcache
, SPARC64_FSR_REGNUM
,
2143 regs
+ fpregmap
->r_fsr_offset
);
2148 sparc64_collect_fpregset (const struct sparc_fpregmap
*fpregmap
,
2149 const struct regcache
*regcache
,
2150 int regnum
, void *fpregs
)
2152 int sparc32
= (gdbarch_ptr_bit (get_regcache_arch (regcache
)) == 32);
2153 gdb_byte
*regs
= (gdb_byte
*) fpregs
;
2156 for (i
= 0; i
< 32; i
++)
2158 if (regnum
== (SPARC_F0_REGNUM
+ i
) || regnum
== -1)
2159 regcache_raw_collect (regcache
, SPARC_F0_REGNUM
+ i
,
2160 regs
+ fpregmap
->r_f0_offset
+ (i
* 4));
2165 if (regnum
== SPARC32_FSR_REGNUM
|| regnum
== -1)
2166 regcache_raw_collect (regcache
, SPARC32_FSR_REGNUM
,
2167 regs
+ fpregmap
->r_fsr_offset
);
2171 for (i
= 0; i
< 16; i
++)
2173 if (regnum
== (SPARC64_F32_REGNUM
+ i
) || regnum
== -1)
2174 regcache_raw_collect (regcache
, SPARC64_F32_REGNUM
+ i
,
2175 (regs
+ fpregmap
->r_f0_offset
2176 + (32 * 4) + (i
* 8)));
2179 if (regnum
== SPARC64_FSR_REGNUM
|| regnum
== -1)
2180 regcache_raw_collect (regcache
, SPARC64_FSR_REGNUM
,
2181 regs
+ fpregmap
->r_fsr_offset
);
2185 const struct sparc_fpregmap sparc64_bsd_fpregmap
=