[PATCH] Fix function call bug on AMD64

Mark Kettenis kettenis@chello.nl
Sat Jan 10 17:48:00 GMT 2004


Uncovered by the new gdb.cp/bs15503.exp testcase.  I'll probably add a
non-C++ testcase for this problem to the testsuite too.

Committed.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* x86-64-tdep.c (amd64_push_arguments): Add struct_return
	argument.  Use it to reserve a register if necessary.
	(amd64_push_dummy_call): Pass STRUCT_RETURN in call to
	amd64_push_arguments.

 
Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.109
diff -u -p -r1.109 x86-64-tdep.c
--- x86-64-tdep.c 10 Jan 2004 13:21:06 -0000 1.109
+++ x86-64-tdep.c 10 Jan 2004 17:45:26 -0000
@@ -481,7 +481,7 @@ amd64_return_value (struct gdbarch *gdba
 
 static CORE_ADDR
 amd64_push_arguments (struct regcache *regcache, int nargs,
-		      struct value **args, CORE_ADDR sp)
+		      struct value **args, CORE_ADDR sp, int struct_return)
 {
   static int integer_regnum[] =
   {
@@ -505,6 +505,10 @@ amd64_push_arguments (struct regcache *r
   int sse_reg = 0;
   int i;
 
+  /* Reserve a register for the "hidden" argument.  */
+  if (struct_return)
+    integer_reg++;
+
   for (i = 0; i < nargs; i++)
     {
       struct type *type = VALUE_TYPE (args[i]);
@@ -613,7 +617,7 @@ amd64_push_dummy_call (struct gdbarch *g
   char buf[8];
 
   /* Pass arguments.  */
-  sp = amd64_push_arguments (regcache, nargs, args, sp);
+  sp = amd64_push_arguments (regcache, nargs, args, sp, struct_return);
 
   /* Pass "hidden" argument".  */
   if (struct_return)



More information about the Gdb-patches mailing list