+ sparc64_collect_fpregset (&sparc64_bsd_fpregmap, regcache, regnum, fpregs);
+}
+
+/* Set the program counter for process PTID to PC. */
+
+#define TSTATE_SYSCALL 0x0000000000000020ULL
+
+static void
+sparc64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
+ ULONGEST state;
+
+ regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc);
+ regcache_cooked_write_unsigned (regcache, tdep->npc_regnum, pc + 4);
+
+ /* Clear the "in syscall" bit to prevent the kernel from
+ messing with the PCs we just installed, if we happen to be
+ within an interrupted system call that the kernel wants to
+ restart.
+
+ Note that after we return from the dummy call, the TSTATE et al.
+ registers will be automatically restored, and the kernel
+ continues to restart the system call at this point. */
+ regcache_cooked_read_unsigned (regcache, SPARC64_STATE_REGNUM, &state);
+ state &= ~TSTATE_SYSCALL;
+ regcache_cooked_write_unsigned (regcache, SPARC64_STATE_REGNUM, state);
+}
+
+static LONGEST
+sparc64_linux_get_syscall_number (struct gdbarch *gdbarch,
+ thread_info *thread)
+{
+ struct regcache *regcache = get_thread_regcache (thread);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ /* The content of a register. */
+ gdb_byte buf[8];
+ /* The result. */
+ LONGEST ret;
+
+ /* Getting the system call number from the register.
+ When dealing with the sparc architecture, this information
+ is stored at the %g1 register. */
+ regcache->cooked_read (SPARC_G1_REGNUM, buf);
+
+ ret = extract_signed_integer (buf, 8, byte_order);
+
+ return ret;
+}
+
+\f
+/* Implement the "get_longjmp_target" gdbarch method. */
+
+static int
+sparc64_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
+{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ CORE_ADDR jb_addr;
+ gdb_byte buf[8];
+
+ jb_addr = get_frame_register_unsigned (frame, SPARC_O0_REGNUM);
+
+ /* setjmp and longjmp in SPARC64 are implemented in glibc using the
+ setcontext and getcontext system calls respectively. These
+ system calls operate on ucontext_t structures, which happen to
+ partially have the same structure than jmp_buf. However the
+ ucontext returned by getcontext, and thus the jmp_buf structure
+ returned by setjmp, contains the context of the trap instruction
+ in the glibc __[sig]setjmp wrapper, not the context of the user
+ code calling setjmp.
+
+ %o7 in the jmp_buf structure is stored at offset 18*8 in the
+ mc_gregs array, which is itself located at offset 32 into
+ jmp_buf. See bits/setjmp.h. This register contains the address
+ of the 'call setjmp' instruction in user code.
+
+ In order to determine the longjmp target address in the
+ initiating frame we need to examine the call instruction itself,
+ in particular whether the annul bit is set. If it is not set
+ then we need to jump over the instruction at the delay slot. */
+
+ if (target_read_memory (jb_addr + 32 + (18 * 8), buf, 8))
+ return 0;
+
+ *pc = extract_unsigned_integer (buf, 8, gdbarch_byte_order (gdbarch));
+
+ if (!sparc_is_annulled_branch_insn (*pc))
+ *pc += 4; /* delay slot insn */
+ *pc += 4; /* call insn */
+
+ return 1;