From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5139 invoked by alias); 13 Nov 2002 17:43:39 -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 5132 invoked from network); 13 Nov 2002 17:43:36 -0000 Received: from unknown (HELO zenia.red-bean.com) (66.244.67.22) by sources.redhat.com with SMTP; 13 Nov 2002 17:43:36 -0000 Received: (from jimb@localhost) by zenia.red-bean.com (8.11.6/8.11.6) id gADHRmR12492; Wed, 13 Nov 2002 12:27:48 -0500 To: Donn Terry Cc: Michael Snyder , gdb-patches@sources.redhat.com Subject: Re: Single step vs. "tail recursion" optimization References: <3DCC4497.1FC39237@redhat.com> From: Jim Blandy Date: Wed, 13 Nov 2002 09:43:00 -0000 In-Reply-To: <3DCC4497.1FC39237@redhat.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.92 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-11/txt/msg00369.txt.bz2 Michael Snyder writes: > Donn Terry wrote: > > > > (I'm sorry to have to be the messenger on this one...) > > > > Here's a mini testcase. I've also attached the resulting .s files for > > -O2 and -O3. > > You do know, don't you, that there are lots of optimizations that GDB > fails to debug at -O2 and -O3? If something bad happens at those > levels, our practice is to say "turn down the optimization and try again". Yeah, in general there's no way for GDB to produce the expected backtrace when the compiler has turned a call in tail position into a pop-frame-and-jump. There's simply no record at all of the function that made the tail call on the stack. But when there's a tail call to a function with no debug info, it seems to me that GDB should still do better than just letting the program run away. When "step" or "next" notice that they've stepped into a new function which has no debug info, they're supposed to set a breakpoint at the return address and run until that's hit. Now, in the presence of tail call optimizations, that return address is going to be one (or more) stack frames further back than you expect, but it should still get hit eventually. In your program, that breakpoint should be set in main, I think. Doesn't that work?