public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "anant.sogani at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/30083] New: GDB loop_continue produces warning message Date: Sun, 05 Feb 2023 17:48:50 +0000 [thread overview] Message-ID: <bug-30083-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=30083 Bug ID: 30083 Summary: GDB loop_continue produces warning message Product: gdb Version: 7.11.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: anant.sogani at gmail dot com Target Milestone: --- Created attachment 14654 --> https://sourceware.org/bugzilla/attachment.cgi?id=14654&action=edit Possible fix -------- Overview -------- If the last iteration of a `while` loop encounters a `loop_continue`, then a warning message is emitted, and commands subsequent to the `while` loop do not get executed. ------------------ Steps to Reproduce ------------------ Consider the following user-defined command: # # Print all odd numbers less than a given number. # define print_all_odds_less_than set $max = $arg0 set $i = 0 while $i < ($max - 1) set $i = $i + 1 if ($i % 2) == 0 loop_continue end printf "Odd number %u is less than %u\n", $i, $max end printf "Done\n" end Execute it by providing an argument that triggers the condition mentioned in the Overview. For example: (gdb) print_all_odds_less_than 9 Here, in the last iteration of the `while` loop, the variable `$i` equals 7, gets incremented to 8, then a is-remainder-zero `if` check passes, causing `loop_continue` to be encountered. ------------- Actual Result ------------- Odd number 1 is less than 9 Odd number 3 is less than 9 Odd number 5 is less than 9 Odd number 7 is less than 9 warning: Error executing canned sequence of commands. --------------- Expected Result --------------- Odd number 1 is less than 9 Odd number 3 is less than 9 Odd number 5 is less than 9 Odd number 7 is less than 9 Done ----------- Environment ----------- bash$ gdb --version GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 ... This GDB was configured as "x86_64-linux-gnu". bash$ uname -a Linux 4.15.0-43-generic #46~16.04.1-Ubuntu SMP Fri Dec 7 13:31:08 UTC 2018 x86_64 GNU/Linux bash$ lsb_release -a | grep Description Description: Ubuntu 16.04.4 LTS ---------------- Additional Build ---------------- The issue exists on a relatively recent version of GDB also. bash$ git branch * gdb-13-branch bash$ git describe gdb-13-branchpoint-73-g9a7d273 bash$ gdb --version GNU gdb (GDB) 13.0.91.20230205-git ---------------------- Additional Information ---------------------- In the Stack Overflow question posed for this issue (https://stackoverflow.com/q/75300651/2254621), user Mark Plotnick points out the following: "I think one possible fix is in cli-script.c:execute_control_command_1. There's code that looks at the type of the command that terminated a while loop. Right now, it alters the type if it was a break command. It should do the same if the command was loop_continue" Upon making the suggested change, the issue does get resolved! @@ -605,6 +605,9 @@ execute_control_command_1 (struct command_line *cmd, int from_tty) if (ret == break_control) ret = simple_control; + if (ret == continue_control) + ret = simple_control; + break; } -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2023-02-05 17:48 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-05 17:48 anant.sogani at gmail dot com [this message] 2023-02-05 18:31 ` [Bug gdb/30083] " ssbssa at sourceware dot org
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-30083-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).