This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[ping] [RFA] Fix varargs calls for PowerPC System V ABI
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: gdb-patches at sources dot redhat dot com
- Cc: kevinb at redhat dot com, cagney at gnu dot org
- Date: Sun, 19 Jun 2005 12:30:55 +0200 (CEST)
- Subject: [ping] [RFA] Fix varargs calls for PowerPC System V ABI
Sent this one about two months ago. Kevin is excused since I
misspelled his mail address ;-).
------- Start of forwarded message -------
Date: Sun, 19 Jun 2005 12:30:55 +0200 (CEST)
From: Mark Kettenis <kettenis@elgar.sibelius.xs4all.nl>
To: gdb-patches@sources.redhat.com
CC: kevinb@redhat.com, cagney@gnu.org
Subject: [ping] [RFA] Fix varargs calls for PowerPC System V ABI
The patch below fixes
FAIL: gdb.base/varargs.exp: print find_max_double(5,1.0,17.0,2.0,3.0,4.0)
on my OpenBSD/macppc system. Rather than having a (possibly) fragile
check for vararg-ness, it always sets the bit in the condition
register. Normal functions shouldn't care for it, and indeed the way
we did these calls in the past, the condition register might be set to
anything.
OK?
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Set condition
register appropriately for varargs functions.
Index: ppc-sysv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v
retrieving revision 1.29
diff -u -p -r1.29 ppc-sysv-tdep.c
--- ppc-sysv-tdep.c 25 May 2005 03:12:13 -0000 1.29
+++ ppc-sysv-tdep.c 19 Jun 2005 10:24:55 -0000
@@ -295,6 +295,24 @@ ppc_sysv_abi_push_dummy_call (struct gdb
/* Ensure that the stack is still 16 byte aligned. */
sp = align_down (sp, 16);
}
+
+ /* The psABI says that "A caller of a function that takes a
+ variable argument list shall set condition register bit 6 to
+ 1 if it passes one or more arguments in the floating-point
+ registers. It is strongly recommended that the caller set the
+ bit to 0 otherwise..." Doing this for normal functions too
+ shouldn't hurt. */
+ if (write_pass)
+ {
+ ULONGEST cr;
+
+ regcache_cooked_read_unsigned (regcache, tdep->ppc_cr_regnum, &cr);
+ if (freg > 1)
+ cr |= 0x02000000;
+ else
+ cr &= ~0x02000000;
+ regcache_cooked_write_unsigned (regcache, tdep->ppc_cr_regnum, cr);
+ }
}
/* Update %sp. */