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]

[PATCH] i386-tdep.c fix for *BSD.


The following patch fixes a problem on *BSD (or at least FreeBSD) with
returning  structs that have a single floating point member (which is
tested for a `double' in the testsuite).

Note that when debugging code generated with older versions of GCC
(<=2.7.2.3) there are still problems, since the compiler returns
struct such as those mentioned to be returned in memory, wheras newer
GCC versions put them in a register.  That problem should be addressed
in USE_STRUCT_CONVENTION, but I don't think it is possible to
distinguish between those GCC's.

Checked in.

Mark


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

	* i386-tdep.c (i386_extract_return_value): If the type of the
	return value is TYPE_STRUCT and the number of fields is one, call
	ourselves with TYPE set tp the type of the first field.
	(i386_store_return_value): Likewise.
	This fixes a problem with returning structs consisting of a single
	`float' or `double' on *BSD.

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.23
diff -u -p -r1.23 i386-tdep.c
--- i386-tdep.c 2001/03/26 12:11:13 1.23
+++ i386-tdep.c 2001/03/31 12:58:24
@@ -733,7 +733,12 @@ i386_extract_return_value (struct type *
 {
   int len = TYPE_LENGTH (type);
 
-  if (TYPE_CODE_FLT == TYPE_CODE (type))
+  if (TYPE_CODE (type) == TYPE_CODE_STRUCT
+      && TYPE_NFIELDS (type) == 1)
+    return i386_extract_return_value (TYPE_FIELD_TYPE (type, 0),
+				      regbuf, valbuf);
+
+  if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
       if (NUM_FREGS == 0)
 	{
@@ -790,8 +795,12 @@ void
 i386_store_return_value (struct type *type, char *valbuf)
 {
   int len = TYPE_LENGTH (type);
+
+  if (TYPE_CODE (type) == TYPE_CODE_STRUCT
+      && TYPE_NFIELDS (type) == 1)
+    return i386_store_return_value (TYPE_FIELD_TYPE (type, 0), valbuf);
 
-  if (TYPE_CODE_FLT == TYPE_CODE (type))
+  if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
       if (NUM_FREGS == 0)
 	{


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