annotate man/lispref/edebug-inc.texi @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents 3ecd8885ac67
children 755ae5b97edb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 @comment -*-texinfo-*-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 @node Edebug, , Compilation Errors, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 @section Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 @cindex Edebug mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 @cindex Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Edebug is a source-level debugger for XEmacs Lisp programs that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 provides the following features:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 Step through evaluation, stopping before and after each expression.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 Set conditional or unconditional breakpoints, install embedded
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 breakpoints, or a global break event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Trace slow or fast stopping briefly at each stop point, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 each breakpoint.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 Display expression results and evaluate expressions as if outside of
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
25 Edebug. Interface with the custom printing package
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 for printing circular structures.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
28 @item
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 Automatically reevaluate a list of expressions and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 display their results each time Edebug updates the display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 Output trace info on function enter and exit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 Errors stop before the source causing the error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 Display backtrace without Edebug calls.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 Allow specification of argument evaluation for macros and defining forms.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Provide rudimentary coverage testing and display of frequency counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 The first three sections should tell you enough about Edebug to enable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 you to use it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 * Using Edebug:: Introduction to use of Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 * Instrumenting:: You must first instrument code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 * Edebug Execution Modes:: Execution modes, stopping more or less often.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 * Jumping:: Commands to jump to a specified place.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 * Edebug Misc:: Miscellaneous commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 * Breakpoints:: Setting breakpoints to make the program stop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 * Trapping Errors:: trapping errors with Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 * Edebug Views:: Views inside and outside of Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 * Edebug Eval:: Evaluating expressions within Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 * Eval List:: Automatic expression evaluation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 * Reading in Edebug:: Customization of reading.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 * Printing in Edebug:: Customization of printing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 * Tracing:: How to produce tracing output.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 * Coverage Testing:: How to test evaluation coverage.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 * The Outside Context:: Data that Edebug saves and restores.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 * Instrumenting Macro Calls:: Specifying how to handle macro calls.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 * Edebug Options:: Option variables for customizing Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 @node Using Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 @subsection Using Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 To debug an XEmacs Lisp program with Edebug, you must first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 @dfn{instrument} the Lisp code that you want to debug. If you want to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 just try it now, load @file{edebug.el}, move point into a definition and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 do @kbd{C-u C-M-x} (@code{eval-defun} with a prefix argument).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 See @ref{Instrumenting} for alternative ways to instrument code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 Once a function is instrumented, any call to the function activates
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 Edebug. Activating Edebug may stop execution and let you step through
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 the function, or it may update the display and continue execution while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 checking for debugging commands, depending on the selected Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 execution mode. The initial execution mode is @code{step}, by default,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 which does stop execution. @xref{Edebug Execution Modes}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 Within Edebug, you normally view an XEmacs buffer showing the source of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 the Lisp function you are debugging. This is referred to as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 @dfn{source code buffer}---but note that it is not always the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 buffer depending on which function is currently being executed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 An arrow at the left margin indicates the line where the function is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 executing. Point initially shows where within the line the function is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 executing, but you can move point yourself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 If you instrument the definition of @code{fac} (shown below) and then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 execute @code{(fac 3)}, here is what you normally see. Point is at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 open-parenthesis before @code{if}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (defun fac (n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 =>@point{}(if (< 0 n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (* n (fac (1- n)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 @cindex stop points
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 The places within a function where Edebug can stop execution are called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 @dfn{stop points}. These occur both before and after each subexpression
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
111 that is a list, and also after each variable reference.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 Here we show with periods the stop points found in the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 @code{fac}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 (defun fac (n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 .(if .(< 0 n.).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 .(* n. .(fac (1- n.).).).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 1).)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 While the source code buffer is selected, the special commands of Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 are available in it, in addition to the commands of XEmacs Lisp mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 (The buffer is temporarily made read-only, however.) For example, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 can type the Edebug command @key{SPC} to execute until the next stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 point. If you type @key{SPC} once after entry to @code{fac}, here is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 the display you will see:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (defun fac (n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 =>(if @point{}(< 0 n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 (* n (fac (1- n)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 When Edebug stops execution after an expression, it displays the
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
137 expression's value in the echo area.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 Other frequently used commands are @kbd{b} to set a breakpoint at a stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 point, @kbd{g} to execute until a breakpoint is reached, and @kbd{q} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 exit to the top-level command loop. Type @kbd{?} to display a list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 all Edebug commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 @node Instrumenting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 @subsection Instrumenting for Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 In order to use Edebug to debug Lisp code, you must first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 @dfn{instrument} the code. Instrumenting a form inserts additional code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 into it which invokes Edebug at the proper places. Furthermore, if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 Edebug detects a syntax error while instrumenting, point is left at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 erroneous code and an @code{invalid-read-syntax} error is signaled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 @kindex C-M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 @findex eval-defun (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 @findex edebug-all-defs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 Once you have loaded Edebug, the command @kbd{C-M-x}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (@code{eval-defun}) is redefined so that when invoked with a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 argument on a definition, it instruments the definition before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 evaluating it. (The source code itself is not modified.) If the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 variable @code{edebug-all-defs} is non-@code{nil}, that inverts the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 meaning of the prefix argument: then @kbd{C-M-x} instruments the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 definition @emph{unless} it has a prefix argument. The default value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 @code{edebug-all-defs} is @code{nil}. The command @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 edebug-all-defs} toggles the value of the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 @code{edebug-all-defs}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 @findex edebug-all-forms
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 @findex eval-region (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 @findex eval-current-buffer (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 If @code{edebug-all-defs} is non-@code{nil}, then the commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 @code{eval-region}, @code{eval-current-buffer}, and @code{eval-buffer}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 also instrument any definitions they evaluate. Similarly,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 @code{edebug-all-forms} controls whether @code{eval-region} should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 instrument @emph{any} form, even non-defining forms. This doesn't apply
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 to loading or evaluations in the minibuffer. The command @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 edebug-all-forms} toggles this option.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 @findex edebug-eval-top-level-form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 Another command, @kbd{M-x edebug-eval-top-level-form}, is available to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 instrument any top-level form regardless of the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 @code{edebug-all-defs} or @code{edebug-all-forms}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 Just before Edebug instruments any code, it calls any functions in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 variable @code{edebug-setup-hook} and resets its value to @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 You could use this to load up Edebug specifications associated with a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 package you are using but only when you also use Edebug. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 @file{my-specs.el} may be loaded automatically when you use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 @code{my-package} with Edebug by including the following code in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 @file{my-package.el}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 @example
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
193 (add-hook 'edebug-setup-hook
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (function (lambda () (require 'my-specs))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 While Edebug is active, the command @kbd{I}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (@code{edebug-instrument-callee}) instruments the definition of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 function or macro called by the list form after point, if is not already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 instrumented. If the location of the definition is not known to Edebug,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 this command cannot be used. After loading Edebug, @code{eval-region}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 records the position of every definition it evaluates, even if not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 instrumenting it. Also see the command @kbd{i} (@ref{Jumping}) which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 steps into the callee.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 @cindex special forms (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 @cindex interactive commands (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 @cindex anonymous lambda expressions (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 @cindex Common Lisp (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 @pindex cl.el (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 @pindex cl-specs.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 Edebug knows how to instrument all the standard special forms, an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 interactive form with an expression argument, anonymous lambda
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 expressions, and other defining forms. (Specifications for macros
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 defined by @file{cl.el} (version 2.03) are provided in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 @file{cl-specs.el}.) Edebug cannot know what a user-defined macro will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 do with the arguments of a macro call so you must tell it. See
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 @ref{Instrumenting Macro Calls} for the details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 @findex eval-expression (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 Note that a couple ways remain to evaluate expressions without
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 instrumenting them. Loading a file via the @code{load} subroutine does
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 not instrument expressions for Edebug. Evaluations in the minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 via @code{eval-expression} (@kbd{M-ESC}) are not instrumented.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 To remove instrumentation from a definition, simply reevaluate it with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 one of the non-instrumenting commands, or reload the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 See @ref{Edebug Eval} for other evaluation functions available
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 inside of Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 @node Edebug Execution Modes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 @subsection Edebug Execution Modes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 @cindex Edebug execution modes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 Edebug supports several execution modes for running the program you are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 debugging. We call these alternatives @dfn{Edebug execution modes}; do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 not confuse them with major or minor modes. The current Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 execution mode determines how Edebug displays the progress of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 evaluation, whether it stops at each stop point, or continues to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 next breakpoint, for example.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 Normally, you specify the Edebug execution mode by typing a command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 to continue the program in a certain mode. Here is a table of these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 commands. All except for @kbd{S} resume execution of the program, at
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 least for a certain distance.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 @item S
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 Stop: don't execute any more of the program for now, just wait for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 Edebug commands (@code{edebug-stop}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 @item @key{SPC}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 Step: stop at the next stop point encountered (@code{edebug-step-mode}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 @item n
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 Next: stop at the next stop point encountered after an expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (@code{edebug-next-mode}). Also see @code{edebug-forward-sexp} in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 @ref{Edebug Misc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 @item t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 Trace: pause one second at each Edebug stop point (@code{edebug-trace-mode}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 @item T
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 Rapid trace: update at each stop point, but don't actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 pause (@code{edebug-Trace-fast-mode}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 @item g
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 Go: run until the next breakpoint (@code{edebug-go-mode}). @xref{Breakpoints}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 @item c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 Continue: pause for one second at each breakpoint, but don't stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 (@code{edebug-continue-mode}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 @item C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 Rapid continue: update at each breakpoint, but don't actually pause
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 (@code{edebug-Continue-fast-mode}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 @item G
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 Go non-stop: ignore breakpoints (@code{edebug-Go-nonstop-mode}). You
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 can still stop the program by hitting any key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 In general, the execution modes earlier in the above list run the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 program more slowly or stop sooner.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 When you enter a new Edebug level, the initial execution mode comes from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 the value of the variable @code{edebug-initial-mode}. By default, this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 specifies @code{step} mode. Note that you may reenter the same Edebug
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
291 level several times if, for example, an instrumented function is called
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 several times from one command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 While executing or tracing, you can interrupt the execution by typing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 any Edebug command. Edebug stops the program at the next stop point and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 then executes the command that you typed. For example, typing @kbd{t}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 during execution switches to trace mode at the next stop point. You can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 use @kbd{S} to stop execution without doing anything else.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 If your function happens to read input, a character you hit intending to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 interrupt execution may be read by the function instead. You can avoid
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 such unintended results by paying attention to when your program wants
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 input.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 @cindex keyboard macros (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 Keyboard macros containing Edebug commands do not work; when you exit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 from Edebug, to resume the program, whether you are defining or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 executing a keyboard macro is forgotten. Also, defining or executing a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 keyboard macro outside of Edebug does not affect the command loop inside
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 Edebug. This is usually an advantage. But see
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 @code{edebug-continue-kbd-macro}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 @node Jumping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 @subsection Jumping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 Commands described here let you jump to a specified location.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 All, except @kbd{i}, use temporary breakpoints to establish the stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 point and then switch to @code{go} mode. Any other breakpoint reached
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 before the intended stop point will also stop execution. See
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 @ref{Breakpoints} for the details on breakpoints.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 @item f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 Run the program forward over one expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (@code{edebug-forward-sexp}). More precisely, set a temporary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 breakpoint at the position that @kbd{C-M-f} would reach, then execute in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 @code{go} mode so that the program will stop at breakpoints.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 With a prefix argument @var{n}, the temporary breakpoint is placed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 @var{n} sexps beyond point. If the containing list ends before @var{n}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 more elements, then the place to stop is after the containing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 expression.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 Be careful that the position @kbd{C-M-f} finds is a place that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 program will really get to; this may not be true in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 @code{cond}, for example.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 This command does @code{forward-sexp} starting at point rather than the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 stop point. If you want to execute one expression from the current stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 point, type @kbd{w} first, to move point there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 @item o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 Continue ``out of'' an expression (@code{edebug-step-out}). It places a
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
345 temporary breakpoint at the end of the sexp containing point.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 If the containing sexp is a function definition itself, it continues
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 until just before the last sexp in the definition. If that is where you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 are now, it returns from the function and then stops. In other words,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 this command does not exit the currently executing function unless you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 are positioned after the last sexp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 @item I
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 Step into the function or macro after point after first ensuring that it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 is instrumented. It does this by calling @code{edebug-on-entry} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 then switching to @code{go} mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 Although the automatic instrumentation is convenient, it is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 later automatically uninstrumented.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 @item h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 Proceed to the stop point near where point is using a temporary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 breakpoint (@code{edebug-goto-here}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 All the commands in this section may fail to work as expected in case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 of nonlocal exit, because a nonlocal exit can bypass the temporary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 breakpoint where you expected the program to stop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 @node Edebug Misc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 @subsection Miscellaneous
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 Some miscellaneous commands are described here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 @item ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 Display the help message for Edebug (@code{edebug-help}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 @item C-]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 Abort one level back to the previous command level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (@code{abort-recursive-edit}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 @item q
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 Return to the top level editor command loop (@code{top-level}). This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 exits all recursive editing levels, including all levels of Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 activity. However, instrumented code protected with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 @code{unwind-protect} or @code{condition-case} forms may resume
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 debugging.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 @item Q
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 Like @kbd{q} but don't stop even for protected code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (@code{top-level-nonstop}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 @item r
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 Redisplay the most recently known expression result in the echo area
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (@code{edebug-previous-result}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 @item d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 Display a backtrace, excluding Edebug's own functions for clarity
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 (@code{edebug-backtrace}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 You cannot use debugger commands in the backtrace buffer in Edebug as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 you would in the standard debugger.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 The backtrace buffer is killed automatically when you continue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 execution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 From the Edebug recursive edit, you may invoke commands that activate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 Edebug again recursively. Any time Edebug is active, you can quit to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 the top level with @kbd{q} or abort one recursive edit level with
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
413 @kbd{C-]}. You can display a backtrace of all the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 pending evaluations with @kbd{d}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 @node Breakpoints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 @subsection Breakpoints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 @cindex breakpoints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 There are three more ways to stop execution once it has started:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 breakpoints, the global break condition, and embedded breakpoints.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 While using Edebug, you can specify @dfn{breakpoints} in the program you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 are testing: points where execution should stop. You can set a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 breakpoint at any stop point, as defined in @ref{Using Edebug}. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 setting and unsetting breakpoints, the stop point that is affected is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 the first one at or after point in the source code buffer. Here are the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 Edebug commands for breakpoints:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 @item b
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 Set a breakpoint at the stop point at or after point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (@code{edebug-set-breakpoint}). If you use a prefix argument, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 breakpoint is temporary (it turns off the first time it stops the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 program).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 @item u
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 Unset the breakpoint (if any) at the stop point at or after the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 point (@code{edebug-unset-breakpoint}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 @item x @var{condition} @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 Set a conditional breakpoint which stops the program only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 @var{condition} evaluates to a non-@code{nil} value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (@code{edebug-set-conditional-breakpoint}). If you use a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 argument, the breakpoint is temporary (it turns off the first time it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 stops the program).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 @item B
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 Move point to the next breakpoint in the definition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (@code{edebug-next-breakpoint}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 While in Edebug, you can set a breakpoint with @kbd{b} and unset one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 with @kbd{u}. First you must move point to a position at or before the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 desired Edebug stop point, then hit the key to change the breakpoint.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 Unsetting a breakpoint that has not been set does nothing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 Reevaluating or reinstrumenting a definition clears all its breakpoints.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 A @dfn{conditional breakpoint} tests a condition each time the program
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 gets there. To set a conditional breakpoint, use @kbd{x}, and specify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 the condition expression in the minibuffer. Setting a conditional
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 breakpoint at a stop point that already has a conditional breakpoint
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 puts the current condition expression in the minibuffer so you can edit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 You can make both conditional and unconditional breakpoints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 @dfn{temporary} by using a prefix arg to the command to set the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 breakpoint. After breaking at a temporary breakpoint, it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 automatically cleared.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 Edebug always stops or pauses at a breakpoint except when the Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 mode is @code{Go-nonstop}. In that mode, it ignores breakpoints entirely.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 To find out where your breakpoints are, use @kbd{B}, which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 moves point to the next breakpoint in the definition following point, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 to the first breakpoint if there are no following breakpoints. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 command does not continue execution---it just moves point in the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 @menu
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
482 * Global Break Condition:: Breaking on an event.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 * Embedded Breakpoints:: Embedding breakpoints in code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 @node Global Break Condition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 @subsubsection Global Break Condition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 @cindex stopping on events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 @cindex global break condition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 In contrast to breaking when execution reaches specified locations,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 you can also cause a break when a certain event occurs. The @dfn{global
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 break condition} is a condition that is repeatedly evaluated at every
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 stop point. If it evaluates to a non-@code{nil} value, then execution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 is stopped or paused depending on the execution mode, just like a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 breakpoint. Any errors that might occur as a result of evaluating the
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
498 condition are ignored, as if the result were @code{nil}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 @findex edebug-set-global-break-condition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 @vindex edebug-global-break-condition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 You can set or edit the condition expression, stored in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 @code{edebug-global-break-condition}, using @kbd{X}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (@code{edebug-set-global-break-condition}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 Using the global break condition is perhaps the fastest way
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 to find where in your code some event occurs, but since it is rather
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 expensive you should reset the condition to @code{nil} when not in use.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 @node Embedded Breakpoints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 @subsubsection Embedded Breakpoints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 @findex edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 @cindex embedded breakpoints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 Since all breakpoints in a definition are cleared each time you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 reinstrument it, you might rather create an @dfn{embedded breakpoint}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 which is simply a call to the function @code{edebug}. You can, of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 course, make such a call conditional. For example, in the @code{fac}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 function, insert the first line as shown below to stop when the argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 reaches zero:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 (defun fac (n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 (if (= n 0) (edebug))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 (if (< 0 n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (* n (fac (1- n)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 When the @code{fac} definition is instrumented and the function is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 called, Edebug will stop before the call to @code{edebug}. Depending on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 the execution mode, Edebug will stop or pause.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 However, if no instrumented code is being executed, calling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 @code{edebug} will instead invoke @code{debug}. Calling @code{debug}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 will always invoke the standard backtrace debugger.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 @node Trapping Errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 @subsection Trapping Errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 @vindex edebug-on-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 @vindex edebug-on-quit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 An error may be signaled by subroutines or XEmacs Lisp code. If a signal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 is not handled by a @code{condition-case}, this indicates an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 unrecognized situation has occurred. If Edebug is not active when an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 unhandled error is signaled, @code{debug} is run normally (if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 @code{debug-on-error} is non-@code{nil}). But while Edebug is active,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 @code{debug-on-error} and @code{debug-on-quit} are bound to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 @code{edebug-on-error} and @code{edebug-on-quit}, which are both
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 @code{t} by default. Actually, if @code{debug-on-error} already has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 a non-@code{nil} value, that value is still used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 It is best to change the values of @code{edebug-on-error} or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 @code{edebug-on-quit} when Edebug is not active since their values won't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 be used until the next time Edebug is invoked at a deeper command level.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 If you only change @code{debug-on-error} or @code{debug-on-quit} while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 Edebug is active, these changes will be forgotten when Edebug becomes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 inactive. Furthermore, during Edebug's recursive edit, these variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 are bound to the values they had outside of Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 Edebug shows you the last stop point that it knew about before the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 error was signaled. This may be the location of a call to a function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 which was not instrumented, within which the error actually occurred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 For an unbound variable error, the last known stop point might be quite
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 distant from the offending variable. If the cause of the error is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 obvious at first, note that you can also get a full backtrace inside of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 Edebug (see @ref{Edebug Misc}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 Edebug can also trap signals even if they are handled. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 @code{debug-on-error} is a list of signal names, Edebug will stop when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 any of these errors are signaled. Edebug shows you the last known stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 point just as for unhandled errors. After you continue execution, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 error is signaled again (but without being caught by Edebug). Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 can only trap errors that are handled if they are signaled in Lisp code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (not subroutines) since it does so by temporarily replacing the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 @code{signal} function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 @node Edebug Views
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 @subsection Edebug Views
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 The following Edebug commands let you view aspects of the buffer and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 window status that obtained before entry to Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 @item v
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 View the outside window configuration (@code{edebug-view-outside}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 @item p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 Temporarily display the outside current buffer with point at its outside
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 position (@code{edebug-bounce-point}). If prefix arg is supplied, sit for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 that many seconds instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 @item w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 Move point back to the current stop point (@code{edebug-where}) in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 source code buffer. Also, if you use this command in another window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 displaying the same buffer, this window will be used instead to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 display the buffer in the future.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 @item W
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 Toggle the @code{edebug-save-windows} variable which indicates whether
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 the outside window configuration is saved and restored
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 (@code{edebug-toggle-save-windows}). Also, each time it is toggled on,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 make the outside window configuration the same as the current window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 With a prefix argument, @code{edebug-toggle-save-windows} only toggles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 saving and restoring of the selected window. To specify a window that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 is not displaying the source code buffer, you must use @kbd{C-xXW} from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 the global keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 You can view the outside window configuration with @kbd{v} or just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 bounce to the current point in the current buffer with @kbd{p}, even if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 it is not normally displayed. After moving point, you may wish to pop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 back to the stop point with @kbd{w} from a source code buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 By using @kbd{W} twice, Edebug again saves and restores the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 outside window configuration, but to the current configuration. This is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 a convenient way to, for example, add another buffer to be displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 whenever Edebug is active. However, the automatic redisplay of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 @samp{*edebug*} and @samp{*edebug-trace*} may conflict with the buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 you wish to see unless you have enough windows open.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 @node Edebug Eval
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 @subsection Evaluation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 While within Edebug, you can evaluate expressions ``as if'' Edebug were
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 not running. Edebug tries to be invisible to the expression's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 evaluation and printing. Evaluation of expressions that cause side
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 effects will work as expected except for things that Edebug explicitly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 saves and restores. See @ref{The Outside Context} for details on this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 process. Also see @ref{Reading in Edebug} and @ref{Printing in Edebug}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 for topics related to evaluation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 @item e @var{exp} @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 Evaluate expression @var{exp} in the context outside of Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 (@code{edebug-eval-expression}). In other words, Edebug tries to avoid
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 altering the effect of @var{exp}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 @item M-@key{ESC} @var{exp} @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 Evaluate expression @var{exp} in the context of Edebug itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 @item C-x C-e
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 Evaluate the expression before point, in the context outside of Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 (@code{edebug-eval-last-sexp}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 @cindex lexical binding (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 Edebug supports evaluation of expressions containing references to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 lexically bound symbols created by the following constructs in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 @file{cl.el} (version 2.03 or later): @code{lexical-let},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 @code{macrolet}, and @code{symbol-macrolet}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 @node Eval List
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 @subsection Evaluation List Buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 You can use the @dfn{evaluation list buffer}, called @samp{*edebug*}, to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 evaluate expressions interactively. You can also set up the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 @dfn{evaluation list} of expressions to be evaluated automatically each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 time Edebug updates the display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 @item E
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 Switch to the evaluation list buffer @samp{*edebug*}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (@code{edebug-visit-eval-list}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 In the @samp{*edebug*} buffer you can use the commands of Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 Interaction as well as these special commands:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 @item LFD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 Evaluate the expression before point, in the outside context, and insert
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 the value in the buffer (@code{edebug-eval-print-last-sexp}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 @item C-x C-e
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 Evaluate the expression before point, in the context outside of Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 (@code{edebug-eval-last-sexp}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 @item C-c C-u
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 Build a new evaluation list from the first expression of each group,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 reevaluate and redisplay (@code{edebug-update-eval-list}). Groups are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 separated by comment lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 @item C-c C-d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 Delete the evaluation list group that point is in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 (@code{edebug-delete-eval-item}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 @item C-c C-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 Switch back to the source code buffer at the current stop point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 (@code{edebug-where}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 You can evaluate expressions in the evaluation list window with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 @kbd{LFD} or @kbd{C-x C-e}, just as you would in @samp{*scratch*};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 but they are evaluated in the context outside of Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 @cindex evaluation list (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 The expressions you enter interactively (and their results) are lost
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 when you continue execution unless you add them to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 evaluation list with @kbd{C-c C-u}. This command builds a new list from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 the first expression of each @dfn{evaluation list group}. Groups are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 separated by comment lines. Be careful not to add expressions that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 execute instrumented code otherwise an infinite loop will result.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 When the evaluation list is redisplayed, each expression is displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 followed by the result of evaluating it, and a comment line. If an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 error occurs during an evaluation, the error message is displayed in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 string as if it were the result. Therefore expressions that, for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 example, use variables not currently valid do not interrupt your
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 debugging.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 Here is an example of what the evaluation list window looks like after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 several expressions have been added to it:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 (current-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 #<buffer *scratch*>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 ;---------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 (selected-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 #<window 16 on *scratch*>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 ;---------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 (point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 ;---------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 bad-var
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 "Symbol's value as variable is void: bad-var"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 ;---------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 (recursion-depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 ;---------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 this-command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 eval-last-sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 ;---------------------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 To delete a group, move point into it and type @kbd{C-c C-d}, or simply
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 delete the text for the group and update the evaluation list with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 @kbd{C-c C-u}. When you add a new group, be sure it is separated from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 its neighbors by a comment line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 After selecting @samp{*edebug*}, you can return to the source code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 buffer with @kbd{C-c C-w}. The @samp{*edebug*} buffer is killed when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 you continue execution, and recreated next time it is needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 @node Reading in Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 @subsection Reading in Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 @cindex reading (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 To instrument a form, Edebug first reads the whole form. Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 replaces the standard Lisp Reader with its own reader that remembers the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 positions of expressions. This reader is used by the Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 replacements for @code{eval-region}, @code{eval-defun},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 @code{eval-buffer}, and @code{eval-current-buffer}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 @pindex cl-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 Another package, @file{cl-read.el}, replaces the standard reader with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 one that understands Common Lisp reader macros. If you use that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 package, Edebug will automatically load @file{edebug-cl-read.el} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 provide corresponding reader macros that remember positions of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 expressions. If you define new reader macros, you will have to define
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 similar reader macros for Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 @node Printing in Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 @subsection Printing in Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 @cindex printing (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 @cindex printing circular structures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 @pindex cust-print
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 If the result of an expression in your program contains a circular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 reference, you may get an error when Edebug attempts to print it. You
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 can set @code{print-length} to a non-zero value to limit the print
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 length of lists (the number of cdrs), and in Emacs 19, set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 @code{print-level} to a non-zero value to limit the print depth of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 lists. But you can print such circular structures and structures that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 share elements more informatively by using the @file{cust-print}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 package.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 To load @file{cust-print} and activate custom printing only for Edebug,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 simply use the command @kbd{M-x edebug-install-custom-print}. To
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 restore the standard print functions, use @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 edebug-uninstall-custom-print}. You can also activate custom printing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 for printing in any Lisp code; see the package for details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 Here is an example of code that creates a circular structure:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 (edebug-install-custom-print)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 (setq a '(x y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 (setcar a a))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 Edebug will print the result of the @code{setcar} as @samp{Result:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 #1=(#1# y)}. The @samp{#1=} notation names the structure that follows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 it, and the @samp{#1#} notation references the previously named
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 structure. This notation is used for any shared elements of lists or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 vectors.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 @vindex edebug-print-length
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 @vindex edebug-print-level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 @vindex edebug-print-circle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 @vindex print-readably
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 Independent of whether @file{cust-print} is active, while printing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 results Edebug binds @code{print-length}, @code{print-level}, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 @code{print-circle} to @code{edebug-print-length} (@code{50}),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 @code{edebug-print-level} (@code{50}), and @code{edebug-print-circle}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 (@code{t}) respectively, if these values are non-@code{nil}. Also,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 @code{print-readably} is bound to @code{nil} since some objects simply
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 cannot be printed readably.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 @node Tracing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 @subsection Tracing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 @cindex tracing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 In addition to automatic stepping through source code, which is also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 called @emph{tracing} (see @ref{Edebug Execution Modes}), Edebug can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 produce a traditional trace listing of execution in a separate buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 @samp{*edebug-trace*}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 @findex edebug-print-trace-before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 @findex edebug-print-trace-after
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
834 If the variable @code{edebug-trace} is non-@code{nil}, each function entry and
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 exit adds lines to the trace buffer. On function entry, Edebug prints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 @samp{::::@{} followed by the function name and argument values. On
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 function exit, Edebug prints @samp{::::@}} followed by the function name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 and result of the function. The number of @samp{:}s is computed from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 the recursion depth. The balanced braces in the trace buffer can be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 used to find the matching beginning or end of function calls. These
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 displays may be customized by replacing the functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 @code{edebug-print-trace-before} and @code{edebug-print-trace-after},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 which take an arbitrary message string to print.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 @findex edebug-tracing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 The macro @code{edebug-tracing} provides tracing similar to function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 enter and exit tracing, but for arbitrary expressions. This macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 should be explicitly inserted by you around expressions you wish to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 trace the execution of. The first argument is a message string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 (evaluated), and the rest are expressions to evaluate. The result of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 the last expression is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 @findex edebug-trace
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 Finally, you can insert arbitrary strings into the trace buffer with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 explicit calls to @code{edebug-trace}. The arguments of this function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 are the same as for @code{message}, but a newline is always inserted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 after each string printed in this way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 @code{edebug-tracing} and @code{edebug-trace} insert lines in the trace
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 buffer even if Edebug is not active. Every time the trace buffer is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 added to, the window is scrolled to show the last lines inserted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 (There may be some display problems if you use tracing along with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 evaluation list.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 @node Coverage Testing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 @subsection Coverage Testing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 @cindex coverage testing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 @cindex frequency counts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 @cindex performance analysis
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 Edebug provides a rudimentary coverage tester and display of execution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 frequency. Frequency counts are always accumulated, both before and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 after evaluation of each instrumented expression, even if the execution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 mode is @code{Go-nonstop}. Coverage testing is only done if the option
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 @code{edebug-test-coverage} is non-@code{nil} because this is relatively
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 expensive. Both data sets are displayed by @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 edebug-display-freq-count}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 @deffn Command edebug-display-freq-count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 Display the frequency count data for each line of the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 definition. The frequency counts are inserted as comment lines after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 each line, and you can undo all insertions with one @code{undo} command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 The counts are inserted starting under the @kbd{(} before an expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 or the @kbd{)} after an expression, or on the last char of a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 The counts are only displayed when they differ from previous counts on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 the same line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 If coverage is being tested, whenever all known results of an expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 are @code{eq}, the char @kbd{=} will be appended after the count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 for that expression. Note that this is always the case for an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 expression only evaluated once.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 To clear the frequency count and coverage data for a definition,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 reinstrument it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 @end deffn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 For example, after evaluating @code{(fac 5)} with an embedded
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 breakpoint, and setting @code{edebug-test-coverage} to @code{t}, when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 the breakpoint is reached, the frequency data is looks like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 (defun fac (n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 (if (= n 0) (edebug))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
906 ;#6 1 0 =5
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 (if (< 0 n)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
908 ;#5 =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 (* n (fac (1- n)))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
910 ;# 5 0
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 1))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
912 ;# 0
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 The comment lines show that @code{fac} has been called 6 times. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 first @code{if} statement has returned 5 times with the same result each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 time, and the same is true for the condition on the second @code{if}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 The recursive call of @code{fac} has not returned at all.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 @node The Outside Context
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 @subsection The Outside Context
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 Edebug tries to be transparent to the program you are debugging. In
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 addition, most evaluations you do within Edebug (see @ref{Edebug Eval})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 occur in the same outside context which is temporarily restored for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 evaluation. But Edebug is not completely successful and this section
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 explains precisely how it fails. Edebug operation unavoidably alters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 some data in XEmacs, and this can interfere with debugging certain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 programs. Also notice that Edebug's protection against change of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 outside data means that any side effects @emph{intended} by the user in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 the course of debugging will be defeated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 * Checking Whether to Stop:: When Edebug decides what to do.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 * Edebug Display Update:: When Edebug updates the display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 * Edebug Recursive Edit:: When Edebug stops execution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 @node Checking Whether to Stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 @subsubsection Checking Whether to Stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 Whenever Edebug is entered just to think about whether to take some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 action, it needs to save and restore certain data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 @itemize @bullet
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
948 @item
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 @code{max-lisp-eval-depth} and @code{max-specpdl-size} are both
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 incremented one time to reduce Edebug's impact on the stack.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 You could, however, still run out of stack space when using Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
953 @item
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 The state of keyboard macro execution is saved and restored. While
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 Edebug is active, @code{executing-macro} is bound to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 @code{edebug-continue-kbd-macro}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 @node Edebug Display Update
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 @subsubsection Edebug Display Update
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 When Edebug needs to display something (e.g., in trace mode), it saves
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 the current window configuration from ``outside'' Edebug. When you exit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 Edebug (by continuing the program), it restores the previous window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 XEmacs redisplays only when it pauses. Usually, when you continue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 execution, the program comes back into Edebug at a breakpoint or after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 stepping without pausing or reading input in between. In such cases,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 XEmacs never gets a chance to redisplay the ``outside'' configuration.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 What you see is the same window configuration as the last time Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 was active, with no interruption.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 Entry to Edebug for displaying something also saves and restores the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 following data, but some of these are deliberately not restored if an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 error or quit signal occurs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 @itemize @bullet
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
981 @item
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 @cindex current buffer point and mark (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 Which buffer is current, and where point and mark are in the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 buffer are saved and restored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
986 @item
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 @cindex window configuration (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 @findex save-excursion (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 @vindex edebug-save-windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 The Edebug Display Update, is saved and restored if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 @code{edebug-save-windows} is non-@code{nil}. It is not restored on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 error or quit, but the outside selected window @emph{is} reselected even
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
993 on error or quit in case a @code{save-excursion} is active.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 If the value of @code{edebug-save-windows} is a list, only the listed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 windows are saved and restored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 The window start and horizontal scrolling of the source code buffer are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 not restored, however, so that the display remains coherent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 @vindex edebug-save-displayed-buffer-points
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 The value of point in each displayed buffer is saved and restored if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 @code{edebug-save-displayed-buffer-points} is non-@code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 The variables @code{overlay-arrow-position} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 @code{overlay-arrow-string} are saved and restored. So you can safely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 invoke Edebug from the recursive edit elsewhere in the same buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1010 @item
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 @code{cursor-in-echo-area} is locally bound to @code{nil} so that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 the cursor shows up in the window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 @node Edebug Recursive Edit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 @subsubsection Edebug Recursive Edit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 When Edebug is entered and actually reads commands from the user, it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 saves (and later restores) these additional data:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 The current match data, for whichever buffer was current.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 @code{last-command}, @code{this-command}, @code{last-command-char},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 @code{last-input-char}, @code{last-input-event},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 @code{last-command-event},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 @code{last-event-frame}, @code{last-nonmenu-event}, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 @code{track-mouse} . Commands used within Edebug do not affect these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 variables outside of Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 The key sequence returned by @code{this-command-keys} is changed by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 executing commands within Edebug and there is no way to reset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 the key sequence from Lisp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 For Emacs 18, Edebug cannot save and restore the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 @code{unread-command-char}. Entering Edebug while this variable has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 a nontrivial value can interfere with execution of the program you are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 debugging.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 Complex commands executed while in Edebug are added to the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 @code{command-history}. In rare cases this can alter execution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 Within Edebug, the recursion depth appears one deeper than the recursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 depth outside Edebug. This is not true of the automatically updated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 evaluation list window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 @code{standard-output} and @code{standard-input} are bound to @code{nil}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 by the @code{recursive-edit}, but Edebug temporarily restores them during
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 evaluations.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1058 @item
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 The state of keyboard macro definition is saved and restored. While
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 Edebug is active, @code{defining-kbd-macro} is bound to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 @code{edebug-continue-kbd-macro}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 @node Instrumenting Macro Calls
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 @subsection Instrumenting Macro Calls
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 When Edebug instruments an expression that calls a Lisp macro, it needs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 additional advice to do the job properly. This is because there is no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 way to tell which subexpressions of the macro call may be evaluated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 (Evaluation may occur explicitly in the macro body, or when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 resulting expansion is evaluated, or any time later.) You must explain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 the format of macro call arguments by using @code{def-edebug-spec} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 define an @dfn{Edebug specification} for each macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1077 @defmac def-edebug-spec macro specification
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 Specify which expressions of a call to macro @var{macro} are forms to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 evaluated. For simple macros, the @var{specification} often looks very
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 similar to the formal argument list of the macro definition, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 specifications are much more general than macro arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 The @var{macro} argument may actually be any symbol, not just a macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 Unless you are using Emacs 19 or XEmacs, this macro is only defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 in Edebug, so you may want to use the following which is equivalent:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 @code{(put '@var{macro} 'edebug-form-spec '@var{specification})}
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1089 @end defmac
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 Here is a simple example that defines the specification for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 @code{for} macro described in the XEmacs Lisp Reference Manual, followed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 by an alternative, equivalent specification.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 (def-edebug-spec for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 (symbolp "from" form "to" form "do" &rest form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 (def-edebug-spec for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 (symbolp ['from form] ['to form] ['do body]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 Here is a table of the possibilities for @var{specification} and how each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 directs processing of arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 @table @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 @item @code{t}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 All arguments are instrumented for evaluation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 @item @code{0}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 None of the arguments is instrumented.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 @item a symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 The symbol must have an Edebug specification which is used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 This indirection is repeated until another kind of specification is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 found. This allows you to inherit the specification for another macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 @item a list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 The elements of the list describe the types of the arguments of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 calling form. The possible elements of a specification list are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 described in the following sections.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 * Specification List:: How to specify complex patterns of evaluation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 * Backtracking:: What Edebug does when matching fails.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 * Debugging Backquote:: Debugging Backquote
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 * Specification Examples:: To help understand specifications.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 @node Specification List
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 @subsubsection Specification List
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 @cindex Edebug specification list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 A @dfn{specification list} is required for an Edebug specification if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 some arguments of a macro call are evaluated while others are not. Some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 elements in a specification list match one or more arguments, but others
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 modify the processing of all following elements. The latter, called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 @dfn{keyword specifications}, are symbols beginning with @samp{@code{&}}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 (e.g. @code{&optional}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 A specification list may contain sublists which match arguments that are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 themselves lists, or it may contain vectors used for grouping. Sublists
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 and groups thus subdivide the specification list into a hierarchy of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 levels. Keyword specifications only apply to the remainder of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 sublist or group they are contained in and there is an implicit grouping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 around a keyword specification and all following elements in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 sublist or group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 If a specification list fails
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 at some level, then backtracking may be invoked to find some alternative
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 at a higher level, or if no alternatives remain, an error will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 signaled. See @ref{Backtracking} for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 Edebug specifications provide at least the power of regular expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 matching. Some context-free constructs are also supported: the matching
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 of sublists with balanced parentheses, recursive processing of forms,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 and recursion via indirect specifications.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 Each element of a specification list may be one of the following, with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 the corresponding type of argument:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 @item sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 A single unevaluated expression.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 @item form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 A single evaluated expression, which is instrumented.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 @item place
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 @findex edebug-unwrap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 A place as in the Common Lisp @code{setf} place argument. It will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 instrumented just like a form, but the macro is expected to strip the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 instrumentation. Two functions, @code{edebug-unwrap} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 @code{edebug-unwrap*}, are provided to strip the instrumentation one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 level or recursively at all levels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 @item body
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 Short for @code{&rest form}. See @code{&rest} below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 @item function-form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 A function form: either a quoted function symbol, a quoted lambda expression,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 or a form (that should evaluate to a function symbol or lambda
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 expression). This is useful when function arguments might be quoted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 with @code{quote} rather than @code{function} since the body of a lambda
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 expression will be instrumented either way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 @item lambda-expr
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 An unquoted anonymous lambda expression.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 @item &optional
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 @cindex &optional (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 All following elements in the specification list are optional; as soon
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1197 as one does not match, Edebug stops matching at this level.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 To make just a few elements optional followed by non-optional elements,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 use @code{[&optional @var{specs}@dots{}]}. To specify that several
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 elements should all succeed together, use @code{&optional
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 [@var{specs}@dots{}]}. See the @code{defun} example below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 @item &rest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 @cindex &rest (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 All following elements in the specification list are repeated zero or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 more times. All the elements need not match in the last repetition,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 however.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 To repeat only a few elements, use @code{[&rest @var{specs}@dots{}]}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 To specify all elements must match on every repetition, use @code{&rest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 [@var{specs}@dots{}]}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 @item &or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 @cindex &or (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 Each of the following elements in the specification list is an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 alternative, processed left to right until one matches. One of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 alternatives must match otherwise the @code{&or} specification fails.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 Each list element following @code{&or} is a single alternative even if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 it is a keyword specification. (This breaks the implicit grouping rule.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 To group two or more list elements as a single alternative, enclose them
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 in @code{[@dots{}]}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 @item &not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 @cindex &not (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 Each of the following elements is matched as alternatives as if by using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 @code{&or}, but if any of them match, the specification fails. If none
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 of them match, nothing is matched, but the @code{&not} specification
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 succeeds.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1232 @item &define
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 @cindex &define (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 Indicates that the specification is for a defining form. The defining
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 form itself is not instrumented (i.e. Edebug does not stop before and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 after the defining form), but forms inside it typically will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 instrumented. The @code{&define} keyword should be the first element in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 a list specification.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 Additional specifications that may only appear after @code{&define} are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 described here. See the @code{defun} example below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 @item name
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1246 The argument, a symbol, is the name of the defining form.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 But a defining form need not be named at all, in which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 case a unique name will be created for it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 The @code{name} specification may be used more than once in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 specification and each subsequent use will append the corresponding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 symbol argument to the previous name with @samp{@code{@@}} between them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 This is useful for generating unique but meaningful names for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 definitions such as @code{defadvice} and @code{defmethod}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 @item :name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 The element following @code{:name} should be a symbol; it is used as an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 additional name component for the definition. This is useful to add a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 unique, static component to the name of the definition. It may be used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 more than once. No argument is matched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 @item arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 The argument, a symbol, is the name of an argument of the defining form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 However, lambda list keywords (symbols starting with @samp{@code{&}})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 are not allowed. See @code{lambda-list} and the example below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 @item lambda-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 @cindex lambda-list (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 This matches the whole argument list of an XEmacs Lisp lambda
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 expression, which is a list of symbols and the keywords
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 @code{&optional} and @code{&rest}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 @item def-body
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 The argument is the body of code in a definition. This is like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 @code{body}, described above, but a definition body must be instrumented
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 with a different Edebug call that looks up information associated with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 the definition. Use @code{def-body} for the highest level list of forms
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 within the definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 @item def-form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 The argument is a single, highest-level form in a definition. This is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 like @code{def-body}, except use this to match a single form rather than
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 a list of forms. As a special case, @code{def-form} also means that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 tracing information is not output when the form is executed. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 @code{interactive} example below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 @item nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 This is successful when there are no more arguments to match at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 current argument list level; otherwise it fails. See sublist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 specifications and the backquote example below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 @item gate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 @cindex preventing backtracking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 No argument is matched but backtracking through the gate is disabled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 while matching the remainder of the specifications at this level. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 is primarily used to generate more specific syntax error messages. See
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 @ref{Backtracking} for more details. Also see the @code{let} example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 @item @var{other-symbol}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 @cindex indirect specifications
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 Any other symbol in a specification list may be a predicate or an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 indirect specification.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 If the symbol has an Edebug specification, this @dfn{indirect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 specification} should be either a list specification that is used in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 place of the symbol, or a function that is called to process the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 arguments. The specification may be defined with @code{def-edebug-spec}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 just as for macros. See the @code{defun} example below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 Otherwise, the symbol should be a predicate. The predicate is called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 with the argument and the specification fails if the predicate fails.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 The argument is not instrumented.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 @findex keywordp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 @findex lambda-list-keywordp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 Predicates that may be used include: @code{symbolp}, @code{integerp},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 @code{stringp}, @code{vectorp}, @code{atom} (which matches a number,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 string, symbol, or vector), @code{keywordp}, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 @code{lambda-list-keywordp}. The last two, defined in @file{edebug.el},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 test whether the argument is a symbol starting with @samp{@code{:}} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 @samp{@code{&}} respectively.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 @item [@var{elements}@dots{}]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 @cindex [@dots{}] (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 Rather than matching a vector argument, a vector treats
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 the @var{elements} as a single @dfn{group specification}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 @item "@var{string}"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 The argument should be a symbol named @var{string}. This specification
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 is equivalent to the quoted symbol, @code{'@var{symbol}}, where the name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 of @var{symbol} is the @var{string}, but the string form is preferred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 @item '@var{symbol} @r{or} (quote @var{symbol})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 The argument should be the symbol @var{symbol}. But use a string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 specification instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 @item (vector @var{elements}@dots{})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 The argument should be a vector whose elements must match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 @var{elements} in the specification. See the backquote example below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 @item (@var{elements}@dots{})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 Any other list is a @dfn{sublist specification} and the argument must be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 a list whose elements match the specification @var{elements}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 @cindex dotted lists (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 A sublist specification may be a dotted list and the corresponding list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 argument may then be a dotted list. Alternatively, the last cdr of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 dotted list specification may be another sublist specification (via a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 grouping or an indirect specification, e.g. @code{(spec . [(more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 specs@dots{})])}) whose elements match the non-dotted list arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 This is useful in recursive specifications such as in the backquote
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 example below. Also see the description of a @code{nil} specification
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 above for terminating such recursion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 Note that a sublist specification of the form @code{(specs . nil)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 means the same as @code{(specs)}, and @code{(specs .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 (sublist-elements@dots{}))} means the same as @code{(specs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 sublist-elements@dots{})}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 @c Need to document extensions with &symbol and :symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 @node Backtracking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 @subsubsection Backtracking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 @cindex backtracking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 @cindex syntax error (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 If a specification fails to match at some point, this does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 necessarily mean a syntax error will be signaled; instead,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 @dfn{backtracking} will take place until all alternatives have been
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 exhausted. Eventually every element of the argument list must be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 matched by some element in the specification, and every required element
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 in the specification must match some argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 Backtracking is disabled for the remainder of a sublist or group when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 certain conditions occur, described below. Backtracking is reenabled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 when a new alternative is established by @code{&optional}, @code{&rest},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 or @code{&or}. It is also reenabled initially when processing a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 sublist or group specification or an indirect specification.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 You might want to disable backtracking to commit to some alternative so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 that Edebug can provide a more specific syntax error message. Normally,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 if no alternative matches, Edebug reports that none matched, but if one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 alternative is committed to, Edebug can report how it failed to match.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 First, backtracking is disabled while matching any of the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 specifications (i.e. @code{form}, @code{body}, @code{def-form}, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 @code{def-body}). These specifications will match any form so any error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 must be in the form itself rather than at a higher level.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 Second, backtracking is disabled after successfully matching a quoted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 symbol or string specification, since this usually indicates a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 recognized construct. If you have a set of alternative constructs that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 all begin with the same symbol, you can usually work around this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 constraint by factoring the symbol out of the alternatives, e.g.,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 @code{["foo" &or [first case] [second case] ...]}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 Third, backtracking may be explicitly disabled by using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 @code{gate} specification. This is useful when you know that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 no higher alternatives may apply.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 @node Debugging Backquote
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 @subsubsection Debugging Backquote
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 @findex ` (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 @cindex backquote (Edebug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 Backquote (@kbd{`}) is a macro that results in an expression that may or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 may not be evaluated. It is often used to simplify the definition of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 macro to return an expression that is evaluated, but Edebug does not know
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 when this is the case. However, the forms inside unquotes (@code{,} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 @code{,@@}) are evaluated and Edebug instruments them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 Nested backquotes are supported by Edebug, but there is a limit on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 support of quotes inside of backquotes. Quoted forms (with @code{'})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 are not normally evaluated, but if the quoted form appears immediately
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 within @code{,} and @code{,@@} forms, Edebug treats this as a backquoted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 form at the next higher level (even if there is not a next higher level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 - this is difficult to fix).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 @findex edebug-`
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 If the backquoted forms happen to be code intended to be evaluated, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 can have Edebug instrument them by using @code{edebug-`} instead of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 regular @code{`}. Unquoted forms can always appear inside
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 @code{edebug-`} anywhere a form is normally allowed. But @code{(,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 @var{form})} may be used in two other places specially recognized by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 Edebug: wherever a predicate specification would match, and at the head
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 of a list form in place of a function name or lambda expression. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 @var{form} inside a spliced unquote, @code{(,@@ @var{form})}, will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 wrapped, but the unquote form itself will not be wrapped since this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 would interfere with the splicing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 There is one other complication with using @code{edebug-`}. If the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 @code{edebug-`} call is in a macro and the macro may be called from code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 that is also instrumented, and if unquoted forms contain any macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 arguments bound to instrumented forms, then you should modify the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 specification for the macro as follows: the specifications for those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 arguments must use @code{def-form} instead of @code{form}. (This is to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 reestablish the Edebugging context for those external forms.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1445 For example, the @code{for} macro
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 @c (@pxref{Problems with Macros}) @c in XEmacs Lisp Reference Manual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 (@pxref{Problems with Macros,,,, XEmacs Lisp Reference Manual}) @c Edebug Doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 is shown here but with @code{edebug-`}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 substituted for regular @code{`}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 (defmacro inc (var)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 (list 'setq var (list '1+ var)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 (defmacro for (var from init to final do &rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 (let ((tempvar (make-symbol "max")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 (edebug-` (let (((, var) (, init))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 ((, tempvar) (, final)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 (while (<= (, var) (, tempvar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 (,@ body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 (inc (, var)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 Here is the corresponding modified Edebug specification and some code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 that calls the macro:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 (def-edebug-spec for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 (symbolp "from" def-form "to" def-form "do" &rest def-form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 (let ((n 5))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 (for i from n to (* n (+ n 1)) do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 (message "%s" i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 After instrumenting the @code{for} macro and the macro call, Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 first steps to the beginning of the macro call, then into the macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 body, then through each of the unquoted expressions in the backquote
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 showing the expressions that will be embedded in the backquote form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 Then when the macro expansion is evaluated, Edebug will step through the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 @code{let} form and each time it gets to an unquoted form, it will jump
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 back to an argument of the macro call to step through that expression.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 Finally stepping will continue after the macro call. Even more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 convoluted execution paths may result when using anonymous functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 @vindex edebug-unwrap-results
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 When the result of an expression is an instrumented expression, it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 difficult to see the expression inside the instrumentation. So
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 you may want to set the option @code{edebug-unwrap-results} to a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 non-@code{nil} value while debugging such expressions, but it would slow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 Edebug down to always do this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 @node Specification Examples
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 @subsubsection Specification Examples
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 Here we provide several examples of Edebug specifications to show
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 many of its capabilities.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 A @code{let} special form has a sequence of bindings and a body. Each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 of the bindings is either a symbol or a sublist with a symbol and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 optional value. In the specification below, notice the @code{gate}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 inside of the sublist to prevent backtracking.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 (def-edebug-spec let
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 ((&rest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 &or symbolp (gate symbolp &optional form))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 Edebug uses the following specifications for @code{defun} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 @code{defmacro} and the associated argument list and @code{interactive}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 specifications. It is necessary to handle the expression argument of an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 interactive form specially since it is actually evaluated outside of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 function body.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 (def-edebug-spec defmacro defun) ; @r{Indirect ref to @code{defun} spec}
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1520 (def-edebug-spec defun
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1521 (&define name lambda-list
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 [&optional stringp] ; @r{Match the doc string, if present.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 [&optional ("interactive" interactive)]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 def-body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 (def-edebug-spec lambda-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 (([&rest arg]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 [&optional ["&optional" arg &rest arg]]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 &optional ["&rest" arg]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 (def-edebug-spec interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 (&optional &or stringp def-form)) ; @r{Notice: @code{def-form}}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 The specification for backquote below illustrates how to match
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 dotted lists and use @code{nil} to terminate recursion. It also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 illustrates how components of a vector may be matched. (The actual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 specification provided by Edebug does not support dotted lists because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 doing so causes very deep recursion that could fail.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 (def-edebug-spec ` (backquote-form)) ;; alias just for clarity
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 (def-edebug-spec backquote-form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 (&or ([&or "," ",@@"] &or ("quote" backquote-form) form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 (backquote-form . [&or nil backquote-form])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 (vector &rest backquote-form)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 sexp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 @node Edebug Options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 @subsection Edebug Options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 These options affect the behavior of Edebug:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 @defopt edebug-setup-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 Functions to call before Edebug is used. Each time it is set to a new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 value, Edebug will call those functions once and then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 @code{edebug-setup-hook} is reset to @code{nil}. You could use this to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 load up Edebug specifications associated with a package you are using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 but only when you also use Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 See @ref{Instrumenting}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 @defopt edebug-all-defs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 If non-@code{nil}, normal evaluation of any defining forms (e.g.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 @code{defun} and @code{defmacro}) will instrument them for Edebug. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 applies to @code{eval-defun}, @code{eval-region}, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 @code{eval-current-buffer}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 Use the command @kbd{M-x edebug-all-defs} to toggle the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 this variable. You may want to make this variable local to each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 buffer by calling @code{(make-local-variable 'edebug-all-defs)} in your
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 @code{emacs-lisp-mode-hook}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 See @ref{Instrumenting}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 @defopt edebug-all-forms
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 If non-@code{nil}, normal evaluation of any forms by @code{eval-defun},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 @code{eval-region}, and @code{eval-current-buffer} will instrument them
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 for Edebug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 Use the command @kbd{M-x edebug-all-forms} to toggle the value of this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 option.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 See @ref{Instrumenting}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 @defopt edebug-save-windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 If non-@code{nil}, save and restore window configuration on Edebug
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 calls. It takes some time to do this, so if your program does not care
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 what happens to data about windows, you may want to set this variable to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 If the value is a list, only the listed windows are saved and
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1597 restored.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 @kbd{M-x edebug-toggle-save-windows} may be used to change this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 This command is bound to @kbd{W} in source code buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 See @ref{Edebug Display Update}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 @defopt edebug-save-displayed-buffer-points
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 If non-@code{nil}, save and restore point in all displayed buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 This is necessary if you are debugging code that changes the point of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 buffer which is displayed in a non-selected window. If Edebug or the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 user then selects the window, the buffer's point will be changed to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 window's point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 This is an expensive operation since it visits each window and therefore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 each displayed buffer twice for each Edebug activation, so it is best to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 avoid it if you can.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 See @ref{Edebug Display Update}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 @defopt edebug-initial-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 If this variable is non-@code{nil}, it specifies the initial execution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 mode for Edebug when it is first activated. Possible values are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 @code{step}, @code{next}, @code{go}, @code{Go-nonstop}, @code{trace},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 @code{Trace-fast}, @code{continue}, and @code{Continue-fast}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1624 The default value is @code{step}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 See @ref{Edebug Execution Modes}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 @defopt edebug-trace
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 @findex edebug-print-trace-before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 @findex edebug-print-trace-after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 Non-@code{nil} means display a trace of function entry and exit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 Tracing output is displayed in a buffer named @samp{*edebug-trace*}, one
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1633 function entry or exit per line, indented by the recursion level.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1635 The default value is @code{nil}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 Also see @code{edebug-tracing}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 See @ref{Tracing}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1641 @defopt edebug-test-coverage
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 If non-@code{nil}, Edebug tests coverage of all expressions debugged.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 This is done by comparing the result of each expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 with the previous result. Coverage is considered OK if two different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 results are found. So to sufficiently test the coverage of your code,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 try to execute it under conditions that evaluate all expressions more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 than once, and produce different results for each expression.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 Use @kbd{M-x edebug-display-freq-count} to display the frequency count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 and coverage information for a definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 See @ref{Coverage Testing}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1654 @defopt edebug-continue-kbd-macro
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 If non-@code{nil}, continue defining or executing any keyboard macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 that is executing outside of Edebug. Use this with caution since it is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 debugged.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 See @ref{Edebug Execution Modes}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 @defopt edebug-print-length
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 If non-@code{nil}, bind @code{print-length} to this while printing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 results in Edebug. The default value is @code{50}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 See @ref{Printing in Edebug}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1667 @defopt edebug-print-level
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 If non-@code{nil}, bind @code{print-level} to this while printing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 results in Edebug. The default value is @code{50}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1672 @defopt edebug-print-circle
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 If non-@code{nil}, bind @code{print-circle} to this while printing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 results in Edebug. The default value is @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 @defopt edebug-on-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 @code{debug-on-error} is bound to this while Edebug is active.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 See @ref{Trapping Errors}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 @defopt edebug-on-quit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 @code{debug-on-quit} is bound to this while Edebug is active.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 See @ref{Trapping Errors}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 @defopt edebug-unwrap-results
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 Non-@code{nil} if Edebug should unwrap results of expressions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 This is useful when debugging macros where the results of expressions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 are instrumented expressions. But don't do this when results might be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 circular or an infinite loop will result.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 See @ref{Debugging Backquote}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 @end defopt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 @defopt edebug-global-break-condition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 If non-@code{nil}, an expression to test for at every stop point.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
1697 If the result is non-@code{nil}, then break. Errors are ignored.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 See @ref{Global Break Condition}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 @end defopt