From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 813 invoked by alias); 21 Jan 2002 00:24:53 -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 724 invoked from network); 21 Jan 2002 00:24:52 -0000 Received: from unknown (HELO localhost.cygnus.com) (24.114.42.213) by sources.redhat.com with SMTP; 21 Jan 2002 00:24:52 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.cygnus.com (Postfix) with ESMTP id CCB333F0A; Sun, 20 Jan 2002 19:24:48 -0500 (EST) Message-ID: <3C4B5FD0.8030809@cygnus.com> Date: Sun, 20 Jan 2002 16:24:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.7) Gecko/20020103 X-Accept-Language: en-us MIME-Version: 1.0 To: Jim Blandy , Fernando Nasser Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: try to ensure abort has valid return address References: <20020112064706.52E575E9D8@zwingli.cygnus.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-01/txt/msg00613.txt.bz2 > 2002-01-12 Jim Blandy > > * gdb.base/coremaker.c (func2): Try to arrange for the return > address passed to `abort' to fall within `func2', so we can get > backtraces. > > Index: gdb/testsuite/gdb.base/coremaker.c > =================================================================== > RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/coremaker.c,v > retrieving revision 1.4 > diff -c -r1.4 coremaker.c > *** gdb/testsuite/gdb.base/coremaker.c 1999/06/25 23:44:28 1.4 > --- gdb/testsuite/gdb.base/coremaker.c 2002/01/12 06:42:09 > *************** > *** 81,87 **** > } > > void > ! func2 () > { > int coremaker_local[5]; > int i; > --- 81,87 ---- > } > > void > ! func2 (int please_abort) > { > int coremaker_local[5]; > int i; > *************** > *** 104,116 **** > for (i = 0; i < 5; i++) > coremaker_bss += coremaker_local[i]; > coremaker_data = coremaker_ro + 1; > ! abort (); > } > > void > func1 () > { > ! func2 (); > } > > int main () > --- 104,138 ---- > for (i = 0; i < 5; i++) > coremaker_bss += coremaker_local[i]; > coremaker_data = coremaker_ro + 1; > ! > ! /* This function used to simply call `abort' unconditionally. > ! However, because GCC sometimes knows that `abort' will never > ! return, the `call' instruction that invokes `abort' would > ! sometimes be the very last instruction in this function. The > ! epilogue instructions you'd normally expect --- deallocating the > ! frame, jumping to the return address --- were omitted, since > ! they'd never be reached anyway. This means that the return > ! address passed to abort (which it'll never use) actually points > ! beyond the end of the caller! Sometimes the return address > ! seemed to be in the next function; sometimes it seemed to be in > ! padding instructions between functions, for which there was no > ! line number info. In any case, GDB had difficulties producing a > ! backtrace in this case. > ! > ! There's no way to force the compiler not to put the call to > ! `abort' at the very end of the function --- after all, it is > ! functionally correct to do so. But we hope that putting it in a > ! conditional will make it more likely that GDB can get a > ! backtrace, and find coremaker_local, which is what we really care > ! about. */ > ! if (please_abort) > ! abort (); > } > > void > func1 () > { > ! func2 (1); > } > > int main () > >