From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F0CE73858D33; Fri, 17 Nov 2023 06:36:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0CE73858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700202988; bh=Ob710ZV+pcqsB0V9NXYhzNftN/Jr/cWD/Pi9Rr85x1Y=; h=From:To:Subject:Date:From; b=dLW7IePTXmrZEwXwpDBmB9X3LeCHuoONjW/hOy8pofwl6Qyq8aJ0fvw57Z9r/zJcb LfnanMDwXMTsb2E3JgaHwXYVeWYCe+PNrk+8NzGKurDA0Iv85AKuuTcIgcSQj7OdjO 6hiqQ5X6+sSRi5K0RR4Fyrw5FsOx1h5zsTSNi9B4= From: "iamanonymous.cs at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/31073] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging Date: Fri, 17 Nov 2023 06:36:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: iamanonymous.cs at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31073 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 a= nd 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=20 Breakpoint 1, main () at small.c:30 30 x =3D -5; (gdb) s 31 y =3D -10; (gdb) s 32 foo (&x, &y); (gdb) info locals x =3D 65531 y =3D 65526 (gdb)=20 ###### 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=20 Breakpoint 1, main () at small.c:27 27 x =3D -5; (gdb) si 0x0000000000401064 27 x =3D -5; (gdb) info locals x =3D 0 y =3D 0 (gdb) si 0x0000000000401069 28 y =3D -10; (gdb) info locals x =3D 0 y =3D 0 (gdb) si 0x000000000040106e 29 foo (&x, &y); (gdb) info locals x =3D 0 y =3D 0 (gdb)=20 ###### 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 =3D *p1; x2 =3D (int) x1; x3 =3D x2 * 65536; x4 =3D *p2; x5 =3D (int) x4; x6 =3D x3 + x4; x7 =3D (unsigned int) x6; if (x7 <=3D 268435455U) abort (); exit (0); } int main() { short unsigned int x, y; x =3D -5; y =3D -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 This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. --=20 You are receiving this mail because: You are on the CC list for the bug.=