static void amd64bsd_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = get_regcache_arch (regcache); if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) { struct reg regs; if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); amd64_collect_native_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't write registers")); if (regnum != -1) return; } if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum)) { struct fpreg fpregs; #ifdef PT_GETXSTATE_INFO void *xstateregs; if (x86bsd_xsave_len != 0) { xstateregs = alloca (x86bsd_xsave_len); if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) perror_with_name (_("Couldn't get extended state status")); amd64_collect_xsave (regcache, regnum, xstateregs, 0); if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1) perror_with_name (_("Couldn't write extended state status")); return; } #endif if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); amd64_collect_fxsave (regcache, regnum, &fpregs); if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't write floating point status")); } }
static void amd64_linux_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = get_regcache_arch (regcache); int tid; /* GNU/Linux LWP ID's are process ID's. */ tid = ptid_get_lwp (inferior_ptid); if (tid == 0) tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */ if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) { elf_gregset_t regs; if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) perror_with_name (_("Couldn't get registers")); amd64_collect_native_gregset (regcache, ®s, regnum); if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) perror_with_name (_("Couldn't write registers")); if (regnum != -1) return; } if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum)) { elf_fpregset_t fpregs; if (have_ptrace_getregset) { char xstateregs[I386_XSTATE_MAX_SIZE]; struct iovec iov; iov.iov_base = xstateregs; iov.iov_len = sizeof (xstateregs); if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE, (long) &iov) < 0) perror_with_name (_("Couldn't get extended state status")); amd64_collect_xsave (regcache, regnum, xstateregs, 0); if (ptrace (PTRACE_SETREGSET, tid, (unsigned int) NT_X86_XSTATE, (long) &iov) < 0) perror_with_name (_("Couldn't write extended state status")); } else { if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); amd64_collect_fxsave (regcache, regnum, &fpregs); if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0) perror_with_name (_("Couldn't write floating point status")); } } }
void amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = regcache->arch (); pid_t pid = get_ptrace_pid (regcache->ptid ()); if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) { struct reg regs; if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); amd64_collect_native_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't write registers")); if (regnum != -1) return; } #ifdef PT_SETFSBASE if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM) { register_t base; regcache->raw_collect (AMD64_FSBASE_REGNUM, &base); if (ptrace (PT_SETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) perror_with_name (_("Couldn't write segment register fs_base")); if (regnum != -1) return; } #endif #ifdef PT_SETGSBASE if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM) { register_t base; regcache->raw_collect (AMD64_GSBASE_REGNUM, &base); if (ptrace (PT_SETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) perror_with_name (_("Couldn't write segment register gs_base")); if (regnum != -1) return; } #endif if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum)) { struct fpreg fpregs; #ifdef PT_GETXSTATE_INFO void *xstateregs; if (x86bsd_xsave_len != 0) { xstateregs = alloca (x86bsd_xsave_len); if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) perror_with_name (_("Couldn't get extended state status")); amd64_collect_xsave (regcache, regnum, xstateregs, 0); if (ptrace (PT_SETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1) perror_with_name (_("Couldn't write extended state status")); return; } #endif if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); amd64_collect_fxsave (regcache, regnum, &fpregs); if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't write floating point status")); } }