public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30083] New: GDB loop_continue produces warning message
@ 2023-02-05 17:48 anant.sogani at gmail dot com
  2023-02-05 18:31 ` [Bug gdb/30083] " ssbssa at sourceware dot org
  0 siblings, 1 reply; 2+ messages in thread
From: anant.sogani at gmail dot com @ 2023-02-05 17:48 UTC (permalink / raw)
  To: gdb-prs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gdb/30083] GDB loop_continue produces warning message
  2023-02-05 17:48 [Bug gdb/30083] New: GDB loop_continue produces warning message anant.sogani at gmail dot com
@ 2023-02-05 18:31 ` ssbssa at sourceware dot org
  0 siblings, 0 replies; 2+ messages in thread
From: ssbssa at sourceware dot org @ 2023-02-05 18:31 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30083

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-05 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-05 17:48 [Bug gdb/30083] New: GDB loop_continue produces warning message anant.sogani at gmail dot com
2023-02-05 18:31 ` [Bug gdb/30083] " ssbssa 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).