This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 00/16] Add styling to the gdb CLI and TUI
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, Eli Zaretskii <eliz at gnu dot org>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 1 Mar 2019 13:10:35 +0000
- Subject: Re: [PATCH 00/16] Add styling to the gdb CLI and TUI
- References: <20181128001435.12703-1-tom@tromey.com> <83k1kxfzwo.fsf@gnu.org> <8736rja4i8.fsf@tromey.com> <83r2f3caje.fsf@gnu.org> <87o9a61qvz.fsf@tromey.com>
On 11/30/2018 04:17 PM, Tom Tromey wrote:
>>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> Tom> I think it should work, but you'd have to "set style enabled on" first.
>
> Eli> Maybe a TUI invocation should "set style enabled on" on all platforms?
> Eli> Or at least on those that use ncurses?
>
> That would possibly override the user's setting. It's probably better
> to simply implement the console support for Windows. Or, change how the
> disabling is done on Windows -- right now it is done by changing the
> default for this setting, but perhaps it could be done some other way.
>
> Is it possible to ssh in to a Windows machine and then use gdb? That's
> one scenario where you may want to keep the ANSI terminal escape
> sequences in the output. It also may affect how calls to the Windows
> API are handled.
>
> Eli> One problem with this approach is that it needs to fix the escape
> Eli> sequences for the relevant attributes, whereas AFAIU your code
> Eli> simply uses the terminfo that happens to be in effect, is that
> Eli> right?
>
> This patch series uses ANSI escape sequences for the styling; and the
> TUI decodes these and turns them into curses calls.
>
> Tom> Doing it that way can't work due to buffering.
>
> Eli> Not sure I understand. Console output is generally line-buffered, and
> Eli> there's fflush to force writing any buffered output before applying
> Eli> text attributes. Am I missing something?
>
> utils.c implements its own buffering. Previous to this series this was
> only done when "wrap_column > 0", but patch #1 changes this code to
> always buffer.
>
> This is a problem for other approaches because styles are emitted inline
> with other text; and then flushed as a unit.
>
> Tom> Also, this approach would be undesirable anyway, because GNU Source
> Tom> Highlight emits escape codes -- that's why I abandoned my earlier
> Tom> plan of implementing styling as objects in the utils.c buffer.
>
> Eli> What is GNU Source Highlight, and what is its relevance to the issue
> Eli> at hand?
>
> GNU Source Highlight is used to style source text.
>
> https://www.gnu.org/software/src-highlite/
>
> Support for using it is added to gdb in patch #15.
>
> Tom> Instead, I think filtering the escape sequences is really the only
> Tom> way.
>
> Eli> The problem with that is that it hard-codes the SGR sequences concepts
> Eli> right into the design, and the escape sequences are unknown in advance
> Eli> on systems where there's no terminfo.
>
> Only terminals using the ANSI sequences are supported by this series, at
> least for the CLI. The TUI can support more in theory, though I have no
> way to test that.
The Windows console in Windows 10 Anniversary Update supports ANSI escape sequences:
[1] https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
[2] https://blogs.msdn.microsoft.com/commandline/2017/04/11/windows-10-creators-update-whats-new-in-bashwsl-windows-console/
Basically, GDB needs to call SetConsoleMode with
ENABLE_VIRTUAL_TERMINAL_PROCESSING at early startup to enable the feature.
There's an example at the bottom of page [1] above.
I have no idea whether that interacts badly with readline or curses, but
it seems like the ideal solution going forward.
Thanks,
Pedro Alves