From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2478 invoked by alias); 18 Mar 2010 15:10:59 -0000 Received: (qmail 2435 invoked by uid 22791); 18 Mar 2010 15:10:56 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Mar 2010 15:10:47 +0000 Received: from kpbe18.cbf.corp.google.com (kpbe18.cbf.corp.google.com [172.25.105.82]) by smtp-out.google.com with ESMTP id o2IFAi1M022908 for ; Thu, 18 Mar 2010 08:10:44 -0700 Received: from fg-out-1718.google.com (fgae21.prod.google.com [10.86.56.21]) by kpbe18.cbf.corp.google.com with ESMTP id o2IFAg9A022019 for ; Thu, 18 Mar 2010 08:10:42 -0700 Received: by fg-out-1718.google.com with SMTP id e21so174156fga.0 for ; Thu, 18 Mar 2010 08:10:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.90.77 with SMTP id d55mr1547162wef.17.1268925041864; Thu, 18 Mar 2010 08:10:41 -0700 (PDT) In-Reply-To: References: <11611.203.63.255.139.1268879984.squirrel@webmail5.pair.com> Date: Thu, 18 Mar 2010 15:10:00 -0000 Message-ID: Subject: Re: Getting pissed off by gdb. Please help with stepping in. From: Doug Evans To: Eli Zaretskii Cc: temp@sourceboost.com, gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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/msg00132.txt.bz2 On Thu, Mar 18, 2010 at 2:07 AM, Eli Zaretskii wrote: >> Date: Thu, 18 Mar 2010 00:22:20 -0700 >> From: Doug Evans >> Cc: gdb@sourceware.org >> >> I agree it should work as you expect. =A0I 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.] >> One *could* use `finish' to accomplish what you want but I think a >> `step' at the end of the function should behave like `finish' (modulo >> printing the return value of course). > > I'm confused: what exactly does this patch fix, i.e. what was the > behavior before it and what it will be after it? > > My confusion stems from the fact that you first say that the problem > described by the OP does not exist, i.e. GDB does _not_ continue past > foo, but then you say something is wrong and suggest a fix. =A0What did > I miss here? Suppose we have this code: int g; int bar () { return 1; } void foo (int x) { g =3D x; } int main () { foo (bar ()); return 0; } And suppose we've stepped into `bar' during the setup for the call to `foo'. (gdb) start Temporary breakpoint 1 at 0x4003ad: file stepout.c, line 11. Starting program: /home/dje/src/play/stepout.x64 Temporary breakpoint 1, main () at stepout.c:11 11 foo (bar ()); (gdb) s bar () at stepout.c:4 4 int bar () { return 1; } (gdb) Now suppose the user does a "step" at this point. There are several possibilities for what can happen, and that is what we are discussing. Here's what gdb 7.1 does: (gdb) f #0 bar () at stepout.c:4 4 int bar () { return 1; } (gdb) s foo (x=3D1) at stepout.c:6 6 void foo (int x) { g =3D x; } (gdb) Note that we've stepped out of bar and into foo. Here is what Pavel is expecting instead: (gdb) f #0 bar () at stepout.c:4 4 int bar () { return 1; } (gdb) s 0x00000000004003b7 in main () at stepout.c:11 11 foo (bar ()); (gdb) [or some such. I cut-n-pasted that from a session with my patch applied. IWBN to remove all those zeroes in 0x00000... of course] Note that we've stepped out of bar but have not yet stepped into foo. The behaviour Pavel describes in his message, but which I do not see, is th= is: (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.