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

            Bug ID: 90584
           Summary: [gdb] gdb is not stopped at a breakpoint in an
                    executed 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.


$ cat small.c
#include <stdio.h>
int main()
{
  int i = 0;
  int j = 0;
  for (; i<=1; i++) {
    for (; j<=1; j++) {
      goto lbl;
    }
  }
lbl:  // line 11
  printf("hello\n");
  return 0;
}

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

$ gdb -batch -x cmds a.out
Breakpoint 1 at 0x40051a: file small.c, line 11.
hello
[Inferior 1 (process 2774) exited normally]
cmds:3: Error in sourced command file:
No frame selected.

$ cat cmds
b 11
r
info locals
kill
q

According to the program output, Line 11 should be executed. Thus, when we set
breakpoint at line 11, it should be stopped and print something. However, the
program executed and exit directly.

Reply via email to