This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Getting pissed off by gdb. Please help with stepping in.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]