diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cf65de2e211..3652685986f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2019-11-21 Tom de Vries + + PR gdb/24956 + * cli/cli-script.c (execute_control_command): Only switch to + INTERP_CONSOLE's ui_out when INTERP_MI is active. + 2019-11-19 Tom Tromey * tui/tui-win.c (tui_partial_win_by_name): Move from tui-data.c. diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 316aca0f274..06cdcd6bfe5 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -696,6 +696,9 @@ execute_control_command_1 (struct command_line *cmd, int from_tty) enum command_control_type execute_control_command (struct command_line *cmd, int from_tty) { + if (!current_uiout->is_mi_like_p ()) + return execute_control_command_1 (cmd, from_tty); + /* Make sure we use the console uiout. It's possible that we are executing breakpoint commands while running the MI interpreter. */ interp *console = interp_lookup (current_ui, INTERP_CONSOLE); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f47ed172a64..16027e47498 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-21 Tom de Vries + + PR gdb/24956 + * gdb.base/ui-redirect.exp: Test output of user-defined command. + 2019-11-20 Sergio Durigan Junior * gdb.python/py-progspace.exp: Add missing parentheses on some diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp index efcac14b7cc..932c74af4b5 100644 --- a/gdb/testsuite/gdb.base/ui-redirect.exp +++ b/gdb/testsuite/gdb.base/ui-redirect.exp @@ -57,6 +57,24 @@ set cmds "$cmds\n" set outdir [standard_output_file {}] set cmds_file "$outdir/cmds.txt" +with_test_prefix "userdefined" { + set test "define userdefined" + gdb_test_multiple $test $test { + -re "End with a line saying just \"end\"\\.\r\n>$" { + pass $test + } + } + + set test "bt" + gdb_test_multiple $test $test { + -re "\r\n>$" { + pass $test + } + } + + gdb_test_no_output "end" +} + with_test_prefix "logging" { gdb_test_no_output "set logging file /dev/null" gdb_test "set logging on" \ @@ -64,6 +82,7 @@ with_test_prefix "logging" { gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \ "save breakpoints cmds.txt" cmp_file_string "$cmds_file" "$cmds" "cmds.txt" + gdb_test "userdefined" "#0 main ().*" gdb_test "set logging off" "Done logging to /dev/null\\." gdb_test "help" "List of classes of commands:.*" } @@ -74,6 +93,7 @@ with_test_prefix "redirect" { "Redirecting output to /dev/null.*Copying debug output to /dev/null\\." gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt" cmp_file_string "$cmds_file" "$cmds" "cmds.txt" + gdb_test_no_output "userdefined" gdb_test "set logging off" "Done logging to /dev/null\\." gdb_test "help" "List of classes of commands:.*" } @@ -87,6 +107,7 @@ with_test_prefix "redirect while already logging" { gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \ "save breakpoints cmds.txt" cmp_file_string "$cmds_file" "$cmds" "cmds.txt" + gdb_test "userdefined" "#0 main ().*" gdb_test "set logging off" "Done logging to /dev/null\\." gdb_test "help" "List of classes of commands:.*" gdb_test_no_output "set logging redirect off"