Bug 32736 - gdb seems to print wrong values
Summary: gdb seems to print wrong values
Status: RESOLVED DUPLICATE of bug 28987
Alias: None
Product: gdb
Classification: Unclassified
Component: exp (show other bugs)
Version: 13.1
: P2 normal
Target Milestone: 15.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-22 06:41 UTC by Hu ZW
Modified: 2025-02-22 15:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments
test_case.cpp (558 bytes, text/plain)
2025-02-22 06:42 UTC, Hu ZW
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hu ZW 2025-02-22 06:41:22 UTC
COMMAND:
g++ ./test_case.cpp -O2 -o test_case.o -g
gdb ./test_case
(gdb) b main
(gdb) r
9           ~Container_1() {}
(gdb) p var1767
$1 = 5000
(gdb) stepi
0x000000000040110b      9           ~Container_1() {}
(gdb) p var1767
$2 = 10003

lldb ./test_case
(lldb) b main
(lldb) r
   87       return 0;
-> 88   }
(lldb) p var1767
(long) 10003
(lldb) stepi
(lldb) p var1767
(long) 10003

The printing results of lldb and gdb are inconsistent. I think this should be a problem with gdb, because gdb shows that it is in the destructor and the main function is about to end. The value of variable var1767 should have been updated, not the initial value at the beginning.

g++ --version:
g++ (GCC) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.

gdb --version
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.

Ubuntu 20.04
Comment 1 Hu ZW 2025-02-22 06:42:09 UTC
Created attachment 15971 [details]
test_case.cpp
Comment 2 Hannes Domani 2025-02-22 15:13:19 UTC
Dup of PR28987, which is fixed since gdb-15.1.

*** This bug has been marked as a duplicate of bug 28987 ***