public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "iamanonymous.cs at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/112582] New: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging Date: Fri, 17 Nov 2023 06:35:09 +0000 [thread overview] Message-ID: <bug-112582-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112582 Bug ID: 112582 Summary: Inconsistent Variable Values: Discrepancy between Source-Level and Instruction-Level Debugging Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.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 code optimization. ######################## ###### 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.
next reply other threads:[~2023-11-17 6:35 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-17 6:35 iamanonymous.cs at gmail dot com [this message] 2023-11-17 6:45 ` [Bug debug/112582] " pinskia at gcc dot gnu.org 2023-11-20 8:28 ` iamanonymous.cs at gmail dot com 2023-11-20 8:40 ` rguenth at gcc dot gnu.org 2023-11-20 9:20 ` iamanonymous.cs at gmail dot com 2023-11-20 9:21 ` sjames at gcc dot gnu.org 2023-11-20 9:25 ` iamanonymous.cs at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-112582-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).