/* 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 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); }