Bug 1688372

Summary: New gdb terminal colors are unreadable on GNOME Terminal "dark" theme
Product: [Fedora] Fedora Reporter: Stephen Gallagher <sgallagh>
Component: gdbAssignee: Sergio Durigan Junior <sergiodj>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 30CC: adrian, jan.kratochvil, keiths, kevinb, otaylor, pmuldoon, sergiodj
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-8.2.90.20190320-21.fc30 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-31 00:03:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Screenshot of the problem none

Description Stephen Gallagher 2019-03-13 16:03:32 UTC
Created attachment 1543697 [details]
Screenshot of the problem

Description of problem:
GDB in Fedora 30 has added support for colorized output. This is great, except that some of the selected colors are nearly impossible to view with a dark terminal theme.

Version-Release number of selected component (if applicable):
gdb-8.2.90.20190310-20.fc30.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. Set GNOME Terminal to the "dark" theme variant in Preferences->General
2. Set the "Text and Background Color" to "Use colors from system theme".
3. Start gdb to debug a C program
4. Set a breakpoint on a function
5. Run the debugger
6. When the code breaks, type 'list'

Actual results:
The colorization for any function name is a dark-grey color which is nearly impossible to see against a dark or black background.


Expected results:
The colors should be visible against a dark background.

Additional info:

Comment 1 Sergio Durigan Junior 2019-03-13 20:54:08 UTC
Thanks for the report.

IIUC, you haven't tried changing the output style of the various "objects", right?  You can look at the different ways to change the output here:

  https://sourceware.org/gdb/current/onlinedocs/gdb/Output-Styling.html#Output-Styling

I'm kind of reticent to report this upstream, because GDB offers a way to either disable the feature or to customize it according to the user's needs.  But let me know whether customization doesn't work for your case.

Thanks.

Comment 2 Stephen Gallagher 2019-03-13 20:57:14 UTC
I have made no modifications at all to the output style. I am using the defaults as shipped in Fedora 30 right now. I have no .gdbinit config file either.

My main concern was that the default configuration does not work with the "dark" theme of GNOME Terminal (or, in fact, any of the pre-defined color schemes in that program whose names end in "dark" or "on black").

I can probably customize my own setup, but this seems non-optimal for the general case.

Comment 3 Sergio Durigan Junior 2019-03-13 21:17:03 UTC
I've just talked to upstream author of the feature, who shares my opinion here.  I understand the frustration, but in my experience it is sometimes necessary to adjust colour schemes here and there when you're dealing with styled applications.  The fact that GDB (and GNOME terminal, for that matter) provides ways to customize and disable the feature makes me see this as NOTABUG.  However, this is a new feature and there's a conversation going on upstream exactly about this topic, so changes may be implemented which minimize or solve the problem for your case.

Feel free to reopen this if you disagree with the decision.

Comment 4 Owen Taylor 2019-03-19 18:17:06 UTC
Since the default for Fedora Workstation is to have terminals with dark backgrounds (the Tango Dark theme), and the colors used do not work for dark background:

  $ grep function /usr/share/source-highlight/esc.style
  function black b;

I think we should default to not styling sources. https://sourceware.org/gdb/onlinedocs/gdb/Output-Styling.html implies that 'set style sources off' should work - but doesn't seem to be in the f30 gdb. You can only 'set style enabled off' and disable all colorization.

If the only option is to put 'set style sources off' into /etc/gdbinit - I think we should do that, or disable source-highlight integration if we want to keep the other colors that gdb uses on by default.

It would of course be better if we could default-disable only source styling, and even better there was a real fix to the issue (either defaults that work for all colors - see https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/diagnostic-color.c, or two different color schemes picked between based on querying the terminal.)

Comment 5 Sergio Durigan Junior 2019-03-19 20:38:03 UTC
(In reply to Owen Taylor from comment #4)
> Since the default for Fedora Workstation is to have terminals with dark
> backgrounds (the Tango Dark theme), and the colors used do not work for dark
> background:
> 
>   $ grep function /usr/share/source-highlight/esc.style
>   function black b;

It seems to me that this is a source-highlight bug, then.  As you pointed out above, GDB is only using the default style already shipped by the source-highlight package.

> I think we should default to not styling sources.
> https://sourceware.org/gdb/onlinedocs/gdb/Output-Styling.html implies that
> 'set style sources off' should work - but doesn't seem to be in the f30 gdb.
> You can only 'set style enabled off' and disable all colorization.

FWIW, 'set style sources off' has been pushed very recently.  I'm preparing an update to Fedora Rawhide GDB that will contain it.

> If the only option is to put 'set style sources off' into /etc/gdbinit - I
> think we should do that, or disable source-highlight integration if we want
> to keep the other colors that gdb uses on by default.

I still disagree that the best option is to disable the feature.  I think it's a useful thing to have (I remember many users requesting this feature over many years), and the only thing we have to do is to make sure that the default style being shipped in Fedora can be properly used.

> It would of course be better if we could default-disable only source
> styling, and even better there was a real fix to the issue (either defaults
> that work for all colors - see
> https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/diagnostic-color.c, or two
> different color schemes picked between based on querying the terminal.)

I talked to the upstream author of the feature, and he told me that querying the terminal is not a very portable/feasible solution, that's why he didn't pursue that.

As for default-disable only source styling, it is possible to use /etc/gdbinit as you mentioned above.  Or maybe you're referring to something else?

Comment 6 Owen Taylor 2019-03-20 14:25:44 UTC
(In reply to Sergio Durigan Junior from comment #5)
> (In reply to Owen Taylor from comment #4)
> > Since the default for Fedora Workstation is to have terminals with dark
> > backgrounds (the Tango Dark theme), and the colors used do not work for dark
> > background:
> > 
> >   $ grep function /usr/share/source-highlight/esc.style
> >   function black b;
> 
> It seems to me that this is a source-highlight bug, then.  As you pointed
> out above, GDB is only using the default style already shipped by the
> source-highlight package.

Hmm, well, certainly, things are much improved if you change:

-   function black b;
+   function b;

in esc.style - so "bold foreground color" instead of "bold black". That would be a minimal fix to not expose users to something unusable. The result seems to work OK-ish - keywords in dark blue are hard to read, but not invisible.

test with: source-highlight -f esc --style-file=esc.style -i <source-file> -o STDOUT  | less -R

> > I think we should default to not styling sources.
> > https://sourceware.org/gdb/onlinedocs/gdb/Output-Styling.html implies that
> > 'set style sources off' should work - but doesn't seem to be in the f30 gdb.
> > You can only 'set style enabled off' and disable all colorization.
> 
> FWIW, 'set style sources off' has been pushed very recently.  I'm preparing
> an update to Fedora Rawhide GDB that will contain it.

Do you think this is back-portable to the Fedora 30 gdb? If we fix source-highlight htat way, may not be necessary.

> > If the only option is to put 'set style sources off' into /etc/gdbinit - I
> > think we should do that, or disable source-highlight integration if we want
> > to keep the other colors that gdb uses on by default.
> 
> I still disagree that the best option is to disable the feature.  I think
> it's a useful thing to have (I remember many users requesting this feature
> over many years), and the only thing we have to do is to make sure that the
> default style being shipped in Fedora can be properly used.

I'd just like to see us get some fix into Fedora 30, so you can use gdb without having to change your terminal color scheme or your .gdbinit file :-)
 
> > It would of course be better if we could default-disable only source
> > styling, and even better there was a real fix to the issue (either defaults
> > that work for all colors - see
> > https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/diagnostic-color.c, or two
> > different color schemes picked between based on querying the terminal.)
> 
> I talked to the upstream author of the feature, and he told me that querying
> the terminal is not a very portable/feasible solution, that's why he didn't
> pursue that.

Some programs definitely do that, but it could get complicated, yes. If we can find a good-enough fix esc.style, that may be sufficient. The gdb source listing doesn't need to be as pretty as a code editor.
 
> As for default-disable only source styling, it is possible to use
> /etc/gdbinit as you mentioned above.  Or maybe you're referring to something
> else?

I was referring to having 'set style sources off' available to use in the gdbinit.

Comment 7 Sergio Durigan Junior 2019-03-20 16:00:26 UTC
(In reply to Owen Taylor from comment #6)
> (In reply to Sergio Durigan Junior from comment #5)
> > (In reply to Owen Taylor from comment #4)
> > > Since the default for Fedora Workstation is to have terminals with dark
> > > backgrounds (the Tango Dark theme), and the colors used do not work for dark
> > > background:
> > > 
> > >   $ grep function /usr/share/source-highlight/esc.style
> > >   function black b;
> > 
> > It seems to me that this is a source-highlight bug, then.  As you pointed
> > out above, GDB is only using the default style already shipped by the
> > source-highlight package.
> 
> Hmm, well, certainly, things are much improved if you change:
> 
> -   function black b;
> +   function b;
> 
> in esc.style - so "bold foreground color" instead of "bold black". That
> would be a minimal fix to not expose users to something unusable. The result
> seems to work OK-ish - keywords in dark blue are hard to read, but not
> invisible.
> 
> test with: source-highlight -f esc --style-file=esc.style -i <source-file>
> -o STDOUT  | less -R

Great.  I'm not involved with the source-highlight package, but it seems to me that this would be a sensible change to propose, which would benefit not only GDB but other applications that use source-highlight.

> > > I think we should default to not styling sources.
> > > https://sourceware.org/gdb/onlinedocs/gdb/Output-Styling.html implies that
> > > 'set style sources off' should work - but doesn't seem to be in the f30 gdb.
> > > You can only 'set style enabled off' and disable all colorization.
> > 
> > FWIW, 'set style sources off' has been pushed very recently.  I'm preparing
> > an update to Fedora Rawhide GDB that will contain it.
> 
> Do you think this is back-portable to the Fedora 30 gdb? If we fix
> source-highlight htat way, may not be necessary.

I'm actually starting to work on sync'ing F30 GDB with the upstream 8.3 branch, which contains the patch for 'set style source', so yeah, if all goes well by the end of the day we'll have a new F30 GDB with the feature.

> > > If the only option is to put 'set style sources off' into /etc/gdbinit - I
> > > think we should do that, or disable source-highlight integration if we want
> > > to keep the other colors that gdb uses on by default.
> > 
> > I still disagree that the best option is to disable the feature.  I think
> > it's a useful thing to have (I remember many users requesting this feature
> > over many years), and the only thing we have to do is to make sure that the
> > default style being shipped in Fedora can be properly used.
> 
> I'd just like to see us get some fix into Fedora 30, so you can use gdb
> without having to change your terminal color scheme or your .gdbinit file :-)

Fair enough.  As I mentioned above, the next F30 GDB will contain the 'set style source' command.  I hope this + a possible tweak on source-highlight (which, IMO, is the correct fix for this problem) will be enough to provide a better user experience.

> > > It would of course be better if we could default-disable only source
> > > styling, and even better there was a real fix to the issue (either defaults
> > > that work for all colors - see
> > > https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/diagnostic-color.c, or two
> > > different color schemes picked between based on querying the terminal.)
> > 
> > I talked to the upstream author of the feature, and he told me that querying
> > the terminal is not a very portable/feasible solution, that's why he didn't
> > pursue that.
> 
> Some programs definitely do that, but it could get complicated, yes. If we
> can find a good-enough fix esc.style, that may be sufficient. The gdb source
> listing doesn't need to be as pretty as a code editor.

I was talking to Tom yesterday, and he seemed inclined to try this terminal query idea.  Let's see.

> > As for default-disable only source styling, it is possible to use
> > /etc/gdbinit as you mentioned above.  Or maybe you're referring to something
> > else?
> 
> I was referring to having 'set style sources off' available to use in the
> gdbinit.

Cool.  Then we're on the same page :-).

Comment 9 Fedora Update System 2019-03-21 03:09:44 UTC
gdb-8.2.90.20190320-21.fc30 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-2d48e90404

Comment 10 Fedora Update System 2019-03-21 19:12:29 UTC
gdb-8.2.90.20190320-21.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-2d48e90404

Comment 11 Adrian Reber 2019-03-22 07:04:47 UTC
(In reply to Owen Taylor from comment #8)
> https://src.fedoraproject.org/rpms/source-highlight/pull-request/1

Pull request merged and available in F30: https://bodhi.fedoraproject.org/updates/FEDORA-2019-eb13419ce4

Comment 12 Sergio Durigan Junior 2019-03-22 16:21:08 UTC
(In reply to Adrian Reber from comment #11)
> (In reply to Owen Taylor from comment #8)
> > https://src.fedoraproject.org/rpms/source-highlight/pull-request/1
> 
> Pull request merged and available in F30:
> https://bodhi.fedoraproject.org/updates/FEDORA-2019-eb13419ce4

Thanks, Owen and Adrian, for taking care of this from the source-highlight side.

Comment 13 Fedora Update System 2019-03-31 00:03:13 UTC
gdb-8.2.90.20190320-21.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.