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 Thu, Mar 18, 2010 at 2:07 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Thu, 18 Mar 2010 00:22:20 -0700
>> From: Doug Evans <dje@google.com>
>> Cc: gdb@sourceware.org
>>
>> 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.]
>> 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. ?What did
> I miss here?

Suppose we have this code:

int g;

int bar () { return 1; }

void foo (int x) { g = 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=1) at stepout.c:6
6       void foo (int x) { g = 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 this:

(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.


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