+
+ /* GNU/Linux LWP ID's are process ID's. */
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+
+ errno = 0;
+ val = ptrace (PTRACE_PEEKUSER, tid, 4 * regmap[regno], 0);
+ if (errno != 0)
+ error (_("Couldn't read register %s (#%d): %s."),
+ gdbarch_register_name (get_regcache_arch (regcache), regno),
+ regno, safe_strerror (errno));
+
+ regcache_raw_supply (regcache, regno, &val);
+}
+
+/* Store one register. */
+
+static void
+store_register (const struct regcache *regcache, int regno)
+{
+ int tid;
+ int val;
+
+ gdb_assert (!have_ptrace_getregs);
+ if (regmap[regno] == -1)
+ 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. */
+
+ errno = 0;
+ regcache_raw_collect (regcache, regno, &val);
+ ptrace (PTRACE_POKEUSER, tid, 4 * regmap[regno], val);
+ if (errno != 0)
+ error (_("Couldn't write register %s (#%d): %s."),
+ gdbarch_register_name (get_regcache_arch (regcache), regno),
+ regno, safe_strerror (errno));
+}
+\f
+
+/* Transfering the general-purpose registers between GDB, inferiors
+ and core files. */
+
+/* Fill GDB's register array with the general-purpose register values
+ in *GREGSETP. */
+
+void
+supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp)
+{
+ const elf_greg_t *regp = (const elf_greg_t *) gregsetp;
+ int i;
+
+ for (i = 0; i < I386_NUM_GREGS; i++)
+ regcache_raw_supply (regcache, i, regp + regmap[i]);
+
+ if (I386_LINUX_ORIG_EAX_REGNUM
+ < gdbarch_num_regs (get_regcache_arch (regcache)))
+ regcache_raw_supply (regcache, I386_LINUX_ORIG_EAX_REGNUM,
+ regp + ORIG_EAX);