This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: [rfa/arm] Make arm float->double arg pass portable(ish)


> And the patch is really attached ....


Hmm, ScottB got back with some feed back and I'm, for the moment going 
to withdraw this patch.

While I don't think there is anything techically wrong with my change, 
it fixes the local code but reveals a deeper problem.

Check the functions arm-tdep.c:convert_{to,from}_extended() where it 
converts a target byte ordered buffer into a host double using a cast.

Taking a step back, I think there is a more fundamental problem, that 
conversion shouldn't even be necessary.  I think the type of the cooked 
register should be ``builtin_type_floatformat_arm_ext'' instead of being 
cast into ``builtin_type_double''.  At present we're part way there, 
MIPS returns builtin_type_uint{32,64} depending on the architecture.

	Andrew

PS: Remember, the *REGISTER_CONVERT* functions are this -><- far from 
being marked as deprecated)


> 
> OK?
> 
>     Andrew
> 
> Hello,
> 
> per discussion in the thread:
> 
> http://sources.redhat.com/ml/gdb-patches/2001-06/msg00504.html
> 
> this just addresses the ARM.  It uses extract_floating() and store_floating() as the conversion functions.  Those go out of their way to preserve accuracy.
> 
> You'll notice that in the patch I deleted a comment.  The coment was simply wrong.  GDB keeps everything in target byte order.
> 
> OK?
> 
> Now to sort out findvar.c and that HOST_FLOAT_FORMAT stuff :-/
> 
>     Andrew
> 
> 
> 
> 
> 2001-06-29  Andrew Cagney  <ac131313@redhat.com>
> 
> * arm-tdep.c (arm_push_arguments): Use extract_floating and
> 	store_floating to perform floating point conversions.
> 	* arm-linux-tdep.c (arm_linux_push_arguments): Ditto.
> 
> Index: arm-linux-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/arm-linux-tdep.c,v
> retrieving revision 1.8
> diff -p -r1.8 arm-linux-tdep.c
> *** arm-linux-tdep.c	2001/03/01 01:39:20	1.8
> --- arm-linux-tdep.c	2001/07/04 19:40:47
> *************** arm_linux_push_arguments (int nargs, val
> *** 159,165 ****
>       {
>         int len;
>         char *val;
> -       double dbl_arg;
>         CORE_ADDR regval;
>         enum type_code typecode;
>         struct type *arg_type, *target_type;
> --- 159,164 ----
> *************** arm_linux_push_arguments (int nargs, val
> *** 179,192 ****
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
> - 	  /* Float argument in buffer is in host format.  Read it and 
> - 	     convert to DOUBLEST, and store it in target double.  */
>   	  DOUBLEST dblval;
> ! 	  
>   	  len = TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
> ! 	  floatformat_to_doublest (HOST_FLOAT_FORMAT, val, &dblval);
> ! 	  store_floating (&dbl_arg, len, dblval);
> ! 	  val = (char *) &dbl_arg;
>   	}
>   
>         /* If the argument is a pointer to a function, and it is a Thumb
> --- 178,188 ----
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
>   	  DOUBLEST dblval;
> ! 	  dblval = extract_floating (val, len);
>   	  len = TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
> ! 	  val = alloca (len);
> ! 	  store_floating (val, len, dblval);
>   	}
>   
>         /* If the argument is a pointer to a function, and it is a Thumb
> Index: arm-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/arm-tdep.c,v
> retrieving revision 1.12
> diff -p -r1.12 arm-tdep.c
> *** arm-tdep.c	2001/03/06 08:21:05	1.12
> --- arm-tdep.c	2001/07/04 19:40:56
> *************** struct frame_extra_info
> *** 117,140 ****
>   #define MAKE_THUMB_ADDR(addr)	((addr) | 1)
>   #define UNMAKE_THUMB_ADDR(addr) ((addr) & ~1)
>   
> - #define SWAP_TARGET_AND_HOST(buffer,len) 				\
> -   do									\
> -     {									\
> -       if (TARGET_BYTE_ORDER != HOST_BYTE_ORDER)				\
> - 	{								\
> - 	  char tmp;							\
> - 	  char *p = (char *)(buffer);					\
> - 	  char *q = ((char *)(buffer)) + len - 1;		   	\
> - 	  for (; p < q; p++, q--)				 	\
> - 	    {								\
> - 	      tmp = *q;							\
> - 	      *q = *p;							\
> - 	      *p = tmp;							\
> - 	    }								\
> - 	}								\
> -     }									\
> -   while (0)
> - 
>   /* Will a function return an aggregate type in memory or in a
>      register?  Return 0 if an aggregate type can be returned in a
>      register, 1 if it must be returned in memory.  */
> --- 117,122 ----
> *************** arm_push_arguments (int nargs, value_ptr
> *** 1309,1315 ****
>       {
>         int len;
>         char *val;
> -       double dbl_arg;
>         CORE_ADDR regval;
>         enum type_code typecode;
>         struct type *arg_type, *target_type;
> --- 1291,1296 ----
> *************** arm_push_arguments (int nargs, value_ptr
> *** 1329,1350 ****
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
> ! 	  float f;
> ! 	  double d;
> ! 	  char * bufo = (char *) &d;
> ! 	  char * bufd = (char *) &dbl_arg;
> ! 
> ! 	  len = sizeof (double);
> ! 	  f = *(float *) val;
> ! 	  SWAP_TARGET_AND_HOST (&f, sizeof (float));  /* adjust endianess */
> ! 	  d = f;
> ! 	  /* We must revert the longwords so they get loaded into the
> ! 	     the right registers. */
> ! 	  memcpy (bufd, bufo + len / 2, len / 2);
> ! 	  SWAP_TARGET_AND_HOST (bufd, len / 2);  /* adjust endianess */
> ! 	  memcpy (bufd + len / 2, bufo, len / 2);
> ! 	  SWAP_TARGET_AND_HOST (bufd + len / 2, len / 2); /* adjust endianess */
> ! 	  val = (char *) &dbl_arg;
>   	}
>   #if 1
>         /* I don't know why this code was disable. The only logical use
> --- 1310,1320 ----
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
> ! 	  DOUBLEST dblval;
> ! 	  dblval = extract_floating (val, len);
> ! 	  len = TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
> ! 	  val = alloca (len);
> ! 	  store_floating (val, len, dblval);
>   	}
>   #if 1
>         /* I don't know why this code was disable. The only logical use
> 



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