diff mbox

[8/11] Add FRV_MAX_REGISTER_SIZE

Message ID EBF2EEFF-20D5-43F3-B35D-5BB37C3CB153@arm.com
State New
Headers show

Commit Message

Alan Hayward April 12, 2017, 8:27 a.m. UTC
> On 11 Apr 2017, at 11:02, Yao Qi <qiyaoltc@gmail.com> wrote:

> 

> Alan Hayward <Alan.Hayward@arm.com> writes:

> 

>> -  char zerobuf[MAX_REGISTER_SIZE];

>> +  char zerobuf[FRV_MAX_REGISTER_SIZE];

>> 

>> -  memset (zerobuf, 0, MAX_REGISTER_SIZE);

>> +  memset (zerobuf, 0, FRV_MAX_REGISTER_SIZE);

>> 

>>   /* gr0 always contains 0.  Also, the kernel passes the TBR value in

>>      this slot.  */

> 

> The code here fills some gr registers with zeros,

> 

>  /* gr0 always contains 0.  Also, the kernel passes the TBR value in

>     this slot.  */

>  regcache_raw_supply (regcache, first_gpr_regnum, zerobuf);

> 

>  /* Fill gr32, ..., gr63 with zeros. */

>  for (regi = first_gpr_regnum + 32; regi <= last_gpr_regnum; regi++)

>    regcache_raw_supply (regcache, regi, zerobuf);

> 

> the size of these gr registers are know, 8 bytes.  It won't be changed.

> We can do,

> 

> gdb_byte zerobuf[8] = { 0 };

> 

> the code is still easy to read.  If you really dislike magic number (IMO, 8

> is not a magic number in this context), you can define FRR_GR_REGISTER_SIZE.

> 

> Alternatively, you can add a new regache api, regcache_raw_supply_zero.

> Many places can use this api, and some uses of MAX_REGISTER_SIZE can be

> removed too, for example,

> 

>  regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf);

> 

> -- 

> Yao (齐尧)


Went with the simpler solution.

I don't have a FRV machine to test on.
Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.

Ok to commit?

Alan.

2017-04-12  Alan Hayward  <alan.hayward@arm.com>

	* gdb/frv-linux-tdep.c (frv_linux_supply_gregset): Remove MAX_REGISTER_SIZE.
diff mbox

Patch

diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index eb87f93058b0287e8f05c585d1b6aa1ff2bffb78..3f91bf0ee81a5d5ca915c88337c6a4b4ed53d344 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -413,9 +413,7 @@  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);
+  gdb_byte zerobuf[8] = { 0 };

   /* gr0 always contains 0.  Also, the kernel passes the TBR value in
      this slot.  */