From: Per Bothner Date: Tue, 14 Mar 1995 00:49:33 +0000 (+0000) Subject: * gdb.texinfo (Define): Document $arg0... arguments to commands, X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0b2a91c25190f8697f3c39af9875e4c5eb3dc83;p=binutils-gdb.git * gdb.texinfo (Define): Document $arg0... arguments to commands, and new 'if' and 'while' commands. --- diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 79f5b0c83d7..8cc1d5feba1 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +Mon Mar 13 16:49:13 1995 Per Bothner + + * gdb.texinfo (Define): Document $arg0... arguments to commands, + and new 'if' and 'while' commands. + Fri Feb 17 15:24:35 1995 Per Bothner * gdb.texinfo (Artificial arrays): Note use of coerce-to-array-type. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 7e445aada92..898f6b97a47 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -7816,6 +7816,24 @@ The definition of the command is made up of other @value{GDBN} command lines, which are given following the @code{define} command. The end of these commands is marked by a line containing @code{end}. +@item if +@kindex if +@kindex else +Takes a single argument, which is an expression to evaluate. +It is followed by a series of commands that are executed +only if the expression is true (nonzero). +There can then optionally be a line @code{else}, followed +by a series of commands that are only executed if the expression +was false. The end of the list is marked by a line containing @code{end}. + +@item while +@kindex while +The syntax is similar to @code{if}: The command takes a single argument, +which is an expression to evaluate, and must be followed by the commands to +execute, one per line, terminated by an @code{end}. +The commands are executed repeatedly as long as the expression +evaluates to true. + @item document @var{commandname} @kindex document Give documentation to the user-defined command @var{commandname}. The @@ -7842,7 +7860,24 @@ documentation). If no @var{commandname} is given, display the definitions for all user-defined commands. @end table -User-defined commands do not take arguments. When they are executed, the +User-defined commands may accept up to 10 arguments separated by whitespace. +Arguments are accessed within the user command via @code{$arg0}..@code{$arg9}. +A trivial example: +@smallexample +define adder +print $arg0 + $arg1 + $arg2 +end +@end smallexample +Defines the command @code{adder} which prints the sum of its three arguments. +To execute the command use: +@smallexample +adder 1 2 3 +@end smallexample + +Note the arguments are text substitutions, so they may reference variables, +use complex expressions, or even perform inferior function calls. + +When user-defined commands are executed, the commands of the definition are not printed. An error in any command stops execution of the user-defined command.