diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 537213db6d7..7e89c749e80 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-04-28 Yao Qi + + * regcache.c (regcache_dup): Assert !src->m_readonly_p and + call method save instead of regcache_cpy. + * regcache.h (struct regcache): Make regcache_dup a friend. + 2017-04-28 Yao Qi * regcache.c (struct regcache): Move to regcache.h diff --git a/gdb/regcache.c b/gdb/regcache.c index 11f6a874f31..c30d1c73b81 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -422,8 +422,9 @@ regcache_dup (struct regcache *src) { struct regcache *newbuf; + gdb_assert (!src->m_readonly_p); newbuf = regcache_xmalloc (src->arch (), get_regcache_aspace (src)); - regcache_cpy (newbuf, src); + newbuf->save (do_cooked_read, src); return newbuf; } diff --git a/gdb/regcache.h b/gdb/regcache.h index e03a39fbcef..c5d21f7439a 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -373,6 +373,9 @@ private: friend void regcache_cpy (struct regcache *dst, struct regcache *src); + + friend struct regcache * + regcache_dup (struct regcache *src); }; /* Copy/duplicate the contents of a register cache. By default, the