+ thread_state_t state;
+ thread_state_data_t old_state;
+ int was_aborted = thread->aborted;
+ int was_valid = thread->state_valid;
+ int trace;
+
+ if (!was_aborted && was_valid)
+ memcpy (&old_state, &thread->state, sizeof (old_state));
+
+ state = proc_get_state (thread, 1);
+ if (!state)
+ {
+ warning (_("Couldn't store registers into %s"),
+ proc_string (thread));
+ return;
+ }
+
+ /* Save the T bit. We might try to restore the %eflags register
+ below, but changing the T bit would seriously confuse GDB. */
+ trace = ((struct i386_thread_state *)state)->efl & 0x100;
+
+ if (!was_aborted && was_valid)
+ /* See which registers have changed after aborting the thread. */
+ {
+ int check_regno;
+
+ for (check_regno = 0; check_regno < I386_NUM_GREGS; check_regno++)
+ if ((thread->fetched_regs & (1 << check_regno))
+ && memcpy (REG_ADDR (&old_state, check_regno),
+ REG_ADDR (state, check_regno),
+ register_size (gdbarch, check_regno)))
+ /* Register CHECK_REGNO has changed! Ack! */
+ {
+ warning (_("Register %s changed after the thread was aborted"),
+ gdbarch_register_name (gdbarch, check_regno));
+ if (regno >= 0 && regno != check_regno)
+ /* Update GDB's copy of the register. */
+ regcache_raw_supply (regcache, check_regno,
+ REG_ADDR (state, check_regno));
+ else
+ warning (_("... also writing this register! "
+ "Suspicious..."));
+ }
+ }
+
+ if (regno == -1)
+ {
+ int i;
+
+ proc_debug (thread, "storing all registers");
+
+ for (i = 0; i < I386_NUM_GREGS; i++)
+ if (REG_VALID == regcache_register_status (regcache, i))
+ regcache_raw_collect (regcache, i, REG_ADDR (state, i));
+ }
+ else