2 |
@node Debugging |
@node Debugging |
3 |
@chapter Debugging Infrastructure |
@chapter Debugging Infrastructure |
4 |
|
|
5 |
@deffn {Scheme Procedure} debug-options-interface [setting] |
@menu |
6 |
@deffnx {C Function} scm_debug_options (setting) |
* Source Properties:: Remembering the source of an expression. |
7 |
Option interface for the debug options. Instead of using |
* Using Traps:: |
8 |
this procedure directly, use the procedures @code{debug-enable}, |
* Capturing the Stack or Innermost Stack Frame:: |
9 |
@code{debug-disable}, @code{debug-set!} and @code{debug-options}. |
* Examining the Stack:: |
10 |
@end deffn |
* Examining Stack Frames:: |
11 |
|
* Decoding Memoized Source Expressions:: |
12 |
|
* Starting a New Stack:: |
13 |
|
@end menu |
14 |
|
|
15 |
|
|
16 |
|
@node Source Properties |
17 |
|
@section Source Properties |
18 |
|
|
19 |
|
@cindex source properties |
20 |
|
As Guile reads in Scheme code from file or from standard input, it |
21 |
|
remembers the file name, line number and column number where each |
22 |
|
expression begins. These pieces of information are known as the |
23 |
|
@dfn{source properties} of the expression. If an expression undergoes |
24 |
|
transformation --- for example, if there is a syntax transformer in |
25 |
|
effect, or the expression is a macro call --- the source properties are |
26 |
|
copied from the untransformed to the transformed expression so that, if |
27 |
|
an error occurs when evaluating the transformed expression, Guile's |
28 |
|
debugger can point back to the file and location where the expression |
29 |
|
originated. |
30 |
|
|
31 |
|
The way that source properties are stored means that Guile can only |
32 |
|
associate source properties with parenthesized expressions, and not, for |
33 |
|
example, with individual symbols, numbers or strings. The difference |
34 |
|
can be seen by typing @code{(xxx)} and @code{xxx} at the Guile prompt |
35 |
|
(where the variable @code{xxx} has not been defined): |
36 |
|
|
37 |
|
@example |
38 |
|
guile> (xxx) |
39 |
|
standard input:2:1: In expression (xxx): |
40 |
|
standard input:2:1: Unbound variable: xxx |
41 |
|
ABORT: (unbound-variable) |
42 |
|
guile> xxx |
43 |
|
<unnamed port>: In expression xxx: |
44 |
|
<unnamed port>: Unbound variable: xxx |
45 |
|
ABORT: (unbound-variable) |
46 |
|
@end example |
47 |
|
|
48 |
|
@noindent |
49 |
|
In the latter case, no source properties were stored, so the best that |
50 |
|
Guile could say regarding the location of the problem was ``<unnamed |
51 |
|
port>''. |
52 |
|
|
53 |
|
The recording of source properties is controlled by the read option |
54 |
|
named ``positions'' (@pxref{Reader options}). This option is switched |
55 |
|
@emph{on} by default, together with the debug options ``debug'' and |
56 |
|
``backtrace'' (@pxref{Debugger options}), when Guile is run |
57 |
|
interactively; all these options are @emph{off} by default when Guile |
58 |
|
runs a script non-interactively. |
59 |
|
|
60 |
|
|
61 |
|
@node Using Traps |
62 |
@section Using Traps |
@section Using Traps |
63 |
|
|
64 |
@deffn {Scheme Procedure} with-traps thunk |
@deffn {Scheme Procedure} with-traps thunk |
72 |
@end deffn |
@end deffn |
73 |
|
|
74 |
|
|
75 |
|
@node Capturing the Stack or Innermost Stack Frame |
76 |
@section Capturing the Stack or Innermost Stack Frame |
@section Capturing the Stack or Innermost Stack Frame |
77 |
|
|
78 |
When an error occurs in a running program, or the program hits a |
When an error occurs in a running program, or the program hits a |
122 |
@end deffn |
@end deffn |
123 |
|
|
124 |
|
|
125 |
|
@node Examining the Stack |
126 |
@section Examining the Stack |
@section Examining the Stack |
127 |
|
|
128 |
@deffn {Scheme Procedure} stack? obj |
@deffn {Scheme Procedure} stack? obj |
155 |
@end deffn |
@end deffn |
156 |
|
|
157 |
|
|
158 |
|
@node Examining Stack Frames |
159 |
@section Examining Stack Frames |
@section Examining Stack Frames |
160 |
|
|
161 |
@deffn {Scheme Procedure} frame? obj |
@deffn {Scheme Procedure} frame? obj |
224 |
@end deffn |
@end deffn |
225 |
|
|
226 |
|
|
227 |
|
@node Decoding Memoized Source Expressions |
228 |
@section Decoding Memoized Source Expressions |
@section Decoding Memoized Source Expressions |
229 |
|
|
230 |
@deffn {Scheme Procedure} memoized? obj |
@deffn {Scheme Procedure} memoized? obj |
243 |
@end deffn |
@end deffn |
244 |
|
|
245 |
|
|
246 |
|
@node Starting a New Stack |
247 |
@section Starting a New Stack |
@section Starting a New Stack |
248 |
|
|
249 |
@deffn {Scheme Syntax} start-stack id exp |
@deffn {Scheme Syntax} start-stack id exp |