static void i386bsd_fetch_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { struct reg regs; if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); i386bsd_supply_gregset (regcache, ®s); 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, pid, (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) perror_with_name (_("Couldn't get extended state status")); i387_supply_xsave (regcache, -1, xstateregs); return; } #endif #ifdef HAVE_PT_GETXMMREGS if (have_ptrace_xmmregs != 0 && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) { have_ptrace_xmmregs = 1; i387_supply_fxsave (regcache, -1, xmmregs); } else { have_ptrace_xmmregs = 0; #endif if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); i387_supply_fsave (regcache, -1, &fpregs); #ifdef HAVE_PT_GETXMMREGS } #endif } }
static void shnbsd_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regno) { pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); if (regno == -1 || GETREGS_SUPPLIES (regcache->arch (), regno)) { struct reg inferior_registers; if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) perror_with_name (_("Couldn't get registers")); sh_corefile_collect_regset (&sh_corefile_gregset, regcache, regno, (char *) &inferior_registers, SHNBSD_SIZEOF_GREGS); if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) perror_with_name (_("Couldn't set registers")); if (regno != -1) return; } }
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 } }
/* Store register REGNO back into the child process. If REGNO is -1, do this for all registers (including the floating point and SSE registers). */ static void i386_linux_store_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regno) { int tid; /* Use the old method of poking around in `struct user' if the SETREGS request isn't available. */ if (!have_ptrace_getregs) { int i; for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) if (regno == -1 || regno == i) store_register (regcache, i); return; } /* GNU/Linux LWP ID's are process ID's. */ tid = TIDGET (inferior_ptid); if (tid == 0) tid = PIDGET (inferior_ptid); /* Not a threaded program. */ /* Use the PTRACE_SETFPXREGS requests whenever possible, since it transfers more registers in one system call. But remember that store_fpxregs can fail, and return zero. */ if (regno == -1) { store_regs (regcache, tid, regno); if (store_fpxregs (regcache, tid, regno)) return; store_fpregs (regcache, tid, regno); return; } if (GETREGS_SUPPLIES (regno)) { store_regs (regcache, tid, regno); return; } if (GETFPXREGS_SUPPLIES (regno)) { if (store_fpxregs (regcache, tid, regno)) return; /* Either our processor or our kernel doesn't support the SSE registers, so just write the FP registers in the traditional way. */ store_fpregs (regcache, tid, regno); return; } internal_error (__FILE__, __LINE__, _("Got request to store bad register number %d."), regno); }
static void i386bsd_fetch_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { struct reg regs; if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't get registers")); i386bsd_supply_gregset (regcache, ®s); 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, ptid_get_pid (inferior_ptid), (PTRACE_TYPE_ARG3) xmmregs, ptid_get_lwp (inferior_ptid)) == 0) { have_ptrace_xmmregs = 1; i387_supply_fxsave (regcache, -1, xmmregs); } else { if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't get floating point status")); i387_supply_fsave (regcache, -1, &fpregs); } #else if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1) perror_with_name (_("Couldn't get floating point status")); i387_supply_fsave (regcache, -1, &fpregs); #endif } }
void fetch_inferior_registers (int regno) { if (regno == -1 || GETREGS_SUPPLIES (regno)) { struct reg inferior_registers; if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) perror_with_name (_("Couldn't get registers")); shnbsd_supply_reg ((char *) &inferior_registers, regno); if (regno != -1) return; } }
void fetch_inferior_registers (int regnum) { if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { struct reg regs; if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) ®s, 0) == -1) perror_with_name ("Couldn't get registers"); i386bsd_supply_gregset (current_regcache, ®s); 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_ARG3_TYPE) xmmregs, 0) == 0) { have_ptrace_xmmregs = 1; i387_supply_fxsave (current_regcache, -1, xmmregs); } else { if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); i387_supply_fsave (current_regcache, -1, &fpregs); } #else if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); i387_supply_fsave (current_regcache, -1, &fpregs); #endif } }
static void shnbsd_fetch_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regno) { if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno)) { struct reg inferior_registers; if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) perror_with_name (_("Couldn't get registers")); sh_corefile_supply_regset (&sh_corefile_gregset, regcache, regno, (char *) &inferior_registers, SHNBSD_SIZEOF_GREGS); if (regno != -1) return; } }
static void i386_linux_fetch_inferior_registers (struct target_ops *ops, struct regcache *regcache, int regno) { int tid; /* Use the old method of peeking around in `struct user' if the GETREGS request isn't available. */ if (!have_ptrace_getregs) { int i; for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) if (regno == -1 || regno == i) fetch_register (regcache, i); return; } /* 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. */ /* Use the PTRACE_GETFPXREGS request whenever possible, since it transfers more registers in one system call, and we'll cache the results. But remember that fetch_fpxregs can fail, and return zero. */ if (regno == -1) { fetch_regs (regcache, tid); /* The call above might reset `have_ptrace_getregs'. */ if (!have_ptrace_getregs) { i386_linux_fetch_inferior_registers (ops, regcache, regno); return; } if (fetch_xstateregs (regcache, tid)) return; if (fetch_fpxregs (regcache, tid)) return; fetch_fpregs (regcache, tid); return; } if (GETREGS_SUPPLIES (regno)) { fetch_regs (regcache, tid); return; } if (GETXSTATEREGS_SUPPLIES (regno)) { if (fetch_xstateregs (regcache, tid)) return; } if (GETFPXREGS_SUPPLIES (regno)) { if (fetch_fpxregs (regcache, tid)) return; /* Either our processor or our kernel doesn't support the SSE registers, so read the FP registers in the traditional way, and fill the SSE registers with dummy values. It would be more graceful to handle differences in the register set using gdbarch. Until then, this will at least make things work plausibly. */ fetch_fpregs (regcache, tid); return; } internal_error (__FILE__, __LINE__, _("Got request for bad register number %d."), regno); }