From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25113 invoked by alias); 3 Oct 2006 19:15:09 -0000 Received: (qmail 25073 invoked by uid 22791); 3 Oct 2006 19:15:06 -0000 X-Spam-Check-By: sourceware.org Received: from e36.co.us.ibm.com (HELO e36.co.us.ibm.com) (32.97.110.154) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 03 Oct 2006 19:14:59 +0000 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e36.co.us.ibm.com (8.13.8/8.12.11) with ESMTP id k93JEwXE016400 for ; Tue, 3 Oct 2006 15:14:58 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id k93JEvZ0291586 for ; Tue, 3 Oct 2006 13:14:57 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k93JEvrh030903 for ; Tue, 3 Oct 2006 13:14:57 -0600 Received: from jananij.austin.ibm.com (jananij.austin.ibm.com [9.53.38.37]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k93JEv0m030886 for ; Tue, 3 Oct 2006 13:14:57 -0600 Received: by jananij.austin.ibm.com (Postfix, from userid 1000) id 03663140EE8; Tue, 3 Oct 2006 14:11:30 -0500 (CDT) Date: Tue, 03 Oct 2006 19:15:00 -0000 To: gdb-patches@sourceware.org Subject: [patch] Pushing Inferior Function Arguments onto Stack on PowerPC64 machines Message-ID: <4522B5E2.mailKT8130U2Q@jananij.austin.ibm.com> User-Agent: nail 10.6 11/15/03 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: janani@linux.ibm.com (Janani Janakiraman) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00008.txt.bz2 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 * 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