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]
Other format: [Raw text]

[PATCH] Print in-memory return values for m68k SVR4 ABI


Tested on NetBSD/m68k

Committed,

Mark


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

	* m68k-tdep.c (m68k_svr4_return_value): Implement
	RETURN_VALUE_ABI_RETURNS_ADDRESS.

Index: m68k-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m68k-tdep.c,v
retrieving revision 1.90
diff -u -p -r1.90 m68k-tdep.c
--- m68k-tdep.c 9 May 2004 18:51:38 -0000 1.90
+++ m68k-tdep.c 16 May 2004 23:01:29 -0000
@@ -360,7 +360,27 @@ m68k_svr4_return_value (struct gdbarch *
 
   if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
       && !m68k_reg_struct_return_p (gdbarch, type))
-    return RETURN_VALUE_STRUCT_CONVENTION;
+    {
+      /* The System V ABI says that:
+
+	 "A function returning a structure or union also sets %a0 to
+	 the value it finds in %a0.  Thus when the caller receives
+	 control again, the address of the returned object resides in
+	 register %a0."
+
+	 So the ABI guarantees that we can always find the return
+	 value just after the function has returned.  */
+
+      if (readbuf)
+	{
+	  ULONGEST addr;
+
+	  regcache_raw_read_unsigned (regcache, M68K_A0_REGNUM, &addr);
+	  read_memory (addr, readbuf, TYPE_LENGTH (type));
+	}
+
+      return RETURN_VALUE_ABI_RETURNS_ADDRESS;
+    }
 
   /* This special case is for structures consisting of a single
      `float' or `double' member.  These structures are returned in


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