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>
#include "frame.h"
#include "block.h"
#include "ada-exp.h"
+#include "cli/cli-style.h"
#define parse_type(ps) builtin_type (ps->gdbarch ())
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
}
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. */
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))
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 ());
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"));
}
}
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;
}
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"));
}
}
}
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. */
#include "target-float.h"
#include "c-exp.h"
#include "macroexp.h"
+#include "cli/cli-style.h"
#define parse_type(ps) builtin_type (ps->gdbarch ())
{
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 ());
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));
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));
{
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)
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
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;
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,
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)
= 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"));
/* 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));
}
}
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);
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;
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
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
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 ())
{
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"
{
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. */
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));
}
#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"
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 ());
}
#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 ())
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 ());
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.
#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"
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);
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. */
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);
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)
#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"
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);
}
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.
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;
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."));
#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"
{
/* 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. */
#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>
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 ");
}
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
/* 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 ();
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));
#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. */
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);
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);
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);
}
{
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);
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;
}
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
}
}
- gdb_test "$cmd" "$cmd command requires an argument." "type $cmd without args"
+ gdb_test "$cmd" "\"$cmd\" command requires an argument." \
+ "type $cmd without args"
}
}
#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