Re: Is that a GDB bug?
Simon Marchi <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <CAFXXi0=x_VVt3Jdw6V+hhb_DqEfAB+NwFYvw2UerxNfSxiKy5g@mail.gmail.com> |
On 12 October 2015 at 12:39, Mike Frysinger <[email protected]> wrote: > On 12 Oct 2015 15:32, Andreas Schwab wrote: >> Mike Frysinger <[email protected]> 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