Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

501 lines
25KB

  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>Values From Inferior In Guile (Debugging with GDB)</title>
  17. <meta name="description" content="Values From Inferior In Guile (Debugging with GDB)">
  18. <meta name="keywords" content="Values From Inferior 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="Arithmetic-In-Guile.html#Arithmetic-In-Guile" rel="next" title="Arithmetic In Guile">
  27. <link href="Guile-Exception-Handling.html#Guile-Exception-Handling" rel="prev" title="Guile Exception Handling">
  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="Values-From-Inferior-In-Guile"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Arithmetic-In-Guile.html#Arithmetic-In-Guile" accesskey="n" rel="next">Arithmetic In Guile</a>, Previous: <a href="Guile-Exception-Handling.html#Guile-Exception-Handling" accesskey="p" rel="prev">Guile Exception Handling</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="Values-From-Inferior-In-Guile-1"></a>
  64. <h4 class="subsubsection">23.3.3.5 Values From Inferior In Guile</h4>
  65. <a name="index-values-from-inferior_002c-in-guile"></a>
  66. <a name="index-guile_002c-working-with-values-from-inferior"></a>
  67. <a name="index-_003cgdb_003avalue_003e"></a>
  68. <p><small>GDB</small> provides values it obtains from the inferior program in
  69. an object of type <code>&lt;gdb:value&gt;</code>. <small>GDB</small> uses this object
  70. for its internal bookkeeping of the inferior&rsquo;s values, and for
  71. fetching values when necessary.
  72. </p>
  73. <p><small>GDB</small> does not memoize <code>&lt;gdb:value&gt;</code> objects.
  74. <code>make-value</code> always returns a fresh object.
  75. </p>
  76. <div class="smallexample">
  77. <pre class="smallexample">(gdb) guile (eq? (make-value 1) (make-value 1))
  78. $1 = #f
  79. (gdb) guile (equal? (make-value 1) (make-value 1))
  80. $1 = #t
  81. </pre></div>
  82. <p>A <code>&lt;gdb:value&gt;</code> that represents a function can be executed via
  83. inferior function call with <code>value-call</code>.
  84. Any arguments provided to the call must match the function&rsquo;s prototype,
  85. and must be provided in the order specified by that prototype.
  86. </p>
  87. <p>For example, <code>some-val</code> is a <code>&lt;gdb:value&gt;</code> instance
  88. representing a function that takes two integers as arguments. To
  89. execute this function, call it like so:
  90. </p>
  91. <div class="smallexample">
  92. <pre class="smallexample">(define result (value-call some-val 10 20))
  93. </pre></div>
  94. <p>Any values returned from a function call are <code>&lt;gdb:value&gt;</code> objects.
  95. </p>
  96. <p>Note: Unlike Python scripting in <small>GDB</small>,
  97. inferior values that are simple scalars cannot be used directly in
  98. Scheme expressions that are valid for the value&rsquo;s data type.
  99. For example, <code>(+ (parse-and-eval &quot;int_variable&quot;) 2)</code> does not work.
  100. And inferior values that are structures or instances of some class cannot
  101. be accessed using any special syntax, instead <code>value-field</code> must be used.
  102. </p>
  103. <p>The following value-related procedures are provided by the
  104. <code>(gdb)</code> module.
  105. </p>
  106. <dl>
  107. <dt><a name="index-value_003f"></a>Scheme Procedure: <strong>value?</strong> <em>object</em></dt>
  108. <dd><p>Return <code>#t</code> if <var>object</var> is a <code>&lt;gdb:value&gt;</code> object.
  109. Otherwise return <code>#f</code>.
  110. </p></dd></dl>
  111. <dl>
  112. <dt><a name="index-make_002dvalue"></a>Scheme Procedure: <strong>make-value</strong> <em>value <span class="roman">[</span>#:type type<span class="roman">]</span></em></dt>
  113. <dd><p>Many Scheme values can be converted directly to a <code>&lt;gdb:value&gt;</code>
  114. with this procedure. If <var>type</var> is specified, the result is a value
  115. of this type, and if <var>value</var> can&rsquo;t be represented with this type
  116. an exception is thrown. Otherwise the type of the result is determined from
  117. <var>value</var> as described below.
  118. </p>
  119. <p>See <a href="Architectures-In-Guile.html#Architectures-In-Guile">Architectures In Guile</a>, for a list of the builtin
  120. types for an architecture.
  121. </p>
  122. <p>Here&rsquo;s how Scheme values are converted when <var>type</var> argument to
  123. <code>make-value</code> is not specified:
  124. </p>
  125. <dl compact="compact">
  126. <dt>Scheme boolean</dt>
  127. <dd><p>A Scheme boolean is converted the boolean type for the current language.
  128. </p>
  129. </dd>
  130. <dt>Scheme integer</dt>
  131. <dd><p>A Scheme integer is converted to the first of a C <code>int</code>,
  132. <code>unsigned int</code>, <code>long</code>, <code>unsigned long</code>,
  133. <code>long long</code> or <code>unsigned long long</code> type
  134. for the current architecture that can represent the value.
  135. </p>
  136. <p>If the Scheme integer cannot be represented as a target integer
  137. an <code>out-of-range</code> exception is thrown.
  138. </p>
  139. </dd>
  140. <dt>Scheme real</dt>
  141. <dd><p>A Scheme real is converted to the C <code>double</code> type for the
  142. current architecture.
  143. </p>
  144. </dd>
  145. <dt>Scheme string</dt>
  146. <dd><p>A Scheme string is converted to a string in the current target
  147. language using the current target encoding.
  148. Characters that cannot be represented in the current target encoding
  149. are replaced with the corresponding escape sequence. This is Guile&rsquo;s
  150. <code>SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE</code> conversion strategy
  151. (see <a href="http://www.gnu.org/software/guile/manual/html_node/Strings.html#Strings">Strings</a> in <cite>GNU Guile Reference Manual</cite>).
  152. </p>
  153. <p>Passing <var>type</var> is not supported in this case,
  154. if it is provided a <code>wrong-type-arg</code> exception is thrown.
  155. </p>
  156. </dd>
  157. <dt><code>&lt;gdb:lazy-string&gt;</code></dt>
  158. <dd><p>If <var>value</var> is a <code>&lt;gdb:lazy-string&gt;</code> object (see <a href="Lazy-Strings-In-Guile.html#Lazy-Strings-In-Guile">Lazy Strings In Guile</a>), then the <code>lazy-string-&gt;value</code> procedure is called, and
  159. its result is used.
  160. </p>
  161. <p>Passing <var>type</var> is not supported in this case,
  162. if it is provided a <code>wrong-type-arg</code> exception is thrown.
  163. </p>
  164. </dd>
  165. <dt>Scheme bytevector</dt>
  166. <dd><p>If <var>value</var> is a Scheme bytevector and <var>type</var> is provided,
  167. <var>value</var> must be the same size, in bytes, of values of type <var>type</var>,
  168. and the result is essentially created by using <code>memcpy</code>.
  169. </p>
  170. <p>If <var>value</var> is a Scheme bytevector and <var>type</var> is not provided,
  171. the result is an array of type <code>uint8</code> of the same length.
  172. </p></dd>
  173. </dl>
  174. </dd></dl>
  175. <a name="index-optimized-out-value-in-guile"></a>
  176. <dl>
  177. <dt><a name="index-value_002doptimized_002dout_003f"></a>Scheme Procedure: <strong>value-optimized-out?</strong> <em>value</em></dt>
  178. <dd><p>Return <code>#t</code> if the compiler optimized out <var>value</var>,
  179. thus it is not available for fetching from the inferior.
  180. Otherwise return <code>#f</code>.
  181. </p></dd></dl>
  182. <dl>
  183. <dt><a name="index-value_002daddress"></a>Scheme Procedure: <strong>value-address</strong> <em>value</em></dt>
  184. <dd><p>If <var>value</var> is addressable, returns a
  185. <code>&lt;gdb:value&gt;</code> object representing the address.
  186. Otherwise, <code>#f</code> is returned.
  187. </p></dd></dl>
  188. <dl>
  189. <dt><a name="index-value_002dtype"></a>Scheme Procedure: <strong>value-type</strong> <em>value</em></dt>
  190. <dd><p>Return the type of <var>value</var> as a <code>&lt;gdb:type&gt;</code> object
  191. (see <a href="Types-In-Guile.html#Types-In-Guile">Types In Guile</a>).
  192. </p></dd></dl>
  193. <dl>
  194. <dt><a name="index-value_002ddynamic_002dtype"></a>Scheme Procedure: <strong>value-dynamic-type</strong> <em>value</em></dt>
  195. <dd><p>Return the dynamic type of <var>value</var>. This uses C<tt>++</tt> run-time
  196. type information (<acronym>RTTI</acronym>) to determine the dynamic type of the
  197. value. If the value is of class type, it will return the class in
  198. which the value is embedded, if any. If the value is of pointer or
  199. reference to a class type, it will compute the dynamic type of the
  200. referenced object, and return a pointer or reference to that type,
  201. respectively. In all other cases, it will return the value&rsquo;s static
  202. type.
  203. </p>
  204. <p>Note that this feature will only work when debugging a C<tt>++</tt> program
  205. that includes <acronym>RTTI</acronym> for the object in question. Otherwise,
  206. it will just return the static type of the value as in <kbd>ptype foo</kbd>.
  207. See <a href="Symbols.html#Symbols">ptype</a>.
  208. </p></dd></dl>
  209. <dl>
  210. <dt><a name="index-value_002dcast"></a>Scheme Procedure: <strong>value-cast</strong> <em>value type</em></dt>
  211. <dd><p>Return a new instance of <code>&lt;gdb:value&gt;</code> that is the result of
  212. casting <var>value</var> to the type described by <var>type</var>, which must
  213. be a <code>&lt;gdb:type&gt;</code> object. If the cast cannot be performed for some
  214. reason, this method throws an exception.
  215. </p></dd></dl>
  216. <dl>
  217. <dt><a name="index-value_002ddynamic_002dcast"></a>Scheme Procedure: <strong>value-dynamic-cast</strong> <em>value type</em></dt>
  218. <dd><p>Like <code>value-cast</code>, but works as if the C<tt>++</tt> <code>dynamic_cast</code>
  219. operator were used. Consult a C<tt>++</tt> reference for details.
  220. </p></dd></dl>
  221. <dl>
  222. <dt><a name="index-value_002dreinterpret_002dcast"></a>Scheme Procedure: <strong>value-reinterpret-cast</strong> <em>value type</em></dt>
  223. <dd><p>Like <code>value-cast</code>, but works as if the C<tt>++</tt> <code>reinterpret_cast</code>
  224. operator were used. Consult a C<tt>++</tt> reference for details.
  225. </p></dd></dl>
  226. <dl>
  227. <dt><a name="index-value_002ddereference"></a>Scheme Procedure: <strong>value-dereference</strong> <em>value</em></dt>
  228. <dd><p>For pointer data types, this method returns a new <code>&lt;gdb:value&gt;</code> object
  229. whose contents is the object pointed to by <var>value</var>. For example, if
  230. <code>foo</code> is a C pointer to an <code>int</code>, declared in your C program as
  231. </p>
  232. <div class="smallexample">
  233. <pre class="smallexample">int *foo;
  234. </pre></div>
  235. <p>then you can use the corresponding <code>&lt;gdb:value&gt;</code> to access what
  236. <code>foo</code> points to like this:
  237. </p>
  238. <div class="smallexample">
  239. <pre class="smallexample">(define bar (value-dereference foo))
  240. </pre></div>
  241. <p>The result <code>bar</code> will be a <code>&lt;gdb:value&gt;</code> object holding the
  242. value pointed to by <code>foo</code>.
  243. </p>
  244. <p>A similar function <code>value-referenced-value</code> exists which also
  245. returns <code>&lt;gdb:value&gt;</code> objects corresponding to the values pointed to
  246. by pointer values (and additionally, values referenced by reference
  247. values). However, the behavior of <code>value-dereference</code>
  248. differs from <code>value-referenced-value</code> by the fact that the
  249. behavior of <code>value-dereference</code> is identical to applying the C
  250. unary operator <code>*</code> on a given value. For example, consider a
  251. reference to a pointer <code>ptrref</code>, declared in your C<tt>++</tt> program
  252. as
  253. </p>
  254. <div class="smallexample">
  255. <pre class="smallexample">typedef int *intptr;
  256. ...
  257. int val = 10;
  258. intptr ptr = &amp;val;
  259. intptr &amp;ptrref = ptr;
  260. </pre></div>
  261. <p>Though <code>ptrref</code> is a reference value, one can apply the method
  262. <code>value-dereference</code> to the <code>&lt;gdb:value&gt;</code> object corresponding
  263. to it and obtain a <code>&lt;gdb:value&gt;</code> which is identical to that
  264. corresponding to <code>val</code>. However, if you apply the method
  265. <code>value-referenced-value</code>, the result would be a <code>&lt;gdb:value&gt;</code>
  266. object identical to that corresponding to <code>ptr</code>.
  267. </p>
  268. <div class="smallexample">
  269. <pre class="smallexample">(define scm-ptrref (parse-and-eval &quot;ptrref&quot;))
  270. (define scm-val (value-dereference scm-ptrref))
  271. (define scm-ptr (value-referenced-value scm-ptrref))
  272. </pre></div>
  273. <p>The <code>&lt;gdb:value&gt;</code> object <code>scm-val</code> is identical to that
  274. corresponding to <code>val</code>, and <code>scm-ptr</code> is identical to that
  275. corresponding to <code>ptr</code>. In general, <code>value-dereference</code> can
  276. be applied whenever the C unary operator <code>*</code> can be applied
  277. to the corresponding C value. For those cases where applying both
  278. <code>value-dereference</code> and <code>value-referenced-value</code> is allowed,
  279. the results obtained need not be identical (as we have seen in the above
  280. example). The results are however identical when applied on
  281. <code>&lt;gdb:value&gt;</code> objects corresponding to pointers (<code>&lt;gdb:value&gt;</code>
  282. objects with type code <code>TYPE_CODE_PTR</code>) in a C/C<tt>++</tt> program.
  283. </p></dd></dl>
  284. <dl>
  285. <dt><a name="index-value_002dreferenced_002dvalue"></a>Scheme Procedure: <strong>value-referenced-value</strong> <em>value</em></dt>
  286. <dd><p>For pointer or reference data types, this method returns a new
  287. <code>&lt;gdb:value&gt;</code> object corresponding to the value referenced by the
  288. pointer/reference value. For pointer data types,
  289. <code>value-dereference</code> and <code>value-referenced-value</code> produce
  290. identical results. The difference between these methods is that
  291. <code>value-dereference</code> cannot get the values referenced by reference
  292. values. For example, consider a reference to an <code>int</code>, declared
  293. in your C<tt>++</tt> program as
  294. </p>
  295. <div class="smallexample">
  296. <pre class="smallexample">int val = 10;
  297. int &amp;ref = val;
  298. </pre></div>
  299. <p>then applying <code>value-dereference</code> to the <code>&lt;gdb:value&gt;</code> object
  300. corresponding to <code>ref</code> will result in an error, while applying
  301. <code>value-referenced-value</code> will result in a <code>&lt;gdb:value&gt;</code> object
  302. identical to that corresponding to <code>val</code>.
  303. </p>
  304. <div class="smallexample">
  305. <pre class="smallexample">(define scm-ref (parse-and-eval &quot;ref&quot;))
  306. (define err-ref (value-dereference scm-ref)) ;; error
  307. (define scm-val (value-referenced-value scm-ref)) ;; ok
  308. </pre></div>
  309. <p>The <code>&lt;gdb:value&gt;</code> object <code>scm-val</code> is identical to that
  310. corresponding to <code>val</code>.
  311. </p></dd></dl>
  312. <dl>
  313. <dt><a name="index-value_002dfield"></a>Scheme Procedure: <strong>value-field</strong> <em>value field-name</em></dt>
  314. <dd><p>Return field <var>field-name</var> from <code>&lt;gdb:value&gt;</code> object <var>value</var>.
  315. </p></dd></dl>
  316. <dl>
  317. <dt><a name="index-value_002dsubscript"></a>Scheme Procedure: <strong>value-subscript</strong> <em>value index</em></dt>
  318. <dd><p>Return the value of array <var>value</var> at index <var>index</var>.
  319. The <var>value</var> argument must be a subscriptable <code>&lt;gdb:value&gt;</code> object.
  320. </p></dd></dl>
  321. <dl>
  322. <dt><a name="index-value_002dcall"></a>Scheme Procedure: <strong>value-call</strong> <em>value arg-list</em></dt>
  323. <dd><p>Perform an inferior function call, taking <var>value</var> as a pointer
  324. to the function to call.
  325. Each element of list <var>arg-list</var> must be a &lt;gdb:value&gt; object or an object
  326. that can be converted to a value.
  327. The result is the value returned by the function.
  328. </p></dd></dl>
  329. <dl>
  330. <dt><a name="index-value_002d_003ebool"></a>Scheme Procedure: <strong>value-&gt;bool</strong> <em>value</em></dt>
  331. <dd><p>Return the Scheme boolean representing <code>&lt;gdb:value&gt;</code> <var>value</var>.
  332. The value must be &ldquo;integer like&rdquo;. Pointers are ok.
  333. </p></dd></dl>
  334. <dl>
  335. <dt><a name="index-value_002d_003einteger"></a>Scheme Procedure: <strong>value-&gt;integer</strong></dt>
  336. <dd><p>Return the Scheme integer representing <code>&lt;gdb:value&gt;</code> <var>value</var>.
  337. The value must be &ldquo;integer like&rdquo;. Pointers are ok.
  338. </p></dd></dl>
  339. <dl>
  340. <dt><a name="index-value_002d_003ereal"></a>Scheme Procedure: <strong>value-&gt;real</strong></dt>
  341. <dd><p>Return the Scheme real number representing <code>&lt;gdb:value&gt;</code> <var>value</var>.
  342. The value must be a number.
  343. </p></dd></dl>
  344. <dl>
  345. <dt><a name="index-value_002d_003ebytevector"></a>Scheme Procedure: <strong>value-&gt;bytevector</strong></dt>
  346. <dd><p>Return a Scheme bytevector with the raw contents of <code>&lt;gdb:value&gt;</code>
  347. <var>value</var>. No transformation, endian or otherwise, is performed.
  348. </p></dd></dl>
  349. <dl>
  350. <dt><a name="index-value_002d_003estring"></a>Scheme Procedure: <strong>value-&gt;string</strong> <em>value <span class="roman">[</span>#:encoding encoding<span class="roman">]</span> <span class="roman">[</span>#:errors errors<span class="roman">]</span> <span class="roman">[</span>#:length length<span class="roman">]</span></em></dt>
  351. <dd><p>If <var>value&gt;</var> represents a string, then this method
  352. converts the contents to a Guile string. Otherwise, this method will
  353. throw an exception.
  354. </p>
  355. <p>Values are interpreted as strings according to the rules of the
  356. current language. If the optional length argument is given, the
  357. string will be converted to that length, and will include any embedded
  358. zeroes that the string may contain. Otherwise, for languages
  359. where the string is zero-terminated, the entire string will be
  360. converted.
  361. </p>
  362. <p>For example, in C-like languages, a value is a string if it is a pointer
  363. to or an array of characters or ints of type <code>wchar_t</code>, <code>char16_t</code>,
  364. or <code>char32_t</code>.
  365. </p>
  366. <p>If the optional <var>encoding</var> argument is given, it must be a string
  367. naming the encoding of the string in the <code>&lt;gdb:value&gt;</code>, such as
  368. <code>&quot;ascii&quot;</code>, <code>&quot;iso-8859-6&quot;</code> or <code>&quot;utf-8&quot;</code>. It accepts
  369. the same encodings as the corresponding argument to Guile&rsquo;s
  370. <code>scm_from_stringn</code> function, and the Guile codec machinery will be used
  371. to convert the string. If <var>encoding</var> is not given, or if
  372. <var>encoding</var> is the empty string, then either the <code>target-charset</code>
  373. (see <a href="Character-Sets.html#Character-Sets">Character Sets</a>) will be used, or a language-specific encoding
  374. will be used, if the current language is able to supply one.
  375. </p>
  376. <p>The optional <var>errors</var> argument is one of <code>#f</code>, <code>error</code> or
  377. <code>substitute</code>. <code>error</code> and <code>substitute</code> must be symbols.
  378. If <var>errors</var> is not specified, or if its value is <code>#f</code>, then the
  379. default conversion strategy is used, which is set with the Scheme function
  380. <code>set-port-conversion-strategy!</code>.
  381. If the value is <code>'error</code> then an exception is thrown if there is any
  382. conversion error. If the value is <code>'substitute</code> then any conversion
  383. error is replaced with question marks.
  384. See <a href="http://www.gnu.org/software/guile/manual/html_node/Strings.html#Strings">Strings</a> in <cite>GNU Guile Reference Manual</cite>.
  385. </p>
  386. <p>If the optional <var>length</var> argument is given, the string will be
  387. fetched and converted to the given length.
  388. The length must be a Scheme integer and not a <code>&lt;gdb:value&gt;</code> integer.
  389. </p></dd></dl>
  390. <dl>
  391. <dt><a name="index-value_002d_003elazy_002dstring"></a>Scheme Procedure: <strong>value-&gt;lazy-string</strong> <em>value <span class="roman">[</span>#:encoding encoding<span class="roman">]</span> <span class="roman">[</span>#:length length<span class="roman">]</span></em></dt>
  392. <dd><p>If this <code>&lt;gdb:value&gt;</code> represents a string, then this method
  393. converts <var>value</var> to a <code>&lt;gdb:lazy-string</code> (see <a href="Lazy-Strings-In-Guile.html#Lazy-Strings-In-Guile">Lazy Strings In Guile</a>). Otherwise, this method will throw an exception.
  394. </p>
  395. <p>If the optional <var>encoding</var> argument is given, it must be a string
  396. naming the encoding of the <code>&lt;gdb:lazy-string</code>. Some examples are:
  397. <code>&quot;ascii&quot;</code>, <code>&quot;iso-8859-6&quot;</code> or <code>&quot;utf-8&quot;</code>. If the
  398. <var>encoding</var> argument is an encoding that <small>GDB</small> does not
  399. recognize, <small>GDB</small> will raise an error.
  400. </p>
  401. <p>When a lazy string is printed, the <small>GDB</small> encoding machinery is
  402. used to convert the string during printing. If the optional
  403. <var>encoding</var> argument is not provided, or is an empty string,
  404. <small>GDB</small> will automatically select the encoding most suitable for
  405. the string type. For further information on encoding in <small>GDB</small>
  406. please see <a href="Character-Sets.html#Character-Sets">Character Sets</a>.
  407. </p>
  408. <p>If the optional <var>length</var> argument is given, the string will be
  409. fetched and encoded to the length of characters specified. If
  410. the <var>length</var> argument is not provided, the string will be fetched
  411. and encoded until a null of appropriate width is found.
  412. The length must be a Scheme integer and not a <code>&lt;gdb:value&gt;</code> integer.
  413. </p></dd></dl>
  414. <dl>
  415. <dt><a name="index-value_002dlazy_003f"></a>Scheme Procedure: <strong>value-lazy?</strong> <em>value</em></dt>
  416. <dd><p>Return <code>#t</code> if <var>value</var> has not yet been fetched
  417. from the inferior.
  418. Otherwise return <code>#f</code>.
  419. <small>GDB</small> does not fetch values until necessary, for efficiency.
  420. For example:
  421. </p>
  422. <div class="smallexample">
  423. <pre class="smallexample">(define myval (parse-and-eval &quot;somevar&quot;))
  424. </pre></div>
  425. <p>The value of <code>somevar</code> is not fetched at this time. It will be
  426. fetched when the value is needed, or when the <code>fetch-lazy</code>
  427. procedure is invoked.
  428. </p></dd></dl>
  429. <dl>
  430. <dt><a name="index-make_002dlazy_002dvalue"></a>Scheme Procedure: <strong>make-lazy-value</strong> <em>type address</em></dt>
  431. <dd><p>Return a <code>&lt;gdb:value&gt;</code> that will be lazily fetched from the
  432. target. The object of type <code>&lt;gdb:type&gt;</code> whose value to fetch is
  433. specified by its <var>type</var> and its target memory <var>address</var>, which
  434. is a Scheme integer.
  435. </p></dd></dl>
  436. <dl>
  437. <dt><a name="index-value_002dfetch_002dlazy_0021"></a>Scheme Procedure: <strong>value-fetch-lazy!</strong> <em>value</em></dt>
  438. <dd><p>If <var>value</var> is a lazy value (<code>(value-lazy? value)</code> is <code>#t</code>),
  439. then the value is fetched from the inferior.
  440. Any errors that occur in the process will produce a Guile exception.
  441. </p>
  442. <p>If <var>value</var> is not a lazy value, this method has no effect.
  443. </p>
  444. <p>The result of this function is unspecified.
  445. </p></dd></dl>
  446. <dl>
  447. <dt><a name="index-value_002dprint"></a>Scheme Procedure: <strong>value-print</strong> <em>value</em></dt>
  448. <dd><p>Return the string representation (print form) of <code>&lt;gdb:value&gt;</code>
  449. <var>value</var>.
  450. </p></dd></dl>
  451. <hr>
  452. <div class="header">
  453. <p>
  454. Next: <a href="Arithmetic-In-Guile.html#Arithmetic-In-Guile" accesskey="n" rel="next">Arithmetic In Guile</a>, Previous: <a href="Guile-Exception-Handling.html#Guile-Exception-Handling" accesskey="p" rel="prev">Guile Exception Handling</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>
  455. </div>
  456. </body>
  457. </html>