error (_("Argument required (%s)."), why);
}
-/* The "info" command is defined as a prefix, with allow_unknown = 0.
- Therefore, its own definition is called only for "info" with no
- args. */
+/* This implements the "info" prefix command. Normally such commands
+ are automatically handled by add_basic_prefix_cmd, but in this case
+ a separate command is used so that it can be hooked into by
+ gdb-gdb.gdb. */
static void
info_command (const char *arg, int from_tty)
{
- printf_unfiltered (_("\"info\" must be followed by "
- "the name of an info command.\n"));
help_list (infolist, "info ", all_commands, gdb_stdout);
}
-/* The "show" command with no arguments shows all the settings. */
-
-static void
-show_command (const char *arg, int from_tty)
-{
- cmd_show_list (showlist, from_tty, "");
-}
-
/* See cli/cli-cmds.h. */
void
/* Make sure to return to the directory GDB thinks it is, in case
the shell command we just ran changed it. */
chdir (current_directory);
- exit_status_set_internal_vars (rc);
#endif
+ exit_status_set_internal_vars (rc);
#else /* Can fork. */
int status, pid;
error (_("No source file for address %s."),
paddress (get_current_arch (), sal.pc));
- gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab));
+ gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
error (_("No source file for address %s."),
paddress (get_current_arch (), sal.pc));
- gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab));
+ gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
/* ALIAS must not exist. */
std::string alias_string (argv_to_string (alias_argv, alias_argc));
alias = alias_string.c_str ();
- if (valid_command_p (alias))
- error (_("Alias already exists: %s"), alias);
+ {
+ cmd_list_element *alias_cmd, *prefix_cmd, *cmd;
+
+ if (lookup_cmd_composition (alias, &alias_cmd, &prefix_cmd, &cmd))
+ {
+ const char *alias_name = alias_argv[alias_argc-1];
+
+ /* If we found an existing ALIAS_CMD, check that the prefix differ or
+ the name differ. */
+
+ if (alias_cmd != nullptr
+ && alias_cmd->prefix == prefix_cmd
+ && strcmp (alias_name, alias_cmd->name) == 0)
+ error (_("Alias already exists: %s"), alias);
+
+ /* Check ALIAS differs from the found CMD. */
+
+ if (cmd->prefix == prefix_cmd
+ && strcmp (alias_name, cmd->name) == 0)
+ error (_("Alias %s is the name of an existing command"), alias);
+ }
+ }
+
/* If ALIAS is one word, it is an alias for the entire COMMAND.
Example: alias spe = set print elements
sals.erase (from, sals.end ());
}
-static void
-set_debug (const char *arg, int from_tty)
-{
- printf_unfiltered (_("\"set debug\" must be followed by "
- "the name of a debug subcommand.\n"));
- help_list (setdebuglist, "set debug ", all_commands, gdb_stdout);
-}
-
-static void
-show_debug (const char *args, int from_tty)
-{
- cmd_show_list (showdebuglist, from_tty, "");
-}
-
void
init_cmd_lists (void)
{
struct type *type0 = check_typedef (value_type (argv[0]));
- if (TYPE_CODE (type0) != TYPE_CODE_ARRAY
- && TYPE_CODE (type0) != TYPE_CODE_STRING)
+ if (type0->code () != TYPE_CODE_ARRAY
+ && type0->code () != TYPE_CODE_STRING)
error (_("First argument of %s must be a string."), fnname);
const char *a0 = (const char *) value_contents (argv[0]);
gdbarch);
}
+void _initialize_cli_cmds ();
void
-_initialize_cli_cmds (void)
+_initialize_cli_cmds ()
{
struct cmd_list_element *c;
When the program being debugged stops, gdb selects the innermost frame.\n\
The commands below can be used to select other frames by number or address."),
&cmdlist);
+#ifdef TUI
+ add_cmd ("text-user-interface", class_tui,
+ _("TUI is the GDB text based interface.\n\
+In TUI mode, GDB can display several text windows showing\n\
+the source file, the processor registers, the program disassembly, ..."), &cmdlist);
+#endif
add_cmd ("running", class_run, _("Running the program."), &cmdlist);
/* Define general commands. */
show_info_verbose,
&setlist, &showlist);
- add_prefix_cmd ("history", class_support, set_history,
- _("Generic command for setting command history parameters."),
- &sethistlist, "set history ", 0, &setlist);
- add_prefix_cmd ("history", class_support, show_history,
- _("Generic command for showing command history parameters."),
- &showhistlist, "show history ", 0, &showlist);
+ add_basic_prefix_cmd ("history", class_support, _("\
+Generic command for setting command history parameters."),
+ &sethistlist, "set history ", 0, &setlist);
+ add_show_prefix_cmd ("history", class_support, _("\
+Generic command for showing command history parameters."),
+ &showhistlist, "show history ", 0, &showlist);
add_setshow_boolean_cmd ("expansion", no_class, &history_expansion_p, _("\
Set history expansion on command input."), _("\
add_com ("complete", class_obscure, complete_command,
_("List the completions for the rest of the line as a command."));
- add_prefix_cmd ("show", class_info, show_command, _("\
+ c = add_show_prefix_cmd ("show", class_info, _("\
Generic command for showing things about the debugger."),
- &showlist, "show ", 0, &cmdlist);
+ &showlist, "show ", 0, &cmdlist);
/* Another way to get at the same thing. */
- add_info ("set", show_command, _("Show all GDB settings."));
+ add_alias_cmd ("set", c, class_info, 0, &infolist);
c = add_com ("with", class_vars, with_command, _("\
Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.\n\
show_remote_timeout,
&setlist, &showlist);
- add_prefix_cmd ("debug", no_class, set_debug,
- _("Generic command for setting gdb debugging flags."),
- &setdebuglist, "set debug ", 0, &setlist);
+ add_basic_prefix_cmd ("debug", no_class,
+ _("Generic command for setting gdb debugging flags."),
+ &setdebuglist, "set debug ", 0, &setlist);
- add_prefix_cmd ("debug", no_class, show_debug,
- _("Generic command for showing gdb debugging flags."),
- &showdebuglist, "show debug ", 0, &showlist);
+ add_show_prefix_cmd ("debug", no_class,
+ _("Generic command for showing gdb debugging flags."),
+ &showdebuglist, "show debug ", 0, &showlist);
c = add_com ("shell", class_support, shell_command, _("\
Execute the rest of the line as a shell command.\n\
ALIAS is the name of the alias command to create.\n\
COMMAND is the command being aliased to.\n\
If \"-a\" is specified, the command is an abbreviation,\n\
-and will not appear in help command list output.\n\
+and will not be used in command completion.\n\
\n\
Examples:\n\
Make \"spe\" an alias of \"set print elements\":\n\