This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa/arm] Make arm float->double arg pass portable(ish)
- To: gdb-patches at sources dot redhat dot com
- Subject: Re: [rfa/arm] Make arm float->double arg pass portable(ish)
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Wed, 04 Jul 2001 16:06:43 -0400
- References: <3B3CA824.5080308@cygnus.com>
And the patch is really attached ....
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