[2/11] Add IA64_MAX_REGISTER_SIZE

Message ID 79E51549-1B65-4DA8-891A-17EF061E03A3@arm.com
State New, archived
Headers

Commit Message

Alan Hayward June 5, 2017, 4:27 p.m. UTC
  > On 27 Apr 2017, at 11:48, Alan Hayward <Alan.Hayward@arm.com> wrote:
> 
>> 
>> On 27 Apr 2017, at 11:17, Yao Qi <qiyaoltc@gmail.com> wrote:
>> 
>> Alan Hayward <Alan.Hayward@arm.com> writes:
>> 

I’ve rebased this patch due to Yao’s unit test changes.


I don't have an IA64 machine to test on.
Faked up a libunwind in order to build libunwind code.
Tested on a --enable-targets=all and --enable-libsanitizer build using
make check with board files unix and native-gdbserver.

Ok to commit?

Alan.


2017-06-05  Alan Hayward  <alan.hayward@arm.com>

	* ia64-tdep.c (IA64_MAX_FP_REGISTER_SIZE) Add.
	(ia64_register_to_value): Use IA64_MAX_FP_REGISTER_SIZE.
	(ia64_value_to_register): Likewise.
	(ia64_extract_return_value): Likewise.
	(ia64_store_return_value): Likewise.
	(ia64_push_dummy_call): Likewise.
  

Comments

Yao Qi June 6, 2017, 10:04 a.m. UTC | #1
Alan Hayward <Alan.Hayward@arm.com> writes:

> Tested on a --enable-targets=all and --enable-libsanitizer build using

Beside --enable-targets=all, do you configure with --enable-64-bit-bfd?

Why do you configure with --enable-libsanitizer?  It is a top-level
configure option which enables to build libsanitizer.  What we need here
is to build GDB with ASAN like this,

 $ make CXXFLAGS='-fsanitize=address' gdb

and run gdb.gdb/unittest.exp.

>
>
> diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
> index 7282acb20ac2c25e7f2c48fec3106300c385679f..d396fb81a62b0c2522900fd9cb0980aa2a5fb767 100644
> --- a/gdb/ia64-tdep.c
> +++ b/gdb/ia64-tdep.c
> @@ -125,6 +125,9 @@ static CORE_ADDR ia64_find_global_pointer (struct gdbarch *gdbarch,
>
>  #define NUM_IA64_RAW_REGS 462
>
> +/* Big enough to hold a FP register in bytes.  */
> +#define IA64_FP_REGISTER_SIZE 16

Nit, we can replace one magic number 128 with this macro in ia64_ext_type,

  if (!tdep->ia64_ext_type)
    tdep->ia64_ext_type
      = arch_float_type (gdbarch, 128, "builtin_type_ia64_ext",
			 floatformats_ia64_ext);

Patch is OK if there is no fail in gdb.gdb/unittest.exp.
  
Alan Hayward June 6, 2017, 12:57 p.m. UTC | #2
> On 6 Jun 2017, at 11:04, Yao Qi <qiyaoltc@gmail.com> wrote:

> 

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

> 

>> Tested on a --enable-targets=all and --enable-libsanitizer build using

> 

> Beside --enable-targets=all, do you configure with --enable-64-bit-bfd?

> 


Yes.

> Why do you configure with --enable-libsanitizer?  It is a top-level

> configure option which enables to build libsanitizer.  What we need here

> is to build GDB with ASAN like this,

> 

> $ make CXXFLAGS='-fsanitize=address' gdb

> 

> and run gdb.gdb/unittest.exp.


Sorry, my mistake. 
I’ve rebuild using the above, and unittest.exp passes.

This also applies to my other 3 patches I’ve posted. My git log includes
all of those patches.

> 

>> 

>> 

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

>> index 7282acb20ac2c25e7f2c48fec3106300c385679f..d396fb81a62b0c2522900fd9cb0980aa2a5fb767 100644

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

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

>> @@ -125,6 +125,9 @@ static CORE_ADDR ia64_find_global_pointer (struct gdbarch *gdbarch,

>> 

>> #define NUM_IA64_RAW_REGS 462

>> 

>> +/* Big enough to hold a FP register in bytes.  */

>> +#define IA64_FP_REGISTER_SIZE 16

> 

> Nit, we can replace one magic number 128 with this macro in ia64_ext_type,

> 

>  if (!tdep->ia64_ext_type)

>    tdep->ia64_ext_type

>      = arch_float_type (gdbarch, 128, "builtin_type_ia64_ext",

> 			 floatformats_ia64_ext);


I’m not sure about this. Other files in gdb use things like 
gdbarch_long_double_bit (gdbarch) instead of 128, which sounds a better solution.
Therefore, I’ve left it as it is for now.

> 

> Patch is OK if there is no fail in gdb.gdb/unittest.exp.

> 


Committed as originally posted.



Alan.
  

Patch

diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 7282acb20ac2c25e7f2c48fec3106300c385679f..d396fb81a62b0c2522900fd9cb0980aa2a5fb767 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -125,6 +125,9 @@  static CORE_ADDR ia64_find_global_pointer (struct gdbarch *gdbarch,

 #define NUM_IA64_RAW_REGS 462

+/* Big enough to hold a FP register in bytes.  */
+#define IA64_FP_REGISTER_SIZE 16
+
 static int sp_regnum = IA64_GR12_REGNUM;

 /* NOTE: we treat the register stack registers r32-r127 as
@@ -1228,7 +1231,7 @@  ia64_register_to_value (struct frame_info *frame, int regnum,
 			int *optimizedp, int *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  gdb_byte in[MAX_REGISTER_SIZE];
+  gdb_byte in[IA64_FP_REGISTER_SIZE];

   /* Convert to TYPE.  */
   if (!get_frame_register_bytes (frame, regnum, 0,
@@ -1246,7 +1249,7 @@  ia64_value_to_register (struct frame_info *frame, int regnum,
                          struct type *valtype, const gdb_byte *in)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  gdb_byte out[MAX_REGISTER_SIZE];
+  gdb_byte out[IA64_FP_REGISTER_SIZE];
   convert_typed_floating (in, valtype, out, ia64_ext_type (gdbarch));
   put_frame_register (frame, regnum, out);
 }
@@ -3209,7 +3212,7 @@  ia64_extract_return_value (struct type *type, struct regcache *regcache,
   float_elt_type = is_float_or_hfa_type (type);
   if (float_elt_type != NULL)
     {
-      gdb_byte from[MAX_REGISTER_SIZE];
+      gdb_byte from[IA64_FP_REGISTER_SIZE];
       int offset = 0;
       int regnum = IA64_FR8_REGNUM;
       int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
@@ -3274,7 +3277,7 @@  ia64_store_return_value (struct type *type, struct regcache *regcache,
   float_elt_type = is_float_or_hfa_type (type);
   if (float_elt_type != NULL)
     {
-      gdb_byte to[MAX_REGISTER_SIZE];
+      gdb_byte to[IA64_FP_REGISTER_SIZE];
       int offset = 0;
       int regnum = IA64_FR8_REGNUM;
       int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
@@ -3836,7 +3839,7 @@  ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	  len = TYPE_LENGTH (type);
 	  while (len > 0 && floatreg < IA64_FR16_REGNUM)
 	    {
-	      gdb_byte to[MAX_REGISTER_SIZE];
+	      gdb_byte to[IA64_FP_REGISTER_SIZE];
 	      convert_typed_floating (value_contents (arg) + argoffset,
 				      float_elt_type, to,
 				      ia64_ext_type (gdbarch));