+ regcache *rc = pair.second;
+ if (rc->ptid () == old_ptid)
+ keys_to_update.push_back (pair.first);
+ }
+
+ for (const ptid_arch &old_key : keys_to_update)
+ {
+ /* Get the regcache, delete the hash map entry. */
+ auto it = the_regcaches.find (old_key);
+ gdb_assert (it != the_regcaches.end ());
+ regcache *rc = it->second;
+
+ the_regcaches.erase (it);
+
+ /* Insert the regcache back, with an updated key. */
+ ptid_arch new_key (new_ptid, rc->arch ());
+ rc->set_ptid (new_ptid);
+ the_regcaches[new_key] = rc;