aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-01-13 20:08:51 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-01-22 19:09:31 +0000
commit9d2d8a16e1ce033d6b7956d4b4f37961705bb5cf (patch)
tree8125bc0637b54354f56ba62a74e3dc46bb3b8149 /gdb/cli
parente7b430724d89288f06926999811c71400e0d1531 (diff)
downloadgdb-9d2d8a16e1ce033d6b7956d4b4f37961705bb5cf.zip
gdb-9d2d8a16e1ce033d6b7956d4b4f37961705bb5cf.tar.gz
gdb-9d2d8a16e1ce033d6b7956d4b4f37961705bb5cf.tar.bz2
gdb: add new version style
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. This commit should probably be considered only a partial solution to issue PR cli/25956. The colours of the style are no longer hard coded, however, it is still impossible to change the styling of the version string displayed during startup, so in one sense, the styling of that string is still "hard coded". A later patch will hopefully extend GDB to allow it to adjust the version styling before the initial version string is printed. gdb/ChangeLog: PR cli/25956 * 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. gdb/doc/ChangeLog: PR cli/25956 * gdb.texinfo (Output Styling): Document version style. gdb/testsuite/ChangeLog: PR cli/25956 * 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.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-style.c17
-rw-r--r--gdb/cli/cli-style.h6
2 files changed, 20 insertions, 3 deletions
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index cbedd30..8b4b6b2 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 cd51bf4..187e1d0 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;