public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging
@ 2023-11-17 6:36 iamanonymous.cs at gmail dot com
2023-11-17 6:37 ` [Bug gdb/31073] " iamanonymous.cs at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2023-11-17 6:36 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31073
Bug ID: 31073
Summary: Inconsistent Variable Values: Discrepancy between
Source-Level and Instruction-Level Debugging
Product: gdb
Version: unknown
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: iamanonymous.cs at gmail dot com
Target Milestone: ---
########################
As shows in the following, we can observed that the values of variables x and y
exhibit inconsistencies between source-level debugging and instruction-level
debugging prior to entering the function foo. I'm not sure whether the
inconsistency is a result of incorrect debugging.
########################
###### source-level debugging ######
$ gcc -O2 -g small.c
root@ubuntu:~# gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401060: file small.c, line 30.
(gdb) r
Starting program: /root/a.out
Breakpoint 1, main () at small.c:30
30 x = -5;
(gdb) s
31 y = -10;
(gdb) s
32 foo (&x, &y);
(gdb) info locals
x = 65531
y = 65526
(gdb)
###### instruction-level debugging ######
$ gcc -O2 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401060: file small.c, line 27.
(gdb) r
Starting program: /root/a.out
Breakpoint 1, main () at small.c:27
27 x = -5;
(gdb) si
0x0000000000401064 27 x = -5;
(gdb) info locals
x = 0
y = 0
(gdb) si
0x0000000000401069 28 y = -10;
(gdb) info locals
x = 0
y = 0
(gdb) si
0x000000000040106e 29 foo (&x, &y);
(gdb) info locals
x = 0
y = 0
(gdb)
###### bug-triggering code ######
$ cat small.c
extern void abort (void);
extern void exit (int);
__attribute__ ((noinline)) void
foo(short unsigned int *p1, short unsigned int *p2)
{
short unsigned int x1, x4;
int x2, x3, x5, x6;
unsigned int x7;
x1 = *p1;
x2 = (int) x1;
x3 = x2 * 65536;
x4 = *p2;
x5 = (int) x4;
x6 = x3 + x4;
x7 = (unsigned int) x6;
if (x7 <= 268435455U)
abort ();
exit (0);
}
int
main()
{
short unsigned int x, y;
x = -5;
y = -10;
foo (&x, &y);
}
###### gcc and gdb version ######
$ gcc --version
gcc (GCC) 14.0.0 20231116 (experimental)
Copyright (C) 2023 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) 15.0.50.20231116-git
Copyright (C) 2023 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.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31073] Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging
2023-11-17 6:36 [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging iamanonymous.cs at gmail dot com
@ 2023-11-17 6:37 ` iamanonymous.cs at gmail dot com
2023-11-17 7:42 ` vries at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2023-11-17 6:37 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31073
Anonymous <iamanonymous.cs at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vries at gcc dot gnu.org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31073] Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging
2023-11-17 6:36 [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging iamanonymous.cs at gmail dot com
2023-11-17 6:37 ` [Bug gdb/31073] " iamanonymous.cs at gmail dot com
@ 2023-11-17 7:42 ` vries at gcc dot gnu.org
2023-11-19 11:43 ` iamanonymous.cs at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2023-11-17 7:42 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31073
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |NOTABUG
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Inconsistencies between source-level debugging and instruction-level debugging
is not a bug.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31073] Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging
2023-11-17 6:36 [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging iamanonymous.cs at gmail dot com
2023-11-17 6:37 ` [Bug gdb/31073] " iamanonymous.cs at gmail dot com
2023-11-17 7:42 ` vries at gcc dot gnu.org
@ 2023-11-19 11:43 ` iamanonymous.cs at gmail dot com
2023-11-20 8:55 ` iamanonymous.cs at gmail dot com
2023-11-20 13:56 ` tromey at sourceware dot org
4 siblings, 0 replies; 6+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2023-11-19 11:43 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31073
--- Comment #2 from Anonymous <iamanonymous.cs at gmail dot com> ---
(In reply to Tom de Vries from comment #1)
> Inconsistencies between source-level debugging and instruction-level
> debugging is not a bug.
Thanks Tom. However, I hold the perception that the information presented by
the debugger may possess a slight degree of misleading. It seems that,
according to the debugger, lines 27 and 28 are executed; however, upon
scrutiny, it becomes evident that the assigned values of the x and y variables
do not align with expectations.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31073] Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging
2023-11-17 6:36 [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging iamanonymous.cs at gmail dot com
` (2 preceding siblings ...)
2023-11-19 11:43 ` iamanonymous.cs at gmail dot com
@ 2023-11-20 8:55 ` iamanonymous.cs at gmail dot com
2023-11-20 13:56 ` tromey at sourceware dot org
4 siblings, 0 replies; 6+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2023-11-20 8:55 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31073
--- Comment #3 from Anonymous <iamanonymous.cs at gmail dot com> ---
(In reply to Tom de Vries from comment #1)
> Inconsistencies between source-level debugging and instruction-level
> debugging is not a bug.
Hi Tom,
I still have some concerns regarding the information provided by the debugger,
as it may be somewhat misleading. From the user's perspective, it appears that
lines 27 and 28 have indeed been executed, yet the variable values remain
unchanged. Consequently, I am curious if there are any assurances or guarantees
from the compiler or debugger.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gdb/31073] Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging
2023-11-17 6:36 [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging iamanonymous.cs at gmail dot com
` (3 preceding siblings ...)
2023-11-20 8:55 ` iamanonymous.cs at gmail dot com
@ 2023-11-20 13:56 ` tromey at sourceware dot org
4 siblings, 0 replies; 6+ messages in thread
From: tromey at sourceware dot org @ 2023-11-20 13:56 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31073
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Anonymous from comment #3)
> (In reply to Tom de Vries from comment #1)
> > Inconsistencies between source-level debugging and instruction-level
> > debugging is not a bug.
>
> Hi Tom,
>
> I still have some concerns regarding the information provided by the
> debugger, as it may be somewhat misleading. From the user's perspective, it
> appears that lines 27 and 28 have indeed been executed, yet the variable
> values remain unchanged. Consequently, I am curious if there are any
> assurances or guarantees from the compiler or debugger.
Normally for this sort of thing, the debugger is at the mercy of
the compiler. If this is a concern to you, what you should try
is digging into the location expressions for these variables.
If they do cover all the intermediate PCs, then perhaps it is
a compiler bug.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-20 13:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-17 6:36 [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging iamanonymous.cs at gmail dot com
2023-11-17 6:37 ` [Bug gdb/31073] " iamanonymous.cs at gmail dot com
2023-11-17 7:42 ` vries at gcc dot gnu.org
2023-11-19 11:43 ` iamanonymous.cs at gmail dot com
2023-11-20 8:55 ` iamanonymous.cs at gmail dot com
2023-11-20 13:56 ` 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).