Avoid memcpys in regcache read_part/write_part for full registers.
[deliverable/binutils-gdb.git] / gdb / regcache.h
index 3b72986db1a0cf81b9a00cc3d4efdff783af174d..5e96a7a9716414291c193d47fd2b59eb3a003813 100644 (file)
@@ -125,9 +125,8 @@ extern struct type *register_type (struct gdbarch *gdbarch, int regnum);
    
 extern int register_size (struct gdbarch *gdbarch, int regnum);
 
-typedef enum register_status (regcache_cooked_read_ftype) (void *src,
-                                                          int regnum,
-                                                          gdb_byte *buf);
+typedef gdb::function_view<register_status (int regnum, gdb_byte *buf)>
+  register_read_ftype;
 
 /* A (register_number, register_value) pair.  */
 
@@ -188,6 +187,9 @@ public:
 
   virtual ~reg_buffer () = default;
 
+  /* See common/common-regcache.h.  */
+  bool raw_compare (int regnum, const void *buf, int offset) const override;
+
 protected:
   /* Assert on the range of REGNUM.  */
   void assert_regnum (int regnum) const;
@@ -199,7 +201,7 @@ protected:
   /* Save a register cache.  The set of registers saved into the
      regcache determined by the save_reggroup.  COOKED_READ returns
      zero iff the register's value can't be returned.  */
-  void save (regcache_cooked_read_ftype *cooked_read, void *src);
+  void save (register_read_ftype cooked_read);
 
   struct regcache_descr *m_descr;
 
@@ -251,8 +253,11 @@ public:
   struct value *cooked_read_value (int regnum);
 
 protected:
-  enum register_status read_part (int regnum, int offset, int len, void *in,
-                                 bool is_raw);
+
+  /* Perform a partial register transfer using a read, modify, write
+     operation.  Will fail if register is currently invalid.  */
+  enum register_status read_part (int regnum, int offset, int len,
+                                 gdb_byte *out, bool is_raw);
 };
 
 /* Buffer of registers, can be read and written.  */
@@ -353,9 +358,10 @@ private:
                        int regnum, const void *in_buf,
                        void *out_buf, size_t size) const;
 
+  /* Perform a partial register transfer using a read, modify, write
+     operation.  */
   enum register_status write_part (int regnum, int offset, int len,
-                                  const void *out, bool is_raw);
-
+                                  const gdb_byte *in, bool is_raw);
 
   /* The address space of this register cache (for registers where it
      makes sense, like PC or SP).  */
@@ -376,16 +382,14 @@ private:
 class readonly_detached_regcache : public readable_regcache
 {
 public:
-  readonly_detached_regcache (const regcache &src);
+  readonly_detached_regcache (regcache &src);
 
   /* Create a readonly regcache by getting contents from COOKED_READ.  */
 
-  readonly_detached_regcache (gdbarch *gdbarch,
-                             regcache_cooked_read_ftype *cooked_read,
-                             void *src)
+  readonly_detached_regcache (gdbarch *gdbarch, register_read_ftype cooked_read)
     : readable_regcache (gdbarch, true)
   {
-    save (cooked_read, src);
+    save (cooked_read);
   }
 
   DISABLE_COPY_AND_ASSIGN (readonly_detached_regcache);
This page took 0.025129 seconds and 4 git commands to generate.