public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/26061] New: Wrong debug info for argc at -O2
@ 2020-05-29 12:30 yangyibiao at hust dot edu.cn
2020-05-29 15:47 ` [Bug symtab/26061] " yangyibiao at hust dot edu.cn
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: yangyibiao at hust dot edu.cn @ 2020-05-29 12:30 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
Bug ID: 26061
Summary: Wrong debug info for argc 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: ---
Created attachment 12577
--> https://sourceware.org/bugzilla/attachment.cgi?id=12577&action=edit
a.out
$ 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.
yibiao:~/Debugger$ 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.
Consider test-case:
...
$ cat small.c
#include <stdio.h>
int main(int argc, char **argv) {
char buf[6];
char c[] = "abc";
sprintf(buf, (char *)c, 1);
return 0;
}
...
$ gcc -O2 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401040: file small.c, line 5.
(gdb) r
Starting program: /home/yibiao/Debugger/a.out
Breakpoint 1, main (argc=1, argv=0x7fffffffdff8) at small.c:5
5 char c[] = "abc";
(gdb) info args argc
argc = 1
(gdb) step
6 sprintf(buf, (char *)c, 1);
(gdb) info args argc
argc = -8454
(gdb)
/**************************************
We can find that at line 5, the value of argc is 1. When stepping to line 6,
the value of argc is changed to -8454. When stepping with stepi, the value of
argc is correct.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
@ 2020-05-29 15:47 ` yangyibiao at hust dot edu.cn
2020-05-30 17:03 ` tankut.baris.aktemur at intel dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: yangyibiao at hust dot edu.cn @ 2020-05-29 15:47 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
Yibiao Yang <yangyibiao at hust dot edu.cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tankut.baris.aktemur@intel.
| |com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
2020-05-29 15:47 ` [Bug symtab/26061] " yangyibiao at hust dot edu.cn
@ 2020-05-30 17:03 ` tankut.baris.aktemur at intel dot com
2020-05-31 0:39 ` yangyibiao at hust dot edu.cn
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tankut.baris.aktemur at intel dot com @ 2020-05-30 17:03 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
--- Comment #1 from Baris Aktemur <tankut.baris.aktemur at intel dot com> ---
I used gcc-10 ((Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0) and gdb
(10.0.50.20200525-git), but the scenario did not reproduce.
My initial guess is that it's related to the debug info. I'd suggest printing
the value of argc in hex (e.g. `(gdb) p/x -8454` gives 0xffffdefa) and also
printing the address of local variables, in particular `buf`. Also, doing stepi
multiple times and checking the values each time an instruction is stepped may
help narrow down the problem.
Judging from the title, I conclude you also think that the problem is related
to the debug info. In that case, I believe it would fit better to report this
to gcc, rather than gdb.
PS: Just out of curiosity, I wonder why you CC'ed me to this bug report.
Thanks.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
2020-05-29 15:47 ` [Bug symtab/26061] " yangyibiao at hust dot edu.cn
2020-05-30 17:03 ` tankut.baris.aktemur at intel dot com
@ 2020-05-31 0:39 ` yangyibiao at hust dot edu.cn
2020-12-29 6:38 ` yangyibiao at outlook dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: yangyibiao at hust dot edu.cn @ 2020-05-31 0:39 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
--- Comment #2 from Yibiao Yang <yangyibiao at hust dot edu.cn> ---
(In reply to Baris Aktemur from comment #1)
> I used gcc-10 ((Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0) and gdb
> (10.0.50.20200525-git), but the scenario did not reproduce.
>
> My initial guess is that it's related to the debug info. I'd suggest
> printing the value of argc in hex (e.g. `(gdb) p/x -8454` gives 0xffffdefa)
> and also printing the address of local variables, in particular `buf`. Also,
> doing stepi multiple times and checking the values each time an instruction
> is stepped may help narrow down the problem.
>
> Judging from the title, I conclude you also think that the problem is
> related to the debug info. In that case, I believe it would fit better to
> report this to gcc, rather than gdb.
>
> PS: Just out of curiosity, I wonder why you CC'ed me to this bug report.
> Thanks.
Thank you very much for your suggestion.
I CC'ed it to you as I found you are mentioned in a prior bug relate to this
one.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
` (2 preceding siblings ...)
2020-05-31 0:39 ` yangyibiao at hust dot edu.cn
@ 2020-12-29 6:38 ` yangyibiao at outlook dot com
2022-05-29 2:24 ` yangyibiao at outlook dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: yangyibiao at outlook dot com @ 2020-12-29 6:38 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
Yibiao Yang <yangyibiao at outlook dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
CC| |yangyibiao at outlook dot com
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Yibiao Yang <yangyibiao at outlook dot com> ---
This problem is no longer exists in the latest version of gdb.
$ gdb --version
GNU gdb (GDB) 11.0.50.20201224-git
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
` (3 preceding siblings ...)
2020-12-29 6:38 ` yangyibiao at outlook dot com
@ 2022-05-29 2:24 ` yangyibiao at outlook dot com
2022-11-08 3:34 ` yangyibiao at nju dot edu.cn
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: yangyibiao at outlook dot com @ 2022-05-29 2:24 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
Yibiao Yang <yangyibiao at outlook dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |---
Status|RESOLVED |UNCONFIRMED
--- Comment #4 from Yibiao Yang <yangyibiao at outlook dot com> ---
Not sure whether this bug is fixed in the latest version.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
` (4 preceding siblings ...)
2022-05-29 2:24 ` yangyibiao at outlook dot com
@ 2022-11-08 3:34 ` yangyibiao at nju dot edu.cn
2022-11-08 8:13 ` sam at gentoo dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: yangyibiao at nju dot edu.cn @ 2022-11-08 3:34 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
Yibiao Yang <yangyibiao at nju dot edu.cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
` (5 preceding siblings ...)
2022-11-08 3:34 ` yangyibiao at nju dot edu.cn
@ 2022-11-08 8:13 ` sam at gentoo dot org
2022-11-09 2:28 ` tromey at sourceware dot org
2022-11-09 2:42 ` yangyibiao at nju dot edu.cn
8 siblings, 0 replies; 10+ messages in thread
From: sam at gentoo dot org @ 2022-11-08 8:13 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sam at gentoo dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
` (6 preceding siblings ...)
2022-11-08 8:13 ` sam at gentoo dot org
@ 2022-11-09 2:28 ` tromey at sourceware dot org
2022-11-09 2:42 ` yangyibiao at nju dot edu.cn
8 siblings, 0 replies; 10+ messages in thread
From: tromey at sourceware dot org @ 2022-11-09 2:28 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |NOTABUG
--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
I can reproduce this with the attached a.out and with git master gdb.
Here's an informative transcript:
(gdb) info addr argc
Symbol "argc" is multi-location:
Range 0x401040-0x401061: a variable in $rdi
Range 0x401061-0x401069: a complex DWARF expression:
0: DW_OP_GNU_entry_value
2: DW_OP_reg5 [$rdi]
3: DW_OP_stack_value
.
(gdb) p $pc
$4 = (void (*)()) 0x401040 <main>
(gdb) p argc
$5 = 1
(gdb) step
6 in small.c
(gdb) p $pc
$6 = (void (*)()) 0x40105d <main+29>
(gdb) p argc
$7 = -7062
(gdb) p $rdi
$8 = 140737488348266
(gdb) p/x $rdi
$9 = 0x7fffffffe46a
(gdb) p/x argc
$10 = 0xffffe46a
Here you can see that the debuginfo claims that 'argc' is
held in '$rdi' for this PC range. However, this isn't true --
rdi changes to some other value even though PC is still in
that range.
Based on this I think this is a compiler bug and not a gdb bug.
There's nothing gdb can do to correct this kind of problem.
I'm going to close this.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug symtab/26061] Wrong debug info for argc at -O2
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
` (7 preceding siblings ...)
2022-11-09 2:28 ` tromey at sourceware dot org
@ 2022-11-09 2:42 ` yangyibiao at nju dot edu.cn
8 siblings, 0 replies; 10+ messages in thread
From: yangyibiao at nju dot edu.cn @ 2022-11-09 2:42 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26061
--- Comment #6 from Yibiao Yang <yangyibiao at nju dot edu.cn> ---
Thanks for the detailed explaination, Tom.
I update gcc to the latest trunk and found this problem have been fixed in the
gcc side.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-11-09 2:42 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 12:30 [Bug symtab/26061] New: Wrong debug info for argc at -O2 yangyibiao at hust dot edu.cn
2020-05-29 15:47 ` [Bug symtab/26061] " yangyibiao at hust dot edu.cn
2020-05-30 17:03 ` tankut.baris.aktemur at intel dot com
2020-05-31 0:39 ` yangyibiao at hust dot edu.cn
2020-12-29 6:38 ` yangyibiao at outlook dot com
2022-05-29 2:24 ` yangyibiao at outlook dot com
2022-11-08 3:34 ` yangyibiao at nju dot edu.cn
2022-11-08 8:13 ` sam at gentoo dot org
2022-11-09 2:28 ` tromey at sourceware dot org
2022-11-09 2:42 ` yangyibiao at nju dot edu.cn
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).