You can implement new gdb parameters using Guile 1.
There are many parameters that already exist and can be set in
gdb. Two examples are: set follow-fork
and
set charset
. Setting these parameters influences certain
behavior in gdb. Similarly, you can define parameters that
can be used to influence behavior in custom Guile scripts and commands.
A new parameter is defined with the make-parameter
Guile function,
and added to gdb with the register-parameter!
Guile function.
This two-step approach is taken to separate out the side-effect of adding
the parameter to gdb from make-parameter
.
Parameters are exposed to the user via the set
and
show
commands. See Help.
The argument name is the name of the new parameter. If name consists of multiple words, then the initial words are looked for as prefix parameters. An example of this can be illustrated with the
set print
set of parameters. If name isprint foo
, thenset print foo
. If name consists of multiple words, and no prefix parameter group can be found, an exception is raised.The result is the
<gdb:parameter>
object representing the parameter. The parameter is not usable until it has been registered with gdb withregister-parameter!
.The rest of the arguments are optional.
The argument command-class should be one of the ‘COMMAND_’ constants (see Commands In Guile). This argument tells gdb how to categorize the new parameter in the help system. The default is
COMMAND_NONE
.The argument parameter-type should be one of the ‘PARAM_’ constants defined below. This argument tells gdb the type of the new parameter; this information is used for input validation and completion. The default is
PARAM_BOOLEAN
.If parameter-type is
PARAM_ENUM
, then enum-list must be a list of strings. These strings represent the possible values for the parameter.If parameter-type is not
PARAM_ENUM
, then the presence of enum-list will cause an exception to be thrown.The argument set-func is a function of one argument: self which is the
<gdb:parameter>
object representing the parameter. gdb will call this function when a parameter's value has been changed via theset
API (for example, set foo off). The value of the parameter has already been set to the new value. This function must return a string to be displayed to the user. gdb will add a trailing newline if the string is non-empty. gdb generally doesn't print anything when a parameter is set, thus typically this function should return ‘""’. A non-empty string result should typically be used for displaying warnings and errors.The argument show-func is a function of two arguments: self which is the
<gdb:parameter>
object representing the parameter, and svalue which is the string representation of the current value. gdb will call this function when a parameter'sshow
API has been invoked (for example, show foo). This function must return a string, and will be displayed to the user. gdb will add a trailing newline.The argument doc is the help text for the new parameter. If there is no documentation string, a default value is used.
The argument set-doc is the help text for this parameter's
set
command.The argument show-doc is the help text for this parameter's
show
command.The argument initial-value specifies the initial value of the parameter. If it is a function, it takes one parameter, the
<gdb:parameter>
object and its result is used as the initial value of the parameter. The initial value must be valid for the parameter type, otherwise an exception is thrown.
Add parameter, a
<gdb:parameter>
object, to gdb's list of parameters. It is an error to register a parameter more than once. The result is unspecified.
Return
#t
if object is a<gdb:parameter>
object. Otherwise return#f
.
Return the value of parameter which may either be a
<gdb:parameter>
object or a string naming the parameter.
Assign parameter the value of new-value. The argument parameter must be an object of type
<gdb:parameter>
. gdb does validation when assignments are made.
When a new parameter is defined, its type must be specified. The
available types are represented by constants defined in the gdb
module:
PARAM_BOOLEAN
#t
and #f
are the only valid values.
PARAM_AUTO_BOOLEAN
#:auto
.
PARAM_UINTEGER
PARAM_ZINTEGER
PARAM_ZUINTEGER
PARAM_ZUINTEGER_UNLIMITED
PARAM_STRING
PARAM_STRING_NOESCAPE
PARAM_OPTIONAL_FILENAME
#f
.
PARAM_FILENAME
PARAM_STRING_NOESCAPE
, but uses file names for completion.
PARAM_ENUM
[1] Note that gdb parameters must not be confused with Guileās parameter objects (see Parameters).