]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add command styling to error messages
authorTom Tromey <tom@tromey.com>
Sat, 28 Mar 2026 23:44:54 +0000 (17:44 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 9 Apr 2026 01:12:44 +0000 (19:12 -0600)
This changes a number of error messages in gdb to use command_style.
In some places I've added double quotes around the command name for
consistency with other messages.

Approved-By: Andrew Burgess <aburgess@redhat.com>
26 files changed:
gdb/ada-exp.y
gdb/ada-tasks.c
gdb/breakpoint.c
gdb/c-exp.y
gdb/cli/cli-cmds.c
gdb/cli/cli-script.c
gdb/cli/cli-utils.c
gdb/compile/compile.c
gdb/d-exp.y
gdb/exec.c
gdb/guile/guile.c
gdb/inf-child.c
gdb/infcmd.c
gdb/maint.c
gdb/parse.c
gdb/printcmd.c
gdb/python/python.c
gdb/record-btrace.c
gdb/record.c
gdb/remote-fileio.c
gdb/remote.c
gdb/symfile-mem.c
gdb/symtab.c
gdb/target.c
gdb/testsuite/gdb.base/commands.exp
gdb/testsuite/gdb.base/default.exp

index 7c691d5a09902200c9b9285c7192f053dcb94899..0262ce74c855f77c3c68a52097469dd1ac1d1701 100644 (file)
@@ -44,6 +44,7 @@
 #include "frame.h"
 #include "block.h"
 #include "ada-exp.h"
+#include "cli/cli-style.h"
 
 #define parse_type(ps) builtin_type (ps->gdbarch ())
 
@@ -1873,7 +1874,8 @@ write_var_or_type (struct parser_state *par_state,
       if (!current_program_space->has_full_symbols ()
          && !current_program_space->has_partial_symbols ()
          && block == NULL)
-       error (_("No symbol table is loaded.  Use the \"file\" command."));
+       error (_("No symbol table is loaded.  Use the \"%ps\" command."),
+              styled_string (command_style.style (), "file"));
       if (block == par_state->expression_context_block)
        error (_("No definition of \"%s\" in current context."), name0.ptr);
       else
index 848c832785e5b514fa0c2892d1825d74bcecfd9d..6bd6600b8025bab23b60b50588fc8aa663b124dd 100644 (file)
@@ -1227,8 +1227,9 @@ info_task (struct ui_out *uiout, const char *taskno_str, struct inferior *inf)
     }
 
   if (taskno <= 0 || taskno > data->task_list.size ())
-    error (_("Task ID %d not known.  Use the \"info tasks\" command to\n"
-            "see the IDs of currently known tasks"), taskno);
+    error (_("Task ID %d not known.  Use the \"%ps\" command to\n"
+            "see the IDs of currently known tasks"),
+          taskno, styled_string (command_style.style (), "info tasks"));
   task_info = &data->task_list[taskno - 1];
 
   /* Print the Ada task ID.  */
@@ -1348,8 +1349,9 @@ task_command_1 (const char *taskno_str, int from_tty, struct inferior *inf)
   struct ada_tasks_inferior_data *data = get_ada_tasks_inferior_data (inf);
 
   if (taskno <= 0 || taskno > data->task_list.size ())
-    error (_("Task ID %d not known.  Use the \"info tasks\" command to\n"
-            "see the IDs of currently known tasks"), taskno);
+    error (_("Task ID %d not known.  Use the \"%ps\" command to\n"
+            "see the IDs of currently known tasks"),
+          taskno, styled_string (command_style.style (), "info tasks"));
   task_info = &data->task_list[taskno - 1];
 
   if (!ada_task_is_alive (task_info))
index 31811e3a5532f8fb6c8d7941e5754862ce7fbe73..55b52d6174a854a0c678c250acf5b7a426a5a910 100644 (file)
@@ -1363,8 +1363,9 @@ check_no_tracepoint_commands (struct command_line *commands)
   for (c = commands; c; c = c->next)
     {
       if (c->control_type == while_stepping_control)
-       error (_("The 'while-stepping' command can "
-                "only be used for tracepoints"));
+       error (_("The \"%ps\" command can "
+                "only be used for tracepoints"),
+              styled_string (command_style.style (), "while-stepping"));
 
       check_no_tracepoint_commands (c->body_list_0.get ());
       check_no_tracepoint_commands (c->body_list_1.get ());
@@ -1373,10 +1374,12 @@ check_no_tracepoint_commands (struct command_line *commands)
         lines and also empty lines.  So, we only need to check for
         command directly.  */
       if (strstr (c->line, "collect ") == c->line)
-       error (_("The 'collect' command can only be used for tracepoints"));
+       error (_("The \"%ps\" command can only be used for tracepoints"),
+              styled_string (command_style.style (), "collect"));
 
       if (strstr (c->line, "teval ") == c->line)
-       error (_("The 'teval' command can only be used for tracepoints"));
+       error (_("The \"%ps\" command can only be used for tracepoints"),
+              styled_string (command_style.style (), "teval"));
     }
 }
 
@@ -1482,16 +1485,22 @@ validate_commands_for_breakpoint (struct breakpoint *b,
          if (c->control_type == while_stepping_control)
            {
              if (b->type == bp_fast_tracepoint)
-               error (_("The 'while-stepping' command "
-                        "cannot be used for fast tracepoint"));
+               error (_("The \"%ps\" command "
+                        "cannot be used for fast tracepoint"),
+                      styled_string (command_style.style (),
+                                     "while-stepping"));
              else if (b->type == bp_static_tracepoint
                       || b->type == bp_static_marker_tracepoint)
-               error (_("The 'while-stepping' command "
-                        "cannot be used for static tracepoint"));
+               error (_("The \"%ps\" command "
+                        "cannot be used for static tracepoint"),
+                      styled_string (command_style.style (),
+                                     "while-stepping"));
 
              if (while_stepping)
-               error (_("The 'while-stepping' command "
-                        "can be used only once"));
+               error (_("The \"%ps\" command "
+                        "can be used only once"),
+                      styled_string (command_style.style (),
+                                     "while-stepping"));
              else
                while_stepping = c;
            }
@@ -1507,7 +1516,9 @@ validate_commands_for_breakpoint (struct breakpoint *b,
          for (; c2; c2 = c2->next)
            {
              if (c2->control_type == while_stepping_control)
-               error (_("The 'while-stepping' command cannot be nested"));
+               error (_("The \"%ps\" command cannot be nested"),
+                      styled_string (command_style.style (),
+                                     "while-stepping"));
            }
        }
     }
@@ -14365,8 +14376,9 @@ trace_pass_command (const char *args, int from_tty)
   ULONGEST count;
 
   if (args == 0 || *args == 0)
-    error (_("passcount command requires an "
-            "argument (count + optional TP num)"));
+    error (_("\"%ps\" command requires an "
+            "argument (count + optional TP num)"),
+          styled_string (command_style.style (), "passcount"));
 
   count = strtoulst (args, &args, 10); /* Count comes first, then TP num.  */
 
index a4a910df712428705dfa3385c9a62b10682dc01c..b036e13d1882dc050901eabb5b0107f07c0de737 100644 (file)
@@ -52,6 +52,7 @@
 #include "target-float.h"
 #include "c-exp.h"
 #include "macroexp.h"
+#include "cli/cli-style.h"
 
 #define parse_type(ps) builtin_type (ps->gdbarch ())
 
@@ -1203,7 +1204,9 @@ variable: name_not_typename
                                {
                                  if (!current_program_space->has_full_symbols ()
                                      && !current_program_space->has_partial_symbols ())
-                                   error (_("No symbol table is loaded.  Use the \"file\" command."));
+                                   error (_("No symbol table is loaded.  Use the \"%ps\" command."),
+                                          styled_string (command_style.style (),
+                                                         "file"));
                                  else
                                    error (_("No symbol \"%s\" in current context."),
                                           arg.c_str ());
index e58553245b3186722ecdc2a697a0263811aa3afc..761158f2ae9610eb1c5369409eeebe1e701532d0 100644 (file)
@@ -245,7 +245,8 @@ with_command_1 (const char *set_cmd_prefix,
   gdb_assert (set_cmd != nullptr);
 
   if (!set_cmd->var.has_value ())
-    error (_("Cannot use this setting with the \"with\" command"));
+    error (_("Cannot use this setting with the \"%ps\" command"),
+          styled_string (command_style.style (), "with"));
 
   std::string temp_value
     = (delim == nullptr ? args : std::string (args, delim - args));
@@ -489,7 +490,9 @@ static void
 pwd_command (const char *args, int from_tty)
 {
   if (args)
-    error (_("The \"pwd\" command does not take an argument: %s"), args);
+    error (_("The \"%ps\" command does not take an argument: %s"),
+          styled_string (command_style.style (), "pwd"),
+          args);
 
   gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0));
 
@@ -718,7 +721,8 @@ source_script_with_search (const char *file, int from_tty, int search_path)
 {
 
   if (file == NULL || *file == 0)
-    error (_("source command requires file name of file to source."));
+    error (_("\"%ps\" command requires file name of file to source."),
+          styled_string (command_style.style (), "source"));
 
   std::optional<open_script> opened = find_and_open_script (file, search_path);
   if (!opened)
@@ -1276,8 +1280,9 @@ list_command (const char *arg, int from_tty)
            print_source_lines (cursal.symtab,
                                source_lines_range (cursal.line), 0);
          else
-           error (_("End of the file was already reached, use \"list .\" to"
-                    " list the current location again"));
+           error (_("End of the file was already reached, use \"%ps\" to"
+                    " list the current location again"),
+                  styled_string (command_style.style (), "list ."));
        }
 
       /* "l -" lists previous ten lines, the ones before the ten just
@@ -1354,7 +1359,8 @@ list_command (const char *arg, int from_tty)
 
   if (!current_program_space->has_full_symbols ()
       && !current_program_space->has_partial_symbols ())
-    error (_("No symbol table is loaded.  Use the \"file\" command."));
+    error (_("No symbol table is loaded.  Use the \"%ps\" command."),
+          styled_string (command_style.style (), "file"));
 
   std::vector<symtab_and_line> sals;
   symtab_and_line sal, sal_end;
@@ -1535,7 +1541,8 @@ list_command (const char *arg, int from_tty)
     set_repeat_arguments ("");
 
   if (dummy_beg && sal_end.symtab == nullptr)
-    error (_("No default source file yet.  Do \"help list\"."));
+    error (_("No default source file yet.  Do \"%ps\"."),
+          styled_string (command_style.style (), "help list"));
   if (dummy_beg)
     {
       source_lines_range range (sal_end.line + 1,
@@ -1543,7 +1550,8 @@ list_command (const char *arg, int from_tty)
       print_source_lines (sal_end.symtab, range, 0);
     }
   else if (sal.symtab == nullptr)
-    error (_("No default source file yet.  Do \"help list\"."));
+    error (_("No default source file yet.  Do \"%ps\"."),
+          styled_string (command_style.style (), "help list"));
   else if (no_end)
     {
       for (const symtab_and_line &s : sals)
@@ -2101,7 +2109,8 @@ validate_aliased_command (const char *command)
     = lookup_cmd_1 (& command, cmdlist, NULL, &default_args, 1);
 
   if (c == NULL || c == (struct cmd_list_element *) -1)
-    error (_("Invalid command to alias to: %s"), command);
+    error (_("Invalid command to alias to: %ps"),
+          styled_string (command_style.style (), command));
 
   if (!default_args.empty ())
     error (_("Cannot define an alias of an alias that has default args"));
@@ -2199,7 +2208,8 @@ alias_command (const char *args, int from_tty)
        /* Check ALIAS differs from the found CMD.  */
 
        if (cmd->prefix == prefix_cmd && streq (alias_name, cmd->name))
-         error (_("Alias %s is the name of an existing command"), alias);
+         error (_("Alias \"%ps\" is the name of an existing command"),
+                styled_string (command_style.style (), alias));
       }
   }
 
index 253e63af570f1367ace99d258f41a3f0c6c5fd74..13ef2fb03ce1c55bba016ce06b9e3e954d51c43a 100644 (file)
@@ -160,13 +160,17 @@ build_command_line (enum command_control_type type, const char *args)
   if (args == NULL || *args == '\0')
     {
       if (type == if_control)
-       error (_("if command requires an argument."));
+       error (_("\"%ps\" command requires an argument."),
+              styled_string (command_style.style (), "if"));
       else if (type == while_control)
-       error (_("while command requires an argument."));
+       error (_("\"%ps\" command requires an argument."),
+              styled_string (command_style.style (), "while"));
       else if (type == define_control)
-       error (_("define command requires an argument."));
+       error (_("\"%ps\" command requires an argument."),
+              styled_string (command_style.style (), "define"));
       else if (type == document_control)
-       error (_("document command requires an argument."));
+       error (_("\"%ps\" command requires an argument."),
+              styled_string (command_style.style (), "document"));
     }
   gdb_assert (args != NULL);
 
@@ -1338,7 +1342,8 @@ validate_comname (const char **comname)
 
       c = lookup_cmd (&tem, cmdlist, "", NULL, 0, 1);
       if (!c->is_prefix ())
-       error (_("\"%s\" is not a prefix command."), prefix.c_str ());
+       error (_("\"%ps\" is not a prefix command."),
+              styled_string (command_style.style (), prefix.c_str ()));
 
       list = c->subcommands;
       *comname = last_word;
@@ -1411,7 +1416,8 @@ do_define_command (const char *comname, int from_tty,
       else
        q = query (_("Really redefine built-in command \"%s\"? "), c->name);
       if (!q)
-       error (_("Command \"%s\" not redefined."), c->name);
+       error (_("Command \"%ps\" not redefined."),
+              styled_string (command_style.style (), c->name));
     }
 
   /* If this new command is a hook, then mark the command which it
@@ -1520,17 +1526,21 @@ do_document_command (const char *comname, int from_tty,
 
   lookup_cmd_composition (comfull, &alias, &prefix_cmd, &c);
   if (c == nullptr)
-    error (_("Undefined command: \"%s\"."), comfull);
+    error (_("Undefined command: \"%ps\"."),
+          styled_string (command_style.style (), comfull));
   else if (c == CMD_LIST_AMBIGUOUS)
-    error (_("Ambiguous command: \"%s\"."), comfull);
+    error (_("Ambiguous command: \"%ps\"."),
+          styled_string (command_style.style (), comfull));
 
   if (c->theclass != class_user
       && (alias == nullptr || alias->theclass != class_alias))
     {
       if (alias == nullptr)
-       error (_("Command \"%s\" is built-in."), comfull);
+       error (_("Command \"%ps\" is built-in."),
+              styled_string (command_style.style (), comfull));
       else
-       error (_("Alias \"%s\" is built-in."), comfull);
+       error (_("Alias \"%ps\" is built-in."),
+              styled_string (command_style.style (), comfull));
     }
 
   /* If we found an alias of class_alias, the user is documenting this
@@ -1595,7 +1605,8 @@ define_prefix_command (const char *comname, int from_tty)
   c = lookup_cmd_exact (comname, *list);
 
   if (c != nullptr && c->theclass != class_user)
-    error (_("Command \"%s\" is built-in."), comfull);
+    error (_("Command \"%ps\" is built-in."),
+          styled_string (command_style.style (), comfull));
 
   if (c != nullptr && c->is_prefix ())
     {
index 347e2918dfeeeb686729ca43de63a63a93de046a..18f112c1aadd79321136609f5fcbc9cc738bae83 100644 (file)
@@ -17,7 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "cli/cli-style.h"
 #include "cli/cli-utils.h"
+#include "ui-out.h"
 #include "value.h"
 
 
@@ -183,9 +185,11 @@ report_unrecognized_option_error (const char *command, const char *args)
 {
   std::string option = extract_arg (&args);
 
-  error (_("Unrecognized option '%s' to %s command.  "
-          "Try \"help %s\"."), option.c_str (),
-        command, command);
+  error (_("Unrecognized option '%s' to \"%ps\" command.  "
+          "Try \"%p[help %s%p]\"."),
+        option.c_str (),
+        styled_string (command_style.style (), command),
+        command_style.style ().ptr (), command, nullptr);
 }
 
 /* See documentation in cli-utils.h.  */
@@ -434,5 +438,6 @@ void
 validate_flags_qcs (const char *which_command, qcs_flags *flags)
 {
   if (flags->cont && flags->silent)
-    error (_("%s: -c and -s are mutually exclusive"), which_command);
+    error (_("%ps: -c and -s are mutually exclusive"),
+          styled_string (command_style.style (), which_command));
 }
index a64297bcbe1c4ca596c147b346dd84914df925f5..c0b548fefd8f60c11e9b9e08407be2d59761445c 100644 (file)
@@ -22,6 +22,7 @@
 #include "ui-out.h"
 #include "command.h"
 #include "cli/cli-script.h"
+#include "cli/cli-style.h"
 #include "cli/cli-utils.h"
 #include "cli/cli-option.h"
 #include "completer.h"
@@ -630,8 +631,9 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
   if (!compile_gcc.empty ())
     {
       if (compiler->version () < GCC_FE_VERSION_1)
-       error (_("Command 'set compile-gcc' requires GCC version 6 or higher "
-                "(libcc1 interface version 1 or higher)"));
+       error (_("Command \"%ps\" requires GCC version 6 or higher "
+                "(libcc1 interface version 1 or higher)"),
+              styled_string (command_style.style (), "set compile-gcc"));
 
       compiler->set_driver_filename (compile_gcc.c_str ());
     }
index a3b1b507ef9bdc10872a8b3dc4e14572a6eaacc4..1031eb1eccac8bbc3992bce30a6bb90177d297d6 100644 (file)
@@ -48,6 +48,7 @@
 #include "block.h"
 #include "type-stack.h"
 #include "expop.h"
+#include "cli/cli-style.h"
 
 #define parse_type(ps) builtin_type (ps->gdbarch ())
 #define parse_d_type(ps) builtin_d_type (ps->gdbarch ())
@@ -468,7 +469,8 @@ PrimaryExpression:
                        pstate->push_new<var_msym_value_operation> (msymbol);
                      else if (!current_program_space->has_full_symbols ()
                               && !current_program_space->has_partial_symbols ())
-                       error (_("No symbol table is loaded.  Use the \"file\" command"));
+                       error (_("No symbol table is loaded.  Use the \"%ps\" command"),
+                              styled_string (command_style.style (), "file"));
                      else
                        error (_("No symbol \"%s\" in current context."),
                               copy.c_str ());
index 0ad3944004dc8ab13f4e0bd84ce52ce12081eaf0..b1b2d2d190df45e6b44277be3ff47a0b8dcf5045 100644 (file)
@@ -524,7 +524,9 @@ void
 no_executable_specified_error ()
 {
   error (_("No executable file specified.\n\
-Use the \"file\" or \"exec-file\" command."));
+Use the \"%ps\" or \"%ps\" command."),
+        styled_string (command_style.style (), "file"),
+        styled_string (command_style.style (), "exec-file"));
 }
 
 /*  Process the first arg in ARGS as the new exec file.
index 3e876f9386be819e2f67fa544de982985dd2a9bc..ec5f6d0895119d720bf41e31def6e73c4d74190a 100644 (file)
@@ -23,6 +23,7 @@
 #include "breakpoint.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-script.h"
+#include "cli/cli-style.h"
 #include "cli/cli-utils.h"
 #include "command.h"
 #include "top.h"
@@ -256,7 +257,8 @@ gdbscm_eval_from_control_command
   char *script;
 
   if (cmd->body_list_1 != nullptr)
-    error (_("Invalid \"guile\" block structure."));
+    error (_("Invalid \"%ps\" block structure."),
+          styled_string (command_style.style (), "guile"));
 
   script = compute_scheme_string (cmd->body_list_0.get ());
   gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_eval_string (script, 0);
index 7983ecb0d923b2668a6c6c426ee739342d1c392c..a87aa925133959487accfd26d8e7b3bda73f5562 100644 (file)
@@ -171,7 +171,8 @@ void
 inf_child_target::disconnect (const char *args, int from_tty)
 {
   if (args != NULL)
-    error (_("Argument given to \"disconnect\"."));
+    error (_("Argument given to \"%ps\"."),
+          styled_string (command_style.style (), "disconnect"));
 
   /* This offers to detach/kill current inferiors, and then pops all
      targets.  */
index b51d2e64f801e50f5ca2964ce0c69856352c2dc9..fa7b273ae57f74276f957f75b01890613690b829 100644 (file)
@@ -1950,11 +1950,13 @@ finish_command (const char *arg, int from_tty)
   prepare_execution_command (current_inferior ()->top_target (), async_exec);
 
   if (arg)
-    error (_("The \"finish\" command does not take any arguments."));
+    error (_("The \"%ps\" command does not take any arguments."),
+          styled_string (command_style.style (), "finish"));
 
   frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
   if (frame == 0)
-    error (_("\"finish\" not meaningful in the outermost frame."));
+    error (_("\"%ps\" not meaningful in the outermost frame."),
+          styled_string (command_style.style (), "finish"));
 
   clear_proceed_status (0);
 
index b29da2b48f8e9bfcbfcab6a94df6e607193f69ea..1daa6ce1d2e02a2765568cbebc6d28866104952e 100644 (file)
@@ -1141,7 +1141,8 @@ set_per_command_cmd (const char *args, int from_tty)
 
   val = parse_cli_boolean_value (args);
   if (val < 0)
-    error (_("Bad value for 'mt set per-command no'."));
+    error (_("Bad value for \"%ps\"."),
+          styled_string (command_style.style (), "mt set per-command no"));
 
   for (list = per_command_setlist; list != NULL; list = list->next)
     if (list->var->type () == var_boolean)
index 9769150a13489f1d51179c1146a27d5291f2c06c..fd190d6e15e71a52e85325c917687a5ad3ce7020 100644 (file)
@@ -39,6 +39,7 @@
 #include "language.h"
 #include "parser-defs.h"
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 #include "symfile.h"
 #include "inferior.h"
 #include "target-float.h"
@@ -150,7 +151,8 @@ parser_state::push_symbol (const char *name, block_symbol sym)
        push_new<expr::var_msym_value_operation> (msymbol);
       else if (!current_program_space->has_full_symbols ()
               && !current_program_space->has_partial_symbols ())
-       error (_("No symbol table is loaded.  Use the \"file\" command."));
+       error (_("No symbol table is loaded.  Use the \"%ps\" command."),
+              styled_string (command_style.style (), "file"));
       else
        error (_("No symbol \"%s\" in current context."), name);
     }
index 38a2e231d88faa66adb4ccc9c7323ccd9ed6798f..ae4983954362588184b3780921f73ae97cc6867f 100644 (file)
@@ -1232,13 +1232,14 @@ static void
 validate_format (struct format_data fmt, const char *cmdname)
 {
   if (fmt.size != 0)
-    error (_("Size letters are meaningless in \"%s\" command."), cmdname);
+    error (_("Size letters are meaningless in \"%ps\" command."),
+          styled_string (command_style.style (), cmdname));
   if (fmt.count != 1)
-    error (_("Item count other than 1 is meaningless in \"%s\" command."),
-          cmdname);
+    error (_("Item count other than 1 is meaningless in \"%ps\" command."),
+          styled_string (command_style.style (), cmdname));
   if (fmt.format == 'i')
-    error (_("Format letter \"%c\" is meaningless in \"%s\" command."),
-          fmt.format, cmdname);
+    error (_("Format letter \"%c\" is meaningless in \"%ps\" command."),
+          fmt.format, styled_string (command_style.style (), cmdname));
 }
 
 /* Parse print command format string into *OPTS and update *EXPP.
index 4182c699cb5d193582221278110bd7f2417f0c24..502fe682b2c3f27c0bf0826149fde10324ec57d6 100644 (file)
@@ -452,7 +452,8 @@ gdbpy_eval_from_control_command (const struct extension_language_defn *extlang,
                                 struct command_line *cmd)
 {
   if (cmd->body_list_1 != nullptr)
-    error (_("Invalid \"python\" block structure."));
+    error (_("Invalid \"%ps\" block structure."),
+          styled_string (command_style.style (), "python"));
 
   gdbpy_enter enter_py;
 
index d12d861614029b978f025d7299d2daa7b60a7620..b4f1dcc3dea812bf93d7ae4d769bd876b98bdfd6 100644 (file)
@@ -3035,7 +3035,9 @@ cmd_set_record_btrace_cpu (const char *args, int from_tty)
       stepping = 0;
     }
   else
-    error (_("Bad format.  See \"help set record btrace cpu\"."));
+    error (_("Bad format.  See \"%ps\"."),
+          styled_string (command_style.style (),
+                         "help set record btrace cpu"));
 
   if (USHRT_MAX < family)
     error (_("Cpu family too big."));
index c01a1fd2bcf14684c5418ad6b1de4e8bc31f8143..35f9f0eb1e4ba419b4e1e20c8ca62f19409e8f13 100644 (file)
@@ -23,6 +23,7 @@
 #include "observable.h"
 #include "inferior.h"
 #include "gdbsupport/common-utils.h"
+#include "cli/cli-style.h"
 #include "cli/cli-utils.h"
 #include "disasm.h"
 #include "interps.h"
@@ -87,8 +88,9 @@ record_preopen (void)
 {
   /* Check if a record target is already running.  */
   if (find_record_target () != NULL)
-    error (_("The process is already being recorded.  Use \"record stop\" to "
-            "stop recording first."));
+    error (_("The process is already being recorded.  Use \"%ps\" to "
+            "stop recording first."),
+          styled_string (command_style.style (), "record stop"));
 }
 
 /* See record.h.  */
index 0b56e1ddca9350d0cfd6aec4726911867464bbe6..ef608cabfab33b9cb120d418e0414dafa344b36d 100644 (file)
@@ -22,6 +22,7 @@
 #include "event-top.h"
 #include "extract-store-integer.h"
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 #include "remote.h"
 #include "gdbsupport/gdb_wait.h"
 #include <sys/stat.h>
@@ -1226,15 +1227,19 @@ set_system_call_allowed (const char *args, int from_tty)
          return;
        }
     }
-  error (_("Illegal argument for \"set remote system-call-allowed\" command"));
+  error (_("Illegal argument for \"%ps\" command"),
+        styled_string (command_style.style (),
+                       "set remote system-call-allowed"));
 }
 
 static void
 show_system_call_allowed (const char *args, int from_tty)
 {
   if (args)
-    error (_("Garbage after \"show remote "
-            "system-call-allowed\" command: `%s'"), args);
+    error (_("Garbage after \"%ps\" command: `%s'"),
+          styled_string (command_style.style (),
+                         "show remote system-call-allowed"),
+          args);
   gdb_printf ("Calling host system(3) call from target is %sallowed\n",
              remote_fio_system_call_allowed ? "" : "not ");
 }
index c2555d528fa8a62806b021dfcd208637e81bac06..914a7a7823cc2349cb12fb37d36be9d0052c2807 100644 (file)
@@ -7049,7 +7049,8 @@ void
 remote_target::disconnect (const char *args, int from_tty)
 {
   if (args)
-    error (_("Argument given to \"disconnect\" when remotely debugging."));
+    error (_("Argument given to \"%ps\" when remotely debugging."),
+          styled_string (command_style.style (), "disconnect"));
 
   /* Make sure we unpush even the extended remote targets.  Calling
      target_mourn_inferior won't unpush, and
@@ -11558,9 +11559,15 @@ Remote replied unexpectedly while setting startup-with-shell: %s"),
       /* vRun was not supported.  Fail if we need it to do what the
         user requested.  */
       if (remote_exec_file[0])
-       error (_("Remote target does not support \"set remote exec-file\""));
+       error (_("Remote target does not support \"%ps\""),
+              styled_string (command_style.style (),
+                             "set remote exec-file"));
       if (!args.empty ())
-       error (_("Remote target does not support \"set args\" or run ARGS"));
+       error (_("Remote target does not support \"%ps\" or \"%ps\""),
+              styled_string (command_style.style (),
+                             "set args"),
+              styled_string (command_style.style (),
+                             "run ARGS"));
 
       /* Fall back to "R".  */
       extended_remote_restart ();
@@ -12606,7 +12613,9 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf)
 
   if ((strlen (rs->buf.data ()) + strlen (command) * 2 + 8/*misc*/)
       > get_remote_packet_size ())
-    error (_("\"monitor\" command ``%s'' is too long."), command);
+    error (_("\"%ps\" command ``%s'' is too long."),
+          styled_string (command_style.style (), "monitor"),
+          command);
 
   /* Encode the actual command.  */
   bin2hex ((const gdb_byte *) command, p, strlen (command));
index b749c90afd206b005d35b9d9fe53bed3d759bf50..941292d3128a430e2bc420882a89a11f75b1b7ed 100644 (file)
@@ -54,6 +54,7 @@
 #include "elf/common.h"
 #include "gdb_bfd.h"
 #include "inferior.h"
+#include "cli/cli-style.h"
 
 /* Verify parameters of target_read_memory_bfd and target_read_memory are
    compatible.  */
@@ -91,7 +92,9 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
   symfile_add_flags add_flags = SYMFILE_NOT_FILENAME;
 
   if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
-    error (_("add-symbol-file-from-memory not supported for this target"));
+    error (_("\"%ps\" not supported for this target"),
+          styled_string (command_style.style (),
+                         "add-symbol-file-from-memory"));
 
   nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, size, &loadbase,
                                         target_read_memory_bfd);
@@ -138,7 +141,9 @@ add_symbol_file_from_memory_command (const char *args, int from_tty)
   struct bfd *templ;
 
   if (args == NULL)
-    error (_("add-symbol-file-from-memory requires an expression argument"));
+    error (_("\"%ps\" requires an expression argument"),
+          styled_string (command_style.style (),
+                         "add-symbol-file-from-memory"));
 
   addr = parse_and_eval_address (args);
 
@@ -148,8 +153,11 @@ add_symbol_file_from_memory_command (const char *args, int from_tty)
   else
     templ = current_program_space->exec_bfd ();
   if (templ == NULL)
-    error (_("Must use symbol-file or exec-file "
-            "before add-symbol-file-from-memory."));
+    error (_("Must use \"%ps\" or \"%ps\" before \"%ps\"."),
+          styled_string (command_style.style (), "symbol-file"),
+          styled_string (command_style.style (), "exec-file"),
+          styled_string (command_style.style (),
+                         "add-symbol-file-from-memory"));
 
   symbol_file_add_from_memory (templ, addr, 0, NULL, from_tty);
 }
index e02744331c63a7d1b9a313919182c138d3aefc0f..a6b145e5331ba8921ce0a2e7959576d3aab2b595 100644 (file)
@@ -4541,7 +4541,8 @@ info_sources_command (const char *args, int from_tty)
 {
   if (!current_program_space->has_full_symbols ()
       && !current_program_space->has_partial_symbols ())
-    error (_("No symbol table is loaded.  Use the \"file\" command."));
+    error (_("No symbol table is loaded.  Use the \"%ps\" command."),
+          styled_string (command_style.style (), "file"));
 
   filename_partial_match_opts match_opts;
   auto group = make_info_sources_options_def_group (&match_opts);
index b38a0536525f065a3dadfaf4af42d5bf2effe623..99e9770d5a86414aff360402cdb81615465d6d65 100644 (file)
@@ -2899,7 +2899,9 @@ find_default_run_target (const char *do_mesg)
     return the_native_target;
 
   if (do_mesg != NULL)
-    error (_("Don't know how to %s.  Try \"help target\"."), do_mesg);
+    error (_("Don't know how to %s.  Try \"%ps\"."),
+          do_mesg,
+          styled_string (command_style.style (), "help target"));
   return NULL;
 }
 
@@ -4245,7 +4247,8 @@ static void
 default_rcmd (struct target_ops *self, const char *command,
              struct ui_file *output)
 {
-  error (_("\"monitor\" command not supported by this target."));
+  error (_("\"%ps\" command not supported by this target."),
+        styled_string (command_style.style (), "monitor"));
 }
 
 static void
index 77da367b2accc39b32f6b2f4b6d59e59be449abd..b8b44d8f874f4fb52c64025def2f4c44979fb876 100644 (file)
@@ -1108,7 +1108,8 @@ proc define_if_without_arg_test {} {
            }
        }
 
-       gdb_test "$cmd" "$cmd command requires an argument." "type $cmd without args"
+       gdb_test "$cmd" "\"$cmd\" command requires an argument." \
+           "type $cmd without args"
     }
 }
 
index 5917181effb64917dd6d5bbc4802de9b524d71a2..002f6354e7aeaddb8d047bbe1ed0e8f92df0a640 100644 (file)
@@ -951,7 +951,7 @@ gdb_test "stepi" "The program is not being run."
 #test signal
 gdb_test "signal" "The program is not being run."
 #test source
-gdb_test "source" "source command requires file name of file to source..*|No such file or directory.*"
+gdb_test "source" "\"source\" command requires file name of file to source..*|No such file or directory.*"
 #test step "s" abbreviation
 gdb_test "s" "The program is not being run." "step \"s\" abbreviation #2"
 #test step