#1001322 gdb: Can't seem to turn colour off

Package:
gdb
Source:
gdb
Description:
GNU Debugger
Submitter:
Mouse
Date:
2025-02-21 02:33:01 UTC
Severity:
important
#1001322#5
Date:
2021-12-08 12:39:38 UTC
From:
To:
Dear Maintainer,

I'm not sure I've marked this bug report correctly; it was not clear
what values I should pick for "borderline unusable, but for only a
small fraction of all users".  Please reclassify as appropriate.

gdb borders on unusable when using a terminal type that does not
support X3.64 escape/control sequences, even though $TERM is set
correctly and gdb thus should know this is the case.  For example,
here's what I see, cut-and-pasted directly from the terminal window I
ran gdb in:

[?2004h(gdb) finish
Run till exit from #0  [34m0xb770acf9[m in [33m__kernel_vsyscall[m ()
[34m0xb74b82f7[m in [33m__GI___poll[m ([36mfds[m=0xbffcce50, [36mnfds[m=2, [36mtimeout[m=-1)[m
   [m at [32m../sysdeps/unix/sysv/linux/poll.c[m:29
29	in [32m../sysdeps/unix/sysv/linux/poll.c[m
[?2004h(gdb) finish
Run till exit from #0  [34m0xb74b82f7[m in [33m__GI___poll[m ([36mfds[m=0xbffcce50, [36mnfds[m=2, [36mtimeout[m=-1)[m
   [m at [32m../sysdeps/unix/sysv/linux/poll.c[m:29
[34m0x004b48cb[m in [33msubproc_finish[m ([36msp[m=0x1b04250, [36moutstr[m=0xbffcced8, [36merrstr[m=0xbffcced0)[m
   [m at [32mfind-invite.c[m:1261
1261	    np [31m=[m [01mpoll[m[31m(&[mpfds[31m[[m[35m0[m[31m],[mnpfd[31m,[mINFTIM[31m);[m
Value returned is $1 = 2
[?2004h(gdb) n
126204l     [01;34mif[m [31m([mnp [31m<[m [35m0[m[31m)[m
[?2004h(gdb) p np
$2 = 2l
[?2004h(gdb)

Telling gdb "!printenv TERM" prints "mterm4l"; the actual $TERM setting
is "mterm" - I conjecture that gdb is postprocessing the output of the
command, adding yet more inappropriate X3.64 sequences.

If there is a way to turn this off, it is far too well hidden; I have
found commands for changing the colours (er, sorry, "colors") used to
decorate various pieces of the UI, but nothing at all for completely
turning it all off.  Nor should I need to, when I've already told gdb,
via $TERM, that X3.64 sequences will not work.

					Mouse

#1001322#10
Date:
2025-02-21 02:26:44 UTC
From:
To:
Control: severity -1 wishlist

So, GDB 16.2 (from unstable) supports NO_COLOR (https://no-color.org/),
so that should be an easy way to disable colours on it.

GDB from bookworm and unstable both support "set style enabled off",
which does what you want.

I understand that the request here is that GDB should be aware of TERM
and set things accordingly, but I don't consider that to be an important
bug, so I'm adjusting the severity to wishlist.  Meanwhile, if that's
still something important for you, could you:

1) Verify that GDB from unstable/bookworm still suffers from this
problem.

2) File an upstream issue if that's still the case.

Thanks,