From: Simon Marchi <simon.marchi@polymtl.ca>
To: Andreas Schwab <schwab@suse.de>, Nancy <nancydreaming@gmail.com>,
"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Is that a GDB bug?
Date: Mon, 12 Oct 2015 16:56:00 -0000 [thread overview]
Message-ID: <CAFXXi0=x_VVt3Jdw6V+hhb_DqEfAB+NwFYvw2UerxNfSxiKy5g@mail.gmail.com> (raw)
In-Reply-To: <20151012163933.GA4446@vapier.lan>
On 12 October 2015 at 12:39, Mike Frysinger <vapier@gentoo.org> wrote:
> On 12 Oct 2015 15:32, Andreas Schwab wrote:
>> Mike Frysinger <vapier@gentoo.org> writes:
>> > next operates on statements, not lines.
>>
>> That's not true.
>>
>> (gdb) help step
>> Step program until it reaches a different source line.
>
> "next" != "step"
Andreas probably pasted the help for "step" because the help for
"next" refers to "step":
(gdb) help next
Step program, proceeding through subroutine calls.
Usage: next [N]
Unlike "step", if the current source line calls a subroutine,
this command does not enter the subroutine, but instead steps over
the call, in effect treating it as a single source line.
If I understand correctly (and please correct me if I'm wrong), the
debug info only maps each instruction to a line of the original source
file. The algorithm for step/next when no subroutines are involved is
equivalent to "step instructions as long as they belong to the same
source line". When the CPU is about to execute an instruction that
belongs to an other source line, we stop. So there is no knowledge of
statements.
You can verify what Pedro said by removing the breakpoint before doing the next:
(gdb) b 5
Breakpoint 1 at 0x80483d8: file test.c, line 5.
(gdb) r
Starting program: /tmp/binutils-gdb/gdb/test
Breakpoint 1, main () at test.c:5
5 L1: switch(x) { case 0: x=1; goto L1; case 1: if(x==0) goto
L1; else break; }
(gdb) delete 1
(gdb) n
6 x=2;
(gdb)
Here, the next is not interrupted by the breakpoint, so the program
stops just before executing the first instruction that belongs to
x=2;.
Simon
next prev parent reply other threads:[~2015-10-12 16:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 12:46 Nancy
2015-10-12 13:20 ` Mike Frysinger
2015-10-12 13:32 ` Andreas Schwab
2015-10-12 16:39 ` Mike Frysinger
2015-10-12 16:56 ` Simon Marchi [this message]
2015-10-12 16:59 ` Andreas Schwab
2015-10-12 14:14 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFXXi0=x_VVt3Jdw6V+hhb_DqEfAB+NwFYvw2UerxNfSxiKy5g@mail.gmail.com' \
--to=simon.marchi@polymtl.ca \
--cc=gdb@sourceware.org \
--cc=nancydreaming@gmail.com \
--cc=schwab@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox