diff mbox

[11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE

Message ID 45FE08DA-87EC-48FB-97EC-8463A473126F@arm.com
State New
Headers show

Commit Message

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

> 

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

> 

>> diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c

>> index 9b3692dc0c32ffcb53d99f0fc095303d2c221fcb..7e56864202fe9321edb7561c721ef912b3a4f8c5 100644

>> --- a/gdb/sh-tdep.c

>> +++ b/gdb/sh-tdep.c

>> @@ -1648,7 +1648,7 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,

>> 			 int reg_nr, gdb_byte *buffer)

>> {

>>   int base_regnum;

>> -  gdb_byte temp_buffer[MAX_REGISTER_SIZE];

>> +  gdb_byte temp_buffer[SH_MAX_REGISTER_SIZE];

>>   enum register_status status;

>> 

>>   if (reg_nr == PSEUDO_BANK_REGNUM)

> 

> temp_buffer is used for double float register, which is from two fp

> registers,

> 

>  else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)

>    {

>      base_regnum = dr_reg_base_num (gdbarch, reg_nr);

> 

>      /* Build the value in the provided buffer.  */

>      /* Read the real regs for which this one is an alias.  */

>      status = pseudo_register_read_portions (gdbarch, regcache,

> 					      2, base_regnum, temp_buffer);

>      if (status == REG_VALID)

> 	{

> 	  /* We must pay attention to the endiannes. */

> 	  sh_register_convert_to_virtual (gdbarch, reg_nr,

> 					  register_type (gdbarch, reg_nr),

> 					  temp_buffer, buffer);

> 	}

> 

> Can you move "temp_buffer" into this block, and define it

> 

> gdb_byte temp_buffer[4 * 2] or temp_buffer[SH_FLOAT_REGISTER_SIZE * 2];

> 

> -- 

> Yao (齐尧)



Ok.

There doesn't seem to be the same obvious fix for SH64 (unless you wanted
to define a new buf for each block of the read/write functions).

I don't have a SH 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/sh-tdep.c (sh_pseudo_register_read): Remove MAX_REGISTER_SIZE.
	(sh_pseudo_register_write): Likewise.
	* gdb/sh64-tdep.c (SH64_MAX_REGISTER_SIZE): Add.
	(sh64_pseudo_register_read): Use SH64_MAX_REGISTER_SIZE.
	(sh64_pseudo_register_write): Likewise
diff mbox

Patch

diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index f4b4c486fd59715b9eacfecf034653ce570716a9..75bc37c6d77a0d592395e2360549d6831630c017 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1648,13 +1648,14 @@  sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
 			 int reg_nr, gdb_byte *buffer)
 {
   int base_regnum;
-  gdb_byte temp_buffer[MAX_REGISTER_SIZE];
   enum register_status status;

   if (reg_nr == PSEUDO_BANK_REGNUM)
     return regcache_raw_read (regcache, BANK_REGNUM, buffer);
   else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
     {
+      /* Enough space for two float registers.  */
+      gdb_byte temp_buffer[4 * 2];
       base_regnum = dr_reg_base_num (gdbarch, reg_nr);

       /* Build the value in the provided buffer.  */
@@ -1687,7 +1688,6 @@  sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			  int reg_nr, const gdb_byte *buffer)
 {
   int base_regnum, portion;
-  gdb_byte temp_buffer[MAX_REGISTER_SIZE];

   if (reg_nr == PSEUDO_BANK_REGNUM)
     {
@@ -1703,6 +1703,8 @@  sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
     }
   else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
     {
+      /* Enough space for two float registers.  */
+      gdb_byte temp_buffer[4 * 2];
       base_regnum = dr_reg_base_num (gdbarch, reg_nr);

       /* We must pay attention to the endiannes.  */
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 33986fd12ffa37d59a5021cc3dcf25ad6fbceedf..b4cc26503ec2992a5225d8f715661ba9b6409c2a 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -122,6 +122,9 @@  enum
     FP_LAST_REGNUM = SIM_SH64_FR0_REGNUM + SIM_SH64_NR_FP_REGS - 1
   };

+/* Big enough to hold the size of the largest register in bytes.  */
+#define SH64_MAX_REGISTER_SIZE	12
+
 static const char *
 sh64_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
@@ -1528,7 +1531,7 @@  sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int base_regnum;
   int offset = 0;
-  gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+  gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
   enum register_status status;

   if (reg_nr >= DR0_REGNUM
@@ -1704,7 +1707,7 @@  sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int base_regnum, portion;
   int offset;
-  gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+  gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];

   if (reg_nr >= DR0_REGNUM
       && reg_nr <= DR_LAST_REGNUM)