From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YYKwK8FH0mnfgAgAWB0awg (envelope-from ) for ; Sun, 05 Apr 2026 07:30:09 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=c6DzL4kF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id ADD931E04F; Sun, 05 Apr 2026 07:30:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B9B221E04F for ; Sun, 05 Apr 2026 07:30:07 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D70754BA2E27 for ; Sun, 5 Apr 2026 11:30:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D70754BA2E27 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=c6DzL4kF Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 591C64BA2E25 for ; Sun, 5 Apr 2026 11:28:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 591C64BA2E25 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 591C64BA2E25 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775388521; cv=none; b=d6gBM6SUqK9Xyw9+7qkIMkUxKI9Cl8YzF4zqHSTwCVlQVYB44Uw4CleaeuS+L/yfRxo/DXx1yipBxE27zx4FqvPquRfvB+cYHle7UrvsAjvhkAcVv+UDhciZq54IugkqCuSFqlegkkv8NjrsId0cJYft3PbHc+V54vpRknW60Fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775388521; c=relaxed/simple; bh=BHP+FQm4HEHBD7KbSzRCYJy4Y+sSeQfYvO/RS4WCdEs=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=jOmqAZbIzSjMPueH8ygPyLq8T2CEvDDkogUiykNGJL6wZ67EHnMAfuYJVNc+AdK4Wli+PzEA5qmfjjdnMQO8Fz9oriUEzkI1eLbm51TsDpT9pil38b/cN5cWv136cuAocjhuY2ELaLgsrdHebQS5ygCSuzIHZVBK6nsLbuj65fU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 591C64BA2E25 Received: from eig-obgw-5005b.ext.cloudfilter.net ([10.0.29.189]) by cmsmtp with ESMTPS id 9CW7wtZs9c9KC9LejwWhwv; Sun, 05 Apr 2026 11:28:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 9LefwTV4wTFL79LegwbZpb; Sun, 05 Apr 2026 11:28:38 +0000 X-Authority-Analysis: v=2.4 cv=euTfzppX c=1 sm=1 tr=0 ts=69d24767 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=ItBw4LHWJt0A:10 a=mDV3o1hIAAAA:8 a=5ZulIorQxer3hDOjaloA:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=HSf2pcoMbsG4MVPbbSCwzabf01KBUqUvrnj8nD6dqqA=; b=c6DzL4kFxz3n6NpHs7dvbXo/KK HuOOFy7HvjD24VO9a5kI5CGR0J1FBYvu//sFy7iUFiVEnCeNjxapeJVxp2ujhBRLlPckaRxKdFzdu +ytZA/30HesYjuBqHezhct61+; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:42722 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w9Lef-00000001QMu-2v8h; Sun, 05 Apr 2026 05:28:37 -0600 From: Tom Tromey Date: Sun, 05 Apr 2026 05:28:38 -0600 Subject: [PATCH 1/4] Add command styling to error messages MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260405-more-error-style-v1-1-6c04da718875@tromey.com> References: <20260405-more-error-style-v1-0-6c04da718875@tromey.com> In-Reply-To: <20260405-more-error-style-v1-0-6c04da718875@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.225.82 X-Source-L: No X-Exim-ID: 1w9Lef-00000001QMu-2v8h X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net ([192.168.122.1]) [75.166.225.82]:42722 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEyp85sftEI1K0ZjAYHzH3KG6qNMUPV0gnoOTOPALiK+elTBBt5btMtvT24/gYeIJyrIYyOPxJDm2d01vE9omhfM7FiqcQ893vBBKowGhJWa3hQ9JLKe pz7M/+La514GtGcipwyU4+dhOa9ng4Zuimqker8GNRBdfe2Z17LAYtMmxpguPNraLStPYCMaPhob6EJvOe7JV/mUfjf3F9CYRVA= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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. --- gdb/ada-exp.y | 4 +++- gdb/ada-tasks.c | 10 ++++++---- gdb/breakpoint.c | 38 ++++++++++++++++++++++++------------- gdb/c-exp.y | 5 ++++- gdb/cli/cli-cmds.c | 30 +++++++++++++++++++---------- gdb/cli/cli-script.c | 33 +++++++++++++++++++++----------- gdb/cli/cli-utils.c | 13 +++++++++---- gdb/compile/compile.c | 6 ++++-- gdb/d-exp.y | 4 +++- gdb/exec.c | 4 +++- gdb/guile/guile.c | 4 +++- gdb/inf-child.c | 3 ++- gdb/infcmd.c | 6 ++++-- gdb/maint.c | 3 ++- gdb/parse.c | 4 +++- gdb/printcmd.c | 11 ++++++----- gdb/python/python.c | 3 ++- gdb/record-btrace.c | 4 +++- gdb/record.c | 6 ++++-- gdb/remote-fileio.c | 11 ++++++++--- gdb/remote.c | 17 +++++++++++++---- gdb/symfile-mem.c | 16 ++++++++++++---- gdb/symtab.c | 3 ++- gdb/target.c | 7 +++++-- gdb/testsuite/gdb.base/commands.exp | 3 ++- gdb/testsuite/gdb.base/default.exp | 2 +- 26 files changed, 171 insertions(+), 79 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 7c691d5a099..0262ce74c85 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -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 diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 848c832785e..6bd6600b802 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -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)) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index d7be1b44229..fdff6e8fc94 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -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-steppinge")); 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")); } } } @@ -14363,8 +14374,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. */ diff --git a/gdb/c-exp.y b/gdb/c-exp.y index a4a910df712..b036e13d188 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -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 ()); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index e58553245b3..761158f2ae9 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -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 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 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 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)); } } diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 253e63af570..13ef2fb03ce 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -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 ()) { diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index 347e2918dfe..18f112c1aad 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -17,7 +17,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#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)); } diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index a64297bcbe1..c0b548fefd8 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -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 ()); } diff --git a/gdb/d-exp.y b/gdb/d-exp.y index a3b1b507ef9..1031eb1ecca 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -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 (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 ()); diff --git a/gdb/exec.c b/gdb/exec.c index 0ad3944004d..b1b2d2d190d 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -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. diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 3e876f9386b..ec5f6d08951 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -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 msg = gdbscm_safe_eval_string (script, 0); diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 7983ecb0d92..a87aa925133 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -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. */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 98b45f884b1..7bb9e1a22eb 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1949,11 +1949,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); diff --git a/gdb/maint.c b/gdb/maint.c index b29da2b48f8..1daa6ce1d2e 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -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) diff --git a/gdb/parse.c b/gdb/parse.c index 9769150a134..fd190d6e15e 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -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 (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); } diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 38a2e231d88..ae498395436 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -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. diff --git a/gdb/python/python.c b/gdb/python/python.c index 6e13ab5bb3f..f981817f0be 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -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; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index bded22af8e6..90a6346a467 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -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.")); diff --git a/gdb/record.c b/gdb/record.c index c01a1fd2bcf..35f9f0eb1e4 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -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. */ diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 0b56e1ddca9..ef608cabfab 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -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 @@ -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 "); } diff --git a/gdb/remote.c b/gdb/remote.c index 3ec56a6d61b..23ef6145620 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7038,7 +7038,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 @@ -11546,9 +11547,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 (); @@ -12594,7 +12601,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)); diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index b749c90afd2..941292d3128 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -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); } diff --git a/gdb/symtab.c b/gdb/symtab.c index e02744331c6..a6b145e5331 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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); diff --git a/gdb/target.c b/gdb/target.c index 359618e800f..60c04b04b01 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -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; } @@ -4244,7 +4246,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 diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index 77da367b2ac..b8b44d8f874 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -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" } } diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 5917181effb..002f6354e7a 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -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 -- 2.49.0