From: janani@linux.ibm.com (Janani Janakiraman)
To: gdb-patches@sourceware.org
Subject: [patch] Pushing Inferior Function Arguments onto Stack on PowerPC64 machines
Date: Tue, 03 Oct 2006 19:15:00 -0000 [thread overview]
Message-ID: <4522B5E2.mailKT8130U2Q@jananij.austin.ibm.com> (raw)
This fixes a problem on Powerpc 64 machines while running gdb on 64 bit
programs. The problem is with the alignment of the function arguments
when they are pushed to the stack in the ppc64_sysv_abi_push_dummy_call.
GCC expects the values to be right aligned.
gdb:
2006-10-02 Janani Janakiraman <janani@us.ibm.com>
* ppc-sysv-tdep.c: Remove the hack for GCC. Right align
the values on the stack.
Index: gdb/ppc-sysv-tdep.c
===================================================================
*** ppc-sysv-tdep.c.orig 2006-09-29 15:52:35.000000000 -0500
--- ppc-sysv-tdep.c 2006-09-29 15:57:55.000000000 -0500
*************** ppc64_sysv_abi_push_dummy_call (struct g
*** 786,806 ****
if (len > tdep->wordsize)
len = tdep->wordsize;
memset (regval, 0, sizeof regval);
! /* WARNING: cagney/2003-09-21: As best I can
! tell, the ABI specifies that the value should
! be left aligned. Unfortunately, GCC doesn't
! do this - it instead right aligns even sized
! values and puts odd sized values on the
! stack. Work around that by putting both a
! left and right aligned value into the
! register (hopefully no one notices :-^).
! Arrrgh! */
! /* Left aligned (8 byte values such as pointers
! fill the buffer). */
! memcpy (regval, val + byte, len);
! /* Right aligned (but only if even). */
! if (len == 1 || len == 2 || len == 4)
! memcpy (regval + tdep->wordsize - len,
val + byte, len);
regcache_cooked_write (regcache, greg, regval);
}
--- 786,793 ----
if (len > tdep->wordsize)
len = tdep->wordsize;
memset (regval, 0, sizeof regval);
! /* GCC expects values to be right aligned */
! memcpy (regval + tdep->wordsize - len,
val + byte, len);
regcache_cooked_write (regcache, greg, regval);
}
GDB Test from testsuite -- results before the patch.
Note, after the patch is applied,
the results are as expected by the test case.
GCC Version ---- gcc (GCC) 4.1.0 (SUSE Linux)
gdb.base/call-ar-st.exp: continue to 1281
(gdb)print print_small_structs(*struct1, *struct2, *struct3, *struct4,
*flags, *flags_combo, *three_char,*five_char, *int_char_combo, *d1, *d2, *d3,
*f1, *f2, *f3)
alpha
gamma
epsilon
alpha
gamma
epsilon
ch1: y ch2: n
Contents of three_char_t:
<----- This should be "a b c"
Contents of five_char_t:
o p <----- This should be "l m n o p"
....
Janani Janakiraman
next reply other threads:[~2006-10-03 19:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-03 19:15 Janani Janakiraman [this message]
2006-10-03 19:20 ` Daniel Jacobowitz
2006-10-04 19:00 janani
2006-10-04 19:11 ` Daniel Jacobowitz
2006-10-04 19:14 ` Daniel Jacobowitz
2006-10-04 20:19 ` Mark Kettenis
2006-10-04 20:27 ` Andreas Schwab
[not found] ` <OFE88464A1.C58B072A-ON872571FD.006ABA69-862571FD.006C7CFB@us.ibm.com>
2006-10-04 20:26 ` Daniel Jacobowitz
[not found] ` <drow@false.org>
2006-10-04 20:43 ` David Edelsohn
2006-10-04 20:52 ` Daniel Jacobowitz
2006-10-04 19:54 janani
2006-10-04 21:02 janani
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=4522B5E2.mailKT8130U2Q@jananij.austin.ibm.com \
--to=janani@linux.ibm.com \
--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