From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7719 invoked by alias); 18 Mar 2010 14:13:51 -0000 Received: (qmail 7710 invoked by uid 22791); 18 Mar 2010 14:13:51 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Mar 2010 14:13:47 +0000 Received: (qmail 30339 invoked from network); 18 Mar 2010 14:13:45 -0000 Received: from unknown (HELO caradoc.them.org) (dan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 Mar 2010 14:13:45 -0000 Date: Thu, 18 Mar 2010 14:13:00 -0000 From: Daniel Jacobowitz To: =?iso-8859-1?Q?Andr=E9_P=F6nitz?= Cc: gdb@sourceware.org Subject: Re: Getting pissed off by gdb. Please help with stepping in. Message-ID: <20100318141335.GA12031@caradoc.them.org> Mail-Followup-To: =?iso-8859-1?Q?Andr=E9_P=F6nitz?= , gdb@sourceware.org References: <11611.203.63.255.139.1268879984.squirrel@webmail5.pair.com> <20100318133334.GA7732@caradoc.them.org> <201003181506.15964.andre.poenitz@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <201003181506.15964.andre.poenitz@nokia.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00128.txt.bz2 On Thu, Mar 18, 2010 at 03:06:15PM +0100, André Pönitz wrote: > This means a 'next' effectively jumps over two lines, which is rather nasty. > So I have been removing this optimization in gdb for a while (as the stub > is not under my control) without experiencing any bad side effects. Most > notably, stepping over for (;;) does not seem to be affected at all. It's not an "optimization" - it's to improve the user experience, not to improve performance. > I dug a bit in gdb's history, and the code is older than anything I could > access, i.e. before 1991 or so. Together with the comment "That is said > to make things like for (;;) statements work better" one might get the > impression that it was a workaround for some particular compiler or such. > > Does anybody happen to remember what triggered the inclusion of this > optimization into gdb code? I certainly don't remember, but I can make an educated guess. It depends how your compiler lays out for loops. If the condition on the for statement is adjacent to the initial operation: for-init for-cond loop-body for-increment unconditional branch to for-cond Then stepping past the last line in loop-body will take you to the middle of the "line" containing all of init, cond, and increment. I don't think that's how GCC lays out loops nowadays, I think it's more: for-init branch-forwards-to-cond loop-body for-increment for-cond Whether the current behavior matters in practice, there I have no idea. One thing I've found helpful is to diff gdb testsuite log files with such a change; the diff is noisy, but you can see if there was any meaningful impact. -- Daniel Jacobowitz CodeSourcery