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

пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Parameters In Guile (Debugging with GDB)</title>
  17. <meta name="description" content="Parameters In Guile (Debugging with GDB)">
  18. <meta name="keywords" content="Parameters In Guile (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Guile-API.html#Guile-API" rel="up" title="Guile API">
  26. <link href="Progspaces-In-Guile.html#Progspaces-In-Guile" rel="next" title="Progspaces In Guile">
  27. <link href="Commands-In-Guile.html#Commands-In-Guile" rel="prev" title="Commands In Guile">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Parameters-In-Guile"></a>
  58. <div class="header">
  59. <p>
  60. 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>
  61. </div>
  62. <hr>
  63. <a name="Parameters-In-Guile-1"></a>
  64. <h4 class="subsubsection">23.3.3.12 Parameters In Guile</h4>
  65. <a name="index-parameters-in-guile"></a>
  66. <a name="index-guile-parameters"></a>
  67. <a name="index-Parameter-1"></a>
  68. <p>You can implement new <small>GDB</small> <em>parameters</em> using Guile
  69. <a name="DOCF18" href="#FOOT18"><sup>18</sup></a>.
  70. </p>
  71. <p>There are many parameters that already exist and can be set in
  72. <small>GDB</small>. Two examples are: <code>set follow-fork</code> and
  73. <code>set charset</code>. Setting these parameters influences certain
  74. behavior in <small>GDB</small>. Similarly, you can define parameters that
  75. can be used to influence behavior in custom Guile scripts and commands.
  76. </p>
  77. <p>A new parameter is defined with the <code>make-parameter</code> Guile function,
  78. and added to <small>GDB</small> with the <code>register-parameter!</code> Guile function.
  79. This two-step approach is taken to separate out the side-effect of adding
  80. the parameter to <small>GDB</small> from <code>make-parameter</code>.
  81. </p>
  82. <p>Parameters are exposed to the user via the <code>set</code> and
  83. <code>show</code> commands. See <a href="Help.html#Help">Help</a>.
  84. </p>
  85. <dl>
  86. <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>
  87. <dd>
  88. <p>The argument <var>name</var> is the name of the new parameter. If <var>name</var>
  89. consists of multiple words, then the initial words are looked for as prefix
  90. parameters. An example of this can be illustrated with the
  91. <code>set print</code> set of parameters. If <var>name</var> is
  92. <code>print foo</code>, then <code>print</code> will be searched as the prefix
  93. parameter. In this case the parameter can subsequently be accessed in
  94. <small>GDB</small> as <code>set print foo</code>.
  95. If <var>name</var> consists of multiple words, and no prefix parameter group
  96. can be found, an exception is raised.
  97. </p>
  98. <p>The result is the <code>&lt;gdb:parameter&gt;</code> object representing the parameter.
  99. The parameter is not usable until it has been registered with <small>GDB</small>
  100. with <code>register-parameter!</code>.
  101. </p>
  102. <p>The rest of the arguments are optional.
  103. </p>
  104. <p>The argument <var>command-class</var> should be one of the &lsquo;<samp>COMMAND_</samp>&rsquo; constants
  105. (see <a href="Commands-In-Guile.html#Commands-In-Guile">Commands In Guile</a>). This argument tells <small>GDB</small> how to
  106. categorize the new parameter in the help system.
  107. The default is <code>COMMAND_NONE</code>.
  108. </p>
  109. <p>The argument <var>parameter-type</var> should be one of the &lsquo;<samp>PARAM_</samp>&rsquo; constants
  110. defined below. This argument tells <small>GDB</small> the type of the new
  111. parameter; this information is used for input validation and
  112. completion. The default is <code>PARAM_BOOLEAN</code>.
  113. </p>
  114. <p>If <var>parameter-type</var> is <code>PARAM_ENUM</code>, then
  115. <var>enum-list</var> must be a list of strings. These strings
  116. represent the possible values for the parameter.
  117. </p>
  118. <p>If <var>parameter-type</var> is not <code>PARAM_ENUM</code>, then the presence
  119. of <var>enum-list</var> will cause an exception to be thrown.
  120. </p>
  121. <p>The argument <var>set-func</var> is a function of one argument: <var>self</var> which
  122. is the <code>&lt;gdb:parameter&gt;</code> object representing the parameter.
  123. <small>GDB</small> will call this function when a <var>parameter</var>&rsquo;s value has
  124. been changed via the <code>set</code> API (for example, <kbd>set foo off</kbd>).
  125. The value of the parameter has already been set to the new value.
  126. This function must return a string to be displayed to the user.
  127. <small>GDB</small> will add a trailing newline if the string is non-empty.
  128. <small>GDB</small> generally doesn&rsquo;t print anything when a parameter is set,
  129. thus typically this function should return &lsquo;<samp>&quot;&quot;</samp>&rsquo;.
  130. A non-empty string result should typically be used for displaying warnings
  131. and errors.
  132. </p>
  133. <p>The argument <var>show-func</var> is a function of two arguments: <var>self</var> which
  134. is the <code>&lt;gdb:parameter&gt;</code> object representing the parameter, and
  135. <var>svalue</var> which is the string representation of the current value.
  136. <small>GDB</small> will call this function when a <var>parameter</var>&rsquo;s
  137. <code>show</code> API has been invoked (for example, <kbd>show foo</kbd>).
  138. This function must return a string, and will be displayed to the user.
  139. <small>GDB</small> will add a trailing newline.
  140. </p>
  141. <p>The argument <var>doc</var> is the help text for the new parameter.
  142. If there is no documentation string, a default value is used.
  143. </p>
  144. <p>The argument <var>set-doc</var> is the help text for this parameter&rsquo;s
  145. <code>set</code> command.
  146. </p>
  147. <p>The argument <var>show-doc</var> is the help text for this parameter&rsquo;s
  148. <code>show</code> command.
  149. </p>
  150. <p>The argument <var>initial-value</var> specifies the initial value of the parameter.
  151. If it is a function, it takes one parameter, the <code>&lt;gdb:parameter&gt;</code>
  152. object and its result is used as the initial value of the parameter.
  153. The initial value must be valid for the parameter type,
  154. otherwise an exception is thrown.
  155. </p></dd></dl>
  156. <dl>
  157. <dt><a name="index-register_002dparameter_0021"></a>Scheme Procedure: <strong>register-parameter!</strong> <em>parameter</em></dt>
  158. <dd><p>Add <var>parameter</var>, a <code>&lt;gdb:parameter&gt;</code> object, to <small>GDB</small>&rsquo;s
  159. list of parameters.
  160. It is an error to register a parameter more than once.
  161. The result is unspecified.
  162. </p></dd></dl>
  163. <dl>
  164. <dt><a name="index-parameter_003f"></a>Scheme Procedure: <strong>parameter?</strong> <em>object</em></dt>
  165. <dd><p>Return <code>#t</code> if <var>object</var> is a <code>&lt;gdb:parameter&gt;</code> object.
  166. Otherwise return <code>#f</code>.
  167. </p></dd></dl>
  168. <dl>
  169. <dt><a name="index-parameter_002dvalue"></a>Scheme Procedure: <strong>parameter-value</strong> <em>parameter</em></dt>
  170. <dd><p>Return the value of <var>parameter</var> which may either be
  171. a <code>&lt;gdb:parameter&gt;</code> object or a string naming the parameter.
  172. </p></dd></dl>
  173. <dl>
  174. <dt><a name="index-set_002dparameter_002dvalue_0021"></a>Scheme Procedure: <strong>set-parameter-value!</strong> <em>parameter new-value</em></dt>
  175. <dd><p>Assign <var>parameter</var> the value of <var>new-value</var>.
  176. The argument <var>parameter</var> must be an object of type <code>&lt;gdb:parameter&gt;</code>.
  177. <small>GDB</small> does validation when assignments are made.
  178. </p></dd></dl>
  179. <p>When a new parameter is defined, its type must be specified. The
  180. available types are represented by constants defined in the <code>gdb</code>
  181. module:
  182. </p>
  183. <dl compact="compact">
  184. <dt><code>PARAM_BOOLEAN</code>
  185. <a name="index-PARAM_005fBOOLEAN-1"></a>
  186. </dt>
  187. <dd><p>The value is a plain boolean. The Guile boolean values, <code>#t</code>
  188. and <code>#f</code> are the only valid values.
  189. </p>
  190. </dd>
  191. <dt><code>PARAM_AUTO_BOOLEAN</code>
  192. <a name="index-PARAM_005fAUTO_005fBOOLEAN-1"></a>
  193. </dt>
  194. <dd><p>The value has three possible states: true, false, and &lsquo;<samp>auto</samp>&rsquo;. In
  195. Guile, true and false are represented using boolean constants, and
  196. &lsquo;<samp>auto</samp>&rsquo; is represented using <code>#:auto</code>.
  197. </p>
  198. </dd>
  199. <dt><code>PARAM_UINTEGER</code>
  200. <a name="index-PARAM_005fUINTEGER-1"></a>
  201. </dt>
  202. <dd><p>The value is an unsigned integer. The value of 0 should be
  203. interpreted to mean &ldquo;unlimited&rdquo;.
  204. </p>
  205. </dd>
  206. <dt><code>PARAM_ZINTEGER</code>
  207. <a name="index-PARAM_005fZINTEGER-1"></a>
  208. </dt>
  209. <dd><p>The value is an integer.
  210. </p>
  211. </dd>
  212. <dt><code>PARAM_ZUINTEGER</code>
  213. <a name="index-PARAM_005fZUINTEGER-1"></a>
  214. </dt>
  215. <dd><p>The value is an unsigned integer.
  216. </p>
  217. </dd>
  218. <dt><code>PARAM_ZUINTEGER_UNLIMITED</code>
  219. <a name="index-PARAM_005fZUINTEGER_005fUNLIMITED-1"></a>
  220. </dt>
  221. <dd><p>The value is an integer in the range &lsquo;<samp>[0, INT_MAX]</samp>&rsquo;.
  222. A value of &lsquo;<samp>-1</samp>&rsquo; means &ldquo;unlimited&rdquo;, and other negative
  223. numbers are not allowed.
  224. </p>
  225. </dd>
  226. <dt><code>PARAM_STRING</code>
  227. <a name="index-PARAM_005fSTRING-1"></a>
  228. </dt>
  229. <dd><p>The value is a string. When the user modifies the string, any escape
  230. sequences, such as &lsquo;<samp>\t</samp>&rsquo;, &lsquo;<samp>\f</samp>&rsquo;, and octal escapes, are
  231. translated into corresponding characters and encoded into the current
  232. host charset.
  233. </p>
  234. </dd>
  235. <dt><code>PARAM_STRING_NOESCAPE</code>
  236. <a name="index-PARAM_005fSTRING_005fNOESCAPE-1"></a>
  237. </dt>
  238. <dd><p>The value is a string. When the user modifies the string, escapes are
  239. passed through untranslated.
  240. </p>
  241. </dd>
  242. <dt><code>PARAM_OPTIONAL_FILENAME</code>
  243. <a name="index-PARAM_005fOPTIONAL_005fFILENAME-1"></a>
  244. </dt>
  245. <dd><p>The value is a either a filename (a string), or <code>#f</code>.
  246. </p>
  247. </dd>
  248. <dt><code>PARAM_FILENAME</code>
  249. <a name="index-PARAM_005fFILENAME-1"></a>
  250. </dt>
  251. <dd><p>The value is a filename. This is just like
  252. <code>PARAM_STRING_NOESCAPE</code>, but uses file names for completion.
  253. </p>
  254. </dd>
  255. <dt><code>PARAM_ENUM</code>
  256. <a name="index-PARAM_005fENUM-1"></a>
  257. </dt>
  258. <dd><p>The value is a string, which must be one of a collection of string
  259. constants provided when the parameter is created.
  260. </p></dd>
  261. </dl>
  262. <div class="footnote">
  263. <hr>
  264. <h4 class="footnotes-heading">Footnotes</h4>
  265. <h3><a name="FOOT18" href="#DOCF18">(18)</a></h3>
  266. <p>Note that <small>GDB</small> parameters must not be confused with
  267. 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
  268. Reference Manual</cite>).</p>
  269. </div>
  270. <hr>
  271. <div class="header">
  272. <p>
  273. 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>
  274. </div>
  275. </body>
  276. </html>