Simplify regcache::xfer_part
authorYao Qi <yao.qi@linaro.org>
Tue, 17 Oct 2017 11:29:26 +0000 (12:29 +0100)
committerYao Qi <yao.qi@linaro.org>
Tue, 17 Oct 2017 11:29:26 +0000 (12:29 +0100)
Since xfer_part is already a class method, and only
{raw,cooked}_{read,write} are passed to it.  We can remove these two
arguments, but add a bool argument is_raw, indicating raw registers or
cooked registers are accessed.

gdb:

2017-10-17  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache::xfer_part): Remove parameters read and
write, add parameter is_raw.  All callers are updated.

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

index 0906b32e15d8f3e58e0c3f758248c6d04099547d..6a8d16fef5d9f1a2e0348b235906ed13d20aa733 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-17  Yao Qi  <yao.qi@linaro.org>
+
+       * regcache.c (regcache::xfer_part): Remove parameters read and
+       write, add parameter is_raw.  All callers are updated.
+
 2017-10-16  Keith Seitz  <keiths@redhat.com>
 
         * c-typeprint.c (enum access_specifier): Moved here from
index bf448ef123e5137ab6db3e15ce92fcedf9261978..555db578b6ea81cbee7e8ef9acc6cf2fde215b41 100644 (file)
@@ -915,12 +915,7 @@ typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
 
 enum register_status
 regcache::xfer_part (int regnum, int offset, int len, void *in,
-                    const void *out,
-                    enum register_status (*read) (struct regcache *regcache,
-                                                  int regnum,
-                                                  gdb_byte *buf),
-                    void (*write) (struct regcache *regcache, int regnum,
-                                   const gdb_byte *buf))
+                    const void *out, bool is_raw)
 {
   struct gdbarch *gdbarch = arch ();
   gdb_byte *reg = (gdb_byte *) alloca (register_size (gdbarch, regnum));
@@ -938,7 +933,10 @@ regcache::xfer_part (int regnum, int offset, int len, void *in,
       enum register_status status;
 
       gdb_assert (read != NULL);
-      status = read (this, regnum, reg);
+      if (is_raw)
+       status = raw_read (regnum, reg);
+      else
+       status = cooked_read (regnum, reg);
       if (status != REG_VALID)
        return status;
     }
@@ -950,8 +948,10 @@ regcache::xfer_part (int regnum, int offset, int len, void *in,
   /* ... write (when needed).  */
   if (out != NULL)
     {
-      gdb_assert (write != NULL);
-      write (this, regnum, reg);
+      if (is_raw)
+       raw_write (regnum, reg);
+      else
+       cooked_write (regnum, reg);
     }
 
   return REG_VALID;
@@ -968,8 +968,7 @@ enum register_status
 regcache::raw_read_part (int regnum, int offset, int len, gdb_byte *buf)
 {
   gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
-  return xfer_part (regnum, offset, len, buf, NULL,
-                   regcache_raw_read, regcache_raw_write);
+  return xfer_part (regnum, offset, len, buf, NULL, true);
 }
 
 void
@@ -984,8 +983,7 @@ regcache::raw_write_part (int regnum, int offset, int len,
                          const gdb_byte *buf)
 {
   gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
-  xfer_part (regnum, offset, len, NULL, buf, regcache_raw_read,
-            regcache_raw_write);
+  xfer_part (regnum, offset, len, NULL, buf, true);
 }
 
 enum register_status
@@ -1000,8 +998,7 @@ enum register_status
 regcache::cooked_read_part (int regnum, int offset, int len, gdb_byte *buf)
 {
   gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers);
-  return xfer_part (regnum, offset, len, buf, NULL,
-                   regcache_cooked_read, regcache_cooked_write);
+  return xfer_part (regnum, offset, len, buf, NULL, false);
 }
 
 void
@@ -1016,8 +1013,7 @@ regcache::cooked_write_part (int regnum, int offset, int len,
                             const gdb_byte *buf)
 {
   gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers);
-  xfer_part (regnum, offset, len, NULL, buf,
-            regcache_cooked_read, regcache_cooked_write);
+  xfer_part (regnum, offset, len, NULL, buf, false);
 }
 
 /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE.  */
index 6f42fb93769168ee8ab96cf971917ef17ca0e2c8..460d83facdc1dd74b5075fa7df7f40a19b34c1f3 100644 (file)
@@ -354,9 +354,7 @@ private:
   void restore (struct regcache *src);
 
   enum register_status xfer_part (int regnum, int offset, int len, void *in,
-                                 const void *out,
-                                 decltype (regcache_raw_read) read,
-                                 decltype (regcache_raw_write) write);
+                                 const void *out, bool is_raw);
 
   void transfer_regset (const struct regset *regset,
                        struct regcache *out_regcache,
This page took 0.036564 seconds and 4 git commands to generate.