Simplify regcache_cpy and remove regcache::cpy_no_passthrough
authorYao Qi <yao.qi@linaro.org>
Tue, 18 Jul 2017 11:46:14 +0000 (12:46 +0100)
committerYao Qi <yao.qi@linaro.org>
Tue, 18 Jul 2017 11:46:14 +0000 (12:46 +0100)
Nowadays, regcache_cpy is used where src is read-only and dst is not
read-only, so the regcache_cpy can be simplified to handle this case only.
As a result, regcache::cpy_no_passthrough, which is about two read-only
regcache copy, is no longer used, remove it as well.

gdb:

2017-07-18  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache_cpy): Simplify it.
(regcache::cpy_no_passthrough): Remove it.
* regcache.h (cpy_no_passthrough): Remove it.
(regcache_dup, regcache_cpy): Update comments.

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

index 66ae52745f104e070d1a0c8a024e8009375e392d..6b5684a854221278a573d98d55b5aa521237a0cb 100644 (file)
@@ -1,3 +1,10 @@
+2017-07-18  Yao Qi  <yao.qi@linaro.org>
+
+       * regcache.c (regcache_cpy): Simplify it.
+       (regcache::cpy_no_passthrough): Remove it.
+       * regcache.h (cpy_no_passthrough): Remove it.
+       (regcache_dup, regcache_cpy): Update comments.
+
 2017-07-18  Pedro Alves  <palves@redhat.com>
 
        * remote-sim.c (sim_command_completer): Adjust to work with a
index 7eeb7376b2862c7f6b297d4fdefc2f769881eeed..e8f92d684dd80a197e055aa1b1bbe2caaab2392a 100644 (file)
@@ -388,36 +388,9 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
   gdb_assert (src != NULL && dst != NULL);
   gdb_assert (src->m_descr->gdbarch == dst->m_descr->gdbarch);
   gdb_assert (src != dst);
-  gdb_assert (src->m_readonly_p || dst->m_readonly_p);
+  gdb_assert (src->m_readonly_p && !dst->m_readonly_p);
 
-  if (!src->m_readonly_p)
-    regcache_save (dst, do_cooked_read, src);
-  else if (!dst->m_readonly_p)
-    dst->restore (src);
-  else
-    dst->cpy_no_passthrough (src);
-}
-
-/* Copy/duplicate the contents of a register cache.  Unlike regcache_cpy,
-   which is pass-through, this does not go through to the target.
-   Only values values already in the cache are transferred.  The SRC and DST
-   buffers must not overlap.  */
-
-void
-regcache::cpy_no_passthrough (struct regcache *src)
-{
-  gdb_assert (src != NULL);
-  gdb_assert (src->m_descr->gdbarch == m_descr->gdbarch);
-  /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
-     move of data into a thread's regcache.  Doing this would be silly
-     - it would mean that regcache->register_status would be
-     completely invalid.  */
-  gdb_assert (m_readonly_p && src->m_readonly_p);
-
-  memcpy (m_registers, src->m_registers,
-         m_descr->sizeof_cooked_registers);
-  memcpy (m_register_status, src->m_register_status,
-         m_descr->sizeof_cooked_register_status);
+  dst->restore (src);
 }
 
 struct regcache *
index b416d5e8b82cf9b942c23d50c259639ee8927628..aa64a000acf06b90dc7f2f519b07f8ff7e3903b4 100644 (file)
@@ -369,8 +369,6 @@ private:
 
   void restore (struct regcache *src);
 
-  void cpy_no_passthrough (struct regcache *src);
-
   enum register_status xfer_part (int regnum, int offset, int len, void *in,
                                  const void *out,
                                  decltype (regcache_raw_read) read,
@@ -415,13 +413,12 @@ private:
   regcache_cpy (struct regcache *dst, struct regcache *src);
 };
 
-/* Copy/duplicate the contents of a register cache.  By default, the
-   operation is pass-through.  Writes to DST and reads from SRC will
-   go through to the target.  See also regcache_cpy_no_passthrough.
-
-   regcache_cpy can not have overlapping SRC and DST buffers.  */
-
+/* Duplicate the contents of a register cache to a read-only register
+   cache.  The operation is pass-through.  */
 extern struct regcache *regcache_dup (struct regcache *regcache);
+
+/* Writes to DEST will go through to the target.  SRC is a read-only
+   register cache.  */
 extern void regcache_cpy (struct regcache *dest, struct regcache *src);
 
 extern void registers_changed (void);
This page took 0.029134 seconds and 4 git commands to generate.