From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26230 invoked by alias); 16 Aug 2005 17:23:23 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 26211 invoked by uid 22791); 16 Aug 2005 17:23:18 -0000 Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 16 Aug 2005 17:23:18 +0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.0/8.13.0) with ESMTP id j7GHNGP3002564 for ; Tue, 16 Aug 2005 19:23:16 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.4/8.13.3) with ESMTP id j7GHNFjx027097 for ; Tue, 16 Aug 2005 19:23:15 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.4/8.13.4/Submit) id j7GHNF07006802; Tue, 16 Aug 2005 19:23:15 +0200 (CEST) Date: Wed, 17 Aug 2005 00:25:00 -0000 Message-Id: <200508161723.j7GHNF07006802@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: gdb-patches@sourceware.org Subject: [RFA] Fix broken sysv return value code on powerpc X-SW-Source: 2005-08/txt/msg00193.txt.bz2 Not sure whether I submitted this patch for approval before. Anyway, it fixes how we deal with the broken GCC 3.3.5 on OpenBSD 3.7. It also fixes some regression tests on NetBSD 2.0 if I remove the attempt to fix things up from ppcnbsd-tdep.c. There's a small risk that GCC is broken in a different way now, but I suspect that the tests in the testsuite that FAIL (and PASS with this fix) were introduced after the origional code was checked in. In any case, the new code is much simpler ;-). ok? Mark Index: ChangeLog from Mark Kettenis * ppc-sysv-tdep.c (do_ppc_sysv_return_value): Fix the code that deals with the broken GCC convention. Index: ppc-sysv-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v retrieving revision 1.30 diff -u -p -r1.30 ppc-sysv-tdep.c --- ppc-sysv-tdep.c 16 Aug 2005 17:12:35 -0000 1.30 +++ ppc-sysv-tdep.c 16 Aug 2005 17:16:28 -0000 @@ -451,52 +451,33 @@ do_ppc_sysv_return_value (struct gdbarch } if (broken_gcc && TYPE_LENGTH (type) <= 8) { + /* GCC screwed up for structures or unions whose size is less + than or equal to 8 bytes.. Instead of left-aligning, it + right-aligns the data into the buffer formed by r3, r4. */ + gdb_byte regvals[MAX_REGISTER_SIZE * 2]; + int len = TYPE_LENGTH (type); + int offset = (2 * tdep->wordsize - len) % tdep->wordsize; + if (readbuf) { - /* GCC screwed up. The last register isn't "left" aligned. - Need to extract the least significant part of each - register and then store that. */ - /* Transfer any full words. */ - int word = 0; - while (1) - { - ULONGEST reg; - int len = TYPE_LENGTH (type) - word * tdep->wordsize; - if (len <= 0) - break; - if (len > tdep->wordsize) - len = tdep->wordsize; - regcache_cooked_read_unsigned (regcache, - tdep->ppc_gp0_regnum + 3 + word, - ®); - store_unsigned_integer (((bfd_byte *) readbuf - + word * tdep->wordsize), len, reg); - word++; - } + regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, + regvals + 0 * tdep->wordsize); + if (len > tdep->wordsize) + regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4, + regvals + 1 * tdep->wordsize); + memcpy (readbuf, regvals + offset, len); } if (writebuf) { - /* GCC screwed up. The last register isn't "left" aligned. - Need to extract the least significant part of each - register and then store that. */ - /* Transfer any full words. */ - int word = 0; - while (1) - { - ULONGEST reg; - int len = TYPE_LENGTH (type) - word * tdep->wordsize; - if (len <= 0) - break; - if (len > tdep->wordsize) - len = tdep->wordsize; - reg = extract_unsigned_integer (((const bfd_byte *) writebuf - + word * tdep->wordsize), len); - regcache_cooked_write_unsigned (regcache, - tdep->ppc_gp0_regnum + 3 + word, - reg); - word++; - } + memset (regvals, 0, sizeof regvals); + memcpy (regvals + offset, writebuf, len); + regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, + regvals + 0 * tdep->wordsize); + if (len > tdep->wordsize) + regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4, + regvals + 1 * tdep->wordsize); } + return RETURN_VALUE_REGISTER_CONVENTION; } if (TYPE_LENGTH (type) <= 8)