public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/26063] New: inconsistent behaviors at -O2
@ 2020-05-30  2:51 yangyibiao at hust dot edu.cn
  2020-05-30  2:52 ` [Bug symtab/26063] " yangyibiao at hust dot edu.cn
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: yangyibiao at hust dot edu.cn @ 2020-05-30  2:51 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26063

            Bug ID: 26063
           Summary: inconsistent behaviors at -O2
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: yangyibiao at hust dot edu.cn
  Target Milestone: ---

Consider test case:
...
$ cat small.c
__attribute__ ((noinline, noclone)) 
int foo (char *c)
{
  asm volatile ("" : : "r" (c) : "memory");
  return 1;
}

int main ()
{
  char tpl1[20] = "/tmp/test.XXX";
  char tpl2[20] = "/tmp/test.XXX";
  int fd1 = foo (tpl1);
  int fd2 = foo (tpl2);
  if (fd1 == -1) {
    return 1;
  }

  return 0;
}
...



When stepping with step, line 13 is not hit by gdb.
...
$ gcc -O2 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401020: file small.c, line 10.
(gdb) r
Starting program: /home/yibiao/Debugger/a.out 

Breakpoint 1, main () at small.c:10
10        char tpl1[20] = "/tmp/test.XXX";
(gdb) step
11        char tpl2[20] = "/tmp/test.XXX";
(gdb) 
12        int fd1 = foo (tpl1);
(gdb) 
foo (c=c@entry=0x7fffffffdea0 "/tmp/test.XXX") at small.c:5
5         return 1;
(gdb) 
foo (c=c@entry=0x7fffffffdec0 "/tmp/test.XXX") at small.c:5
5         return 1;
(gdb) 
main () at small.c:14
14        if (fd1 == -1) {
(gdb) 
0x00007ffff7df4023 in __libc_start_main () from /usr/lib/libc.so.6
(gdb) 
Single stepping until exit from function __libc_start_main,
which has no line number information.
[Inferior 1 (process 1852557) exited normally]
...



When stepping with stepi, line 13 is hit by gdb as follow.
...
$ gcc -O2 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401020: file small.c, line 10.
(gdb) r
Starting program: /home/yibiao/Debugger/a.out 

Breakpoint 1, main () at small.c:10
10        char tpl1[20] = "/tmp/test.XXX";
(gdb) stepi
0x0000000000401024      10        char tpl1[20] = "/tmp/test.XXX";
(gdb) 
0x000000000040102c      12        int fd1 = foo (tpl1);
(gdb) 
0x000000000040102f      10        char tpl1[20] = "/tmp/test.XXX";
(gdb) 
11        char tpl2[20] = "/tmp/test.XXX";
(gdb) 
12        int fd1 = foo (tpl1);
(gdb) 
0x0000000000401043      11        char tpl2[20] = "/tmp/test.XXX";
(gdb) 
0x0000000000401048      12        int fd1 = foo (tpl1);
(gdb) 
foo (c=c@entry=0x7fffffffdea0 "/tmp/test.XXX") at small.c:5
5         return 1;
(gdb) 
0x0000000000401165      5         return 1;
(gdb) 
0x000000000040104d in main () at small.c:13
13        int fd2 = foo (tpl2);
(gdb) 
...


$ gcc --version
gcc (GCC) 10.0.1 20200419 (experimental)
Copyright (C) 2020 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 (GDB) 10.0.50.20200517-git
Copyright (C) 2020 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.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-01-29 12:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30  2:51 [Bug symtab/26063] New: inconsistent behaviors at -O2 yangyibiao at hust dot edu.cn
2020-05-30  2:52 ` [Bug symtab/26063] " yangyibiao at hust dot edu.cn
2021-01-13  8:38 ` yangyibiao at outlook dot com
2021-01-13 12:44 ` yangyibiao at outlook dot com
2021-01-13 12:58 ` yangyibiao at outlook dot com
2021-01-13 14:24 ` vries at gcc dot gnu.org
2021-01-13 15:18 ` vries at gcc dot gnu.org
2021-01-14 13:00 ` [Bug breakpoints/26063] " vries at gcc dot gnu.org
2021-01-14 13:28 ` vries at gcc dot gnu.org
2021-01-29 12:36 ` cvs-commit at gcc dot gnu.org
2021-01-29 12:37 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).