Remove unnecessary calls to wrap_here and gdb_flush

Various spots in gdb currently know about the wrap buffer, and so are
careful to call wrap_here to be certain that all output has been
flushed.

Now that the pager is just an ordinary stream, this isn't needed, and
a simple call to gdb_flush is enough.

Similarly, there are places where gdb prints to gdb_stderr, but first
flushes gdb_stdout.  stderr_file already flushes gdb_stdout, so these
aren't needed.
This commit is contained in:
Tom Tromey 2022-01-03 17:12:22 -07:00
parent 6b0c115423
commit ebfc93611b
7 changed files with 3 additions and 21 deletions

View file

@ -846,7 +846,6 @@ echo_command (const char *text, int from_tty)
gdb_stdout->reset_style (); gdb_stdout->reset_style ();
/* Force this output to appear now. */ /* Force this output to appear now. */
gdb_stdout->wrap_here (0);
gdb_flush (gdb_stdout); gdb_flush (gdb_stdout);
} }

View file

@ -46,19 +46,15 @@ print_flush (void)
} }
/* We want all output to appear now, before we print the error. We /* We want all output to appear now, before we print the error. We
have 3 levels of buffering we have to flush (it's possible that have 2 levels of buffering we have to flush (it's possible that
some of these should be changed to flush the lower-level ones some of these should be changed to flush the lower-level ones
too): */ too): */
/* 1. The _filtered buffer. */ /* 1. The stdio buffer. */
if (filtered_printing_initialized ())
gdb_stdout->wrap_here (0);
/* 2. The stdio buffer. */
gdb_flush (gdb_stdout); gdb_flush (gdb_stdout);
gdb_flush (gdb_stderr); gdb_flush (gdb_stderr);
/* 3. The system-level buffer. */ /* 2. The system-level buffer. */
gdb_stdout_serial = serial_fdopen (fileno (ui->outstream)); gdb_stdout_serial = serial_fdopen (fileno (ui->outstream));
if (gdb_stdout_serial) if (gdb_stdout_serial)
{ {

View file

@ -1124,7 +1124,6 @@ captured_main_1 (struct captured_main_args *context)
if (print_version) if (print_version)
{ {
print_gdb_version (gdb_stdout, false); print_gdb_version (gdb_stdout, false);
gdb_stdout->wrap_here (0);
gdb_printf ("\n"); gdb_printf ("\n");
exit (0); exit (0);
} }
@ -1138,7 +1137,6 @@ captured_main_1 (struct captured_main_args *context)
if (print_configuration) if (print_configuration)
{ {
print_gdb_configuration (gdb_stdout); print_gdb_configuration (gdb_stdout);
gdb_stdout->wrap_here (0);
gdb_printf ("\n"); gdb_printf ("\n");
exit (0); exit (0);
} }
@ -1154,7 +1152,6 @@ captured_main_1 (struct captured_main_args *context)
print_gdb_version (gdb_stdout, true); print_gdb_version (gdb_stdout, true);
if (symarg) if (symarg)
gdb_printf (".."); gdb_printf ("..");
gdb_stdout->wrap_here (0);
gdb_printf ("\n"); gdb_printf ("\n");
gdb_flush (gdb_stdout); /* Force to screen during slow gdb_flush (gdb_stdout); /* Force to screen during slow
operations. */ operations. */
@ -1175,7 +1172,6 @@ captured_main_1 (struct captured_main_args *context)
print_gdb_version (gdb_stdout, true); print_gdb_version (gdb_stdout, true);
if (symarg) if (symarg)
gdb_printf (".."); gdb_printf ("..");
gdb_stdout->wrap_here (0);
gdb_printf ("\n"); gdb_printf ("\n");
gdb_flush (gdb_stdout); /* Force to screen during slow gdb_flush (gdb_stdout); /* Force to screen during slow
operations. */ operations. */

View file

@ -1493,7 +1493,6 @@ output_command (const char *exp, int from_tty)
annotate_value_end (); annotate_value_end ();
gdb_stdout->wrap_here (0);
gdb_flush (gdb_stdout); gdb_flush (gdb_stdout);
} }

View file

@ -1426,7 +1426,6 @@ partial_symtab::expand_dependencies (struct objfile *objfile)
gdb_puts ("and "); gdb_puts ("and ");
gdb_stdout->wrap_here (0); gdb_stdout->wrap_here (0);
gdb_printf ("%s...", dependencies[i]->filename); gdb_printf ("%s...", dependencies[i]->filename);
gdb_stdout->wrap_here (0); /* Flush output */
gdb_flush (gdb_stdout); gdb_flush (gdb_stdout);
} }
dependencies[i]->expand_psymtab (objfile); dependencies[i]->expand_psymtab (objfile);

View file

@ -1358,7 +1358,6 @@ command_line_input (const char *prompt_arg, const char *annotation_suffix)
/* Make sure that all output has been output. Some machines may /* Make sure that all output has been output. Some machines may
let you get away with leaving out some of the gdb_flush, but let you get away with leaving out some of the gdb_flush, but
not all. */ not all. */
gdb_stdout->wrap_here (0);
gdb_flush (gdb_stdout); gdb_flush (gdb_stdout);
gdb_flush (gdb_stderr); gdb_flush (gdb_stderr);

View file

@ -146,9 +146,6 @@ vwarning (const char *string, va_list args)
term_state.emplace (); term_state.emplace ();
target_terminal::ours_for_output (); target_terminal::ours_for_output ();
} }
if (filtered_printing_initialized ())
gdb_stdout->wrap_here (0); /* Force out any buffered output. */
gdb_flush (gdb_stdout);
if (warning_pre_print) if (warning_pre_print)
gdb_puts (warning_pre_print, gdb_stderr); gdb_puts (warning_pre_print, gdb_stderr);
gdb_vprintf (gdb_stderr, string, args); gdb_vprintf (gdb_stderr, string, args);
@ -650,9 +647,6 @@ void
print_sys_errmsg (const char *string, int errcode) print_sys_errmsg (const char *string, int errcode)
{ {
const char *err = safe_strerror (errcode); const char *err = safe_strerror (errcode);
/* We want anything which was printed on stdout to come out first, before
this message. */
gdb_flush (gdb_stdout);
gdb_printf (gdb_stderr, "%s: %s.\n", string, err); gdb_printf (gdb_stderr, "%s: %s.\n", string, err);
} }