You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

294 lines
14 KiB
HTML

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs
Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Parameters In Guile (Debugging with GDB)</title>
<meta name="description" content="Parameters In Guile (Debugging with GDB)">
<meta name="keywords" content="Parameters In Guile (Debugging with GDB)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Guile-API.html#Guile-API" rel="up" title="Guile API">
<link href="Progspaces-In-Guile.html#Progspaces-In-Guile" rel="next" title="Progspaces In Guile">
<link href="Commands-In-Guile.html#Commands-In-Guile" rel="prev" title="Commands In Guile">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Parameters-In-Guile"></a>
<div class="header">
<p>
Next: <a href="Progspaces-In-Guile.html#Progspaces-In-Guile" accesskey="n" rel="next">Progspaces In Guile</a>, Previous: <a href="Commands-In-Guile.html#Commands-In-Guile" accesskey="p" rel="prev">Commands In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Parameters-In-Guile-1"></a>
<h4 class="subsubsection">23.3.3.12 Parameters In Guile</h4>
<a name="index-parameters-in-guile"></a>
<a name="index-guile-parameters"></a>
<a name="index-Parameter-1"></a>
<p>You can implement new <small>GDB</small> <em>parameters</em> using Guile
<a name="DOCF17" href="#FOOT17"><sup>17</sup></a>.
</p>
<p>There are many parameters that already exist and can be set in
<small>GDB</small>. Two examples are: <code>set follow-fork</code> and
<code>set charset</code>. Setting these parameters influences certain
behavior in <small>GDB</small>. Similarly, you can define parameters that
can be used to influence behavior in custom Guile scripts and commands.
</p>
<p>A new parameter is defined with the <code>make-parameter</code> Guile function,
and added to <small>GDB</small> with the <code>register-parameter!</code> Guile function.
This two-step approach is taken to separate out the side-effect of adding
the parameter to <small>GDB</small> from <code>make-parameter</code>.
</p>
<p>Parameters are exposed to the user via the <code>set</code> and
<code>show</code> commands. See <a href="Help.html#Help">Help</a>.
</p>
<dl>
<dt><a name="index-_0028make_002dparameter"></a>Scheme Procedure: <strong>(make-parameter</strong> <em>name <span class="roman">[</span>#:command-class command-class<span class="roman">]</span> <span class="roman">[</span>#:parameter-type parameter-type] <span class="roman">[</span>#:enum-list enum-list<span class="roman">]</span> <span class="roman">[</span>#:set-func set-func] <span class="roman">[</span>#:show-func show-func] <span class="roman">[</span>#:doc doc] <span class="roman">[</span>#:set-doc set-doc] <span class="roman">[</span>#:show-doc show-doc] <span class="roman">[</span>#:initial-value initial-value])</em></dt>
<dd>
<p>The argument <var>name</var> is the name of the new parameter. If <var>name</var>
consists of multiple words, then the initial words are looked for as prefix
parameters. An example of this can be illustrated with the
<code>set print</code> set of parameters. If <var>name</var> is
<code>print foo</code>, then <code>print</code> will be searched as the prefix
parameter. In this case the parameter can subsequently be accessed in
<small>GDB</small> as <code>set print foo</code>.
If <var>name</var> consists of multiple words, and no prefix parameter group
can be found, an exception is raised.
</p>
<p>The result is the <code>&lt;gdb:parameter&gt;</code> object representing the parameter.
The parameter is not usable until it has been registered with <small>GDB</small>
with <code>register-parameter!</code>.
</p>
<p>The rest of the arguments are optional.
</p>
<p>The argument <var>command-class</var> should be one of the &lsquo;<samp>COMMAND_</samp>&rsquo; constants
(see <a href="Commands-In-Guile.html#Commands-In-Guile">Commands In Guile</a>). This argument tells <small>GDB</small> how to
categorize the new parameter in the help system.
The default is <code>COMMAND_NONE</code>.
</p>
<p>The argument <var>parameter-type</var> should be one of the &lsquo;<samp>PARAM_</samp>&rsquo; constants
defined below. This argument tells <small>GDB</small> the type of the new
parameter; this information is used for input validation and
completion. The default is <code>PARAM_BOOLEAN</code>.
</p>
<p>If <var>parameter-type</var> is <code>PARAM_ENUM</code>, then
<var>enum-list</var> must be a list of strings. These strings
represent the possible values for the parameter.
</p>
<p>If <var>parameter-type</var> is not <code>PARAM_ENUM</code>, then the presence
of <var>enum-list</var> will cause an exception to be thrown.
</p>
<p>The argument <var>set-func</var> is a function of one argument: <var>self</var> which
is the <code>&lt;gdb:parameter&gt;</code> object representing the parameter.
<small>GDB</small> will call this function when a <var>parameter</var>&rsquo;s value has
been changed via the <code>set</code> API (for example, <kbd>set foo off</kbd>).
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.
<small>GDB</small> will add a trailing newline if the string is non-empty.
<small>GDB</small> generally doesn&rsquo;t print anything when a parameter is set,
thus typically this function should return &lsquo;<samp>&quot;&quot;</samp>&rsquo;.
A non-empty string result should typically be used for displaying warnings
and errors.
</p>
<p>The argument <var>show-func</var> is a function of two arguments: <var>self</var> which
is the <code>&lt;gdb:parameter&gt;</code> object representing the parameter, and
<var>svalue</var> which is the string representation of the current value.
<small>GDB</small> will call this function when a <var>parameter</var>&rsquo;s
<code>show</code> API has been invoked (for example, <kbd>show foo</kbd>).
This function must return a string, and will be displayed to the user.
<small>GDB</small> will add a trailing newline.
</p>
<p>The argument <var>doc</var> is the help text for the new parameter.
If there is no documentation string, a default value is used.
</p>
<p>The argument <var>set-doc</var> is the help text for this parameter&rsquo;s
<code>set</code> command.
</p>
<p>The argument <var>show-doc</var> is the help text for this parameter&rsquo;s
<code>show</code> command.
</p>
<p>The argument <var>initial-value</var> specifies the initial value of the parameter.
If it is a function, it takes one parameter, the <code>&lt;gdb:parameter&gt;</code>
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.
</p></dd></dl>
<dl>
<dt><a name="index-register_002dparameter_0021"></a>Scheme Procedure: <strong>register-parameter!</strong> <em>parameter</em></dt>
<dd><p>Add <var>parameter</var>, a <code>&lt;gdb:parameter&gt;</code> object, to <small>GDB</small>&rsquo;s
list of parameters.
It is an error to register a parameter more than once.
The result is unspecified.
</p></dd></dl>
<dl>
<dt><a name="index-parameter_003f"></a>Scheme Procedure: <strong>parameter?</strong> <em>object</em></dt>
<dd><p>Return <code>#t</code> if <var>object</var> is a <code>&lt;gdb:parameter&gt;</code> object.
Otherwise return <code>#f</code>.
</p></dd></dl>
<dl>
<dt><a name="index-parameter_002dvalue"></a>Scheme Procedure: <strong>parameter-value</strong> <em>parameter</em></dt>
<dd><p>Return the value of <var>parameter</var> which may either be
a <code>&lt;gdb:parameter&gt;</code> object or a string naming the parameter.
</p></dd></dl>
<dl>
<dt><a name="index-set_002dparameter_002dvalue_0021"></a>Scheme Procedure: <strong>set-parameter-value!</strong> <em>parameter new-value</em></dt>
<dd><p>Assign <var>parameter</var> the value of <var>new-value</var>.
The argument <var>parameter</var> must be an object of type <code>&lt;gdb:parameter&gt;</code>.
<small>GDB</small> does validation when assignments are made.
</p></dd></dl>
<p>When a new parameter is defined, its type must be specified. The
available types are represented by constants defined in the <code>gdb</code>
module:
</p>
<dl compact="compact">
<dt><code>PARAM_BOOLEAN</code>
<a name="index-PARAM_005fBOOLEAN-1"></a>
</dt>
<dd><p>The value is a plain boolean. The Guile boolean values, <code>#t</code>
and <code>#f</code> are the only valid values.
</p>
</dd>
<dt><code>PARAM_AUTO_BOOLEAN</code>
<a name="index-PARAM_005fAUTO_005fBOOLEAN-1"></a>
</dt>
<dd><p>The value has three possible states: true, false, and &lsquo;<samp>auto</samp>&rsquo;. In
Guile, true and false are represented using boolean constants, and
&lsquo;<samp>auto</samp>&rsquo; is represented using <code>#:auto</code>.
</p>
</dd>
<dt><code>PARAM_UINTEGER</code>
<a name="index-PARAM_005fUINTEGER-1"></a>
</dt>
<dd><p>The value is an unsigned integer. The value of 0 should be
interpreted to mean &ldquo;unlimited&rdquo;.
</p>
</dd>
<dt><code>PARAM_ZINTEGER</code>
<a name="index-PARAM_005fZINTEGER-1"></a>
</dt>
<dd><p>The value is an integer.
</p>
</dd>
<dt><code>PARAM_ZUINTEGER</code>
<a name="index-PARAM_005fZUINTEGER-1"></a>
</dt>
<dd><p>The value is an unsigned integer.
</p>
</dd>
<dt><code>PARAM_ZUINTEGER_UNLIMITED</code>
<a name="index-PARAM_005fZUINTEGER_005fUNLIMITED-1"></a>
</dt>
<dd><p>The value is an integer in the range &lsquo;<samp>[0, INT_MAX]</samp>&rsquo;.
A value of &lsquo;<samp>-1</samp>&rsquo; means &ldquo;unlimited&rdquo;, and other negative
numbers are not allowed.
</p>
</dd>
<dt><code>PARAM_STRING</code>
<a name="index-PARAM_005fSTRING-1"></a>
</dt>
<dd><p>The value is a string. When the user modifies the string, any escape
sequences, such as &lsquo;<samp>\t</samp>&rsquo;, &lsquo;<samp>\f</samp>&rsquo;, and octal escapes, are
translated into corresponding characters and encoded into the current
host charset.
</p>
</dd>
<dt><code>PARAM_STRING_NOESCAPE</code>
<a name="index-PARAM_005fSTRING_005fNOESCAPE-1"></a>
</dt>
<dd><p>The value is a string. When the user modifies the string, escapes are
passed through untranslated.
</p>
</dd>
<dt><code>PARAM_OPTIONAL_FILENAME</code>
<a name="index-PARAM_005fOPTIONAL_005fFILENAME-1"></a>
</dt>
<dd><p>The value is a either a filename (a string), or <code>#f</code>.
</p>
</dd>
<dt><code>PARAM_FILENAME</code>
<a name="index-PARAM_005fFILENAME-1"></a>
</dt>
<dd><p>The value is a filename. This is just like
<code>PARAM_STRING_NOESCAPE</code>, but uses file names for completion.
</p>
</dd>
<dt><code>PARAM_ENUM</code>
<a name="index-PARAM_005fENUM-1"></a>
</dt>
<dd><p>The value is a string, which must be one of a collection of string
constants provided when the parameter is created.
</p></dd>
</dl>
<div class="footnote">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>
<h3><a name="FOOT17" href="#DOCF17">(17)</a></h3>
<p>Note that <small>GDB</small> parameters must not be confused with
Guile’s parameter objects (see <a href="http://www.gnu.org/software/guile/manual/html_node/Parameters.html#Parameters">Parameters</a> in <cite>GNU Guile
Reference Manual</cite>).</p>
</div>
<hr>
<div class="header">
<p>
Next: <a href="Progspaces-In-Guile.html#Progspaces-In-Guile" accesskey="n" rel="next">Progspaces In Guile</a>, Previous: <a href="Commands-In-Guile.html#Commands-In-Guile" accesskey="p" rel="prev">Commands In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>