https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90574

            Bug ID: 90574
           Summary: [gdb] gdb wrongly stopped at a breakpoint in an
                    unexecuted line of code
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

$ gcc --version
gcc (GCC) 10.0.0 20190517 (experimental)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gdb --version
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

$ cat small.c
#include <stdio.h>

int main(int argc, char **argv)
{
  if (argc == 0)
  {
    int *ptr;
    label:
      {
      }
  }
  if (argc == 1)
  {
     printf("hello\n");
  }
  return 0;
}

$ gcc -g small.c; ./a.out
hello

$ gdb -batch -x cmds a.out
Breakpoint 1 at 0x400501: file small.c, line 8.

Breakpoint 1, main (argc=1, argv=0x7fffffffde58) at small.c:8
8           label:
ptr = <optimized out>
Kill the program being debugged? (y or n) [answered Y; input not from terminal]


$ cat cmds
b 8
r
info locals
kill
q


Line 8 in the body of the "if (argc==0)" is not executed according to the
program output. 

Thus, when we set breakpoint in Line #8, gdb should not stop. However, in this
case, it stopped and print something. Thus, I was wondering this should be a
bug in gdb.

Reply via email to