From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29532 invoked by alias); 20 Nov 2002 17:18:43 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 29519 invoked from network); 20 Nov 2002 17:18:41 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 20 Nov 2002 17:18:41 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 39FD63E39; Wed, 20 Nov 2002 12:18:36 -0500 (EST) Message-ID: <3DDBC3EC.4010401@redhat.com> Date: Wed, 20 Nov 2002 09:18:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kris Warkentin Cc: Richard.Earnshaw@arm.com, gdb@sources.redhat.com Subject: Re: ARM stack alignment on hand called functions References: <200211201618.gAKGITW18622@pc960.cambridge.arm.com> <191601c290b1$942159e0$0202040a@catdog> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-11/txt/msg00265.txt.bz2 > The problem arises only with functions which return structures whose size is > not evenly divisible by 4. Below is what I did to solve it. Kris, FYI, It's very important to always reproduce problems using the current GDB sources. That way, any confusion arrising from either local modifications (does QNX 6 ship an un-modified GDB 5.2.1?) or out-of-date sources (has the problem been fixed?). For the problem at hand, I suspect the post 5.3 architecture method - gdbarch_frame_align() - is needed. That method is used to align each element's stack address (e.g., struct return) and not the size of each element. (I think I might add a few more juicy comments to valops.c so its clearer what the fix to your problem is :-). Andrew (1) BTW, note: http://sources.redhat.com/gdb/current/onlinedocs/gdbint_15.html#SEC130 To avoid version conflicts, vendors are expected to modify the file `gdb/version.in' to include a vendor unique alphabetic identifier (an official GDB release never uses alphabetic characters in its version identifer). > Index: arm-tdep.c > =================================================================== > RCS file: /product/tools/gdb/gdb/arm-tdep.c,v > retrieving revision 1.9 > retrieving revision 1.10 > diff -c -r1.9 -r1.10 > *** arm-tdep.c 20 Sep 2002 17:11:31 -0000 1.9 > --- arm-tdep.c 19 Nov 2002 18:33:37 -0000 1.10 > *************** > *** 1480,1485 **** > --- 1480,1486 ---- > } > } > > + sp = (sp + 3) & ~3; > /* Return adjusted stack pointer. */ > return sp; > } > > The code in valops.c : hand_function_call() that was causing the problem was > this: > > /* Reserve space for the return structure to be written on the > stack, if necessary */ > if (struct_return) > { > int len = TYPE_LENGTH (value_type); > if (STACK_ALIGN_P ()) > /* MVS 11/22/96: I think at least some of this stack_align > code is really broken. Better to let PUSH_ARGUMENTS adjust > the stack in a target-defined manner. */ > len = STACK_ALIGN (len); > if (INNER_THAN (1, 2)) > { > /* stack grows downward */ > sp -= len; > struct_addr = sp; > } > > So what I did was to make sure that arm_push_arguments would always return > an aligned stack pointer. I think we can safely agree that > arm_push_arguments should NEVER return an unaligned stack pointer right? > > cheers, > > Kris > >