[1/3] Introduce "command" styling

Message ID 20241004-cli-command-style-v1-1-cc1fbb3c40bf@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 Oct. 4, 2024, 11:31 p.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.
---
 gdb/NEWS                    |  5 +++++
 gdb/auto-load.c             | 18 +++++++++++-------
 gdb/breakpoint.c            |  3 ++-
 gdb/cli/cli-decode.c        | 12 ++++++++----
 gdb/cli/cli-style.c         | 11 +++++++++++
 gdb/cli/cli-style.h         |  3 +++
 gdb/darwin-nat.c            | 12 ++++++++----
 gdb/doc/gdb.texinfo         |  5 +++++
 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, 137 insertions(+), 61 deletions(-)
  

Comments

Eli Zaretskii Oct. 5, 2024, 7:14 a.m. UTC | #1
> From: Tom Tromey <tom@tromey.com>
> Date: Fri, 04 Oct 2024 17:31:41 -0600
> 
> 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.
> ---
>  gdb/NEWS                    |  5 +++++
>  gdb/auto-load.c             | 18 +++++++++++-------
>  gdb/breakpoint.c            |  3 ++-
>  gdb/cli/cli-decode.c        | 12 ++++++++----
>  gdb/cli/cli-style.c         | 11 +++++++++++
>  gdb/cli/cli-style.h         |  3 +++
>  gdb/darwin-nat.c            | 12 ++++++++----
>  gdb/doc/gdb.texinfo         |  5 +++++
>  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, 137 insertions(+), 61 deletions(-)

Thanks, the documentation parts are okay.

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

Patch

diff --git a/gdb/NEWS b/gdb/NEWS
index 3a0c8d1049fe5438b2eb37e0863c1f1c12f88800..dda4af6f1aedd4b932089a798bd810d8b929e216 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -70,6 +70,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 command names when displayed by GDB.
+
 maintenance info inline-frames [ADDRESS]
   New command which displays GDB's inline-frame information for the
   current address, or for ADDRESS if specified.  The output identifies
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index e753333b1cdfe6a12b1885d1468ef92ef51776af..a02b3416a4c1fb6cf1df751969eb4108b2e59a82 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 b80b3522dcb721a53c726e5a00e7d10054b4e78a..75e01e0c996780d68ed26e9f5f653292d892e2a2 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9355,7 +9355,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..09c39ed1d6abccaf656326fbb751f80275804aa3 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1875,7 +1875,8 @@  Type \"help%s\" followed by a class name for a list of commands in ",
       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 ",
@@ -1886,9 +1887,12 @@  Type \"help all\" for the list of all commands.");
   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..fda7c9031c9652fb883e780460c04a1af43023c3 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 command names.  */
+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 7ba1fbb67755b030db645da1a08e949bb8da3b24..859076de717afe8e2b96b6f00425dbf992f7f4d1 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1942,16 +1942,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 cc1b69c6978a655eee16912fe4ff8bedff223201..679482ccb21e42fb3a9193388deae58d11ee8f4a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27838,6 +27838,11 @@  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} command names 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 701cdecf392c352c781e6537e8531a77993fc6f4..6cc95997fc829582c06162ba455d8ed04f40fb06 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 74873b9f7c80fa2ec299f528cde748161882c175..dc4d2a7316dd0372e8d8aa769d68054d79bf3716 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 4ca15450afe0344f9acf97ca73dcf837879650e3..ccae286a70f30055f035f3c33ca6d3a16bb487f8 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
@@ -10011,8 +10015,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 e4a40c51023cd6bae8c1e45594ee2b4a7d6c2279..4965090f586607cc593ad60840576730f3821884 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1491,10 +1491,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 735068e5a468e82965b81179784b4b36802f82e4..cf4b399e47e6da9e3deadf979102cf1c3ae3a43f 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 4ec25ee23428364891eb05a899b8142848e0760e..0dd40a1089c10ee9b70aad4b3e8320eb306f46d2 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"
@@ -12816,8 +12817,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 5c926def715080f3ab54172afcabc3361f15ceb0..b34d5ff2262ca7c6feb688d95dc934ec8fb02390 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -859,18 +859,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 eae54aae1ffbe65b34436baca0b8125a4473f6a8..d6b1e4e4076a5519d0a715d23a31b373c8576cf5 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 38ddd2336fe0a9409628691413399bddf9addd05..af69cd744280bf735462e109e6705ee9e6e6cb70 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 d9b3c6ece04c6d0961ef18ab9de24365d10fa22b..09131860f74dbf1f3cebbdf9f7a27ee17e9cf3c7 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2588,8 +2588,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 37c1f46be35cace6a2ff11616ba38d48da2f68e4..0b198ae983dff696112f1c39014a760939be6441 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"));
     }
 }