public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "iamanonymous.cs at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/31849] New: Issue with Unexpected Behavior in GDB Stepping at Optimization Level O2 and O3 Date: Wed, 05 Jun 2024 15:59:04 +0000 [thread overview] Message-ID: <bug-31849-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=31849 Bug ID: 31849 Summary: Issue with Unexpected Behavior in GDB Stepping at Optimization Level O2 and O3 Product: gdb Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- The gdb and gcc versions are as follows: $ gcc --version gcc (GCC) 15.0.0 20240509 (experimental) $ gdb --version GNU gdb (GDB) 15.0.50.20240512-git $ gcc -O2 -g small.c $ gdb a.out -q Reading symbols from a.out... (gdb) b main Breakpoint 1 at 0x401060: file small.c, line 43. (gdb) r Starting program: /root/a.out Breakpoint 1, main () at small.c:43 43 asm volatile ("" : "+r" (x)); (gdb) s 44 foo (x); (gdb) s foo (x=1) at small.c:19 19 if (x == 0) (gdb) s 25 else if (x == 1) (gdb) s 17 foo (int x) (gdb) s foo (x=1) at small.c:28 28 int *b = __builtin_malloc (3 * sizeof (int)); (gdb) ################################## When using GDB to debug the program compiled at optimization level O2 or O3, the expected behavior is that when the execution is stopped at line #25, stepping forward with the 'step' command should advance the execution to the next line. However, it has been observed that the program unexpectedly stops at line #17 instead. ################################## ################################## Here is the source code that can reproduce this problem. $ cat small.c __attribute__((noinline, noclone)) void bar (int *b) { b[0] = b[1] = b[2] = 1; } __attribute__((noinline, noclone)) int baz (int x) { if (x != 1) __builtin_abort (); } void foo (int x) { if (x == 0) { int *b = __builtin_malloc (3 * sizeof (int)); while (b[0]) ; } else if (x == 1) { int i, j; int *b = __builtin_malloc (3 * sizeof (int)); for (i = 0; i < 2; i++) { bar (b); for (j = 0; j < 3; ++j) baz (b[j]); baz (b[0]); } } } int main () { int x = 1; asm volatile ("" : "+r" (x)); foo (x); return 0; } -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2024-06-05 15:59 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-06-05 15:59 iamanonymous.cs at gmail dot com [this message] 2024-06-05 15:59 ` [Bug gdb/31849] " iamanonymous.cs at gmail dot com 2024-06-05 16:02 ` iamanonymous.cs at gmail dot com 2024-06-05 16:16 ` iamanonymous.cs at gmail dot com 2024-06-06 14:29 ` tromey at sourceware dot org 2024-06-08 4:00 ` iamanonymous.cs at gmail dot com 2024-06-08 4:07 ` 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-31849-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.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).