From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 360F7385DC35; Sat, 30 May 2020 03:02:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 360F7385DC35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590807723; bh=CfccHF64H0/Pnp5uK2zRpUQaKxqgv8v0LxbROjQzpBo=; h=From:To:Subject:Date:From; b=CPNHQgHmwlQGgr8O7E173Zq+vCq/IA4AnEvT6SMSj0wXm/lJhKqizNKA6dfFjZDjf T+skzLnJK5xTj5bIob1FGjd5OZ6g/a35JhzV8LTGQDpxvbl+gwA1vFC8pND+m8RjWt skcBSbwuuMRjphNLDfN8kWCaQD4kJdv5Uu3DO46s= From: "yangyibiao at hust dot edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/95432] New: inconsistent behaviors at -O2 Date: Sat, 30 May 2020 03:02:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yangyibiao at hust dot edu.cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2020 03:02:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95432 Bug ID: 95432 Summary: inconsistent behaviors at -O2 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: yangyibiao at hust dot edu.cn Target Milestone: --- Consider test case: ... $ cat small.c __attribute__ ((noinline, noclone))=20 int foo (char *c) { asm volatile ("" : : "r" (c) : "memory"); return 1; } int main () { char tpl1[20] =3D "/tmp/test.XXX"; char tpl2[20] =3D "/tmp/test.XXX"; int fd1 =3D foo (tpl1); int fd2 =3D foo (tpl2); if (fd1 =3D=3D -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=20 Breakpoint 1, main () at small.c:10 10 char tpl1[20] =3D "/tmp/test.XXX"; (gdb) step 11 char tpl2[20] =3D "/tmp/test.XXX"; (gdb)=20 12 int fd1 =3D foo (tpl1); (gdb)=20 foo (c=3Dc@entry=3D0x7fffffffdea0 "/tmp/test.XXX") at small.c:5 5 return 1; (gdb)=20 foo (c=3Dc@entry=3D0x7fffffffdec0 "/tmp/test.XXX") at small.c:5 5 return 1; (gdb)=20 main () at small.c:14 14 if (fd1 =3D=3D -1) { (gdb)=20 0x00007ffff7df4023 in __libc_start_main () from /usr/lib/libc.so.6 (gdb)=20 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=20 Breakpoint 1, main () at small.c:10 10 char tpl1[20] =3D "/tmp/test.XXX"; (gdb) stepi 0x0000000000401024 10 char tpl1[20] =3D "/tmp/test.XXX"; (gdb)=20 0x000000000040102c 12 int fd1 =3D foo (tpl1); (gdb)=20 0x000000000040102f 10 char tpl1[20] =3D "/tmp/test.XXX"; (gdb)=20 11 char tpl2[20] =3D "/tmp/test.XXX"; (gdb)=20 12 int fd1 =3D foo (tpl1); (gdb)=20 0x0000000000401043 11 char tpl2[20] =3D "/tmp/test.XXX"; (gdb)=20 0x0000000000401048 12 int fd1 =3D foo (tpl1); (gdb)=20 foo (c=3Dc@entry=3D0x7fffffffdea0 "/tmp/test.XXX") at small.c:5 5 return 1; (gdb)=20 0x0000000000401165 5 return 1; (gdb)=20 0x000000000040104d in main () at small.c:13 13 int fd2 =3D foo (tpl2); (gdb)=20 ... $ 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 This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.=