[v2,1/3] Introduce "command" styling

Message ID 20241127-cli-command-style-v2-1-6dc216226169@tromey.com
State New
Headers
Series Add "command" styling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey Nov. 28, 2024, 12:20 a.m. UTC
  This adds a new "command" style that is used when styling the name of
a gdb command.

Note that not every instance of a command name that is output by gdb
is changed here.  There is currently no way to style error() strings,
and there is no way to mark up command help strings.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31747
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Keith Seitz <keiths@redhat.com>
---
 gdb/NEWS                    |  5 +++++
 gdb/auto-load.c             | 18 +++++++++++-------
 gdb/breakpoint.c            |  3 ++-
 gdb/cli/cli-decode.c        | 23 +++++++++++++++--------
 gdb/cli/cli-style.c         | 11 +++++++++++
 gdb/cli/cli-style.h         |  3 +++
 gdb/darwin-nat.c            | 12 ++++++++----
 gdb/doc/gdb.texinfo         |  4 ++++
 gdb/dwarf2/read-gdb-index.c |  7 +++++--
 gdb/exec.c                  |  3 ++-
 gdb/inf-child.c             |  4 +++-
 gdb/infcmd.c                |  8 ++++----
 gdb/infrun.c                | 16 ++++++++++------
 gdb/main.c                  |  7 ++++---
 gdb/maint.c                 | 22 +++++++++++++++-------
 gdb/memattr.c               |  4 +++-
 gdb/remote.c                |  6 ++++--
 gdb/solib.c                 | 21 +++++++++++++++------
 gdb/top.c                   | 16 +++++++++-------
 gdb/tui/tui-regs.c          |  6 ++++--
 gdb/value.c                 |  5 +++--
 gdb/windows-nat.c           |  4 +++-
 22 files changed, 143 insertions(+), 65 deletions(-)
  

Comments

Eli Zaretskii Nov. 28, 2024, 7:38 a.m. UTC | #1
> From: Tom Tromey <tom@tromey.com>
> Date: Wed, 27 Nov 2024 17:20:22 -0700
> Cc: Eli Zaretskii <eliz@gnu.org>, Keith Seitz <keiths@redhat.com>
> 
> This adds a new "command" style that is used when styling the name of
> a gdb command.
> 
> Note that not every instance of a command name that is output by gdb
> is changed here.  There is currently no way to style error() strings,
> and there is no way to mark up command help strings.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31747
> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
> Reviewed-By: Keith Seitz <keiths@redhat.com>
> ---
>  gdb/NEWS                    |  5 +++++
>  gdb/auto-load.c             | 18 +++++++++++-------
>  gdb/breakpoint.c            |  3 ++-
>  gdb/cli/cli-decode.c        | 23 +++++++++++++++--------
>  gdb/cli/cli-style.c         | 11 +++++++++++
>  gdb/cli/cli-style.h         |  3 +++
>  gdb/darwin-nat.c            | 12 ++++++++----
>  gdb/doc/gdb.texinfo         |  4 ++++
>  gdb/dwarf2/read-gdb-index.c |  7 +++++--
>  gdb/exec.c                  |  3 ++-
>  gdb/inf-child.c             |  4 +++-
>  gdb/infcmd.c                |  8 ++++----
>  gdb/infrun.c                | 16 ++++++++++------
>  gdb/main.c                  |  7 ++++---
>  gdb/maint.c                 | 22 +++++++++++++++-------
>  gdb/memattr.c               |  4 +++-
>  gdb/remote.c                |  6 ++++--
>  gdb/solib.c                 | 21 +++++++++++++++------
>  gdb/top.c                   | 16 +++++++++-------
>  gdb/tui/tui-regs.c          |  6 ++++--
>  gdb/value.c                 |  5 +++--
>  gdb/windows-nat.c           |  4 +++-
>  22 files changed, 143 insertions(+), 65 deletions(-)

The documentation parts are okay, thanks.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
  

Patch

diff --git a/gdb/NEWS b/gdb/NEWS
index 361d7726ba0f7065b1ad78c34aa0decb860f4e9c..4527a13448868220582f4f7f474129e02de0f092 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -109,6 +109,11 @@  set style line-number background COLOR
 set style line-number intensity VALUE
   Control the styling of line numbers printed by GDB.
 
+set style command foreground COLOR
+set style command background COLOR
+set style command intensity VALUE
+  Control the styling of GDB commands when displayed by GDB.
+
 set warn-language-frame-mismatch [on|off]
 show warn-language-frame-mismatch
   Control the warning that is emitted when specifying a language that
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index e684d7fd896f990aa7b62625af188f9f5dd28888..fe63ecbc410072210cc7d498b9d82a4783a7457f 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -476,19 +476,23 @@  file_is_auto_load_safe (const char *filename)
 
       gdb_printf (_("\
 To enable execution of this file add\n\
-\tadd-auto-load-safe-path %s\n\
+\t%p[add-auto-load-safe-path %s%p]\n\
 line to your configuration file \"%ps\".\n\
 To completely disable this security protection add\n\
-\tset auto-load safe-path /\n\
+\t%ps\n\
 line to your configuration file \"%ps\".\n\
 For more information about this security protection see the\n\
 \"Auto-loading safe path\" section in the GDB manual.  E.g., run from the shell:\n\
 \tinfo \"(gdb)Auto-loading safe path\"\n"),
-		       filename_real.get (),
-		       styled_string (file_name_style.style (),
-				      home_config.c_str ()),
-		       styled_string (file_name_style.style (),
-				      home_config.c_str ()));
+		  command_style.style ().ptr (),
+		  filename_real.get (),
+		  nullptr,
+		  styled_string (file_name_style.style (),
+				 home_config.c_str ()),
+		  styled_string (command_style.style (),
+				 "set auto-load safe-path /"),
+		  styled_string (file_name_style.style (),
+				 home_config.c_str ()));
       advice_printed = true;
     }
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 0a889a04e81ae7b3592434188a162c6db2e99e64..ac337d4c96f09b74cd3a62137fd112a04a2e3736 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9376,7 +9376,8 @@  create_breakpoint (struct gdbarch *gdbarch,
   if (canonical.lsals.size () > 1)
     {
       warning (_("Multiple breakpoints were set.\nUse the "
-		 "\"delete\" command to delete unwanted breakpoints."));
+		 "\"%ps\" command to delete unwanted breakpoints."),
+	       styled_string (command_style.style (), "delete"));
       prev_breakpoint_count = prev_bkpt_count;
     }
 
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 163012a6bec1626143345387cbf78b4c628448ed..295119494ce4e48d047a88ca7b63e4aa26c61c66 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1869,26 +1869,33 @@  help_list (struct cmd_list_element *list, const char *cmdtype,
   if (theclass == all_classes)
     {
       gdb_printf (stream, "\n\
-Type \"help%s\" followed by a class name for a list of commands in ",
-		  cmdtype1);
+Type \"%p[help%s%p]\" followed by a class name for a list of commands in ",
+		  command_style.style ().ptr (),
+		  cmdtype1,
+		  nullptr);
       stream->wrap_here (0);
       gdb_printf (stream, "that class.");
 
       gdb_printf (stream, "\n\
-Type \"help all\" for the list of all commands.");
+Type \"%ps\" for the list of all commands.",
+		  styled_string (command_style.style (), "help all"));
     }
 
-  gdb_printf (stream, "\nType \"help%s\" followed by %scommand name ",
-	      cmdtype1, cmdtype2);
+  gdb_printf (stream, "\nType \"%p[help%s%p]\" followed by %scommand name ",
+	      command_style.style ().ptr (), cmdtype1, nullptr,
+	      cmdtype2);
   stream->wrap_here (0);
   gdb_puts ("for ", stream);
   stream->wrap_here (0);
   gdb_puts ("full ", stream);
   stream->wrap_here (0);
   gdb_puts ("documentation.\n", stream);
-  gdb_puts ("Type \"apropos word\" to search "
-	    "for commands related to \"word\".\n", stream);
-  gdb_puts ("Type \"apropos -v word\" for full documentation", stream);
+  gdb_printf (stream,
+	      "Type \"%ps\" to search "
+	      "for commands related to \"word\".\n",
+	      styled_string (command_style.style (), "apropos word"));
+  gdb_printf (stream, "Type \"%ps\" for full documentation",
+	      styled_string (command_style.style (), "apropos -v word"));
   stream->wrap_here (0);
   gdb_puts (" of commands related to \"word\".\n", stream);
   gdb_puts ("Command name abbreviations are allowed if unambiguous.\n",
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 36a8bd9c526f90fb1e825bafc0110b32859c96b9..fa582a7d4d0fdda18be9b8cefb14aebdab0e3f10 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -91,6 +91,10 @@  cli_style_option title_style ("title", ui_file_style::BOLD);
 
 /* See cli-style.h.  */
 
+cli_style_option command_style ("command", ui_file_style::BOLD);
+
+/* See cli-style.h.  */
+
 cli_style_option tui_border_style ("tui-border", ui_file_style::CYAN);
 
 /* See cli-style.h.  */
@@ -439,6 +443,13 @@  readability."),
 				    &style_set_list, &style_show_list,
 				    false);
 
+  command_style.add_setshow_commands (no_class, _("\
+Command display styling.\n\
+Configure the colors and display intensity for GDB commands mentioned\n\
+in the output."),
+				      &style_set_list, &style_show_list,
+				      false);
+
   highlight_style.add_setshow_commands (no_class, _("\
 Highlight display styling.\n\
 Configure highlight colors and display intensity\n\
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 5052b867cfab864dc3b3219f8cb09b1c514a4e8f..24ec2ce0ad44432f539ae34c9364354a65c57ac7 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -118,6 +118,9 @@  extern cli_style_option highlight_style;
 /* The title style.  */
 extern cli_style_option title_style;
 
+/* Style used for commands.  */
+extern cli_style_option command_style;
+
 /* The metadata style.  */
 extern cli_style_option metadata_style;
 
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 7f6b72bde499b9a27e9d509df162bb8992bfca1c..e1ea020bd5c1e5a5fe3e825785453b1574cf0195 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1943,16 +1943,20 @@  Because `startup-with-shell' is enabled, gdb tried to work around SIP by\n\
 caching a copy of your shell.  However, this failed:\n\
 %s\n\
 If you correct the problem, gdb will automatically try again the next time\n\
-you \"run\".  To prevent these attempts, you can use:\n\
-    set startup-with-shell off"),
-		   ex.what ());
+you \"%ps\".  To prevent these attempts, you can use:\n\
+    %ps"),
+		   ex.what (),
+		   styled_string (command_style.style (), "run"),
+		   styled_string (command_style.style (),
+				  "set startup-with-shell off"));
 	  return false;
 	}
 
       gdb_printf (_("Note: this version of macOS has System Integrity Protection.\n\
 Because `startup-with-shell' is enabled, gdb has worked around this by\n\
-caching a copy of your shell.  The shell used by \"run\" is now:\n\
+caching a copy of your shell.  The shell used by \"%ps\" is now:\n\
     %s\n"),
+		  styled_string (command_style.style (), "run"),
 		  new_name.c_str ());
     }
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 85ac3d9aab63d790b66aae8bfe38156b44f4e8fc..0254b5aa815e3d6fe97d97d79879e13b0ef0cf02 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27864,6 +27864,10 @@  their characteristics and the visual aspect of each style.
 
 The style-able objects are:
 @table @code
+@item command
+Control the styling of any @value{GDBN} commands that are displayed by
+@value{GDBN}.  By default, this style's intensity is bold.
+
 @item filename
 Control the styling of file names and URLs.  By default, this style's
 foreground color is green.
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index c0a33a0c9694fae9b69d359819a02ec2d1f917c6..4dea55957346432bba4b3e262e10aa2ffa9d77d7 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -20,6 +20,7 @@ 
 #include "read-gdb-index.h"
 
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 #include "complaints.h"
 #include "dwz.h"
 #include "event-top.h"
@@ -392,9 +393,11 @@  read_gdb_index_from_buffer (const char *filename,
 	{
 	  warning (_("\
 Skipping deprecated .gdb_index section in %s.\n\
-Do \"set use-deprecated-index-sections on\" before the file is read\n\
+Do \"%ps\" before the file is read\n\
 to use the section anyway."),
-		   filename);
+		   filename,
+		   styled_string (command_style.style (),
+				  "set use-deprecated-index-sections on"));
 	  warning_printed = 1;
 	}
       return 0;
diff --git a/gdb/exec.c b/gdb/exec.c
index 82d9266b7e3669dabfe29c5362498d60be9fa6c5..9c7498ae27a5ecd9f8bdb4eb287c7e0836fcb301 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -327,7 +327,8 @@  exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
       warning (_("No executable has been specified and target does not "
 		 "support\n"
 		 "determining executable automatically.  "
-		 "Try using the \"file\" command."));
+		 "Try using the \"%ps\" command."),
+	       styled_string (command_style.style (), "file"));
       return;
     }
 
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index df993b624dd4ae26c210d07a4b7a42d1d376573c..b6b3750fbb85d8508b4edb10b481a73e7fcc69c0 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -33,6 +33,7 @@ 
 #include "gdbsupport/agent.h"
 #include "gdbsupport/gdb_wait.h"
 #include "gdbsupport/filestuff.h"
+#include "cli/cli-style.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -160,7 +161,8 @@  inf_child_open_target (const char *arg, int from_tty)
   current_inferior ()->push_target (target);
   inf_child_explicitly_opened = 1;
   if (from_tty)
-    gdb_printf ("Done.  Use the \"run\" command to start a process.\n");
+    gdb_printf ("Done.  Use the \"%ps\" command to start a process.\n",
+		styled_string (command_style.style (), "run"));
 }
 
 /* Implement the to_disconnect target_ops method.  */
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 5c0e3f51162803d2aa4e4ca0b41475d616deda29..9fcbadbe0232d8e2a6dc7c545adb1dad39a5d446 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -27,6 +27,7 @@ 
 #include "gdbsupport/environ.h"
 #include "value.h"
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 #include "symfile.h"
 #include "gdbcore.h"
 #include "target.h"
@@ -1999,10 +2000,9 @@  info_program_command (const char *args, int from_tty)
     }
 
   if (from_tty)
-    {
-      gdb_printf (_("Type \"info stack\" or \"info "
-		    "registers\" for more information.\n"));
-    }
+    gdb_printf (_("Type \"%ps\" or \"%ps\" for more information.\n"),
+		styled_string (command_style.style (), "info stack"),
+		styled_string (command_style.style (), "info registers"));
 }
 
 static void
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 43eca814e296e9cd300bdc73a3388af1f2dc0113..8a10119487c4d58660970f27a08acd69ce7acd03 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -19,6 +19,7 @@ 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 #include "displaced-stepping.h"
 #include "infrun.h"
 #include <ctype.h>
@@ -463,8 +464,10 @@  follow_fork_inferior (bool follow_child, bool detach_fork)
 	 back the terminal, effectively hanging the debug session.  */
       gdb_printf (gdb_stderr, _("\
 Can not resume the parent process over vfork in the foreground while\n\
-holding the child stopped.  Try \"set detach-on-fork\" or \
-\"set schedule-multiple\".\n"));
+holding the child stopped.  Try \"set %ps\" or \"%ps\".\n"),
+		  styled_string (command_style.style (), "set detach-on-fork"),
+		  styled_string (command_style.style (),
+				 "set schedule-multiple"));
       return true;
     }
 
@@ -1308,8 +1311,9 @@  follow_exec (ptid_t ptid, const char *exec_file_target)
      so that the user can specify a file manually before continuing.  */
   if (exec_file_host == nullptr)
     warning (_("Could not load symbols for executable %s.\n"
-	       "Do you need \"set sysroot\"?"),
-	     exec_file_target);
+	       "Do you need \"%ps\"?"),
+	     exec_file_target,
+	     styled_string (command_style.style (), "set sysroot"));
 
   /* Reset the shared library package.  This ensures that we get a
      shlib event when the child reaches "_start", at which point the
@@ -10039,8 +10043,8 @@  info_signals_command (const char *signum_exp, int from_tty)
 	sig_print_info (oursig);
     }
 
-  gdb_printf (_("\nUse the \"handle\" command "
-		"to change these tables.\n"));
+  gdb_printf (_("\nUse the \"%ps\" command to change these tables.\n"),
+	      styled_string (command_style.style (), "handle"));
 }
 
 /* The $_siginfo convenience variable is a bit special.  We don't know
diff --git a/gdb/main.c b/gdb/main.c
index 4370e95ada44a5ee4d919267e4feecd27354fdb2..41e27937c133cf4e50a5cefaaab0a14c2a86fb0d 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1493,10 +1493,11 @@  At startup, GDB reads the following init files and executes their commands:\n\
       && local_gdbinit.empty ())
     gdb_printf (stream, _("\
    None found.\n"));
-  gdb_puts (_("\n\
-For more information, type \"help\" from within GDB, or consult the\n\
+  gdb_printf (stream, _("\n\
+For more information, type \"%ps\" from within GDB, or consult the\n\
 GDB manual (available as on-line info or a printed manual).\n\
-"), stream);
+"),
+	      styled_string (command_style.style (), "stream"));
   if (REPORT_BUGS_TO[0] && stream == gdb_stdout)
     gdb_printf (stream, _("\n\
 Report bugs to %ps.\n\
diff --git a/gdb/maint.c b/gdb/maint.c
index 237c9d8c8a35d6718f92e52a2f5e4f345a3af7c3..4fc70d7d0d8dd15379b58daeb2df0b8cb33089a7 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -44,6 +44,7 @@ 
 #include "cli/cli-decode.h"
 #include "cli/cli-utils.h"
 #include "cli/cli-setshow.h"
+#include "cli/cli-style.h"
 #include "cli/cli-cmds.h"
 
 static void maintenance_do_deprecate (const char *, int);
@@ -104,14 +105,16 @@  maintenance_demangler_warning (const char *args, int from_tty)
 static void
 maintenance_demangle (const char *args, int from_tty)
 {
-  gdb_printf (_("This command has been moved to \"demangle\".\n"));
+  gdb_printf (_("This command has been moved to \"%ps\".\n"),
+	      styled_string (command_style.style (), "demangle"));
 }
 
 static void
 maintenance_time_display (const char *args, int from_tty)
 {
   if (args == NULL || *args == '\0')
-    gdb_printf (_("\"maintenance time\" takes a numeric argument.\n"));
+    gdb_printf (_("\"%ps\" takes a numeric argument.\n"),
+		styled_string (command_style.style (), "maintenance time"));
   else
     set_per_command_time (strtol (args, NULL, 10));
 }
@@ -120,7 +123,8 @@  static void
 maintenance_space_display (const char *args, int from_tty)
 {
   if (args == NULL || *args == '\0')
-    gdb_printf ("\"maintenance space\" takes a numeric argument.\n");
+    gdb_printf ("\"%ps\" takes a numeric argument.\n",
+		styled_string (command_style.style (), "maintenance space"));
   else
     set_per_command_space (strtol (args, NULL, 10));
 }
@@ -630,9 +634,11 @@  maintenance_deprecate (const char *args, int from_tty)
 {
   if (args == NULL || *args == '\0')
     {
-      gdb_printf (_("\"maintenance deprecate\" takes an argument,\n\
+      gdb_printf (_("\"%ps\" takes an argument,\n\
 the command you want to deprecate, and optionally the replacement command\n\
-enclosed in quotes.\n"));
+enclosed in quotes.\n"),
+		  styled_string (command_style.style (),
+				 "maintenance deprecate"));
     }
 
   maintenance_do_deprecate (args, 1);
@@ -644,8 +650,10 @@  maintenance_undeprecate (const char *args, int from_tty)
 {
   if (args == NULL || *args == '\0')
     {
-      gdb_printf (_("\"maintenance undeprecate\" takes an argument, \n\
-the command you want to undeprecate.\n"));
+      gdb_printf (_("\"%ps\" takes an argument, \n\
+the command you want to undeprecate.\n"),
+		  styled_string (command_style.style (),
+				 "maintenance undeprecate"));
     }
 
   maintenance_do_deprecate (args, 0);
diff --git a/gdb/memattr.c b/gdb/memattr.c
index 2df8769742de112423e2639c558819a6d64ce541..34999293c4488d062d1ab46002e8a8ea4377de19 100644
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -19,6 +19,7 @@ 
 
 #include "command.h"
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 #include "memattr.h"
 #include "target.h"
 #include "target-dcache.h"
@@ -91,7 +92,8 @@  require_user_regions (int from_tty)
   /* Otherwise, let the user know how to get back.  */
   if (from_tty)
     warning (_("Switching to manual control of memory regions; use "
-	       "\"mem auto\" to fetch regions from the target again."));
+	       "\"%ps\" to fetch regions from the target again."),
+	     styled_string (command_style.style (), "mem auto"));
 
   /* And create a new list (copy of the target-supplied regions) for the user
      to modify.  */
diff --git a/gdb/remote.c b/gdb/remote.c
index f41129915683194237d1bba56d17df61ae89c063..8e3819bdb75de46d35e39776b4e047dcc70eaa61 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -39,6 +39,7 @@ 
 #include "solib.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-setshow.h"
+#include "cli/cli-style.h"
 #include "target-descriptions.h"
 #include "gdb_bfd.h"
 #include "gdbsupport/filestuff.h"
@@ -12814,8 +12815,9 @@  remote_target::remote_hostio_open (inferior *inf, const char *filename,
       if (!warning_issued)
 	{
 	  warning (_("File transfers from remote targets can be slow."
-		     " Use \"set sysroot\" to access files locally"
-		     " instead."));
+		     " Use \"%ps\" to access files locally"
+		     " instead."),
+		   styled_string (command_style.style (), "set sysroot"));
 	  warning_issued = 1;
 	}
     }
diff --git a/gdb/solib.c b/gdb/solib.c
index fdefdf0b1423032fa39f8ee9aae7f1c35f13e1d1..4a04f1ddb1fb6800436fba2cd2f1c09e0d31bfc3 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -860,18 +860,27 @@  update_solib_list (int from_tty)
 
       if (not_found == 1)
 	warning (_ ("Could not load shared library symbols for %ps.\n"
-		    "Do you need \"set solib-search-path\" "
-		    "or \"set sysroot\"?"),
+		    "Do you need \"%ps\" or \"%ps\"?"),
 		 styled_string (file_name_style.style (),
-				not_found_filename));
+				not_found_filename),
+		 styled_string (command_style.style (),
+				"set solib-search-path"),
+		 styled_string (command_style.style (), "set sysroot"));
       else if (not_found > 1)
 	warning (_ ("\
 Could not load shared library symbols for %d libraries, e.g. %ps.\n\
-Use the \"info sharedlibrary\" command to see the complete listing.\n\
-Do you need \"set solib-search-path\" or \"set sysroot\"?"),
+Use the \"%ps\" command to see the complete listing.\n\
+Do you need \"%ps\" or \"%ps\"?"),
 		 not_found,
 		 styled_string (file_name_style.style (),
-				not_found_filename));
+				not_found_filename),
+		 styled_string (command_style.style (),
+				"info sharedlibrary"),
+		 styled_string (command_style.style (),
+				"set solib-search-path"),
+		 styled_string (command_style.style (),
+				"set sysroot"));
+
     }
 }
 
diff --git a/gdb/top.c b/gdb/top.c
index d750f3305f2eef7c5a30cef7f647537916a80499..c7a62c15ae289bef048bb3756aaee8683462c753 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1330,8 +1330,9 @@  There is NO WARRANTY, to the extent permitted by law.",
   if (!interactive)
     return;
 
-  gdb_printf (stream, ("\nType \"show copying\" and "
-		       "\"show warranty\" for details.\n"));
+  gdb_printf (stream, ("\nType \"%ps\" and \"%ps\" for details.\n"),
+	      styled_string (command_style.style (), "show copying"),
+	      styled_string (command_style.style (), "show warranty"));
 
   /* After the required info we print the configuration information.  */
 
@@ -1347,8 +1348,8 @@  There is NO WARRANTY, to the extent permitted by law.",
     }
   gdb_printf (stream, "\".\n");
 
-  gdb_printf (stream, _("Type \"show configuration\" "
-			"for configuration details.\n"));
+  gdb_printf (stream, _("Type \"%ps\" for configuration details.\n"),
+	      styled_string (command_style.style (), "show configuration"));
 
   if (REPORT_BUGS_TO[0])
     {
@@ -1364,10 +1365,11 @@  resources online at:\n    <%ps>."),
 	      styled_string (file_name_style.style (),
 			     "http://www.gnu.org/software/gdb/documentation/"));
   gdb_printf (stream, "\n\n");
-  gdb_printf (stream, _("For help, type \"help\".\n"));
+  gdb_printf (stream, _("For help, type \"%ps\".\n"),
+	      styled_string (command_style.style (), "help"));
   gdb_printf (stream,
-	      _("Type \"apropos word\" to search for commands \
-related to \"word\"."));
+	      _("Type \"%ps\" to search for commands related to \"word\"."),
+	      styled_string (command_style.style (), "apropos word"));
 }
 
 /* Print the details of GDB build-time configuration.  */
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 927b11fce4fc3d034b4434608932e5cb3d4b482d..5158c0662ea761a36e9f72f3d70bc51c941b02ce 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -22,6 +22,7 @@ 
 #include "arch-utils.h"
 #include "tui/tui.h"
 #include "symtab.h"
+#include "cli/cli-style.h"
 #include "frame.h"
 #include "regcache.h"
 #include "inferior.h"
@@ -532,9 +533,10 @@  tui_reg_command (const char *args, int from_tty)
     }
   else
     {
-      gdb_printf (_("\"tui reg\" must be followed by the name of "
+      gdb_printf (_("\"%ps\" must be followed by the name of "
 		    "either a register group,\nor one of 'next' "
-		    "or 'prev'.  Known register groups are:\n"));
+		    "or 'prev'.  Known register groups are:\n"),
+		  styled_string (command_style.style (), "tui reg"));
 
       bool first = true;
       for (const struct reggroup *group : gdbarch_reggroups (gdbarch))
diff --git a/gdb/value.c b/gdb/value.c
index a18491602a8a501475208f8f3774478361a0027a..e498632fe3cae5149d877e3e57b2befde15caa0d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2587,8 +2587,9 @@  show_convenience (const char *ignore, int from_tty)
       gdb_printf (_("No debugger convenience variables now defined.\n"
 		    "Convenience variables have "
 		    "names starting with \"$\";\n"
-		    "use \"set\" as in \"set "
-		    "$foo = 5\" to define them.\n"));
+		    "use \"%ps\" as in \"%ps\" to define them.\n"),
+		  styled_string (command_style.style (), "set"),
+		  styled_string (command_style.style (), "set $foo = 5"));
     }
 }
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index abacafe7af8e48e7c7cb98a464b6314feb0c7f34..fc6e52d8f482ca1f3101f5917384aa4380b91b37 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -3310,7 +3310,9 @@  Show whether to display kernel exceptions in child process."), NULL,
 	 that we're missing some functionality.  */
       warning(_("\
 cannot automatically find executable file or library to read symbols.\n\
-Use \"file\" or \"dll\" command to load executable/libraries directly."));
+Use \"%ps\" or \"%ps\" command to load executable/libraries directly.")
+	      styled_string (command_style.style (), "file"),
+	      styled_string (command_style.style (), "dll"));
     }
 }