public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/29220] New: GDB prints wrong value at -O2
@ 2022-06-02 1:27 yangyibiao at outlook dot com
2022-06-02 16:46 ` [Bug gdb/29220] " tromey at sourceware dot org
2022-06-05 17:53 ` tromey at sourceware dot org
0 siblings, 2 replies; 3+ messages in thread
From: yangyibiao at outlook dot com @ 2022-06-02 1:27 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29220
Bug ID: 29220
Summary: GDB prints wrong value at -O2
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: yangyibiao at outlook dot com
Target Milestone: ---
$ gdb --version
GNU gdb (GDB) 13.0.50.20220531-git
$ gcc --version
gcc (GCC) 13.0.0 20220530 (experimental)
$ cat -n small.c
1 void foo(int *a)
2 {
3 (*a)++;
4 }
5
6 int main ()
7 {
8 int a = 0;
9 foo (&a);
10 return 0;
11 }
$ 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: /root/DeVIL/a.out
Breakpoint 1, main () at small.c:10
10 return 0;
(gdb) info locals
a = 0
(gdb)
### The expected value is "a = 1". However, gdb prints "a = 0". I know that
this function is optimized out. I was wondering that a better solution for this
is that gdb report the value of a is optmized out as well.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/29220] GDB prints wrong value at -O2
2022-06-02 1:27 [Bug gdb/29220] New: GDB prints wrong value at -O2 yangyibiao at outlook dot com
@ 2022-06-02 16:46 ` tromey at sourceware dot org
2022-06-05 17:53 ` tromey at sourceware dot org
1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2022-06-02 16:46 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29220
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
I didn't try your test program, but normally gdb just reports
whatever the compiler tells it here. Most likely this is a compiler
issue, and not a gdb issue. However we'd need to examine the DWARF
to be really sure.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug gdb/29220] GDB prints wrong value at -O2
2022-06-02 1:27 [Bug gdb/29220] New: GDB prints wrong value at -O2 yangyibiao at outlook dot com
2022-06-02 16:46 ` [Bug gdb/29220] " tromey at sourceware dot org
@ 2022-06-05 17:53 ` tromey at sourceware dot org
1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2022-06-05 17:53 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=29220
--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
readelf -wi shows 'a' defined as:
<2><4c>: Abbrev Number: 3 (DW_TAG_variable)
<4d> DW_AT_name : a
<4f> DW_AT_decl_file : 1
<50> DW_AT_decl_line : 8
<51> DW_AT_decl_column : 8
<52> DW_AT_type : <0x5f>
<56> DW_AT_location : 0x10 (location list)
<5a> DW_AT_GNU_locviews: 0xc
However the location lists say:
00000010 v000000000000002 v000000000000003 views at 0000000c for:
0000000000401020 0000000000401020 (DW_OP_lit0; DW_OP_stack_value)
0000001d v000000000000003 v000000000000004 views at 0000000e for:
0000000000401020 0000000000401020 (DW_OP_lit1; DW_OP_stack_value)
So on the one hand, I think gcc is setting the default here
and gdb is printing 0 correctly.
On the other hand, maybe locviews mean that gdb could sometimes show '1'.
I don't know though, and I can't find documentation on this attribute.
Anyway I tend to think this is at worst a missing feature from gdb.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-05 17:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 1:27 [Bug gdb/29220] New: GDB prints wrong value at -O2 yangyibiao at outlook dot com
2022-06-02 16:46 ` [Bug gdb/29220] " tromey at sourceware dot org
2022-06-05 17:53 ` tromey at sourceware dot 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).