From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id upDpImUeAGD1HwAAWB0awg (envelope-from ) for ; Thu, 14 Jan 2021 05:35:17 -0500 Received: by simark.ca (Postfix, from userid 112) id 7FD8C1EF80; Thu, 14 Jan 2021 05:35:17 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4C9591E590 for ; Thu, 14 Jan 2021 05:35:16 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45291385480D; Thu, 14 Jan 2021 10:35:15 +0000 (GMT) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 9FB0E3857C5E for ; Thu, 14 Jan 2021 10:35:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9FB0E3857C5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wm1-x329.google.com with SMTP id 190so4083257wmz.0 for ; Thu, 14 Jan 2021 02:35:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3ir+/3LkE4Nzec+jit+TXrhGyDN9RDquMYrdoLkn7pk=; b=ahXq5PnDQjqYPivbeoFqo8WE8YCuvYTb6zlWEqJO/LTRYH25KYFIN+FiybWwYLzLr6 iZJkndPflXwa9j4NITUXsfemrAkKGTobDsr0rKZFIsSydlofJI4R8Cn4CvzIi4zC3IrX BgreQshkm9otel9iZ+jAlAZjzyDyb7W9pH1GFADgJCSJDrxXEZeyfyVhvfIWUiggC1a0 jdcHgjSBrZWTcaEIDq+zv609kDNd1qUS8eGda0C9vexty0zLg6kHwtNzI6xyVOElz9nY 5BtWnGOIJsewdXHC/HDCoRuLSUTutfbHx6ngDfQpmFWOWPlbGl7tDeRIqWRDu3OgiIM2 Kwog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3ir+/3LkE4Nzec+jit+TXrhGyDN9RDquMYrdoLkn7pk=; b=Hzh9vXSlFAsnzHHuyFmo5UqtJ++RPw6T0DPPE+fKEe4guh0MReCL6LWpJLjPr3VuYI rl4Y3EPbyl4AZ6/1m4CuCseHuI4Tq/1HKyh5DTFYHeDdaT4PaHNaSjhQ0U1dR40wkyca I4V764J2MwOTis/ldKDbLuv0xacimkIq0tcwWQhciv3LQGweijATOjESbgGgjpUA1iUt bwWkDJzu5PVjoXX2AHSWOarciSdxVm9h1XVZDxzZsFXudtznFw1dP+P7eRnyInIPtSDg A/iV6arxNqp9/wLEpoxYOqzyW03VBPVFVuVXltvdRQTsFH/4X9Mrxf+ASUWOqfstyoC7 eZXw== X-Gm-Message-State: AOAM532qaSp5On0UO1L+UYLaHptJlcoDr3Mr4q5qFWpz0FG7UDuL0l4a 8nHojRTsxYqx8z5DXVFvLglBDHgbX1bACw== X-Google-Smtp-Source: ABdhPJwqnFtXL2/M3UVvW0B2RTqUedoNstk184L1JiVWOrMpIwJL2zhMxwBAW8KkuwcsSQSQq4c2KA== X-Received: by 2002:a1c:5406:: with SMTP id i6mr3238785wmb.137.1610620511444; Thu, 14 Jan 2021 02:35:11 -0800 (PST) Received: from localhost (host86-166-129-230.range86-166.btcentralplus.com. [86.166.129.230]) by smtp.gmail.com with ESMTPSA id i11sm7014369wmq.10.2021.01.14.02.35.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 02:35:10 -0800 (PST) Date: Thu, 14 Jan 2021 10:35:09 +0000 From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] gdb: add new version style Message-ID: <20210114103509.GG265215@embecosm.com> References: <04bf183a683d218b38a821a1108716191ea2cf22.1610618063.git.andrew.burgess@embecosm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <04bf183a683d218b38a821a1108716191ea2cf22.1610618063.git.andrew.burgess@embecosm.com> X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 10:34:00 up 36 days, 15:18, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" * Andrew Burgess [2021-01-14 09:56:43 +0000]: > This commit adds a new 'version' style, which replaces the hard coded > styling currently used for GDB's version string. GDB's version number > is displayed: > > 1. In the output of 'show version', and > > 2. When GDB starts up (without the --quiet option). > > This new style can only ever affect the first of these two cases as > the second case is printed before GDB has processed any initialization > files, or processed any GDB commands passed on the command line. > > However, because the first case exists I think this commit makes > sense, it means the style is no longer hard coded into GDB, and we can > add some tests that the style can be enabled/disabled correctly. > > This commit is an alternative to a patch Tom posted here: > > https://sourceware.org/pipermail/gdb-patches/2020-June/169820.html > > I've used the style name 'version' instead of 'startup' to reflect > what the style is actually used for. If other parts of the startup > text end up being highlighted I imagine they would get their own > styles based on what is being highlighted. I feel this is more inline > with the other style names that are already in use within GDB. > > I also decoupled adding this style from the idea of startup options, > and the possibility of auto-saving startup options. Those ideas can > be explored in later patches. > > gdb/ChangeLog: > > * cli/cli-style.c: Add 'cli/cli-setshow.h' include. > (version_style): Define. > (cli_style_option::cli_style_option): Add intensity parameter, and > use as appropriate. > (_initialize_cli_style): Register version style set/show commands. > * cli/cli-style.h (cli_style_option): Add intensity parameter. > (version_style): Declare. > * top.c (print_gdb_version): Use version_stype, and styled_string > to print the GDB version string. I realise I'm missing a ChangeLog entry for NEWS here. I also realise that the change I made to ChangeLog is in the wrong place. The rest of the patch should be OK though. Thanks, Andrew > > gdb/doc/ChangeLog: > > * gdb.texinfo (Output Styling): Document version style. > > gdb/testsuite/ChangeLog: > > * gdb.base/style.exp (run_style_tests): Add version string test. > (test_startup_version_string): Use version style name. > * lib/gdb-utils.exp (style): Handle version style name. > --- > gdb/ChangeLog | 12 ++++++++++++ > gdb/NEWS | 5 +++++ > gdb/cli/cli-style.c | 17 +++++++++++++++-- > gdb/cli/cli-style.h | 6 +++++- > gdb/doc/ChangeLog | 4 ++++ > gdb/doc/gdb.texinfo | 12 ++++++++++++ > gdb/testsuite/ChangeLog | 6 ++++++ > gdb/testsuite/gdb.base/style.exp | 8 +++++++- > gdb/testsuite/lib/gdb-utils.exp | 1 + > gdb/top.c | 11 +++-------- > 10 files changed, 70 insertions(+), 12 deletions(-) > > diff --git a/gdb/NEWS b/gdb/NEWS > index 66702862efb..0ba0c0b5ea2 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -171,6 +171,11 @@ show exec-file-mismatch -- Show exec-file-mismatch handling (ask|warn|off). > executable file; if 'warn', just display a warning; if 'off', don't > attempt to detect a mismatch. > > +set style version foreground COLOR > +set style version background COLOR > +set style version intensity VALUE > + Control the styling of GDB's version number text. > + > tui new-layout NAME WINDOW WEIGHT [WINDOW WEIGHT]... > Define a new TUI layout, specifying its name and the windows that > will be displayed. > diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c > index cbedd30ea74..8b4b6b24cda 100644 > --- a/gdb/cli/cli-style.c > +++ b/gdb/cli/cli-style.c > @@ -19,6 +19,7 @@ > > #include "defs.h" > #include "cli/cli-cmds.h" > +#include "cli/cli-setshow.h" > #include "cli/cli-style.h" > #include "source-cache.h" > #include "observable.h" > @@ -98,13 +99,19 @@ cli_style_option metadata_style ("metadata", ui_file_style::DIM); > > /* See cli-style.h. */ > > +cli_style_option version_style ("version", ui_file_style::MAGENTA, > + ui_file_style::BOLD); > + > +/* See cli-style.h. */ > + > cli_style_option::cli_style_option (const char *name, > - ui_file_style::basic_color fg) > + ui_file_style::basic_color fg, > + ui_file_style::intensity intensity) > : changed (name), > m_name (name), > m_foreground (cli_colors[fg - ui_file_style::NONE]), > m_background (cli_colors[0]), > - m_intensity (cli_intensities[ui_file_style::NORMAL]) > + m_intensity (cli_intensities[intensity]) > { > } > > @@ -382,4 +389,10 @@ TUI window that does have the focus."), > &style_set_list, > &style_show_list, > true); > + > + version_style.add_setshow_commands (no_class, _("\ > +Version string display styling.\n\ > +Configure colors used to display the GDB version string."), > + &style_set_list, &style_show_list, > + false); > } > diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h > index cd51bf4aa94..187e1d07ce7 100644 > --- a/gdb/cli/cli-style.h > +++ b/gdb/cli/cli-style.h > @@ -30,7 +30,8 @@ class cli_style_option > public: > > /* Construct a CLI style option with a foreground color. */ > - cli_style_option (const char *name, ui_file_style::basic_color fg); > + cli_style_option (const char *name, ui_file_style::basic_color fg, > + ui_file_style::intensity = ui_file_style::NORMAL); > > /* Construct a CLI style option with an intensity. */ > cli_style_option (const char *name, ui_file_style::intensity i); > @@ -124,6 +125,9 @@ extern cli_style_option tui_border_style; > /* The border style of a TUI window that does have the focus. */ > extern cli_style_option tui_active_border_style; > > +/* The style to use for the GDB version string. */ > +extern cli_style_option version_style; > + > /* True if source styling is enabled. */ > extern bool source_styling; > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 69fa6b709bf..37f97bfb2b2 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -25872,6 +25872,18 @@ > @code{set style address} family of commands. By default, this style's > foreground color is blue. > > +@item version > +Control the styling of @value{GDBN}'s version number text. By > +default, this style's foreground color is magenta and it has bold > +intensity. The version number is displayed in two placed, the output > +of @command{show version}, and when @value{GDBN} starts up. > + > +Currently the version string displayed at startup is printed before > +@value{GDBN} has parsed any command line options, or parsed any > +command files, so there is currently no way to control the styling of > +this string. However, @value{GDBN}'s @code{--quiet} command line option > +can be used to disable printing of the version string on startup. > + > @item title > Control the styling of titles. These are managed with the > @code{set style title} family of commands. By default, this style's > diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp > index 58c8da0a10e..dfbadd6c1af 100644 > --- a/gdb/testsuite/gdb.base/style.exp > +++ b/gdb/testsuite/gdb.base/style.exp > @@ -264,6 +264,12 @@ proc run_style_tests { } { > gdb_test "p 5" \ > "Warning: '[style p title]', an alias for the command '[style print title]', is deprecated.*Use '[style new_p title]'.*" \ > "p deprecated warning, with replacement" > + > + # Check that the version string is styled in the output of 'show > + # version', and that this styling can be disabled. > + set vers [style "GNU gdb.*" version] > + gdb_test "show version" "${vers}.*" \ > + "version is styled in 'show version'" > } > } > > @@ -274,7 +280,7 @@ proc test_startup_version_string { } { > gdb_exit > gdb_spawn > > - set vers [style "GNU gdb.*" "35;1"] > + set vers [style "GNU gdb.*" version] > gdb_test "" "${vers}.*" "version is styled at startup" > } > > diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp > index 000e3800cd9..ad7d2884aae 100644 > --- a/gdb/testsuite/lib/gdb-utils.exp > +++ b/gdb/testsuite/lib/gdb-utils.exp > @@ -55,6 +55,7 @@ proc style {str style} { > variable { set style 36 } > address { set style 34 } > metadata { set style 2 } > + version { set style "35;1" } > } > return "\033\\\[${style}m${str}\033\\\[m" > } > diff --git a/gdb/top.c b/gdb/top.c > index 2c13864e120..92090bccbf4 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -1395,14 +1395,9 @@ print_gdb_version (struct ui_file *stream, bool interactive) > program to parse, and is just canonical program name and version > number, which starts after last space. */ > > - ui_file_style style; > - if (interactive) > - { > - ui_file_style nstyle = { ui_file_style::MAGENTA, ui_file_style::NONE, > - ui_file_style::BOLD }; > - style = nstyle; > - } > - fprintf_styled (stream, style, "GNU gdb %s%s\n", PKGVERSION, version); > + std::string v_str = string_printf ("GNU gdb %s%s", PKGVERSION, version); > + fprintf_filtered (stream, "%ps\n", > + styled_string (version_style.style (), v_str.c_str ())); > > /* Second line is a copyright notice. */ > > -- > 2.25.4 >