public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/95432] New: inconsistent behaviors at -O2
@ 2020-05-30 3:02 yangyibiao at hust dot edu.cn
2020-05-30 3:03 ` [Bug debug/95432] " yangyibiao at hust dot edu.cn
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: yangyibiao at hust dot edu.cn @ 2020-05-30 3:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95432
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))
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/95432] inconsistent behaviors at -O2
2020-05-30 3:02 [Bug debug/95432] New: inconsistent behaviors at -O2 yangyibiao at hust dot edu.cn
@ 2020-05-30 3:03 ` yangyibiao at hust dot edu.cn
2021-03-07 7:25 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: yangyibiao at hust dot edu.cn @ 2020-05-30 3:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95432
Yibiao Yang <yangyibiao at hust dot edu.cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |yangyibiao at hust dot edu.cn
--- Comment #1 from Yibiao Yang <yangyibiao at hust dot edu.cn> ---
Created attachment 48639
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48639&action=edit
a.out
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/95432] inconsistent behaviors at -O2
2020-05-30 3:02 [Bug debug/95432] New: inconsistent behaviors at -O2 yangyibiao at hust dot edu.cn
2020-05-30 3:03 ` [Bug debug/95432] " yangyibiao at hust dot edu.cn
@ 2021-03-07 7:25 ` pinskia at gcc dot gnu.org
2021-03-07 14:42 ` vries at gcc dot gnu.org
2021-03-07 20:27 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-03-07 7:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95432
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Assembly:
.loc 1 12 3 is_stmt 1 view .LVU12
.loc 1 10 8 is_stmt 0 view .LVU13
movaps %xmm0, (%rsp)
.loc 1 11 8 view .LVU14
movaps %xmm0, 32(%rsp)
.loc 1 12 13 view .LVU15
call foo
.LVL1:
.loc 1 13 13 view .LVU16
leaq 32(%rsp), %rdi
.loc 1 12 13 view .LVU17
movl %eax, %edx
.LVL2:
.loc 1 13 3 is_stmt 1 view .LVU18
.loc 1 13 13 is_stmt 0 view .LVU19
call foo
.LVL3:
.loc 1 14 3 is_stmt 1 view .LVU20
.loc 1 14 6 is_stmt 0 view .LVU21
Looks correct to me, both call foo have the correct line on them. I think this
is another GDB issue, most likely how dwarf3 and is_stmt is handled just like
95431 even.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/95432] inconsistent behaviors at -O2
2020-05-30 3:02 [Bug debug/95432] New: inconsistent behaviors at -O2 yangyibiao at hust dot edu.cn
2020-05-30 3:03 ` [Bug debug/95432] " yangyibiao at hust dot edu.cn
2021-03-07 7:25 ` pinskia at gcc dot gnu.org
@ 2021-03-07 14:42 ` vries at gcc dot gnu.org
2021-03-07 20:27 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2021-03-07 14:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95432
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Assembly:
> .loc 1 12 3 is_stmt 1 view .LVU12
> .loc 1 10 8 is_stmt 0 view .LVU13
> movaps %xmm0, (%rsp)
> .loc 1 11 8 view .LVU14
> movaps %xmm0, 32(%rsp)
> .loc 1 12 13 view .LVU15
> call foo
> .LVL1:
> .loc 1 13 13 view .LVU16
> leaq 32(%rsp), %rdi
> .loc 1 12 13 view .LVU17
> movl %eax, %edx
> .LVL2:
> .loc 1 13 3 is_stmt 1 view .LVU18
> .loc 1 13 13 is_stmt 0 view .LVU19
> call foo
> .LVL3:
> .loc 1 14 3 is_stmt 1 view .LVU20
> .loc 1 14 6 is_stmt 0 view .LVU21
>
> Looks correct to me, both call foo have the correct line on them. I think
> this is another GDB issue, most likely how dwarf3 and is_stmt is handled
> just like 95431 even.
Ack, this is gdb PR breakpoints/26063 (
https://sourceware.org/bugzilla/show_bug.cgi?id=26063 ).
Fixed by
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ebde6f2ddc987e7e2d5a218ee8cf0126ec189424
.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/95432] inconsistent behaviors at -O2
2020-05-30 3:02 [Bug debug/95432] New: inconsistent behaviors at -O2 yangyibiao at hust dot edu.cn
` (2 preceding siblings ...)
2021-03-07 14:42 ` vries at gcc dot gnu.org
@ 2021-03-07 20:27 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-03-07 20:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95432
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |MOVED
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Closing as moved as it was reported and fixed in gdb already.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-03-07 20:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30 3:02 [Bug debug/95432] New: inconsistent behaviors at -O2 yangyibiao at hust dot edu.cn
2020-05-30 3:03 ` [Bug debug/95432] " yangyibiao at hust dot edu.cn
2021-03-07 7:25 ` pinskia at gcc dot gnu.org
2021-03-07 14:42 ` vries at gcc dot gnu.org
2021-03-07 20:27 ` pinskia 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).