From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7353 invoked by alias); 15 Mar 2007 17:18:07 -0000 Received: (qmail 7343 invoked by uid 22791); 15 Mar 2007 17:18:06 -0000 X-Spam-Check-By: sourceware.org Received: from ns.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 15 Mar 2007 17:17:55 +0000 Received: from Relay2.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 2630C1236A for ; Thu, 15 Mar 2007 18:17:52 +0100 (CET) From: Andreas Schwab To: gdb-patches@sourceware.org Subject: Fix altivec vector return location X-Yow: I LOVE juxtaposing th' splendor of an unpopulated ARROYO with th' SLEEK lines of ``NARCISSUS-X'', my new SPORTS UTILITY VEHICLE! Date: Thu, 15 Mar 2007 17:18:00 -0000 Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-03/txt/msg00143.txt.bz2 powerpc-linux is not using -mabi=altivec by default, thus vector types are returned in general registers instead of altivec registers. Andreas. 2007-03-15 Andreas Schwab * ppc-linux-tdep.c (ppc_linux_return_value): Vectors are returned in general registers. Index: gdb/ppc-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v retrieving revision 1.81 diff -u -a -p -u -p -a -r1.81 gdb/ppc-linux-tdep.c --- gdb/ppc-linux-tdep.c 9 Jan 2007 17:58:55 -0000 1.81 +++ gdb/ppc-linux-tdep.c 15 Mar 2007 17:15:50 -0000 @@ -484,17 +484,47 @@ ppc_linux_memory_remove_breakpoint (stru /* For historic reasons, PPC 32 GNU/Linux follows PowerOpen rather than the 32 bit SYSV R4 ABI structure return convention - all structures, no matter their size, are put in memory. Vectors, - which were added later, do get returned in a register though. */ + which were added later, do get returned in a register, although + not in an AltiVec register. */ static enum return_value_convention ppc_linux_return_value (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT - || TYPE_CODE (valtype) == TYPE_CODE_UNION) - && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8) - && TYPE_VECTOR (valtype))) + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (TYPE_LENGTH (valtype) == 16 + && TYPE_CODE (valtype) == TYPE_CODE_ARRAY + && TYPE_VECTOR (valtype)) + { + /* Return value is in r3-r6. */ + if (readbuf) + { + regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, + readbuf + 0); + regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4, + readbuf + 4); + regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 5, + readbuf + 8); + regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 6, + readbuf + 12); + } + if (writebuf) + { + regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, + writebuf + 0); + regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4, + writebuf + 4); + regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 5, + writebuf + 8); + regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 6, + writebuf + 12); + } + return RETURN_VALUE_REGISTER_CONVENTION; + } + else if (TYPE_CODE (valtype) == TYPE_CODE_STRUCT + || TYPE_CODE (valtype) == TYPE_CODE_UNION) return RETURN_VALUE_STRUCT_CONVENTION; else return ppc_sysv_abi_return_value (gdbarch, valtype, regcache, readbuf, -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."