+struct regcache *
+get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
+{
+ struct regcache_list *list;
+ struct regcache *new_regcache;
+
+ for (list = current_regcache; list; list = list->next)
+ if (ptid_equal (list->regcache->ptid, ptid)
+ && get_regcache_arch (list->regcache) == gdbarch)
+ return list->regcache;
+
+ new_regcache = regcache_xmalloc (gdbarch,
+ target_thread_address_space (ptid));
+ new_regcache->readonly_p = 0;
+ new_regcache->ptid = ptid;
+ gdb_assert (new_regcache->aspace != NULL);
+
+ list = xmalloc (sizeof (struct regcache_list));
+ list->regcache = new_regcache;
+ list->next = current_regcache;
+ current_regcache = list;
+
+ return new_regcache;
+}