This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Remove MAX_REGISTER_SIZE from frv-linux-tdep.c


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f81fdd350e688bd0216486b30884a52ebc4f32b8

commit f81fdd350e688bd0216486b30884a52ebc4f32b8
Author: Alan Hayward <alan.hayward@arm.com>
Date:   Wed May 3 14:51:40 2017 +0100

    Remove MAX_REGISTER_SIZE from frv-linux-tdep.c
    
    gdb/
    	* frv-linux-tdep.c (frv_linux_supply_gregset): Use raw_supply_zeroed.
    	* regcache.c (regcache::raw_supply_zeroed): New function.
    	* regcache.h (regcache::raw_supply_zeroed): New declaration.

Diff:
---
 gdb/ChangeLog        |  6 ++++++
 gdb/frv-linux-tdep.c |  7 ++-----
 gdb/regcache.c       | 20 ++++++++++++++++++++
 gdb/regcache.h       |  2 ++
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9bb3510..4e278f5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-03  Alan Hayward  <alan.hayward@arm.com>
+
+	* frv-linux-tdep.c (frv_linux_supply_gregset): Use raw_supply_zeroed.
+	* regcache.c (regcache::raw_supply_zeroed): New function.
+	* regcache.h (regcache::raw_supply_zeroed): New declaration.
+
 2017-05-03  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* gdbarch.sh: Remove commented out definition of
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index eb87f93..cd02669 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -413,17 +413,14 @@ frv_linux_supply_gregset (const struct regset *regset,
 			  int regnum, const void *gregs, size_t len)
 {
   int regi;
-  char zerobuf[MAX_REGISTER_SIZE];
-
-  memset (zerobuf, 0, MAX_REGISTER_SIZE);
 
   /* gr0 always contains 0.  Also, the kernel passes the TBR value in
      this slot.  */
-  regcache_raw_supply (regcache, first_gpr_regnum, zerobuf);
+  regcache->raw_supply_zeroed (first_gpr_regnum);
 
   /* Fill gr32, ..., gr63 with zeros. */
   for (regi = first_gpr_regnum + 32; regi <= last_gpr_regnum; regi++)
-    regcache_raw_supply (regcache, regi, zerobuf);
+    regcache->raw_supply_zeroed (regi);
 
   regcache_supply_regset (regset, regcache, regnum, gregs, len);
 }
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 03f172e..d2c253a 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1199,6 +1199,26 @@ regcache::raw_supply (int regnum, const void *buf)
     }
 }
 
+/* Supply register REGNUM with zeroed value to REGCACHE.  This is not the same
+   as calling raw_supply with NULL (which will set the state to
+   unavailable).  */
+
+void
+regcache::raw_supply_zeroed (int regnum)
+{
+  void *regbuf;
+  size_t size;
+
+  gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+  gdb_assert (!m_readonly_p);
+
+  regbuf = register_buffer (regnum);
+  size = m_descr->sizeof_register[regnum];
+
+  memset (regbuf, 0, size);
+  m_register_status[regnum] = REG_VALID;
+}
+
 /* Collect register REGNUM from REGCACHE and store its contents in BUF.  */
 
 void
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 36255da..da00abd 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -294,6 +294,8 @@ public:
 
   void raw_supply (int regnum, const void *buf);
 
+  void raw_supply_zeroed (int regnum);
+
   enum register_status get_register_status (int regnum) const;
 
   void raw_set_cached_value (int regnum, const gdb_byte *buf);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]