The patch to fix paging with redirection caused a regression in the
internal AdaCore test suite. The problem occurs when running an MI
command from the CLI using interpreter-exec, when paging is enabled.
This scenario isn't covered by the current test suite, so this patch
includes a new test.
The problem is that, in this situation, MI does:
fputs_unfiltered (strcmp (context->command, "target-select") == 0
? "^connected" : "^done", mi->raw_stdout);
Here raw_stdout is a stdio_file wrapping stdout, so the pager thinks
that it is ok to buffer the output. However, in this setup, it isn't
ok, and flushing the wrap buffer doesn't really work properly. Also,
MI next does:
mi_out_put (uiout, mi->raw_stdout);
... but this uses ui_file::write, which also doesn't flush the wrap
buffer.
I think all this will be fixed by the pager rewrite series I'm working
on. However, in the meantime, adding the old gdb_stdout check back to
the pager fixes this problem.
Regression tested on x86-64 Fedora 34.
fail "printf without paging"
}
gdb_test "set logging enabled off" "Done logging to .*"
+
+set cmd "interpreter-exec mi2 \"-data-evaluate-expression 23\""
+gdb_test_multiple $cmd $cmd {
+ -re ".done.value=.23\[^\n\]+\r\n$gdb_prompt " {
+ pass "$cmd"
+ gdb_expect 1 {
+ -re "\r\n$gdb_prompt $" { }
+ }
+ }
+}
/* Don't do any filtering if it is disabled. */
if (!stream->can_page ()
+ || stream != gdb_stdout
|| !pagination_enabled
|| pagination_disabled_for_command
|| batch_flag