static int store_fpxregs (const struct regcache *regcache, int tid, int regno) { elf_fpxregset_t fpxregs; if (! have_ptrace_getfpxregs) return 0; if (ptrace (PTRACE_GETFPXREGS, tid, 0, &fpxregs) == -1) { if (errno == EIO) { have_ptrace_getfpxregs = 0; return 0; } perror_with_name (_("Couldn't read floating-point and SSE registers")); } i387_collect_fxsave (regcache, regno, &fpxregs); if (ptrace (PTRACE_SETFPXREGS, tid, 0, &fpxregs) == -1) perror_with_name (_("Couldn't write floating-point and SSE registers")); return 1; }
static int i386nto_regset_fill (const struct regcache *regcache, int regset, char *data) { if (regset == NTO_REG_GENERAL) { int regno; for (regno = 0; regno < NUM_GPREGS; regno++) { int offset = nto_reg_offset (regno); if (offset != -1) regcache_raw_collect (regcache, regno, data + offset); } } else if (regset == NTO_REG_FLOAT) { if (nto_cpuinfo_valid && nto_cpuinfo_flags | X86_CPU_FXSR) i387_collect_fxsave (regcache, -1, data); else i387_collect_fsave (regcache, -1, data); } else return -1; return 0; }
static void i386bsd_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { struct reg regs; if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); i386bsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't write registers")); if (regnum != -1) return; } if (regnum == -1 || regnum >= I386_ST0_REGNUM) { struct fpreg fpregs; #ifdef HAVE_PT_GETXMMREGS char xmmregs[512]; if (have_ptrace_xmmregs != 0 && ptrace(PT_GETXMMREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) { have_ptrace_xmmregs = 1; i387_collect_fxsave (regcache, regnum, xmmregs); if (ptrace (PT_SETXMMREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) xmmregs, 0) == -1) perror_with_name (_("Couldn't write XMM registers")); } else { have_ptrace_xmmregs = 0; #endif if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); i387_collect_fsave (regcache, regnum, &fpregs); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't write floating point status")); #ifdef HAVE_PT_GETXMMREGS } #endif } }
static void fbsd_lwp_store_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { gregset_t gregs; fpregset_t fpregs; lwpid_t lwp; #ifdef PT_GETXMMREGS char xmmregs[512]; #endif /* FIXME, is it possible ? */ if (!IS_LWP (inferior_ptid)) { struct target_ops *beneath = find_target_beneath (ops); beneath->to_store_registers (ops, regcache, regnum); return ; } lwp = GET_LWP (inferior_ptid); if (regnum != -1) if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1) error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno)); fill_gregset (regcache, &gregs, regnum); if (ptrace (PT_SETREGS, lwp, (caddr_t) &gregs, 0) == -1) error ("Cannot set lwp %d registers: %s\n", lwp, safe_strerror (errno)); #ifdef PT_GETXMMREGS if (regnum != -1) if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == -1) goto noxmm; i387_collect_fxsave (regcache, regnum, xmmregs); if (ptrace (PT_SETXMMREGS, lwp, xmmregs, 0) == -1) goto noxmm; return; noxmm: #endif if (regnum != -1) if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) error ("Cannot get lwp %d float registers: %s\n", lwp, safe_strerror (errno)); fill_fpregset (regcache, &fpregs, regnum); if (ptrace (PT_SETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) error ("Cannot set lwp %d float registers: %s\n", lwp, safe_strerror (errno)); }
ps_err_e ps_lgetxmmregs (struct ps_prochandle *ph, lwpid_t lwpid, char *xmmregs) { struct cleanup *old_chain; struct regcache *regcache; old_chain = save_inferior_ptid (); inferior_ptid = BUILD_LWP (lwpid, ph->pid); regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch); target_fetch_registers (regcache, -1); i387_collect_fxsave (regcache, -1, xmmregs); do_cleanups (old_chain); return PS_OK; }
void amd64_collect_fxsave(const struct regcache *regcache, int regnum, void *fxsave) { gdb_byte *regs = (gdb_byte *)fxsave; i387_collect_fxsave(regcache, regnum, fxsave); if (gdbarch_ptr_bit(get_regcache_arch(regcache)) == 64) { if ((regnum == -1) || (regnum == I387_FISEG_REGNUM)) regcache_raw_collect(regcache, I387_FISEG_REGNUM, regs + 12); if ((regnum == -1) || (regnum == I387_FOSEG_REGNUM)) regcache_raw_collect(regcache, I387_FOSEG_REGNUM, regs + 20); } }
static void i386bsd_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { struct reg regs; if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't get registers")); i386bsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't write registers")); if (regnum != -1) return; } if (regnum == -1 || regnum >= I386_ST0_REGNUM) { struct fpreg fpregs; #ifdef HAVE_PT_GETXMMREGS char xmmregs[512]; #endif #ifdef PT_GETXSTATE_INFO if (x86bsd_xsave_len != 0) { void *xstateregs; 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")); i387_collect_xsave (regcache, -1, 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 #ifdef HAVE_PT_GETXMMREGS if (have_ptrace_xmmregs != 0 && ptrace(PT_GETXMMREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) xmmregs, ptid_get_lwp (inferior_ptid)) == 0) { have_ptrace_xmmregs = 1; i387_collect_fxsave (regcache, regnum, xmmregs); if (ptrace (PT_SETXMMREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) xmmregs, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't write XMM registers")); } else { have_ptrace_xmmregs = 0; #endif if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't get floating point status")); i387_collect_fsave (regcache, regnum, &fpregs); if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't write floating point status")); #ifdef HAVE_PT_GETXMMREGS } #endif } }
static void i386_darwin_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regno) { thread_t current_thread = ptid_get_tid (inferior_ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); #ifdef BFD64 if (gdbarch_ptr_bit (gdbarch) == 64) { if (regno == -1 || amd64_native_gregset_supplies_p (gdbarch, regno)) { x86_thread_state_t gp_regs; kern_return_t ret; unsigned int gp_count = x86_THREAD_STATE_COUNT; ret = thread_get_state (current_thread, x86_THREAD_STATE, (thread_state_t) &gp_regs, &gp_count); MACH_CHECK_ERROR (ret); gdb_assert (gp_regs.tsh.flavor == x86_THREAD_STATE64); gdb_assert (gp_regs.tsh.count == x86_THREAD_STATE64_COUNT); amd64_collect_native_gregset (regcache, &gp_regs.uts, regno); ret = thread_set_state (current_thread, x86_THREAD_STATE, (thread_state_t) &gp_regs, x86_THREAD_STATE_COUNT); MACH_CHECK_ERROR (ret); } if (regno == -1 || !amd64_native_gregset_supplies_p (gdbarch, regno)) { x86_float_state_t fp_regs; kern_return_t ret; unsigned int fp_count = x86_FLOAT_STATE_COUNT; ret = thread_get_state (current_thread, x86_FLOAT_STATE, (thread_state_t) & fp_regs, &fp_count); MACH_CHECK_ERROR (ret); gdb_assert (fp_regs.fsh.flavor == x86_FLOAT_STATE64); gdb_assert (fp_regs.fsh.count == x86_FLOAT_STATE64_COUNT); amd64_collect_fxsave (regcache, regno, &fp_regs.ufs.fs64.__fpu_fcw); ret = thread_set_state (current_thread, x86_FLOAT_STATE, (thread_state_t) & fp_regs, x86_FLOAT_STATE_COUNT); MACH_CHECK_ERROR (ret); } } else #endif { if (regno == -1 || regno < I386_NUM_GREGS) { i386_thread_state_t gp_regs; kern_return_t ret; unsigned int gp_count = i386_THREAD_STATE_COUNT; int i; ret = thread_get_state (current_thread, i386_THREAD_STATE, (thread_state_t) & gp_regs, &gp_count); MACH_CHECK_ERROR (ret); for (i = 0; i < I386_NUM_GREGS; i++) if (regno == -1 || regno == i) regcache_raw_collect (regcache, i, (char *)&gp_regs + i386_darwin_thread_state_reg_offset[i]); ret = thread_set_state (current_thread, i386_THREAD_STATE, (thread_state_t) & gp_regs, i386_THREAD_STATE_COUNT); MACH_CHECK_ERROR (ret); } if (regno == -1 || (regno >= I386_ST0_REGNUM && regno < I386_SSE_NUM_REGS)) { i386_float_state_t fp_regs; unsigned int fp_count = i386_FLOAT_STATE_COUNT; kern_return_t ret; ret = thread_get_state (current_thread, i386_FLOAT_STATE, (thread_state_t) & fp_regs, &fp_count); MACH_CHECK_ERROR (ret); i387_collect_fxsave (regcache, regno, &fp_regs.__fpu_fcw); ret = thread_set_state (current_thread, i386_FLOAT_STATE, (thread_state_t) & fp_regs, i386_FLOAT_STATE_COUNT); MACH_CHECK_ERROR (ret); } } }
static void fbsd_thread_store_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { prgregset_t gregset; prfpregset_t fpregset; td_thrhandle_t th; td_err_e err; #ifdef PT_GETXMMREGS char xmmregs[512]; #endif if (!IS_THREAD (inferior_ptid)) { fbsd_lwp_store_registers (ops, regcache, regnum); return; } err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); if (err != TD_OK) error ("Cannot find thread %d: Thread ID=%ld, %s", pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), thread_db_err_str (err)); if (regnum != -1) { char old_value[MAX_REGISTER_SIZE]; regcache_raw_collect (regcache, regnum, old_value); err = td_thr_getgregs_p (&th, gregset); if (err != TD_OK) error ("%s: td_thr_getgregs %s", __func__, thread_db_err_str (err)); #ifdef PT_GETXMMREGS err = td_thr_getxmmregs_p (&th, xmmregs); if (err != TD_OK) { #endif err = td_thr_getfpregs_p (&th, &fpregset); if (err != TD_OK) error ("%s: td_thr_getfpgregs %s", __func__, thread_db_err_str (err)); #ifdef PT_GETXMMREGS } #endif regcache_raw_supply (regcache, regnum, old_value); } fill_gregset (regcache, gregset, regnum); err = td_thr_setgregs_p (&th, gregset); if (err != TD_OK) error ("Cannot store general-purpose registers for thread %d: Thread ID=%ld, %s", pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), thread_db_err_str (err)); #ifdef PT_GETXMMREGS i387_collect_fxsave (regcache, regnum, xmmregs); err = td_thr_setxmmregs_p (&th, xmmregs); if (err == TD_OK) return; #endif fill_fpregset (regcache, &fpregset, regnum); err = td_thr_setfpregs_p (&th, &fpregset); if (err != TD_OK) error ("Cannot store floating-point registers for thread %d: Thread ID=%ld, %s", pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), thread_db_err_str (err)); }
void fill_fpxregset (const struct regcache *regcache, elf_fpxregset_t *fpxregsetp, int regno) { i387_collect_fxsave (regcache, regno, fpxregsetp); }