This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 06/16] Reset terminal styles
- From: Tom Tromey <tom at tromey dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Fri, 28 Dec 2018 12:01:48 -0700
- Subject: Re: [PATCH 06/16] Reset terminal styles
- References: <20181128001435.12703-1-tom@tromey.com> <20181128001435.12703-7-tom@tromey.com> <20181224041605.GI5246@adacore.com>
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
>> printf_command (const char *arg, int from_tty)
>> {
>> ui_printf (arg, gdb_stdout);
>> + reset_terminal_style (gdb_stdout);
>> + wrap_here ("");
Joel> Can you explain why you added the "wrap_here"?
gdb's pager has the unusual property that it introduces another layer of
buffering that isn't accessible to gdb_flush. So, to properly flush
stdout and I guess stderr, one must first call wrap_here to flush this
buffer.
You can see this most clearly in exceptions.c:print_flush, which is
where this seems to have been documented.
In this particular case, reset_terminal_style might emit an escape
sequence to the wrap buffer. So, wrap_here is needed to be sure this is
flushed. We can't flush in reset_terminal_style because it might be
used in cases where flushing is inappropriate, for example in the middle
of a command when paging is still desired.
I think a better design would be to require nothing more than gdb_flush.
However, this requires some thought and experimentation, and seemed
orthogonal to my goal in this series.
Tom