Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] i386-tdep.c fix for *BSD.
@ 2001-03-31  5:05 Mark Kettenis
  0 siblings, 0 replies; only message in thread
From: Mark Kettenis @ 2001-03-31  5:05 UTC (permalink / raw)
  To: gdb-patches

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)
 	{


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-03-31  5:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-31  5:05 [PATCH] i386-tdep.c fix for *BSD Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox