From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2987 invoked by alias); 18 Mar 2010 18:55:49 -0000 Received: (qmail 2975 invoked by uid 22791); 18 Mar 2010 18:55:48 -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 18:55:43 +0000 Received: (qmail 14479 invoked from network); 18 Mar 2010 18:55:42 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 Mar 2010 18:55:42 -0000 From: Pedro Alves To: gdb@sourceware.org, Eli Zaretskii Subject: Re: Getting pissed off by gdb. Please help with stepping in. Date: Thu, 18 Mar 2010 18:55:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-19-generic; KDE/4.3.2; x86_64; ; ) Cc: dje@google.com, temp@sourceboost.com References: <11611.203.63.255.139.1268879984.squirrel@webmail5.pair.com> <201003181521.48681.pedro@codesourcery.com> <8339zxv5tp.fsf@gnu.org> In-Reply-To: <8339zxv5tp.fsf@gnu.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201003181855.39643.pedro@codesourcery.com> X-IsSubscribed: yes 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/msg00143.txt.bz2 On Thursday 18 March 2010 18:32:34, Eli Zaretskii wrote: > > > (gdb) f > > > #0 bar () at stepout.c:4 > > > 4 int bar () { return 1; } > > > (gdb) s > > > main () at stepout.c:12 > > > 12 return 0; > > > (gdb) > > > > > > Note that we've stepped out of bar, into foo, and back out of foo. > > > > He most probably used "next" when he said: > > > > > I do a step out and wtf... Instead of getting back to the line > > > where 'foo' is called I get passed it. > > I would expect "next" on line 4 to behave the same as "step", since > there's no function call there. But it doesn't. You're missing the issue. "step" on line 4 will take you to line 6, instead of line 11, because GDB keeps stepping after returning from bar (because it landed in the middle of line 11, and we don't stop there when stepping/nexting). Next on line 4 will take you to line 12, instead of line 11, because GDB keeps stepping after returning from bar (because it landed in the middle of line 11, and we don't stop there when stepping/nexting). Users often find this behaviour unexpected (I've often wished GDB would behave like what the OP is suggesting too). In the example being discussed, the OP would have expected that GDB would stop at line 11, when "stepping out of bar", but found GDB stopping at line 12 instead. I was saying that what he was probably calling "stepping", was issueing enough "next"s to step out of bar, not "step"s. I don't suppose people wanting to step out of a function (not knowing about finish) would issue "(gdb) step"s and risk stepping into further nested functions... I was pointing that out, after reading Doug's: > "I agree it should work as you expect. I don't see the step out of bar > continuing passed foo, but I do see it stepping into foo (as if you > had done two steps, so to speak: step out of bar and step into foo). > [This is with gdb 7.0 and cvs head.]" So, I'm merely saying that to reproduce what the OP was saying, you should do "next" to step out of bar, not "step". Visual Studio's "Step (Over)" ==> "(gdb) next" Visual Studio's "Step Into" ==> "(gdb) step" In any case, the behaviour would not be what the OP expected. -- Pedro Alves