From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: gdb-patches@sourceware.org
Subject: [RFA] Fix broken sysv return value code on powerpc
Date: Wed, 17 Aug 2005 00:25:00 -0000 [thread overview]
Message-ID: <200508161723.j7GHNF07006802@elgar.sibelius.xs4all.nl> (raw)
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 <kettenis@gnu.org>
* 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)
next reply other threads:[~2005-08-16 17:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-17 0:25 Mark Kettenis [this message]
2005-08-17 0:37 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200508161723.j7GHNF07006802@elgar.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox