* command.h: Comment clean-up.
* cli/cli-cmds.c: Ditto.
* cli/cli-cmds.h: Ditto.
* cli/cli-decode.c: Ditto.
* cli/cli-decode.h: Ditto.
* cli/cli-dump.c: Ditto.
* cli/cli-interp.c: Ditto.
* cli/cli-logging.c: Ditto.
* cli/cli-script.c: Ditto.
* cli/cli-setshow.c: Ditto.
* cli/cli-setshow.h: Ditto.
+2010-12-28 Michael Snyder <msnyder@vmware.com>
+
+ * command.h: Comment clean-up.
+ * cli/cli-cmds.c: Ditto.
+ * cli/cli-cmds.h: Ditto.
+ * cli/cli-decode.c: Ditto.
+ * cli/cli-decode.h: Ditto.
+ * cli/cli-dump.c: Ditto.
+ * cli/cli-interp.c: Ditto.
+ * cli/cli-logging.c: Ditto.
+ * cli/cli-script.c: Ditto.
+ * cli/cli-setshow.c: Ditto.
+ * cli/cli-setshow.h: Ditto.
+
2010-12-28 Michael Snyder <msnyder@vmware.com>
* event-loop.c: Comment clean-up.
#include "readline/readline.h"
#include "readline/tilde.h"
#include "completer.h"
-#include "target.h" /* For baud_rate, remote_debug and remote_timeout */
-#include "gdb_wait.h" /* For shell escape implementation */
-#include "gdb_regex.h" /* Used by apropos_command */
+#include "target.h" /* For baud_rate, remote_debug and remote_timeout. */
+#include "gdb_wait.h" /* For shell escape implementation. */
+#include "gdb_regex.h" /* Used by apropos_command. */
#include "gdb_string.h"
#include "gdb_vfork.h"
#include "linespec.h"
#include "frame.h"
#include "value.h"
#include "language.h"
-#include "filenames.h" /* for DOSish file names */
+#include "filenames.h" /* For DOSish file names. */
#include "objfiles.h"
#include "source.h"
#include "disasm.h"
#include "python/python.h"
#ifdef TUI
-#include "tui/tui.h" /* For tui_active et.al. */
+#include "tui/tui.h" /* For tui_active et.al. */
#endif
#include <fcntl.h>
struct cmd_list_element *infolist;
-/* Chain containing all defined enable subcommands. */
+/* Chain containing all defined enable subcommands. */
struct cmd_list_element *enablelist;
-/* Chain containing all defined disable subcommands. */
+/* Chain containing all defined disable subcommands. */
struct cmd_list_element *disablelist;
-/* Chain containing all defined toggle subcommands. */
+/* Chain containing all defined toggle subcommands. */
struct cmd_list_element *togglelist;
-/* Chain containing all defined stop subcommands. */
+/* Chain containing all defined stop subcommands. */
struct cmd_list_element *stoplist;
-/* Chain containing all defined delete subcommands. */
+/* Chain containing all defined delete subcommands. */
struct cmd_list_element *deletelist;
-/* Chain containing all defined detach subcommands. */
+/* Chain containing all defined detach subcommands. */
struct cmd_list_element *detachlist;
-/* Chain containing all defined kill subcommands. */
+/* Chain containing all defined kill subcommands. */
struct cmd_list_element *killlist;
-/* Chain containing all defined "enable breakpoint" subcommands. */
+/* Chain containing all defined "enable breakpoint" subcommands. */
struct cmd_list_element *enablebreaklist;
struct cmd_list_element *unsethistlist;
-/* Chain containing all defined maintenance subcommands. */
+/* Chain containing all defined maintenance subcommands. */
struct cmd_list_element *maintenancelist;
-/* Chain containing all defined "maintenance info" subcommands. */
+/* Chain containing all defined "maintenance info" subcommands. */
struct cmd_list_element *maintenanceinfolist;
-/* Chain containing all defined "maintenance print" subcommands. */
+/* Chain containing all defined "maintenance print" subcommands. */
struct cmd_list_element *maintenanceprintlist;
static const char *script_ext_mode = script_ext_soft;
\f
/* Utility used everywhere when at least one argument is needed and
- none is supplied. */
+ none is supplied. */
void
error_no_arg (char *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. */
+ Therefore, its own definition is called only for "info" with no
+ args. */
static void
info_command (char *arg, int from_tty)
arg = "";
argpoint = strlen (arg);
- /* complete_line assumes that its first argument is somewhere within,
- and except for filenames at the beginning of, the word to be completed.
- The following crude imitation of readline's word-breaking tries to
- accomodate this. */
+ /* complete_line assumes that its first argument is somewhere
+ within, and except for filenames at the beginning of, the word to
+ be completed. The following crude imitation of readline's
+ word-breaking tries to accomodate this. */
point = arg + argpoint;
while (point > arg)
{
}
}
else
- /* We are dealing with leading repetitions of "/..", for example
- "/../..", which is the Mach super-root. */
+ /* We are dealing with leading repetitions of "/..", for
+ example "/../..", which is the Mach super-root. */
p += 3;
}
else
if (!find_and_open_script (file, search_path, &stream, &full_path))
{
- /* The script wasn't found, or was otherwise inaccessible.
- If the source command was invoked interactively, throw an error.
- Otherwise (e.g. if it was invoked by a script), silently ignore
- the error. */
+ /* The script wasn't found, or was otherwise inaccessible.
+ If the source command was invoked interactively, throw an
+ error. Otherwise (e.g. if it was invoked by a script),
+ silently ignore the error. */
if (from_tty)
perror_with_name (file);
else
int search_path = 0;
*old_source_verbose = source_verbose;
- old_cleanups = make_cleanup (source_verbose_cleanup, old_source_verbose);
+ old_cleanups = make_cleanup (source_verbose_cleanup,
+ old_source_verbose);
/* -v causes the source command to run in verbose mode.
-s causes the file to be searched in the source search path,
{
while (args[0] != '\0')
{
- /* Make sure leading white space does not break the comparisons. */
+ /* Make sure leading white space does not break the
+ comparisons. */
while (isspace(args[0]))
args++;
gdb_flush (gdb_stderr);
}
#ifdef GLOBAL_CURDIR
- /* Make sure to return to the directory GDB thinks it is, in case the
- shell command we just ran changed it. */
+ /* Make sure to return to the directory GDB thinks it is, in case
+ the shell command we just ran changed it. */
chdir (current_directory);
#endif
#else /* Can fork. */
if ((user_shell = (char *) getenv ("SHELL")) == NULL)
user_shell = "/bin/sh";
- /* Get the name of the shell for arg0 */
+ /* Get the name of the shell for arg0. */
if ((p = strrchr (user_shell, '/')) == NULL)
p = user_shell;
else
sal = get_current_source_symtab_and_line ();
}
- /* bare "edit" edits file with present line. */
+ /* Bare "edit" edits file with present line. */
if (arg == 0)
{
if (*arg1)
error (_("Junk at end of line specification."));
- /* If line was specified by address,
- first print exactly which line, and which file.
- In this case, sal.symtab == 0 means address is outside
- of all known source files, not that user failed to give a filename. */
+ /* If line was specified by address, first print exactly which
+ line, and which file. In this case, sal.symtab == 0 means
+ address is outside of all known source files, not that user
+ failed to give a filename. */
if (*arg == '*')
{
struct gdbarch *gdbarch;
sal.symtab->filename, sal.line);
}
- /* If what was given does not imply a symtab, it must be an undebuggable
- symbol which means no source code. */
+ /* If what was given does not imply a symtab, it must be an
+ undebuggable symbol which means no source code. */
if (sal.symtab == 0)
error (_("No line number known for %s."), arg);
int linenum_beg = 0;
char *p;
- /* Pull in the current default source line if necessary */
+ /* Pull in the current default source line if necessary. */
if (arg == 0 || arg[0] == '+' || arg[0] == '-')
{
set_default_source_symtab_and_line ();
return;
}
- /* "l -" lists previous ten lines, the ones before the ten just listed. */
+ /* "l -" lists previous ten lines, the ones before the ten just
+ listed. */
if (strcmp (arg, "-") == 0)
{
print_source_lines (cursal.symtab,
if (dummy_beg && dummy_end)
error (_("Two empty args do not say what lines to list."));
- /* if line was specified by address,
+ /* If line was specified by address,
first print exactly which line, and which file.
- In this case, sal.symtab == 0 means address is outside
- of all known source files, not that user failed to give a filename. */
+
+ In this case, sal.symtab == 0 means address is outside of all
+ known source files, not that user failed to give a filename. */
if (*arg == '*')
{
struct gdbarch *gdbarch;
sal.symtab->filename, sal.line);
}
- /* If line was not specified by just a line number,
- and it does not imply a symtab, it must be an undebuggable symbol
- which means no source code. */
+ /* If line was not specified by just a line number, and it does not
+ imply a symtab, it must be an undebuggable symbol which means no
+ source code. */
if (!linenum_beg && sal.symtab == 0)
error (_("No line number known for %s."), arg);
}
/* Search through names of commands and documentations for a certain
- regular expression.
-*/
+ regular expression. */
+
void
apropos_command (char *searchstr, int from_tty)
{
- extern struct cmd_list_element *cmdlist; /*This is the main command list*/
+ extern struct cmd_list_element *cmdlist; /* This is the main command
+ list. */
regex_t pattern;
char *pattern_fastmap;
char errorbuffer[512];
}
\f
/* Print a list of files and line numbers which a user may choose from
- in order to list a function which was specified ambiguously (as with
- `list classname::overloadedfuncname', for example). The vector in
- SALS provides the filenames and line numbers. */
+ in order to list a function which was specified ambiguously (as
+ with `list classname::overloadedfuncname', for example). The
+ vector in SALS provides the filenames and line numbers. */
static void
ambiguous_line_spec (struct symtabs_and_lines *sals)
&cmdlist);
add_cmd ("running", class_run, NULL, _("Running the program."), &cmdlist);
- /* Define general commands. */
+ /* Define general commands. */
add_com ("pwd", class_files, pwd_command, _("\
Print working directory. This is used for your program as well."));
and should be terminated by the word 'else' or `end'. If an else clause\n\
is used, the same rules apply to its nested commands as to the first ones."));
- /* If target is open when baud changes, it doesn't take effect until the
- next open (I think, not sure). */
+ /* If target is open when baud changes, it doesn't take effect until
+ the next open (I think, not sure). */
add_setshow_zinteger_cmd ("remotebaud", no_class, &baud_rate, _("\
Set baud rate for remote serial I/O."), _("\
Show baud rate for remote serial I/O."), _("\
this. Instead it adds support for the form ``(gdb) ! ls''
(i.e. the space is required). If the ``!'' command below is
added the complains about no ``!'' command would be replaced by
- complains about how the ``!'' command is broken :-) */
+ complains about how the ``!'' command is broken :-) */
if (xdb_commands)
add_com_alias ("!", "shell", class_support, 0);
extern struct cmd_list_element *infolist;
-/* Chain containing all defined enable subcommands. */
+/* Chain containing all defined enable subcommands. */
extern struct cmd_list_element *enablelist;
-/* Chain containing all defined disable subcommands. */
+/* Chain containing all defined disable subcommands. */
extern struct cmd_list_element *disablelist;
-/* Chain containing all defined delete subcommands. */
+/* Chain containing all defined delete subcommands. */
extern struct cmd_list_element *deletelist;
-/* Chain containing all defined detach subcommands. */
+/* Chain containing all defined detach subcommands. */
extern struct cmd_list_element *detachlist;
extern struct cmd_list_element *killlist;
-/* Chain containing all defined toggle subcommands. */
+/* Chain containing all defined toggle subcommands. */
extern struct cmd_list_element *togglelist;
-/* Chain containing all defined stop subcommands. */
+/* Chain containing all defined stop subcommands. */
extern struct cmd_list_element *stoplist;
-/* Chain containing all defined "enable breakpoint" subcommands. */
+/* Chain containing all defined "enable breakpoint" subcommands. */
extern struct cmd_list_element *enablebreaklist;
extern struct cmd_list_element *unsethistlist;
-/* Chain containing all defined maintenance subcommands. */
+/* Chain containing all defined maintenance subcommands. */
extern struct cmd_list_element *maintenancelist;
-/* Chain containing all defined "maintenance info" subcommands. */
+/* Chain containing all defined "maintenance info" subcommands. */
extern struct cmd_list_element *maintenanceinfolist;
-/* Chain containing all defined "maintenance print" subcommands. */
+/* Chain containing all defined "maintenance print" subcommands. */
extern struct cmd_list_element *maintenanceprintlist;
#include "cli/cli-decode.h"
#ifdef TUI
-#include "tui/tui.h" /* For tui_active et.al. */
+#include "tui/tui.h" /* For tui_active et al. */
#endif
#include "gdb_assert.h"
-/* Prototypes for local functions */
+/* Prototypes for local functions. */
static void undef_cmd_error (char *, char *);
It should start with ? for a command that is an abbreviation
or with * for a command that most users don't need to know about.
- Add this command to command list *LIST.
+ Add this command to command list *LIST.
Returns a pointer to the added command (not necessarily the head
- of *LIST). */
+ of *LIST). */
struct cmd_list_element *
add_cmd (char *name, enum command_class class, void (*fun) (char *, int),
}
/* Deprecates a command CMD.
- REPLACEMENT is the name of the command which should be used in place
- of this command, or NULL if no such command exists.
+ REPLACEMENT is the name of the command which should be used in
+ place of this command, or NULL if no such command exists.
This function does not check to see if command REPLACEMENT exists
- since gdb may not have gotten around to adding REPLACEMENT when this
- function is called.
+ since gdb may not have gotten around to adding REPLACEMENT when
+ this function is called.
Returns a pointer to the deprecated command. */
add_alias_cmd (char *name, char *oldname, enum command_class class,
int abbrev_flag, struct cmd_list_element **list)
{
- /* Must do this since lookup_cmd tries to side-effect its first arg */
+ /* Must do this since lookup_cmd tries to side-effect its first
+ arg. */
char *copied_name;
struct cmd_list_element *old;
struct cmd_list_element *c;
return c;
}
-/* Like add_cmd but adds an element for a command prefix:
- a name that should be followed by a subcommand to be looked up
- in another command list. PREFIXLIST should be the address
- of the variable containing that list. */
+/* Like add_cmd but adds an element for a command prefix: a name that
+ should be followed by a subcommand to be looked up in another
+ command list. PREFIXLIST should be the address of the variable
+ containing that list. */
struct cmd_list_element *
add_prefix_cmd (char *name, enum command_class class, void (*fun) (char *, int),
return c;
}
-/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */
+/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */
struct cmd_list_element *
add_abbrev_prefix_cmd (char *name, enum command_class class,
return aliases;
}
\f
-/* Shorthands to the commands above. */
+/* Shorthands to the commands above. */
/* Add an element to the list of info subcommands. */
name, or their documentation.
*/
void
-apropos_cmd (struct ui_file *stream, struct cmd_list_element *commandlist,
+apropos_cmd (struct ui_file *stream,
+ struct cmd_list_element *commandlist,
struct re_pattern_buffer *regex, char *prefix)
{
struct cmd_list_element *c;
int returnvalue;
- /* Walk through the commands */
+ /* Walk through the commands. */
for (c=commandlist;c;c=c->next)
{
- returnvalue = -1; /*Needed to avoid double printing*/
+ returnvalue = -1; /* Needed to avoid double printing. */
if (c->name != NULL)
{
- /* Try to match against the name*/
+ /* Try to match against the name. */
returnvalue = re_search (regex, c->name, strlen(c->name),
0, strlen (c->name), NULL);
if (returnvalue >= 0)
}
if (c->doc != NULL && returnvalue < 0)
{
- /* Try to match against documentation */
+ /* Try to match against documentation. */
if (re_search(regex,c->doc,strlen(c->doc),0,strlen(c->doc),NULL) >=0)
{
print_help_for_command (c, prefix,
0 /* don't recurse */, stream);
}
}
- /* Check if this command has subcommands and is not an abbreviation.
- We skip listing subcommands of abbreviations in order to avoid
- duplicates in the output.
- */
+ /* Check if this command has subcommands and is not an
+ abbreviation. We skip listing subcommands of abbreviations
+ in order to avoid duplicates in the output. */
if (c->prefixlist != NULL && !c->abbrev_flag)
{
/* Recursively call ourselves on the subcommand list,
- passing the right prefix in.
- */
+ passing the right prefix in. */
apropos_cmd (stream,*c->prefixlist,regex,c->prefixname);
}
}
}
/* This command really has to deal with two things:
- * 1) I want documentation on *this string* (usually called by
- * "help commandname").
- * 2) I want documentation on *this list* (usually called by
- * giving a command that requires subcommands. Also called by saying
- * just "help".)
- *
- * I am going to split this into two seperate comamnds, help_cmd and
- * help_list.
- */
+ 1) I want documentation on *this string* (usually called by
+ "help commandname").
+
+ 2) I want documentation on *this list* (usually called by giving a
+ command that requires subcommands. Also called by saying just
+ "help".)
+
+ I am going to split this into two seperate comamnds, help_cmd and
+ help_list. */
void
help_cmd (char *command, struct ui_file *stream)
return;
fprintf_filtered (stream, "\n");
- /* If this is a prefix command, print it's subcommands */
+ /* If this is a prefix command, print it's subcommands. */
if (c->prefixlist)
help_list (*c->prefixlist, c->prefixname, all_commands, stream);
- /* If this is a class name, print all of the commands in the class */
+ /* If this is a class name, print all of the commands in the class. */
if (c->func == NULL)
help_list (cmdlist, "", c->class, stream);
int len;
char *cmdtype1, *cmdtype2;
- /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub" */
+ /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub".
+ */
len = strlen (cmdtype);
cmdtype1 = (char *) alloca (len + 1);
cmdtype1[0] = 0;
wrap_here ("");
fputs_filtered ("documentation.\n", stream);
fputs_filtered ("Type \"apropos word\" to search "
- "for commands related to \"word\".\n", stream);
+ "for commands related to \"word\".\n", stream);
fputs_filtered ("Command name abbreviations are allowed if unambiguous.\n",
stream);
}
{
if (c->abbrev_flag)
continue;
- /* If this is a class name, print all of the commands in the class */
+ /* If this is a class name, print all of the commands in the
+ class. */
if (c->func == NULL)
{
/* Print one-line help for command C.
If RECURSE is non-zero, also print one-line descriptions
- of all prefixed subcommands. */
+ of all prefixed subcommands. */
static void
print_help_for_command (struct cmd_list_element *c, char *prefix, int recurse,
struct ui_file *stream)
&& c->abbrev_flag == 0)
/* Subcommands of a prefix command typically have 'all_commands'
as class. If we pass CLASS to recursive invocation,
- most often we won't see anything. */
+ most often we won't see anything. */
help_cmd_list (*c->prefixlist, all_commands, c->prefixname, 1, stream);
}
else if (c->abbrev_flag == 0 && recurse
&& class == class_user && c->prefixlist != NULL)
/* User-defined commands may be subcommands. */
- help_cmd_list (*c->prefixlist, class, c->prefixname, recurse, stream);
+ help_cmd_list (*c->prefixlist, class, c->prefixname,
+ recurse, stream);
}
}
\f
/* Search the input clist for 'command'. Return the command if
found (or NULL if not), and return the number of commands
- found in nfound */
+ found in nfound. */
static struct cmd_list_element *
find_cmd (char *command, int len, struct cmd_list_element *clist,
/* Treating underscores as part of command words is important
so that "set args_foo()" doesn't get interpreted as
"set args _foo()". */
- /* Some characters are only used for TUI specific commands. However, they
- are always allowed for the sake of consistency.
- The XDB compatibility characters are only allowed when using the right
- mode because they clash with other GDB commands - specifically '/' is
- used as a suffix for print, examine and display.
- Note that this is larger than the character set allowed when creating
- user-defined commands. */
+ /* Some characters are only used for TUI specific commands.
+ However, they are always allowed for the sake of consistency.
+
+ The XDB compatibility characters are only allowed when using the
+ right mode because they clash with other GDB commands -
+ specifically '/' is used as a suffix for print, examine and
+ display.
+
+ Note that this is larger than the character set allowed when
+ creating user-defined commands. */
+
while (isalnum (*p) || *p == '-' || *p == '_'
/* Characters used by TUI specific commands. */
|| *p == '+' || *p == '<' || *p == '>' || *p == '$'
return 0;
/* *text and p now bracket the first command word to lookup (and
- it's length is len). We copy this into a local temporary */
+ it's length is len). We copy this into a local temporary. */
command = (char *) alloca (len + 1);
nfound = 0;
found = find_cmd (command, len, clist, ignore_help_classes, &nfound);
- /*
- ** We didn't find the command in the entered case, so lower case it
- ** and search again.
- */
+ /* We didn't find the command in the entered case, so lower case it
+ and search again. */
if (!found || nfound == 0)
{
for (tmp = 0; tmp < len; tmp++)
return (struct cmd_list_element *) -1; /* Ambiguous. */
}
- /* We've matched something on this list. Move text pointer forward. */
+ /* We've matched something on this list. Move text pointer forward. */
*text += len;
if (found->cmd_pointer)
{
- /* We drop the alias (abbreviation) in favor of the command it is
- pointing to. If the alias is deprecated, though, we need to
+ /* We drop the alias (abbreviation) in favor of the command it
+ is pointing to. If the alias is deprecated, though, we need to
warn the user about it before we drop it. Note that while we
are warning about the alias, we may also warn about the command
itself and we will adjust the appropriate DEPRECATED_WARN_USER
- flags */
+ flags. */
if (found->flags & DEPRECATED_WARN_USER)
deprecated_cmd_warning (&line);
}
else if (c == (struct cmd_list_element *) -1)
{
- /* We've gotten this far properly, but the next step
- is ambiguous. We need to set the result list to the best
+ /* We've gotten this far properly, but the next step is
+ ambiguous. We need to set the result list to the best
we've found (if an inferior hasn't already set it). */
if (result_list != NULL)
if (!*result_list)
- /* This used to say *result_list = *found->prefixlist
+ /* This used to say *result_list = *found->prefixlist.
If that was correct, need to modify the documentation
- at the top of this function to clarify what is supposed
- to be going on. */
+ at the top of this function to clarify what is
+ supposed to be going on. */
*result_list = found;
return c;
}
return 0;
}
-/* We are here presumably because an alias or command in *TEXT is
- deprecated and a warning message should be generated. This function
- decodes *TEXT and potentially generates a warning message as outlined
- below.
+/* We are here presumably because an alias or command in *TEXT is
+ deprecated and a warning message should be generated. This
+ function decodes *TEXT and potentially generates a warning message
+ as outlined below.
Example for 'set endian big' which has a fictitious alias 'seb'.
If alias was used, and only the alias is deprecated:
"warning: 'seb' an alias for the command 'set endian big' is deprecated."
- If alias was used and command is deprecated (regardless of whether the
- alias itself is deprecated:
+ If alias was used and command is deprecated (regardless of whether
+ the alias itself is deprecated:
"warning: 'set endian big' (seb) is deprecated."
struct cmd_list_element *cmd = NULL;
if (!lookup_cmd_composition (*text, &alias, &prefix_cmd, &cmd))
- /* return if text doesn't evaluate to a command */
+ /* Return if text doesn't evaluate to a command. */
return;
if (!((alias ? (alias->flags & DEPRECATED_WARN_USER) : 0)
|| (cmd->flags & DEPRECATED_WARN_USER) ) )
- /* return if nothing is deprecated */
+ /* Return if nothing is deprecated. */
return;
printf_filtered ("Warning:");
printf_filtered ("' is deprecated.\n");
- /* If it is only the alias that is deprecated, we want to indicate the
- new alias, otherwise we'll indicate the new command. */
+ /* If it is only the alias that is deprecated, we want to indicate
+ the new alias, otherwise we'll indicate the new command. */
if (alias && !(cmd->flags & CMD_DEPRECATED))
{
printf_filtered ("No alternative known.\n\n");
}
- /* We've warned you, now we'll keep quiet */
+ /* We've warned you, now we'll keep quiet. */
if (alias)
alias->flags &= ~DEPRECATED_WARN_USER;
}
-
-/* Look up the contents of LINE as a command in the command list 'cmdlist'.
+/* Look up the contents of LINE as a command in the command list 'cmdlist'.
Return 1 on success, 0 on failure.
If LINE refers to an alias, *alias will point to that alias.
while (1)
{
/* Go through as many command lists as we need to
- to find the command TEXT refers to. */
+ to find the command TEXT refers to. */
prev_cmd = *cmd;
nfound = 0;
*cmd = find_cmd (command, len, cur_list, 1, &nfound);
- /* We didn't find the command in the entered case, so lower case it
- and search again.
+ /* We didn't find the command in the entered case, so lower case
+ it and search again.
*/
if (!*cmd || nfound == 0)
{
{
if ((*cmd)->cmd_pointer)
{
- /* cmd was actually an alias, we note that an alias was used
- (by assigning *alais) and we set *cmd. */
+ /* cmd was actually an alias, we note that an alias was
+ used (by assigning *alais) and we set *cmd. */
*alias = *cmd;
*cmd = (*cmd)->cmd_pointer;
}
/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
/* Return a vector of char pointers which point to the different
- possible completions in LIST of TEXT.
+ possible completions in LIST of TEXT.
WORD points in the same buffer as TEXT, and completions should be
- returned relative to this position. For example, suppose TEXT is "foo"
- and we want to complete to "foobar". If WORD is "oo", return
+ returned relative to this position. For example, suppose TEXT is
+ "foo" and we want to complete to "foobar". If WORD is "oo", return
"oobar"; if WORD is "baz/foo", return "baz/foobar". */
char **
/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
/* Return a vector of char pointers which point to the different
- possible completions in CMD of TEXT.
+ possible completions in CMD of TEXT.
WORD points in the same buffer as TEXT, and completions should be
returned relative to this position. For example, suppose TEXT is "foo"
}
-/* check function pointer */
+/* Check function pointer. */
int
cmd_func_p (struct cmd_list_element *cmd)
{
}
-/* call the command function */
+/* Call the command function. */
void
cmd_func (struct cmd_list_element *cmd, char *args, int from_tty)
{
/* This structure records one command'd definition. */
-/* This flag is used by the code executing commands to warn the user
- the first time a deprecated command is used, see the 'flags' field in
- the following struct.
+/* This flag is used by the code executing commands to warn the user
+ the first time a deprecated command is used, see the 'flags' field
+ in the following struct.
*/
#define CMD_DEPRECATED 0x1
#define DEPRECATED_WARN_USER 0x2
/* flags : a bitfield
bit 0: (LSB) CMD_DEPRECATED, when 1 indicated that this command
- is deprecated. It may be removed from gdb's command set in the
+ is deprecated. It may be removed from gdb's command set in the
future.
bit 1: DEPRECATED_WARN_USER, the user needs to be warned that
memory for replacement is malloc'ed. When a command is
undeprecated or re-deprecated at runtime we don't want to risk
calling free on statically allocated memory, so we check this
- flag.
- */
+ flag. */
+
int flags;
/* If this command is deprecated, this is the replacement name. */
skipped). It stops where we are supposed to stop completing
(rl_point) and is '\0' terminated.
- Return value is a malloc'd vector of pointers to possible completions
- terminated with NULL. If there are no completions, returning a pointer
- to a NULL would work but returning NULL itself is also valid.
- WORD points in the same buffer as TEXT, and completions should be
- returned relative to this position. For example, suppose TEXT is "foo"
- and we want to complete to "foobar". If WORD is "oo", return
- "oobar"; if WORD is "baz/foo", return "baz/foobar". */
- char **(*completer) (struct cmd_list_element *cmd, char *text, char *word);
+ Return value is a malloc'd vector of pointers to possible
+ completions terminated with NULL. If there are no completions,
+ returning a pointer to a NULL would work but returning NULL
+ itself is also valid. WORD points in the same buffer as TEXT,
+ and completions should be returned relative to this position.
+ For example, suppose TEXT is "foo" and we want to complete to
+ "foobar". If WORD is "oo", return "oobar"; if WORD is
+ "baz/foo", return "baz/foobar". */
+ char **(*completer) (struct cmd_list_element *cmd,
+ char *text, char *word);
/* Destruction routine for this command. If non-NULL, this is
called when this command instance is destroyed. This may be
or "show"). */
cmd_types type;
- /* Pointer to variable affected by "set" and "show". Doesn't matter
- if type is not_set. */
+ /* Pointer to variable affected by "set" and "show". Doesn't
+ matter if type is not_set. */
void *var;
/* What kind of variable is *VAR? */
var_types var_type;
- /* Pointer to NULL terminated list of enumerated values (like argv). */
+ /* Pointer to NULL terminated list of enumerated values (like
+ argv). */
const char **enums;
/* Pointer to command strings of user-defined commands */
extern void help_cmd_list (struct cmd_list_element *, enum command_class,
char *, int, struct ui_file *);
-/* Functions that implement commands about CLI commands. */
+/* Functions that implement commands about CLI commands. */
extern void help_cmd (char *, struct ui_file *);
if (!bfd_set_format (obfd, bfd_object))
error (_("bfd_openw_with_cleanup: %s."), bfd_errmsg (bfd_get_error ()));
}
- else if (*mode == 'a') /* Append to existing file */
- { /* FIXME -- doesn't work... */
+ else if (*mode == 'a') /* Append to existing file. */
+ { /* FIXME -- doesn't work... */
error (_("bfd_openw does not work with append."));
}
else
c->doc = concat ("Append ", c->doc + 6, (char *)NULL);
}
-/* Opaque data for restore_section_callback. */
+/* Opaque data for restore_section_callback. */
struct callback_data {
CORE_ADDR load_offset;
CORE_ADDR load_start;
gdb_byte *buf;
int ret;
- /* Ignore non-loadable sections, eg. from elf files. */
+ /* Ignore non-loadable sections, eg. from elf files. */
if (!(bfd_get_section_flags (ibfd, isec) & SEC_LOAD))
return;
if (sec_end <= data->load_start
|| (data->load_end > 0 && sec_start >= data->load_end))
{
- /* No, no useable data in this section. */
+ /* No, no useable data in this section. */
printf_filtered (_("skipping section %s...\n"),
bfd_section_name (ibfd, isec));
return;
transfer should start and end. */
if (sec_start < data->load_start)
sec_offset = data->load_start - sec_start;
- /* Size of a partial transfer: */
+ /* Size of a partial transfer. */
sec_load_count -= sec_offset;
if (data->load_end > 0 && sec_end > data->load_end)
sec_load_count -= sec_end - data->load_end;
error (_("Start address is greater than length of binary file %s."),
filename);
- /* Chop off "len" if it exceeds the requested load_end addr. */
+ /* Chop off "len" if it exceeds the requested load_end addr. */
if (data->load_end != 0 && data->load_end < len)
len = data->load_end;
- /* Chop off "len" if the requested load_start addr skips some bytes. */
+ /* Chop off "len" if the requested load_start addr skips some bytes. */
if (data->load_start > 0)
len -= data->load_start;
if (fread (buf, 1, len, file) != len)
perror_with_name (filename);
- /* Now write the buffer into target memory. */
+ /* Now write the buffer into target memory. */
len = target_write_memory (data->load_start + data->load_offset, buf, len);
if (len != 0)
warning (_("restore: memory write failed (%s)."), safe_strerror (len));
data.load_start = 0;
data.load_end = 0;
- /* Parse the input arguments. First is filename (required). */
+ /* Parse the input arguments. First is filename (required). */
filename = scan_filename_with_cleanup (&args, NULL);
if (args != NULL && *args != '\0')
{
args += strlen (binary_string);
args = skip_spaces (args);
}
- /* Parse offset (optional). */
+ /* Parse offset (optional). */
if (args != NULL && *args != '\0')
data.load_offset =
parse_and_eval_address (scan_expression_with_cleanup (&args, NULL));
if (args != NULL && *args != '\0')
{
- /* Parse start address (optional). */
+ /* Parse start address (optional). */
data.load_start =
parse_and_eval_long (scan_expression_with_cleanup (&args, NULL));
if (args != NULL && *args != '\0')
{
- /* Parse end address (optional). */
+ /* Parse end address (optional). */
data.load_end = parse_and_eval_long (args);
if (data.load_end <= data.load_start)
error (_("Start must be less than end."));
}
else
{
- /* Open the file for loading. */
+ /* Open the file for loading. */
ibfd = bfd_openr_with_cleanup (filename, NULL);
- /* Process the sections. */
+ /* Process the sections. */
bfd_map_over_sections (ibfd, restore_section_callback, &data);
}
return;
If START and END are given, only the file contents within that range\n\
(file relative) will be restored to target memory."));
c->completer = filename_completer;
- /* FIXME: completers for other commands. */
+ /* FIXME: completers for other commands. */
}
struct ui_out *cli_uiout;
-/* These are the ui_out and the interpreter for the console interpreter. */
+/* These are the ui_out and the interpreter for the console
+ interpreter. */
/* Longjmp-safe wrapper for "execute_command". */
static struct gdb_exception safe_execute_command (struct ui_out *uiout,
- char *command, int from_tty);
+ char *command,
+ int from_tty);
struct captured_execute_command_args
{
char *command;
/*sync_execution = 1; */
- /* gdb_setup_readline will change gdb_stdout. If the CLI was previously
- writing to gdb_stdout, then set it to the new gdb_stdout afterwards. */
+ /* gdb_setup_readline will change gdb_stdout. If the CLI was
+ previously writing to gdb_stdout, then set it to the new
+ gdb_stdout afterwards. */
stream = cli_out_set_stream (cli_uiout, gdb_stdout);
if (stream != gdb_stdout)
safe_execute_command. */
char *str = strcpy (alloca (strlen (command_str) + 1), command_str);
- /* gdb_stdout could change between the time cli_uiout was initialized
- and now. Since we're probably using a different interpreter which has
- a new ui_file for gdb_stdout, use that one instead of the default.
+ /* gdb_stdout could change between the time cli_uiout was
+ initialized and now. Since we're probably using a different
+ interpreter which has a new ui_file for gdb_stdout, use that one
+ instead of the default.
- It is important that it gets reset everytime, since the user could
- set gdb to use a different interpreter. */
+ It is important that it gets reset everytime, since the user
+ could set gdb to use a different interpreter. */
old_stream = cli_out_set_stream (cli_uiout, gdb_stdout);
result = safe_execute_command (cli_uiout, str, 1);
cli_out_set_stream (cli_uiout, old_stream);
/* Value as configured by the user. */
static int logging_redirect;
-/* The on-disk file in use if logging is currently active together with
- redirection turned off (and therefore using tee_file_new). For active
- logging with redirection the on-disk file is directly in GDB_STDOUT and
- this variable is NULL. */
+/* The on-disk file in use if logging is currently active together
+ with redirection turned off (and therefore using tee_file_new).
+ For active logging with redirection the on-disk file is directly in
+ GDB_STDOUT and this variable is NULL. */
static struct ui_file *logging_no_redirect_file;
static void
{
gdb_assert (logging_no_redirect_file != NULL);
- /* ui_out_redirect still has not been called for next gdb_stdout. */
+ /* ui_out_redirect still has not been called for next
+ gdb_stdout. */
cleanups = make_cleanup_ui_file_delete (gdb_stdout);
output = logging_no_redirect_file;
gdb_stdtargerr = output;
logging_no_redirect_file = new_logging_no_redirect_file;
- /* There is a former output pushed on the ui_out_redirect stack. We want to
- replace it by OUTPUT so we must pop the former value first. We should
- either do both the pop and push or to do neither of it. At least do not
- try to push OUTPUT if the pop already failed. */
+ /* There is a former output pushed on the ui_out_redirect stack. We
+ want to replace it by OUTPUT so we must pop the former value
+ first. We should either do both the pop and push or to do
+ neither of it. At least do not try to push OUTPUT if the pop
+ already failed. */
if (ui_out_redirect (uiout, NULL) < 0
|| ui_out_redirect (uiout, output) < 0)
#include "python/python.h"
-/* Prototypes for local functions */
+/* Prototypes for local functions. */
static enum command_control_type
recurse_read_control_structure (char * (*read_next_line_func) (void),
{
struct user_args *next;
/* It is necessary to store a malloced copy of the command line to
- ensure that the arguments are not overwritten before they are used. */
+ ensure that the arguments are not overwritten before they are
+ used. */
char *command;
struct
{
continue;
}
- /* loop_break to break out of a while loop, print it and continue. */
+ /* loop_break to break out of a while loop, print it and
+ continue. */
if (list->control_type == break_control)
{
ui_out_field_string (uiout, NULL, "loop_break");
continue;
}
- /* A while command. Recursively print its subcommands and continue. */
+ /* A while command. Recursively print its subcommands and
+ continue. */
if (list->control_type == while_control
|| list->control_type == while_stepping_control)
{
- /* For while-stepping, the line includes the 'while-stepping' token.
- See comment in process_next_line for explanation. Here,
- take care not print 'while-stepping' twice. */
+ /* For while-stepping, the line includes the 'while-stepping'
+ token. See comment in process_next_line for explanation.
+ Here, take care not print 'while-stepping' twice. */
if (list->control_type == while_control)
ui_out_field_fmt (uiout, NULL, "while %s", list->line);
else
continue;
}
- /* An if command. Recursively print both arms before continueing. */
+ /* An if command. Recursively print both arms before
+ continueing. */
if (list->control_type == if_control)
{
ui_out_field_fmt (uiout, NULL, "if %s", list->line);
ui_out_text (uiout, "\n");
- /* The true arm. */
+ /* The true arm. */
print_command_lines (uiout, list->body_list[0], depth + 1);
/* Show the false arm if it exists. */
continue;
}
- /* A commands command. Print the breakpoint commands and continue. */
+ /* A commands command. Print the breakpoint commands and
+ continue. */
if (list->control_type == commands_control)
{
if (*(list->line))
continue;
}
- /* ignore illegal command type and try next */
+ /* Ignore illegal command type and try next. */
list = list->next;
} /* while (list) */
}
{
struct cmd_list_element *c = data;
- c->hook_in = 0; /* Allow hook to work again once it is complete */
+ c->hook_in = 0; /* Allow hook to work again once it is complete. */
}
void
if ((c->hook_pre) && (!c->hook_in))
{
struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
- c->hook_in = 1; /* Prevent recursive hooking */
+ c->hook_in = 1; /* Prevent recursive hooking. */
execute_user_command (c->hook_pre, (char *) 0);
do_cleanups (cleanups);
}
{
struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
- c->hook_in = 1; /* Prevent recursive hooking */
+ c->hook_in = 1; /* Prevent recursive hooking. */
execute_user_command (c->hook_post, (char *) 0);
do_cleanups (cleanups);
}
do_cleanups (old_chain);
}
-/* This function is called every time GDB prints a prompt.
- It ensures that errors and the like to not confuse the command tracing. */
+/* This function is called every time GDB prints a prompt. It ensures
+ that errors and the like do not confuse the command tracing. */
void
reset_command_nest_depth (void)
val_mark = value_mark ();
val = evaluate_expression (expr);
- /* Choose which arm to take commands from based on the value of the
- conditional expression. */
+ /* Choose which arm to take commands from based on the value
+ of the conditional expression. */
if (value_true (val))
current = *cmd->body_list;
else if (cmd->body_count == 2)
}
case commands_control:
{
- /* Breakpoint commands list, record the commands in the breakpoint's
- command list and return. */
+ /* Breakpoint commands list, record the commands in the
+ breakpoint's command list and return. */
new_line = insert_args (cmd->line);
if (!new_line)
break;
}
/* Like execute_control_command, but first set
- suppress_next_print_command_trace. */
+ suppress_next_print_command_trace. */
enum command_control_type
execute_control_command_untraced (struct command_line *cmd)
return old_chain;
}
-/* Given character string P, return a point to the first argument ($arg),
- or NULL if P contains no arguments. */
+/* Given character string P, return a point to the first argument
+ ($arg), or NULL if P contains no arguments. */
static char *
locate_arg (char *p)
}
/* Insert the user defined arguments stored in user_arg into the $arg
- arguments found in line, with the updated copy being placed into nline. */
+ arguments found in line, with the updated copy being placed into
+ nline. */
static char *
insert_args (char *line)
if (user_args == NULL)
return xstrdup (line);
- /* First we need to know how much memory to allocate for the new line. */
+ /* First we need to know how much memory to allocate for the new
+ line. */
save_line = line;
len = 0;
while ((p = locate_arg (line)))
return command_line_input (prompt_ptr, instream == stdin, "commands");
}
-/* Process one input line. If the command is an "end",
- return such an indication to the caller. If PARSE_COMMANDS is true,
- strip leading whitespace (trailing whitespace is always stripped)
- in the line, attempt to recognize GDB control commands, and also
- return an indication if the command is an "else" or a nop.
+/* Process one input line. If the command is an "end", return such an
+ indication to the caller. If PARSE_COMMANDS is true, strip leading
+ whitespace (trailing whitespace is always stripped) in the line,
+ attempt to recognize GDB control commands, and also return an
+ indication if the command is an "else" or a nop.
+
Otherwise, only "end" is recognized. */
static enum misc_command_type
while (p_start < p_end && (*p_start == ' ' || *p_start == '\t'))
p_start++;
- /* 'end' is always recognized, regardless of parse_commands value.
+ /* 'end' is always recognized, regardless of parse_commands value.
We also permit whitespace before end and after. */
if (p_end - p_start == 3 && !strncmp (p_start, "end", 3))
return end_command;
if (parse_commands)
{
- /* If commands are parsed, we skip initial spaces. Otherwise,
+ /* If commands are parsed, we skip initial spaces. Otherwise,
which is the case for Python commands and documentation
(see the 'document' command), spaces are preserved. */
p = p_start;
/* Blanks and comments don't really do anything, but we need to
- distinguish them from else, end and other commands which can be
- executed. */
+ distinguish them from else, end and other commands which can
+ be executed. */
if (p_end == p || p[0] == '#')
return nop_command;
if (p_end - p == 4 && !strncmp (p, "else", 4))
return else_command;
- /* Check for while, if, break, continue, etc and build a new command
- line structure for them. */
+ /* Check for while, if, break, continue, etc and build a new
+ command line structure for them. */
if ((p_end - p >= 14 && !strncmp (p, "while-stepping", 14))
|| (p_end - p >= 8 && !strncmp (p, "stepping", 8))
|| (p_end - p >= 2 && !strncmp (p, "ws", 2)))
include 'while-stepping'.
For 'ws' alias, the command will have 'ws', not expanded
- to 'while-stepping'. This is intentional -- we don't
+ to 'while-stepping'. This is intentional -- we don't
really want frontend to send a command list with 'ws',
- and next break-info returning command line with 'while-stepping'.
- This should work, but might cause the breakpoint to be marked as
- changed while it's actually not. */
+ and next break-info returning command line with
+ 'while-stepping'. This should work, but might cause the
+ breakpoint to be marked as changed while it's actually
+ not. */
*command = build_command_line (while_stepping_control, p);
}
else if (p_end - p > 5 && !strncmp (p, "while", 5))
return ok_command;
}
-/* Recursively read in the control structures and create a command_line
- structure from them. Use read_next_line_func to obtain lines of
- the command.
-
-*/
+/* Recursively read in the control structures and create a
+ command_line structure from them. Use read_next_line_func to
+ obtain lines of the command. */
static enum command_control_type
recurse_read_control_structure (char * (*read_next_line_func) (void),
{
if (deprecated_readline_begin_hook)
{
- /* Note - intentional to merge messages with no newline */
+ /* Note - intentional to merge messages with no newline. */
(*deprecated_readline_begin_hook) ("%s %s\n", prompt_arg, END_MESSAGE);
}
else
comname = xstrdup (comname);
/* If the rest of the commands will be case insensitive, this one
- should behave in the same manner. */
+ should behave in the same manner. */
for (tem = comname; *tem; tem++)
if (isupper (*tem))
*tem = tolower (*tem);
{
case CMD_PRE_HOOK:
hookc->hook_pre = newc; /* Target gets hooked. */
- newc->hookee_pre = hookc; /* We are marked as hooking target cmd. */
+ newc->hookee_pre = hookc; /* We are marked as hooking target cmd. */
break;
case CMD_POST_HOOK:
hookc->hook_post = newc; /* Target gets hooked. */
- newc->hookee_post = hookc; /* We are marked as hooking target cmd. */
+ newc->hookee_post = hookc; /* We are marked as hooking target cmd. */
break;
default:
- /* Should never come here as hookc would be 0. */
+ /* Should never come here as hookc would be 0. */
internal_error (__FILE__, __LINE__, _("bad switch"));
}
}
read_command_file (args->stream);
}
-/* Used to implement source_command */
+/* Used to implement source_command. */
void
script_from_file (FILE *stream, const char *file)
make_cleanup (source_cleanup_lines, &old_lines);
source_line_number = 0;
source_file_name = file;
- /* This will get set every time we read a line. So it won't stay "" for
- long. */
+ /* This will get set every time we read a line. So it won't stay ""
+ for long. */
error_pre_print = "";
{
#include "cli/cli-cmds.h"
#include "cli/cli-setshow.h"
-/* Prototypes for local functions */
+/* Prototypes for local functions. */
static int parse_binary_operation (char *);
return AUTO_BOOLEAN_AUTO;
}
error (_("\"on\", \"off\" or \"auto\" expected."));
- return AUTO_BOOLEAN_AUTO; /* pacify GCC */
+ return AUTO_BOOLEAN_AUTO; /* Pacify GCC. */
}
static int
}
}
-/* Do a "set" or "show" command. ARG is NULL if no argument, or the text
- of the argument, and FROM_TTY is nonzero if this command is being entered
- directly by the user (i.e. these are just like any other
- command). C is the command list element for the command. */
+/* Do a "set" or "show" command. ARG is NULL if no argument, or the
+ text of the argument, and FROM_TTY is nonzero if this command is
+ being entered directly by the user (i.e. these are just like any
+ other command). C is the command list element for the command. */
void
do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
const char *match = NULL;
char *p;
- /* if no argument was supplied, print an informative error message */
+ /* If no argument was supplied, print an informative error
+ message. */
if (arg == NULL)
{
char *msg;
strcat (msg, ", ");
strcat (msg, c->enums[i]);
}
- error (_("Requires an argument. Valid arguments are %s."), msg);
+ error (_("Requires an argument. Valid arguments are %s."),
+ msg);
}
p = strchr (arg, ' ');
{
match = c->enums[i];
nmatches = 1;
- break; /* exact match. */
+ break; /* Exact match. */
}
else
{
/* Exported to cli/cli-cmds.c and gdb/top.c */
-/* Do a "set" or "show" command. ARG is NULL if no argument, or the text
- of the argument, and FROM_TTY is nonzero if this command is being entered
- directly by the user (i.e. these are just like any other
- command). C is the command list element for the command. */
+/* Do a "set" or "show" command. ARG is NULL if no argument, or the
+ text of the argument, and FROM_TTY is nonzero if this command is
+ being entered directly by the user (i.e. these are just like any
+ other command). C is the command list element for the command. */
extern void do_setshow_command (char *arg, int from_tty,
struct cmd_list_element *c);
#define COMMAND_H 1
/* Command classes are top-level categories into which commands are broken
- down for "help" purposes.
+ down for "help" purposes.
Notes on classes: class_alias is for alias commands which are not
abbreviations of the original command. class-pseudo is for
commands which are not really commands nor help topics ("stop"). */
"auto. *VAR is an ``enum auto_boolean''. NOTE: In general a
custom show command will need to be implemented - one that for
"auto" prints both the "auto" and the current auto-selected
- value. */
+ value. */
var_auto_boolean,
/* Unsigned Integer. *VAR is an unsigned int. The user can type 0
extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
void (*cfunc) (char *args, int from_tty));
-/* Each command object has a local context attached to it. . */
+/* Each command object has a local context attached to it. */
extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
extern void *get_cmd_context (struct cmd_list_element *cmd);
extern void cmd_show_list (struct cmd_list_element *, int, char *);
/* Used everywhere whenever at least one parameter is required and
- none is specified. */
+ none is specified. */
extern void error_no_arg (char *) ATTRIBUTE_NORETURN;