From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23837 invoked by alias); 18 Mar 2010 14:33:50 -0000 Received: (qmail 23814 invoked by uid 22791); 18 Mar 2010 14:33:48 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp.nokia.com (HELO mgw-mx09.nokia.com) (192.100.105.134) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Mar 2010 14:33:43 +0000 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2IEXX2o030805 for ; Thu, 18 Mar 2010 09:33:41 -0500 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 16:33:07 +0200 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 16:33:06 +0200 Received: from gar.localnet (berwst16747.europe.nokia.com [172.25.167.47]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2IEX3r7020869 for ; Thu, 18 Mar 2010 16:33:04 +0200 From: =?iso-8859-1?q?Andr=E9_P=F6nitz?= To: gdb@sourceware.org Subject: Re: Getting pissed off by gdb. Please help with stepping in. Date: Thu, 18 Mar 2010 14:33:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-19-generic; KDE/4.3.2; i686; ; ) References: <11611.203.63.255.139.1268879984.squirrel@webmail5.pair.com> <201003181506.15964.andre.poenitz@nokia.com> <20100318141335.GA12031@caradoc.them.org> In-Reply-To: <20100318141335.GA12031@caradoc.them.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201003181533.05408.andre.poenitz@nokia.com> X-Nokia-AV: Clean 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/msg00129.txt.bz2 On Thursday 18 March 2010 15:13:38 Daniel Jacobowitz wrote: > On Thu, Mar 18, 2010 at 03:06:15PM +0100, Andr=E9 P=F6nitz wrote: > > This means a 'next' effectively jumps over two lines, which is rather n= asty. > > So I have been removing this optimization in gdb for a while (as the st= ub=20 > > is not under my control) without experiencing any bad side effects. Most > > notably, stepping over for (;;) does not seem to be affected at all. >=20 > It's not an "optimization" - it's to improve the user experience, not > to improve performance. I used the term from the comment=20 "Optimize by setting the stepping range to the line." For me it's in fact the opposite to an optimization as the single stepping= =20 through the rest of the second line leads to one round trip through the=20 stub for each of the remaining instructions which easily sums up to a couple of seconds for lines that generate a hundred instructions. > > I dug a bit in gdb's history, and the code is older than anything I cou= ld=20 > > access, i.e. before 1991 or so. Together with the comment "That is sai= d=20 > > to make things like for (;;) statements work better" one might get the= =20 > > impression that it was a workaround for some particular compiler or suc= h. > >=20 > > Does anybody happen to remember what triggered the inclusion of this > > optimization into gdb code? >=20 > 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: >=20 > for-init > for-cond > loop-body > for-increment > unconditional branch to for-cond >=20 > 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. >=20 > I don't think that's how GCC lays out loops nowadays, I think it's > more: >=20 > for-init > branch-forwards-to-cond > loop-body > for-increment > for-cond I see. Thanks for the explanation. > Whether the current behavior matters in practice, there I have no > idea. >=20 > 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. I'll do that. Andre'