This is the mail archive of the gdb-patches@sourceware.cygnus.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]

[PATCH RFA] store_floating(), extract_floating() fixes


I'd like approval for committing the patch below.  The rationale for
these fixes may be found in my message from earlier today entitled
"store_floating() rewrite (was Re: bug in arm_push_arguments())".

My rewrite of store_floating() was incorrect in that message though.
It fails to take into account the size of the float when doing the
memcpy (when the float formats are the same).

I've tested the following patch on linux/x86 and linux/ppc and saw
no regressions.

	* findvar.c (extract_floating, store_floating): Use target
	floating point type sizes rather host sizes to determine
	which conversion needs to be done.

Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.2
diff -u -p -r1.2 findvar.c
--- findvar.c	2000/02/08 04:39:02	1.2
+++ findvar.c	2000/02/28 23:48:31
@@ -267,13 +267,11 @@ store_address (addr, len, val)
    dirty work.  */
 
 DOUBLEST
-extract_floating (addr, len)
-     PTR addr;
-     int len;
+extract_floating (void *addr, int len)
 {
   DOUBLEST dretval;
 
-  if (len == sizeof (float))
+  if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
     {
       if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
 	{
@@ -285,7 +283,7 @@ extract_floating (addr, len)
       else
 	floatformat_to_doublest (TARGET_FLOAT_FORMAT, addr, &dretval);
     }
-  else if (len == sizeof (double))
+  else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
     {
       if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
 	{
@@ -297,7 +295,7 @@ extract_floating (addr, len)
       else
 	floatformat_to_doublest (TARGET_DOUBLE_FORMAT, addr, &dretval);
     }
-  else if (len == sizeof (DOUBLEST))
+  else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
     {
       if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
 	{
@@ -322,12 +320,9 @@ extract_floating (addr, len)
 }
 
 void
-store_floating (addr, len, val)
-     PTR addr;
-     int len;
-     DOUBLEST val;
+store_floating (void *addr, int len, DOUBLEST val)
 {
-  if (len == sizeof (float))
+  if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
     {
       if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
 	{
@@ -338,7 +333,7 @@ store_floating (addr, len, val)
       else
 	floatformat_from_doublest (TARGET_FLOAT_FORMAT, &val, addr);
     }
-  else if (len == sizeof (double))
+  else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
     {
       if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
 	{
@@ -349,7 +344,7 @@ store_floating (addr, len, val)
       else
 	floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &val, addr);
     }
-  else if (len == sizeof (DOUBLEST))
+  else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
     {
       if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
 	memcpy (addr, &val, sizeof (val));


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