public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug tui/14126] New: Color escape sequences don't work in tui mode
@ 2012-05-21 3:58 jan at majutsushi dot net
2015-07-08 15:45 ` [Bug tui/14126] " dilyan.palauzov at aegee dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: jan at majutsushi dot net @ 2012-05-21 3:58 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14126
Bug #: 14126
Summary: Color escape sequences don't work in tui mode
Product: gdb
Version: unknown
Status: NEW
Severity: normal
Priority: P2
Component: tui
AssignedTo: unassigned@sourceware.org
ReportedBy: jan@majutsushi.net
Classification: Unclassified
If TUI mode is enabled then coloring the prompt or output using escape
sequences doesn't work, the sequences are instead shown as-is.
Example:
In normal mode, "echo \033[32mFOO\033[0m\n" will print "FOO" in green. However,
if the TUI is enabled, it will print "^[[32mFOO^[[0m" instead. This makes
trying to make the output more readable rather difficult.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
@ 2015-07-08 15:45 ` dilyan.palauzov at aegee dot org
2025-06-08 19:32 ` nav at bloom dot oscillate.io
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: dilyan.palauzov at aegee dot org @ 2015-07-08 15:45 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
dilyan.palauzov at aegee dot org <dilyan.palauzov at aegee dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dilyan.palauzov at aegee dot org
--- Comment #1 from dilyan.palauzov at aegee dot org <dilyan.palauzov at aegee dot org> ---
\w is expanded to the working directory, the problem with TUI and
extended-prompt are (only) the escape sequences. The proposed patch below just
discards all non-printing characters, between \[ and \], in TUI mode.
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index a2df254..cab10d2 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -5137,7 +5137,8 @@ Substitute the current working directory.
Begin a sequence of non-printing characters. These sequences are
typically used with the ESC character, and are not counted in the string
length. Example: ``\[\e[0;34m\](gdb)\[\e[0m\]'' will return a
-blue-colored ``(gdb)'' prompt where the length is five.
+blue-colored ``(gdb)'' prompt where the length is five. In TUI mode
+these characters are discarded.
@item \]
End a sequence of non-printing characters.
@end table
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 97906ce..b77866a 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -232,6 +232,22 @@ tui_redisplay_readline (void)
height = 1;
for (in = 0; prompt && prompt[in]; in++)
{
+ /* Drop characters from extended-prompt between \[ == \001 and \] = \002
+ The point is, that waddch prints ^ instead of control characters and
+ in turn the latter are not interpreted by the terminal. TUI prints
+ then ^ and this is ugly.
+
+ It seems there is no way to send escape characters to the terminal
+ under curses, at least not with fputc (c , stdout);
+
+ Skiping escape sequences, which are not within \[ and \] is hard, as
+ only the terminal has knowledge where the sequence ends and where the
+ actual input starts. */
+ if (prompt[in] == '\001')
+ {
+ do { in++; } while (prompt[in] != '\002' && prompt[in] != '\0');
+ continue;
+ }
waddch (w, prompt[in]);
getyx (w, line, col);
if (col <= prev_col)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
2015-07-08 15:45 ` [Bug tui/14126] " dilyan.palauzov at aegee dot org
@ 2025-06-08 19:32 ` nav at bloom dot oscillate.io
2025-06-11 20:08 ` tromey at sourceware dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: nav at bloom dot oscillate.io @ 2025-06-08 19:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
Nav <nav at bloom dot oscillate.io> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nav at bloom dot oscillate.io
--- Comment #6 from Nav <nav at bloom dot oscillate.io> ---
Apologies for posting on an old thread...
It seems this issue still occurs when GDB outputs responses for qRcmd commands.
My GDB server uses color escape sequences when returning responses to some
qRcmd commands, which works fine when TUI mode is disabled. But when TUI mode
is enabled, the escape sequences are ignored and printed in the output:
(gdb) mon lr porta
`[94mport[0m`, `[94mcfglr[0m`....
The proper output should be:
(gdb) mon lr porta
`port`, `cfglr`....
Where the foreground color of "port" and "cfglr" is set to "blue"
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
2015-07-08 15:45 ` [Bug tui/14126] " dilyan.palauzov at aegee dot org
2025-06-08 19:32 ` nav at bloom dot oscillate.io
@ 2025-06-11 20:08 ` tromey at sourceware dot org
2025-06-11 20:32 ` tromey at sourceware dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2025-06-11 20:08 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
Blocks| |32284
--- Comment #7 from Tom Tromey <tromey at sourceware dot org> ---
Reopening.
Referenced Bugs:
https://sourceware.org/bugzilla/show_bug.cgi?id=32284
[Bug 32284] [meta] CLI Styling
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
` (2 preceding siblings ...)
2025-06-11 20:08 ` tromey at sourceware dot org
@ 2025-06-11 20:32 ` tromey at sourceware dot org
2025-06-11 22:09 ` nav at bloom dot oscillate.io
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2025-06-11 20:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
--- Comment #8 from Tom Tromey <tromey at sourceware dot org> ---
The issue might be that rcmd and remote_console_output work
one character at a time.
Ideally this wouldn't affect the TUI but I suspect it's maybe
a bit dumb about this.
However -- which gdb are you using?
I hacked gdbserver to colorize the "monitor help" output
and tried with gdb trunk. This works... which I think
should be expected now that the TUI I/O stuff was removed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
` (3 preceding siblings ...)
2025-06-11 20:32 ` tromey at sourceware dot org
@ 2025-06-11 22:09 ` nav at bloom dot oscillate.io
2025-06-13 18:07 ` tromey at sourceware dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: nav at bloom dot oscillate.io @ 2025-06-11 22:09 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
--- Comment #9 from Nav <nav at bloom dot oscillate.io> ---
(In reply to Tom Tromey from comment #8)
> The issue might be that rcmd and remote_console_output work
> one character at a time.
>
> Ideally this wouldn't affect the TUI but I suspect it's maybe
> a bit dumb about this.
>
> However -- which gdb are you using?
> I hacked gdbserver to colorize the "monitor help" output
> and tried with gdb trunk. This works... which I think
> should be expected now that the TUI I/O stuff was removed.
Hey, so I was using GDB 13.1, but I just built and tried 16.3, and the same
issue occurs. Works fine with TUI mode disabled, but not when it's enabled.
In case it helps, here's the raw response packet that my server sends to GDB,
in response to a qRcmd command:
$O601b5b39346d706f7274621b5b306d602c20601b5b39346d646472621b5b306d602c202244445242222c20307830303030303032342c20382d626974207c201b5b33336d307830301b5b306d20281b5b33336d301b5b306d2c201b5b33336d306230303030303030301b5b306d290a#db
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
` (4 preceding siblings ...)
2025-06-11 22:09 ` nav at bloom dot oscillate.io
@ 2025-06-13 18:07 ` tromey at sourceware dot org
2025-06-14 16:15 ` tromey at sourceware dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2025-06-13 18:07 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
--- Comment #10 from Tom Tromey <tromey at sourceware dot org> ---
Sorry about this -- I forgot to enter TUI mode when doing
my tests :(
I tried again and I can reproduce the problem.
It's what I thought: the TUI I/O layer is too naive about
looking for terminal escape sequences.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
` (5 preceding siblings ...)
2025-06-13 18:07 ` tromey at sourceware dot org
@ 2025-06-14 16:15 ` tromey at sourceware dot org
2025-07-01 22:00 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2025-06-14 16:15 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
--- Comment #11 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2025-June/218702.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
` (6 preceding siblings ...)
2025-06-14 16:15 ` tromey at sourceware dot org
@ 2025-07-01 22:00 ` cvs-commit at gcc dot gnu.org
2025-07-01 22:01 ` tromey at sourceware dot org
2025-07-01 22:20 ` nav at bloom dot oscillate.io
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2025-07-01 22:00 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
--- Comment #12 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7b18593a9ef94694e2a16ac25133aa8c19dc6a87
commit 7b18593a9ef94694e2a16ac25133aa8c19dc6a87
Author: Tom Tromey <tom@tromey.com>
Date: Fri Jun 13 12:54:16 2025 -0600
Fix handling of terminal escape sequences in TUI
A user noticed that if the remote sends terminal escape sequences from
the "monitor" command, then these will not be correctly displayed when
in TUI mode.
I tracked this down to remote.c emitting one character at a time --
something the TUI output functions did not handle correctly.
I decided in the end to fix in this in the ui-file layer, because the
same bug seems to affect logging and, as is evidenced by the test case
in this patch, Python output in TUI mode.
The idea is simple: buffer escape sequences until they are either
complete or cannot possibly be recognized by gdb.
Regression tested on x86-64 Fedora 40.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14126
Approved-By: Andrew Burgess <aburgess@redhat.com>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
` (7 preceding siblings ...)
2025-07-01 22:00 ` cvs-commit at gcc dot gnu.org
@ 2025-07-01 22:01 ` tromey at sourceware dot org
2025-07-01 22:20 ` nav at bloom dot oscillate.io
9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2025-07-01 22:01 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|REOPENED |RESOLVED
--- Comment #13 from Tom Tromey <tromey at sourceware dot org> ---
Fixed again for 17.1.
I'm not sure if I should update the target milestone or not so
I've left it.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tui/14126] Color escape sequences don't work in tui mode
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
` (8 preceding siblings ...)
2025-07-01 22:01 ` tromey at sourceware dot org
@ 2025-07-01 22:20 ` nav at bloom dot oscillate.io
9 siblings, 0 replies; 11+ messages in thread
From: nav at bloom dot oscillate.io @ 2025-07-01 22:20 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=14126
--- Comment #14 from Nav <nav at bloom dot oscillate.io> ---
Created attachment 16156
--> https://sourceware.org/bugzilla/attachment.cgi?id=16156&action=edit
Screenshot of color escape sequences working in new GDB build
(In reply to Tom Tromey from comment #13)
> Fixed again for 17.1.
> I'm not sure if I should update the target milestone or not so
> I've left it.
Have just built from the master branch and can confirm it's now working as
expected (see attached screenshot).
Thank you for sorting that so quickly!
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-07-01 22:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-21 3:58 [Bug tui/14126] New: Color escape sequences don't work in tui mode jan at majutsushi dot net
2015-07-08 15:45 ` [Bug tui/14126] " dilyan.palauzov at aegee dot org
2025-06-08 19:32 ` nav at bloom dot oscillate.io
2025-06-11 20:08 ` tromey at sourceware dot org
2025-06-11 20:32 ` tromey at sourceware dot org
2025-06-11 22:09 ` nav at bloom dot oscillate.io
2025-06-13 18:07 ` tromey at sourceware dot org
2025-06-14 16:15 ` tromey at sourceware dot org
2025-07-01 22:00 ` cvs-commit at gcc dot gnu.org
2025-07-01 22:01 ` tromey at sourceware dot org
2025-07-01 22:20 ` nav at bloom dot oscillate.io
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).