public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/26586] from_tty argument to Python's gdb.execute is no longer effective
Date: Sat, 26 Sep 2020 18:02:09 +0000	[thread overview]
Message-ID: <bug-26586-4717-wzciT4lvmf@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-26586-4717@http.sourceware.org/bugzilla/>

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

--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8f9929bb97dc0f0fdf60269ac8c9a7d50746646f

commit 8f9929bb97dc0f0fdf60269ac8c9a7d50746646f
Author: Gareth Rees <grees@undo.io>
Date:   Sat Sep 26 11:01:45 2020 -0700

    gdb: Fix from_tty argument to gdb.execute in Python.

    Prior to commit 56bcdbea2b, the from_tty keyword argument to the
    Python function gdb.execute controlled whether the command took input
    from the terminal. When from_tty=True, "starti" and similar commands
    prompted the user:

        (gdb) python gdb.execute("starti", from_tty=True)
        The program being debugged has been started already.
        Start it from the beginning? (y or n) y
        Starting program: /bin/true

        Program stopped.

    When from_tty=False, these commands did not prompt the user, and "yes"
    was assumed:

        (gdb) python gdb.execute("starti", from_tty=False)

        Program stopped.

    However, after commit 56bcdbea2b, the from_tty keyword argument no
    longer had this effect. For example, as of commit 7ade7fba75:

        (gdb) python gdb.execute("starti", from_tty=True)
        The program being debugged has been started already.
        Start it from the beginning? (y or n) [answered Y; input not from
terminal]
        Starting program: /bin/true

        Program stopped.

    Note the "[answered Y; input not from terminal]" in the output even
    though from_tty=True was requested.

    Looking at commit 56bcdbea2b, it seems that the behaviour of the
    from_tty argument was changed accidentally. The commit message said:

        Let gdb.execute handle multi-line commands

        This changes the Python API so that gdb.execute can now handle
        multi-line commands, like "commands" or "define".

    and there was no mention of changing the effect of the from_tty
    argument. It looks as though the code for setting the instream to
    nullptr was accidentally moved from execute_user_command() to
    execute_control_commands() along with the other scoped restores.

    Accordingly, the simplest way to fix this is to partially reverse
    commit 56bcdbea2b by moving the code for setting the instream to
    nullptr back to execute_user_command() where it was to begin with.

    Additionally, add a test case to reduce the risk of similar breakage
    in future.

    gdb/ChangeLog:

            PR python/26586
            * cli/cli-script.c (execute_control_commands): don't set
            instream to nullptr here as this breaks the from_tty argument
            to gdb.execute in Python.
            (execute_user_command): set instream to nullptr here instead.

    gdb/testsuite/ChangeLog:

            PR python/26586
            * gdb.python/python.exp: add test cases for the from_tty
            argument to gdb.execute.

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

  parent reply	other threads:[~2020-09-26 18:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 15:23 [Bug python/26586] New: " grees at undo dot io
2020-09-08 16:33 ` [Bug python/26586] " grees at undo dot io
2020-09-08 17:05 ` brobecker at gnat dot com
2020-09-10 17:35 ` simark at simark dot ca
2020-09-10 17:35 ` simark at simark dot ca
2020-09-10 17:36 ` simark at simark dot ca
2020-09-19 15:39 ` cbiesinger at google dot com
2020-09-22 10:24 ` grees at undo dot io
2020-09-26 18:02 ` cvs-commit at gcc dot gnu.org [this message]
2020-09-28 20:16 ` cvs-commit at gcc dot gnu.org
2020-10-08 17:42 ` simark at simark dot ca

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-26586-4717-wzciT4lvmf@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: link
Be 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).