[Bug gdb/24602] New: [gdb] gdb wrongly stopped at a breakpoint in an unexecuted line of code

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/24602] New: [gdb] gdb wrongly stopped at a breakpoint in an unexecuted line of code

fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24602

            Bug ID: 24602
           Summary: [gdb] gdb wrongly stopped at a breakpoint in an
                    unexecuted line of code
           Product: gdb
           Version: 8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot 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.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/24602] [gdb] gdb wrongly stopped at a breakpoint in an unexecuted line of code

fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24602

Yibiao Yang <yangyibiao at nju dot edu.cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yangyibiao at nju dot edu.cn

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/24602] [gdb] gdb wrongly stopped at a breakpoint in an unexecuted line of code

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24602

Yibiao Yang <yangyibiao at hust dot edu.cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|8.1                         |HEAD
           Severity|normal                      |critical

--- Comment #1 from Yibiao Yang <yangyibiao at hust dot edu.cn> ---
This problem is still exist in latest development version of gdb

$ gdb -v
GNU gdb (GDB) 9.0.50.20191210-git
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ gdb ./a.out -q
Reading symbols from ./a.out...
(gdb) break 8
Breakpoint 1 at 0x1148: file small.c, line 8.
(gdb) run
Starting program: /home/yibiao/tgdb/a.out

Breakpoint 1, main (argc=1, argv=0x7fffffffe008) at small.c:8
8           label:
(gdb)

--
You are receiving this mail because:
You are on the CC list for the bug.