/* Cache and manage the values of registers for GDB, the GNU debugger.
Copyright (C) 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000, 2001,
- 2002, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2002, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GDB.
struct regcache
{
struct regcache_descr *descr;
+
+ /* The address space of this register cache (for registers where it
+ makes sense, like PC or SP). */
+ struct address_space *aspace;
+
/* The register buffers. A read-only register cache can hold the
full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write
register cache can only hold [0 .. gdbarch_num_regs). */
};
struct regcache *
-regcache_xmalloc (struct gdbarch *gdbarch)
+regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
{
struct regcache_descr *descr;
struct regcache *regcache;
= XCALLOC (descr->sizeof_raw_registers, gdb_byte);
regcache->register_valid_p
= XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte);
+ regcache->aspace = aspace;
regcache->readonly_p = 1;
regcache->ptid = minus_one_ptid;
return regcache;
return regcache->descr->gdbarch;
}
+struct address_space *
+get_regcache_aspace (const struct regcache *regcache)
+{
+ return regcache->aspace;
+}
+
/* Return a pointer to register REGNUM's buffer cache. */
static gdb_byte *
{
int i;
gdb_byte *buf;
+
gdb_assert (src != NULL && dst != NULL);
gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
gdb_assert (src != dst);
gdb_assert (src->readonly_p || dst->readonly_p);
+
if (!src->readonly_p)
regcache_save (dst, do_cooked_read, src);
else if (!dst->readonly_p)
move of data into the current regcache. Doing this would be
silly - it would mean that valid_p would be completely invalid. */
gdb_assert (dst->readonly_p);
+
memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers);
memcpy (dst->register_valid_p, src->register_valid_p,
dst->descr->sizeof_raw_register_valid_p);
regcache_dup (struct regcache *src)
{
struct regcache *newbuf;
- newbuf = regcache_xmalloc (src->descr->gdbarch);
+ newbuf = regcache_xmalloc (src->descr->gdbarch, get_regcache_aspace (src));
regcache_cpy (newbuf, src);
return newbuf;
}
regcache_dup_no_passthrough (struct regcache *src)
{
struct regcache *newbuf;
- newbuf = regcache_xmalloc (src->descr->gdbarch);
+ newbuf = regcache_xmalloc (src->descr->gdbarch, get_regcache_aspace (src));
regcache_cpy_no_passthrough (newbuf, src);
return newbuf;
}
&& get_regcache_arch (list->regcache) == gdbarch)
return list->regcache;
- new_regcache = regcache_xmalloc (gdbarch);
+ 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;
Indicate that registers may have changed, so invalidate the cache. */
void
-registers_changed (void)
+registers_changed_ptid (ptid_t ptid)
{
- struct regcache_list *list, *next;
+ struct regcache_list *list, **list_link;
- for (list = current_regcache; list; list = next)
+ list = current_regcache;
+ list_link = ¤t_regcache;
+ while (list)
{
- next = list->next;
- regcache_xfree (list->regcache);
- xfree (list);
+ if (ptid_match (list->regcache->ptid, ptid))
+ {
+ struct regcache_list *dead = list;
+
+ *list_link = list->next;
+ regcache_xfree (list->regcache);
+ list = *list_link;
+ xfree (dead);
+ continue;
+ }
+
+ list_link = &list->next;
+ list = *list_link;
}
current_regcache = NULL;
alloca (0);
}
+void
+registers_changed (void)
+{
+ registers_changed_ptid (minus_one_ptid);
+}
void
regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)