Guile-Exception-Handling.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Guile Exception Handling</title>
  16. <meta name="description" content="Debugging with GDB: Guile Exception Handling">
  17. <meta name="keywords" content="Debugging with GDB: Guile Exception Handling">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="Values-From-Inferior-In-Guile.html#Values-From-Inferior-In-Guile" rel="next" title="Values From Inferior In Guile">
  27. <link href="GDB-Scheme-Data-Types.html#GDB-Scheme-Data-Types" rel="previous" title="GDB Scheme Data Types">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Guile-Exception-Handling"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Values-From-Inferior-In-Guile.html#Values-From-Inferior-In-Guile" accesskey="n" rel="next">Values From Inferior In Guile</a>, Previous: <a href="GDB-Scheme-Data-Types.html#GDB-Scheme-Data-Types" accesskey="p" rel="previous">GDB Scheme Data Types</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>
  62. </div>
  63. <hr>
  64. <a name="Guile-Exception-Handling-1"></a>
  65. <h4 class="subsubsection">23.3.3.4 Guile Exception Handling</h4>
  66. <a name="index-guile-exceptions"></a>
  67. <a name="index-exceptions_002c-guile"></a>
  68. <a name="index-set-guile-print_002dstack"></a>
  69. <p>When executing the <code>guile</code> command, Guile exceptions
  70. uncaught within the Guile code are translated to calls to the
  71. <small>GDB</small> error-reporting mechanism. If the command that called
  72. <code>guile</code> does not handle the error, <small>GDB</small> will
  73. terminate it and report the error according to the setting of
  74. the <code>guile print-stack</code> parameter.
  75. </p>
  76. <p>The <code>guile print-stack</code> parameter has three settings:
  77. </p>
  78. <dl compact="compact">
  79. <dt><code>none</code></dt>
  80. <dd><p>Nothing is printed.
  81. </p>
  82. </dd>
  83. <dt><code>message</code></dt>
  84. <dd><p>An error message is printed containing the Guile exception name,
  85. the associated value, and the Guile call stack backtrace at the
  86. point where the exception was raised. Example:
  87. </p>
  88. <div class="smallexample">
  89. <pre class="smallexample">(gdb) guile (display foo)
  90. ERROR: In procedure memoize-variable-access!:
  91. ERROR: Unbound variable: foo
  92. Error while executing Scheme code.
  93. </pre></div>
  94. </dd>
  95. <dt><code>full</code></dt>
  96. <dd><p>In addition to an error message a full backtrace is printed.
  97. </p>
  98. <div class="smallexample">
  99. <pre class="smallexample">(gdb) set guile print-stack full
  100. (gdb) guile (display foo)
  101. Guile Backtrace:
  102. In ice-9/boot-9.scm:
  103. 157: 10 [catch #t #&lt;catch-closure 2c76e20&gt; ...]
  104. In unknown file:
  105. ?: 9 [apply-smob/1 #&lt;catch-closure 2c76e20&gt;]
  106. In ice-9/boot-9.scm:
  107. 157: 8 [catch #t #&lt;catch-closure 2c76d20&gt; ...]
  108. In unknown file:
  109. ?: 7 [apply-smob/1 #&lt;catch-closure 2c76d20&gt;]
  110. ?: 6 [call-with-input-string &quot;(display foo)&quot; ...]
  111. In ice-9/boot-9.scm:
  112. 2320: 5 [save-module-excursion #&lt;procedure 2c2dc30 ... ()&gt;]
  113. In ice-9/eval-string.scm:
  114. 44: 4 [read-and-eval #&lt;input: string 27cb410&gt; #:lang ...]
  115. 37: 3 [lp (display foo)]
  116. In ice-9/eval.scm:
  117. 387: 2 [eval # ()]
  118. 393: 1 [eval #&lt;memoized foo&gt; ()]
  119. In unknown file:
  120. ?: 0 [memoize-variable-access! #&lt;memoized foo&gt; ...]
  121. ERROR: In procedure memoize-variable-access!:
  122. ERROR: Unbound variable: foo
  123. Error while executing Scheme code.
  124. </pre></div>
  125. </dd>
  126. </dl>
  127. <p><small>GDB</small> errors that happen in <small>GDB</small> commands invoked by
  128. Guile code are converted to Guile exceptions. The type of the
  129. Guile exception depends on the error.
  130. </p>
  131. <p>Guile procedures provided by <small>GDB</small> can throw the standard
  132. Guile exceptions like <code>wrong-type-arg</code> and <code>out-of-range</code>.
  133. </p>
  134. <p>User interrupt (via <kbd>C-c</kbd> or by typing <kbd>q</kbd> at a pagination
  135. prompt) is translated to a Guile <code>signal</code> exception with value
  136. <code>SIGINT</code>.
  137. </p>
  138. <p><small>GDB</small> Guile procedures can also throw these exceptions:
  139. </p>
  140. <dl compact="compact">
  141. <dt><code>gdb:error</code>
  142. <a name="index-gdb_003aerror"></a>
  143. </dt>
  144. <dd><p>This exception is a catch-all for errors generated from within <small>GDB</small>.
  145. </p>
  146. </dd>
  147. <dt><code>gdb:invalid-object</code>
  148. <a name="index-gdb_003ainvalid_002dobject"></a>
  149. </dt>
  150. <dd><p>This exception is thrown when accessing Guile objects that wrap underlying
  151. <small>GDB</small> objects have become invalid. For example, a
  152. <code>&lt;gdb:breakpoint&gt;</code> object becomes invalid if the user deletes it
  153. from the command line. The object still exists in Guile, but the
  154. object it represents is gone. Further operations on this breakpoint
  155. will throw this exception.
  156. </p>
  157. </dd>
  158. <dt><code>gdb:memory-error</code>
  159. <a name="index-gdb_003amemory_002derror"></a>
  160. </dt>
  161. <dd><p>This exception is thrown when an operation tried to access invalid
  162. memory in the inferior.
  163. </p>
  164. </dd>
  165. <dt><code>gdb:pp-type-error</code>
  166. <a name="index-gdb_003app_002dtype_002derror"></a>
  167. </dt>
  168. <dd><p>This exception is thrown when a Guile pretty-printer passes a bad object
  169. to <small>GDB</small>.
  170. </p></dd>
  171. </dl>
  172. <p>The following exception-related procedures are provided by the
  173. <code>(gdb)</code> module.
  174. </p>
  175. <dl>
  176. <dt><a name="index-make_002dexception"></a>Scheme Procedure: <strong>make-exception</strong> <em>key args</em></dt>
  177. <dd><p>Return a <code>&lt;gdb:exception&gt;</code> object given by its <var>key</var> and
  178. <var>args</var>, which are the standard Guile parameters of an exception.
  179. See the Guile documentation for more information (see <a href="http://www.gnu.org/software/guile/manual/html_node/Exceptions.html#Exceptions">Exceptions</a> in <cite>GNU Guile Reference Manual</cite>).
  180. </p></dd></dl>
  181. <dl>
  182. <dt><a name="index-exception_003f"></a>Scheme Procedure: <strong>exception?</strong> <em>object</em></dt>
  183. <dd><p>Return <code>#t</code> if <var>object</var> is a <code>&lt;gdb:exception&gt;</code> object.
  184. Otherwise return <code>#f</code>.
  185. </p></dd></dl>
  186. <dl>
  187. <dt><a name="index-exception_002dkey"></a>Scheme Procedure: <strong>exception-key</strong> <em>exception</em></dt>
  188. <dd><p>Return the <var>args</var> field of a <code>&lt;gdb:exception&gt;</code> object.
  189. </p></dd></dl>
  190. <dl>
  191. <dt><a name="index-exception_002dargs"></a>Scheme Procedure: <strong>exception-args</strong> <em>exception</em></dt>
  192. <dd><p>Return the <var>args</var> field of a <code>&lt;gdb:exception&gt;</code> object.
  193. </p></dd></dl>
  194. <hr>
  195. <div class="header">
  196. <p>
  197. Next: <a href="Values-From-Inferior-In-Guile.html#Values-From-Inferior-In-Guile" accesskey="n" rel="next">Values From Inferior In Guile</a>, Previous: <a href="GDB-Scheme-Data-Types.html#GDB-Scheme-Data-Types" accesskey="p" rel="previous">GDB Scheme Data Types</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>
  198. </div>
  199. </body>
  200. </html>