Go to file
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
bfd PPC64_OPT_LOCALENTRY is incompatible with tail calls 2020-09-26 19:03:02 +09:30
binutils asan: readelf buffer overflow and abort 2020-09-25 11:55:01 +09:30
config sync libiberty from gcc 2020-09-08 20:12:57 +09:30
contrib Import mklog.py from gcc repo 2020-09-25 10:24:44 -04:00
cpu bpf: xBPF SDIV, SMOD instructions 2020-09-18 10:04:23 -07:00
elfcpp Re: Sync libiberty and include with GCC for get_DW_UT_name 2020-09-25 11:55:00 +09:30
etc
gas ubsan: opcodes/csky-opc.h:929 shift exponent 536870912 2020-09-26 15:28:22 +09:30
gdb gdb: Fix from_tty argument to gdb.execute in Python. 2020-09-26 11:01:45 -07:00
gdbserver Handle 64bit breakpoints of WOW64 processes as SIGINT 2020-09-24 19:01:22 +02:00
gdbsupport gdb: remove file_handler typedef 2020-09-24 15:19:46 -04:00
gnulib Do not adjust mtime timezone on Windows 2020-09-08 10:41:03 -06:00
gold [GOLD] PPC64_OPT_LOCALENTRY is incompatible with tail calls 2020-09-26 20:34:55 +09:30
gprof
include Sync libiberty and include with GCC for get_DW_UT_name. 2020-09-24 22:55:24 +02:00
intl
ld PPC64_OPT_LOCALENTRY is incompatible with tail calls 2020-09-26 19:03:02 +09:30
libctf libctf, binutils, include, ld: gettextize and improve error handling 2020-08-27 13:15:43 +01:00
libdecnumber
libiberty Sync libiberty and include with GCC for get_DW_UT_name. 2020-09-24 22:55:24 +02:00
opcodes ubsan: opcodes/csky-opc.h:929 shift exponent 536870912 2020-09-26 15:28:22 +09:30
readline
sim sim/m32r: return register sizes after fetch and store 2020-09-18 17:26:07 +01:00
texinfo
zlib
.cvsignore
.gitattributes
.gitignore
ar-lib
ChangeLog
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
setup.com
src-release.sh
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.