Simplify regcache_dup
authorYao Qi <yao.qi@linaro.org>
Fri, 28 Apr 2017 21:48:42 +0000 (22:48 +0100)
committerYao Qi <yao.qi@linaro.org>
Fri, 28 Apr 2017 21:48:42 +0000 (22:48 +0100)
regcache_dup, in fact, is to create a readonly regcache from a
non-readonly regcache.  This patch adds an assert that src is not
readonly.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

* 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.

gdb/ChangeLog
gdb/regcache.c
gdb/regcache.h

index 537213db6d71dc3a5cef821de02817df2ae79a18..7e89c749e8073406818853081ad7498ab0561aac 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-28  Yao Qi  <yao.qi@linaro.org>
+
+       * 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  <yao.qi@linaro.org>
 
        * regcache.c (struct regcache): Move to regcache.h
index 11f6a874f3190700974187de1408a3fcd6259afd..c30d1c73b81c08f965ba65901448162c3e31dcc2 100644 (file)
@@ -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;
 }
 
index e03a39fbcef7650b87706cc9bc009d9a319b6544..c5d21f7439a217eefbe6e27ed4f3548cf6d35f13 100644 (file)
@@ -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
This page took 0.029902 seconds and 4 git commands to generate.