aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/cli/cli-script.c9
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.python/python.exp13
4 files changed, 32 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 86a841d..b60312c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2020-09-26 Gareth Rees <grees@undo.io> (tiny change)
+
+ 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.
+
2020-09-25 Simon Marchi <simon.marchi@efficios.com>
* infrun.h (infrun_debug_printf): Fix formatting.
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index da4a410..f8ac610 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -392,10 +392,6 @@ execute_cmd_post_hook (struct cmd_list_element *c)
void
execute_control_commands (struct command_line *cmdlines, int from_tty)
{
- /* Set the instream to 0, indicating execution of a
- user-defined function. */
- scoped_restore restore_instream
- = make_scoped_restore (&current_ui->instream, nullptr);
scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
scoped_restore save_nesting
= make_scoped_restore (&command_nest_depth, command_nest_depth + 1);
@@ -464,6 +460,11 @@ execute_user_command (struct cmd_list_element *c, const char *args)
if (user_args_stack.size () > max_user_call_depth)
error (_("Max user call depth exceeded -- command aborted."));
+ /* Set the instream to nullptr, indicating execution of a
+ user-defined function. */
+ scoped_restore restore_instream
+ = make_scoped_restore (&current_ui->instream, nullptr);
+
execute_control_commands (cmdlines, 0);
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2e35f6c..248f039 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2020-09-26 Gareth Rees <grees@undo.io> (tiny change)
+
+ PR python/26586
+ * gdb.python/python.exp: add test cases for the from_tty
+ argument to gdb.execute.
+
2020-09-25 Gary Benson <gbenson@redhat.com>
* gdb.base/infcall-nested-structs.exp.tcl: Add
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index a031ea5..017f33a 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -526,3 +526,16 @@ gdb_test "print \$cvar3" "= void" \
# Test PR 23669, the following would invoke the "commands" command instead of
# "show commands".
gdb_test "python gdb.execute(\"show commands\")" "$decimal print \\\$cvar3.*"
+
+# Test that the from_tty argument to gdb.execute is effective. If
+# False, the user is not prompted for decisions such as restarting the
+# program, and "yes" is assumed. If True, the user is prompted.
+gdb_test "python gdb.execute('starti', from_tty=False)" \
+ "Program stopped.*" \
+ "starti via gdb.execute, not from tty"
+gdb_test_multiple "python gdb.execute('starti', from_tty=True)" \
+ "starti via gdb.execute, from tty" {
+ -re {The program being debugged has been started already\.\r\nStart it from the beginning\? \(y or n\) $} {
+ gdb_test "y" "Starting program:.*" "starti via interactive input"
+ }
+}