binutils-gdb/gdb/testsuite/gdb.python
Gareth Rees 8f9929bb97 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.
2020-09-26 11:01:45 -07:00
..
amd64-py-framefilter-invalidarg.S
lib-types.cc
lib-types.exp
py-arch-reg-groups.exp gdb/python: Reuse gdb.RegisterGroup objects where possible 2020-07-21 21:57:08 +01:00
py-arch-reg-names.exp gdb: Add a find method for RegisterDescriptorIterator 2020-07-28 10:27:53 +01:00
py-arch.c
py-arch.exp
py-as-string.c gdb.python/py-as-string.exp C++ify 2020-09-18 00:08:44 +01:00
py-as-string.exp
py-bad-printers.c
py-bad-printers.exp
py-bad-printers.py
py-block.c
py-block.exp
py-breakpoint-create-fail.c
py-breakpoint-create-fail.exp
py-breakpoint-create-fail.py
py-breakpoint.c
py-breakpoint.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-caller-is.c
py-caller-is.exp
py-cmd.c
py-cmd.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-completion.exp
py-completion.py
py-error.exp
py-error.py
py-events-shlib.c
py-events.c
py-events.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-events.py
py-evsignal.exp
py-evthreads.c
py-evthreads.exp
py-explore-cc.exp
py-explore.c
py-explore.cc
py-explore.exp
py-finish-breakpoint2.cc
py-finish-breakpoint2.exp
py-finish-breakpoint2.py
py-finish-breakpoint.c
py-finish-breakpoint.exp
py-finish-breakpoint.py
py-format-string.c
py-format-string.exp Fix TCL error in gdb.python/py-format-string.exp. 2020-06-17 13:43:32 -07:00
py-format-string.py
py-frame-args.c
py-frame-args.exp
py-frame-args.py
py-frame-inline.c
py-frame-inline.exp gdb.python/py-frame-inline.exp and C++ 2020-09-18 00:09:02 +01:00
py-frame.c
py-frame.exp
py-framefilter-gdb.py.in
py-framefilter-invalidarg-gdb.py.in
py-framefilter-invalidarg.exp
py-framefilter-invalidarg.py
py-framefilter-mi.c gdb.python/{py-framefilter-mi,py-framefilter}.c C++ify 2020-09-18 00:07:03 +01:00
py-framefilter-mi.exp
py-framefilter.c gdb.python/{py-framefilter-mi,py-framefilter}.c C++ify 2020-09-18 00:07:03 +01:00
py-framefilter.exp
py-framefilter.py
py-function.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-inferior.c
py-inferior.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-infthread.c
py-infthread.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-lazy-string.c
py-lazy-string.exp
py-linetable.c
py-linetable.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-linetable.S
py-lookup-type.exp
py-mi-events-gdb.py
py-mi-events.c
py-mi-events.exp
py-mi-objfile-gdb.py
py-mi-objfile.c
py-mi-objfile.exp
py-mi-var-info-path-expression.c
py-mi-var-info-path-expression.exp
py-mi-var-info-path-expression.py
py-mi.exp
py-nested-maps.c gdb.python/py-nested-maps.exp C++ify 2020-09-18 00:07:22 +01:00
py-nested-maps.exp
py-nested-maps.py
py-objfile-script-gdb.py
py-objfile-script.c
py-objfile-script.exp
py-objfile.c
py-objfile.exp
py-parameter.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-pp-integral.c Improve -Wunused-value testcase build failures fix 2020-06-23 15:11:27 +01:00
py-pp-integral.exp
py-pp-integral.py
py-pp-maint.c
py-pp-maint.exp
py-pp-maint.py
py-pp-re-notag.c Improve -Wunused-value testcase build failures fix 2020-06-23 15:11:27 +01:00
py-pp-re-notag.exp
py-pp-re-notag.py
py-pp-registration.c
py-pp-registration.exp
py-pp-registration.py
py-prettyprint.c
py-prettyprint.exp
py-prettyprint.py
py-progspace.c
py-progspace.exp
py-prompt.c
py-prompt.exp
py-rbreak-func2.c
py-rbreak.c gdb/testsuite: Explicitly return from main 2020-09-13 22:47:01 +01:00
py-rbreak.exp
py-record-btrace-threads.c
py-record-btrace-threads.exp
py-record-btrace.c
py-record-btrace.exp
py-record-full.c
py-record-full.exp
py-recurse-unwind.c
py-recurse-unwind.exp
py-recurse-unwind.py
py-rvalue-ref-value-cc.cc
py-rvalue-ref-value-cc.exp
py-section-script.c
py-section-script.exp
py-section-script.py
py-shared-sl.c
py-shared.c
py-shared.exp
py-strfns.c
py-strfns.exp
py-symbol-2.c
py-symbol.c
py-symbol.exp
py-symtab.exp
py-sync-interp.c
py-sync-interp.exp
py-template.cc
py-template.exp
py-thrhandle.c
py-thrhandle.exp
py-type.c
py-type.exp
py-typeprint.cc
py-typeprint.exp
py-typeprint.py
py-unwind-inline.c gdb: Python unwinders, inline frames, and tail-call frames 2020-07-06 15:06:07 +01:00
py-unwind-inline.exp gdb: Python unwinders, inline frames, and tail-call frames 2020-07-06 15:06:07 +01:00
py-unwind-inline.py gdb: Python unwinders, inline frames, and tail-call frames 2020-07-06 15:06:07 +01:00
py-unwind-maint.c
py-unwind-maint.exp
py-unwind-maint.py
py-unwind.c
py-unwind.exp
py-unwind.py gdb/python: make more use of RegisterDescriptors 2020-07-28 10:27:54 +01:00
py-value-cc.cc
py-value-cc.exp
py-value.c
py-value.exp Fix test breakages caused by removal of gdb_py_test_multiple. 2020-06-30 18:40:21 +02:00
py-xmethods.cc
py-xmethods.exp
py-xmethods.py
python-1.c
python.c
python.exp gdb: Fix from_tty argument to gdb.execute in Python. 2020-09-26 11:01:45 -07:00
source1
source2.py
tui-window.exp Fix crash when TUI window creation fails 2020-06-16 17:48:38 -06:00
tui-window.py Fix crash when TUI window creation fails 2020-06-16 17:48:38 -06:00