This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

[RFC] Work around compiler bugs on OpenBSD/m68k


This might be mildly controversal, but it has come up before.  On some
targets (cax, m68k) GCC returns structures in some bit of static
memory.  On m68k this also happens for long doubles.  Now if there are
two invocations of the same function too close together, the second
invocation will overwrite the result of the first.  This is the same
bug as mentioned in frame.h.

I'd really like to check this in, since it's an easy workaround.  I'll
commit this next weekend if nobody objects.

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* valarith.c (value_equal, value_less): Avoid compiler bug on
	systems where `long double' values are returned in static storage.

Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.42
diff -u -p -r1.42 valarith.c
--- valarith.c 11 Aug 2005 13:45:40 -0000 1.42
+++ valarith.c 17 Aug 2005 19:09:44 -0000
@@ -1,8 +1,8 @@
 /* Perform arithmetic and other operations on values, for GDB.
 
    Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
-   Software Foundation, Inc.
+   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -1248,7 +1248,12 @@ value_equal (struct value *arg1, struct 
 						       BINOP_EQUAL)));
   else if ((code1 == TYPE_CODE_FLT || is_int1)
 	   && (code2 == TYPE_CODE_FLT || is_int2))
-    return value_as_double (arg1) == value_as_double (arg2);
+    {
+      /* NOTE: kettenis/20050816: Avoid compiler bug on systems where
+	 `long double' values are returned in static storage (m68k).  */
+      DOUBLEST d = value_as_double (arg1);
+      return d == value_as_double (arg2);
+    }
 
   /* FIXME: Need to promote to either CORE_ADDR or LONGEST, whichever
      is bigger.  */
@@ -1307,7 +1312,12 @@ value_less (struct value *arg1, struct v
 						       BINOP_LESS)));
   else if ((code1 == TYPE_CODE_FLT || is_int1)
 	   && (code2 == TYPE_CODE_FLT || is_int2))
-    return value_as_double (arg1) < value_as_double (arg2);
+    {
+      /* NOTE: kettenis/20050816: Avoid compiler bug on systems where
+	 `long double' values are returned in static storage (m68k).  */
+      DOUBLEST d = value_as_double (arg1);
+      return d < value_as_double (arg2);
+    }
   else if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
     return value_as_address (arg1) < value_as_address (arg2);
 


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