Mercurial > emacs
comparison doc/lispref/edebug.texi @ 103897:e52d10e14bc0
Minor re-phrasings throughout.
(Edebug Execution Modes): Sit-for affects continue mode too.
(Jumping): Use `forward-sexp' rather than its keybinding.
(Edebug Misc): Fix Q binding.
(Edebug Eval): Remove cl version.
(Printing in Edebug): Clarify print-length etc.
(Instrumenting Macro Calls): Defopt edebug-eval-macro-args.
(Specification List): Remove edebug-unwrap findex entry.
(Specification Examples): defmacro is actually not the same as defun.
Escape "`" in example.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 15 Jul 2009 03:09:52 +0000 |
parents | 0340abf40af9 |
children | 1d1d5d9bd884 |
comparison
equal
deleted
inserted
replaced
103896:a4d216dbf517 | 103897:e52d10e14bc0 |
---|---|
12 | 12 |
13 @node Edebug, Syntax Errors, Debugger, Debugging | 13 @node Edebug, Syntax Errors, Debugger, Debugging |
14 @section Edebug | 14 @section Edebug |
15 @cindex Edebug debugging facility | 15 @cindex Edebug debugging facility |
16 | 16 |
17 Edebug is a source-level debugger for Emacs Lisp programs with which | 17 Edebug is a source-level debugger for Emacs Lisp programs, with which |
18 you can: | 18 you can: |
19 | 19 |
20 @itemize @bullet | 20 @itemize @bullet |
21 @item | 21 @item |
22 Step through evaluation, stopping before and after each expression. | 22 Step through evaluation, stopping before and after each expression. |
38 @item | 38 @item |
39 Automatically re-evaluate a list of expressions and | 39 Automatically re-evaluate a list of expressions and |
40 display their results each time Edebug updates the display. | 40 display their results each time Edebug updates the display. |
41 | 41 |
42 @item | 42 @item |
43 Output trace info on function enter and exit. | 43 Output trace information on function calls and returns. |
44 | 44 |
45 @item | 45 @item |
46 Stop when an error occurs. | 46 Stop when an error occurs. |
47 | 47 |
48 @item | 48 @item |
54 @item | 54 @item |
55 Obtain rudimentary coverage testing and frequency counts. | 55 Obtain rudimentary coverage testing and frequency counts. |
56 @end itemize | 56 @end itemize |
57 | 57 |
58 The first three sections below should tell you enough about Edebug to | 58 The first three sections below should tell you enough about Edebug to |
59 enable you to use it. | 59 start using it. |
60 | 60 |
61 @menu | 61 @menu |
62 * Using Edebug:: Introduction to use of Edebug. | 62 * Using Edebug:: Introduction to use of Edebug. |
63 * Instrumenting:: You must instrument your code | 63 * Instrumenting:: You must instrument your code |
64 in order to debug it with Edebug. | 64 in order to debug it with Edebug. |
186 | 186 |
187 While Edebug is active, the command @kbd{I} | 187 While Edebug is active, the command @kbd{I} |
188 (@code{edebug-instrument-callee}) instruments the definition of the | 188 (@code{edebug-instrument-callee}) instruments the definition of the |
189 function or macro called by the list form after point, if is not already | 189 function or macro called by the list form after point, if is not already |
190 instrumented. This is possible only if Edebug knows where to find the | 190 instrumented. This is possible only if Edebug knows where to find the |
191 source for that function; for this reading, after loading Edebug, | 191 source for that function; for this reason, after loading Edebug, |
192 @code{eval-region} records the position of every definition it | 192 @code{eval-region} records the position of every definition it |
193 evaluates, even if not instrumenting it. See also the @kbd{i} command | 193 evaluates, even if not instrumenting it. See also the @kbd{i} command |
194 (@pxref{Jumping}), which steps into the call after instrumenting the | 194 (@pxref{Jumping}), which steps into the call after instrumenting the |
195 function. | 195 function. |
196 | 196 |
197 Edebug knows how to instrument all the standard special forms, | 197 Edebug knows how to instrument all the standard special forms, |
198 @code{interactive} forms with an expression argument, anonymous lambda | 198 @code{interactive} forms with an expression argument, anonymous lambda |
199 expressions, and other defining forms. However, Edebug cannot determine | 199 expressions, and other defining forms. However, Edebug cannot determine |
200 on its own what a user-defined macro will do with the arguments of a | 200 on its own what a user-defined macro will do with the arguments of a |
201 macro call, so you must provide that information using Edebug | 201 macro call, so you must provide that information using Edebug |
202 specifications; see @ref{Edebug and Macros}, for details. | 202 specifications; for details, @pxref{Edebug and Macros}. |
203 | 203 |
204 When Edebug is about to instrument code for the first time in a | 204 When Edebug is about to instrument code for the first time in a |
205 session, it runs the hook @code{edebug-setup-hook}, then sets it to | 205 session, it runs the hook @code{edebug-setup-hook}, then sets it to |
206 @code{nil}. You can use this to load Edebug specifications | 206 @code{nil}. You can use this to load Edebug specifications |
207 associated with a package you are using, but only when you use Edebug. | 207 associated with a package you are using, but only when you use Edebug. |
291 Keyboard macros containing the commands in this section do not | 291 Keyboard macros containing the commands in this section do not |
292 completely work: exiting from Edebug, to resume the program, loses track | 292 completely work: exiting from Edebug, to resume the program, loses track |
293 of the keyboard macro. This is not easy to fix. Also, defining or | 293 of the keyboard macro. This is not easy to fix. Also, defining or |
294 executing a keyboard macro outside of Edebug does not affect commands | 294 executing a keyboard macro outside of Edebug does not affect commands |
295 inside Edebug. This is usually an advantage. See also the | 295 inside Edebug. This is usually an advantage. See also the |
296 @code{edebug-continue-kbd-macro} option (@pxref{Edebug Options}). | 296 @code{edebug-continue-kbd-macro} option in @ref{Edebug Options}. |
297 | 297 |
298 When you enter a new Edebug level, the initial execution mode comes | 298 When you enter a new Edebug level, the initial execution mode comes |
299 from the value of the variable @code{edebug-initial-mode}. | 299 from the value of the variable @code{edebug-initial-mode} |
300 (@xref{Edebug Options}.) By default, this specifies step mode. Note | 300 (@pxref{Edebug Options}). By default, this specifies step mode. Note |
301 that you may reenter the same Edebug level several times if, for | 301 that you may reenter the same Edebug level several times if, for |
302 example, an instrumented function is called several times from one | 302 example, an instrumented function is called several times from one |
303 command. | 303 command. |
304 | 304 |
305 @defopt edebug-sit-for-seconds | 305 @defopt edebug-sit-for-seconds |
306 This option specifies how many seconds to wait between execution steps | 306 This option specifies how many seconds to wait between execution steps |
307 in trace mode. The default is 1 second. | 307 in trace mode or continue mode. The default is 1 second. |
308 @end defopt | 308 @end defopt |
309 | 309 |
310 @node Jumping | 310 @node Jumping |
311 @subsection Jumping | 311 @subsection Jumping |
312 | 312 |
327 @item f | 327 @item f |
328 Run the program for one expression | 328 Run the program for one expression |
329 (@code{edebug-forward-sexp}). | 329 (@code{edebug-forward-sexp}). |
330 | 330 |
331 @item o | 331 @item o |
332 Run the program until the end of the containing sexp. | 332 Run the program until the end of the containing sexp (@code{edebug-step-out}). |
333 | 333 |
334 @item i | 334 @item i |
335 Step into the function or macro called by the form after point. | 335 Step into the function or macro called by the form after point. |
336 @end table | 336 @end table |
337 | 337 |
338 The @kbd{h} command proceeds to the stop point at or after the current | 338 The @kbd{h} command proceeds to the stop point at or after the current |
339 location of point, using a temporary breakpoint. | 339 location of point, using a temporary breakpoint. |
340 | 340 |
341 The @kbd{f} command runs the program forward over one expression. More | 341 The @kbd{f} command runs the program forward over one expression. More |
342 precisely, it sets a temporary breakpoint at the position that | 342 precisely, it sets a temporary breakpoint at the position that |
343 @kbd{C-M-f} would reach, then executes in go mode so that the program | 343 @code{forward-sexp} would reach, then executes in go mode so that |
344 will stop at breakpoints. | 344 the program will stop at breakpoints. |
345 | 345 |
346 With a prefix argument @var{n}, the temporary breakpoint is placed | 346 With a prefix argument @var{n}, the temporary breakpoint is placed |
347 @var{n} sexps beyond point. If the containing list ends before @var{n} | 347 @var{n} sexps beyond point. If the containing list ends before @var{n} |
348 more elements, then the place to stop is after the containing | 348 more elements, then the place to stop is after the containing |
349 expression. | 349 expression. |
350 | 350 |
351 You must check that the position @kbd{C-M-f} finds is a place that the | 351 You must check that the position @code{forward-sexp} finds is a place |
352 program will really get to. In @code{cond}, for example, this may not | 352 that the program will really get to. In @code{cond}, for example, |
353 be true. | 353 this may not be true. |
354 | 354 |
355 For flexibility, the @kbd{f} command does @code{forward-sexp} starting | 355 For flexibility, the @kbd{f} command does @code{forward-sexp} starting |
356 at point, rather than at the stop point. If you want to execute one | 356 at point, rather than at the stop point. If you want to execute one |
357 expression @emph{from the current stop point}, first type @kbd{w}, to | 357 expression @emph{from the current stop point}, first type @kbd{w} |
358 move point there, and then type @kbd{f}. | 358 (@code{edebug-where}) to move point there, and then type @kbd{f}. |
359 | 359 |
360 The @kbd{o} command continues ``out of'' an expression. It places a | 360 The @kbd{o} command continues ``out of'' an expression. It places a |
361 temporary breakpoint at the end of the sexp containing point. If the | 361 temporary breakpoint at the end of the sexp containing point. If the |
362 containing sexp is a function definition itself, @kbd{o} continues until | 362 containing sexp is a function definition itself, @kbd{o} continues until |
363 just before the last sexp in the definition. If that is where you are | 363 just before the last sexp in the definition. If that is where you are |
396 @code{unwind-protect} or @code{condition-case} forms may resume | 396 @code{unwind-protect} or @code{condition-case} forms may resume |
397 debugging. | 397 debugging. |
398 | 398 |
399 @item Q | 399 @item Q |
400 Like @kbd{q}, but don't stop even for protected code | 400 Like @kbd{q}, but don't stop even for protected code |
401 (@code{top-level-nonstop}). | 401 (@code{edebug-top-level-nonstop}). |
402 | 402 |
403 @item r | 403 @item r |
404 Redisplay the most recently known expression result in the echo area | 404 Redisplay the most recently known expression result in the echo area |
405 (@code{edebug-previous-result}). | 405 (@code{edebug-previous-result}). |
406 | 406 |
639 Evaluate expression @var{exp} in the context outside of Edebug | 639 Evaluate expression @var{exp} in the context outside of Edebug |
640 (@code{edebug-eval-expression}). That is, Edebug tries to minimize its | 640 (@code{edebug-eval-expression}). That is, Edebug tries to minimize its |
641 interference with the evaluation. | 641 interference with the evaluation. |
642 | 642 |
643 @item M-: @var{exp} @key{RET} | 643 @item M-: @var{exp} @key{RET} |
644 Evaluate expression @var{exp} in the context of Edebug itself. | 644 Evaluate expression @var{exp} in the context of Edebug itself |
645 (@code{eval-expression}). | |
645 | 646 |
646 @item C-x C-e | 647 @item C-x C-e |
647 Evaluate the expression before point, in the context outside of Edebug | 648 Evaluate the expression before point, in the context outside of Edebug |
648 (@code{edebug-eval-last-sexp}). | 649 (@code{edebug-eval-last-sexp}). |
649 @end table | 650 @end table |
650 | 651 |
651 @cindex lexical binding (Edebug) | 652 @cindex lexical binding (Edebug) |
652 Edebug supports evaluation of expressions containing references to | 653 Edebug supports evaluation of expressions containing references to |
653 lexically bound symbols created by the following constructs in | 654 lexically bound symbols created by the following constructs in |
654 @file{cl.el} (version 2.03 or later): @code{lexical-let}, | 655 @file{cl.el}: @code{lexical-let}, @code{macrolet}, and |
655 @code{macrolet}, and @code{symbol-macrolet}. | 656 @code{symbol-macrolet}. |
656 | 657 |
657 @node Eval List | 658 @node Eval List |
658 @subsection Evaluation List Buffer | 659 @subsection Evaluation List Buffer |
659 | 660 |
660 You can use the @dfn{evaluation list buffer}, called @samp{*edebug*}, to | 661 You can use the @dfn{evaluation list buffer}, called @samp{*edebug*}, to |
716 expression in the buffer, followed by its current value. It also | 717 expression in the buffer, followed by its current value. It also |
717 inserts comment lines so that each expression becomes its own group. | 718 inserts comment lines so that each expression becomes its own group. |
718 Thus, if you type @kbd{C-c C-u} again without changing the buffer text, | 719 Thus, if you type @kbd{C-c C-u} again without changing the buffer text, |
719 the evaluation list is effectively unchanged. | 720 the evaluation list is effectively unchanged. |
720 | 721 |
721 If an error occurs during an evaluation from the evaluation list, the | 722 If an error occurs during an evaluation from the evaluation list, |
722 error message is displayed in a string as if it were the result. | 723 the error message is displayed in a string as if it were the result. |
723 Therefore, expressions that use variables not currently valid do not | 724 Therefore, expressions using variables that are not currently valid do |
724 interrupt your debugging. | 725 not interrupt your debugging. |
725 | 726 |
726 Here is an example of what the evaluation list window looks like after | 727 Here is an example of what the evaluation list window looks like after |
727 several expressions have been added to it: | 728 several expressions have been added to it: |
728 | 729 |
729 @smallexample | 730 @smallexample |
767 If an expression in your program produces a value containing circular | 768 If an expression in your program produces a value containing circular |
768 list structure, you may get an error when Edebug attempts to print it. | 769 list structure, you may get an error when Edebug attempts to print it. |
769 | 770 |
770 One way to cope with circular structure is to set @code{print-length} | 771 One way to cope with circular structure is to set @code{print-length} |
771 or @code{print-level} to truncate the printing. Edebug does this for | 772 or @code{print-level} to truncate the printing. Edebug does this for |
772 you; it binds @code{print-length} and @code{print-level} to 50 if they | 773 you; it binds @code{print-length} and @code{print-level} to the values |
773 were @code{nil}. (Actually, the variables @code{edebug-print-length} | 774 of the variables @code{edebug-print-length} and |
774 and @code{edebug-print-level} specify the values to use within Edebug.) | 775 @code{edebug-print-level} (so long as they have non-@code{nil} |
775 @xref{Output Variables}. | 776 values). @xref{Output Variables}. |
776 | 777 |
777 @defopt edebug-print-length | 778 @defopt edebug-print-length |
778 If non-@code{nil}, Edebug binds @code{print-length} to this value while | 779 If non-@code{nil}, Edebug binds @code{print-length} to this value while |
779 printing results. The default value is @code{50}. | 780 printing results. The default value is @code{50}. |
780 @end defopt | 781 @end defopt |
874 correctly; Edebug will tell you when you have tried enough different | 875 correctly; Edebug will tell you when you have tried enough different |
875 conditions that each form has returned two different values. | 876 conditions that each form has returned two different values. |
876 | 877 |
877 Coverage testing makes execution slower, so it is only done if | 878 Coverage testing makes execution slower, so it is only done if |
878 @code{edebug-test-coverage} is non-@code{nil}. Frequency counting is | 879 @code{edebug-test-coverage} is non-@code{nil}. Frequency counting is |
879 performed for all execution of an instrumented function, even if the | 880 performed for all executions of an instrumented function, even if the |
880 execution mode is Go-nonstop, and regardless of whether coverage testing | 881 execution mode is Go-nonstop, and regardless of whether coverage testing |
881 is enabled. | 882 is enabled. |
882 | 883 |
883 @kindex C-x X = | 884 @kindex C-x X = |
884 @findex edebug-temp-display-freq-count | 885 @findex edebug-temp-display-freq-count |
889 | 890 |
890 @deffn Command edebug-display-freq-count | 891 @deffn Command edebug-display-freq-count |
891 This command displays the frequency count data for each line of the | 892 This command displays the frequency count data for each line of the |
892 current definition. | 893 current definition. |
893 | 894 |
894 The frequency counts appear as comment lines after each line of code, | 895 It inserts frequency counts as comment lines after each line of code. |
895 and you can undo all insertions with one @code{undo} command. The | 896 You can undo all insertions with one @code{undo} command. The counts |
896 counts appear under the @samp{(} before an expression or the @samp{)} | 897 appear under the @samp{(} before an expression or the @samp{)} after |
897 after an expression, or on the last character of a variable. To | 898 an expression, or on the last character of a variable. To simplify |
898 simplify the display, a count is not shown if it is equal to the | 899 the display, a count is not shown if it is equal to the count of an |
899 count of an earlier expression on the same line. | 900 earlier expression on the same line. |
900 | 901 |
901 The character @samp{=} following the count for an expression says that | 902 The character @samp{=} following the count for an expression says that |
902 the expression has returned the same value each time it was evaluated. | 903 the expression has returned the same value each time it was evaluated. |
903 In other words, it is not yet ``covered'' for coverage testing purposes. | 904 In other words, it is not yet ``covered'' for coverage testing purposes. |
904 | 905 |
952 program. | 953 program. |
953 | 954 |
954 @itemize @bullet | 955 @itemize @bullet |
955 @item | 956 @item |
956 @code{max-lisp-eval-depth} and @code{max-specpdl-size} are both | 957 @code{max-lisp-eval-depth} and @code{max-specpdl-size} are both |
957 incremented once to reduce Edebug's impact on the stack. You could, | 958 increased to reduce Edebug's impact on the stack. You could, however, |
958 however, still run out of stack space when using Edebug. | 959 still run out of stack space when using Edebug. |
959 | 960 |
960 @item | 961 @item |
961 The state of keyboard macro execution is saved and restored. While | 962 The state of keyboard macro execution is saved and restored. While |
962 Edebug is active, @code{executing-kbd-macro} is bound to @code{nil} | 963 Edebug is active, @code{executing-kbd-macro} is bound to @code{nil} |
963 unless @code{edebug-continue-kbd-macro} is non-@code{nil}. | 964 unless @code{edebug-continue-kbd-macro} is non-@code{nil}. |
1009 The value of point in each displayed buffer is saved and restored if | 1010 The value of point in each displayed buffer is saved and restored if |
1010 @code{edebug-save-displayed-buffer-points} is non-@code{nil}. | 1011 @code{edebug-save-displayed-buffer-points} is non-@code{nil}. |
1011 | 1012 |
1012 @item | 1013 @item |
1013 The variables @code{overlay-arrow-position} and | 1014 The variables @code{overlay-arrow-position} and |
1014 @code{overlay-arrow-string} are saved and restored. So you can safely | 1015 @code{overlay-arrow-string} are saved and restored, so you can safely |
1015 invoke Edebug from the recursive edit elsewhere in the same buffer. | 1016 invoke Edebug from the recursive edit elsewhere in the same buffer. |
1016 | 1017 |
1017 @item | 1018 @item |
1018 @code{cursor-in-echo-area} is locally bound to @code{nil} so that | 1019 @code{cursor-in-echo-area} is locally bound to @code{nil} so that |
1019 the cursor shows up in the window. | 1020 the cursor shows up in the window. |
1101 (declare (debug (symbolp "from" form "to" form "do" &rest form))) | 1102 (declare (debug (symbolp "from" form "to" form "do" &rest form))) |
1102 ...) | 1103 ...) |
1103 @end smallexample | 1104 @end smallexample |
1104 | 1105 |
1105 The Edebug specification says which parts of a call to the macro are | 1106 The Edebug specification says which parts of a call to the macro are |
1106 forms to be evaluated. For simple macros, the @var{specification} | 1107 forms to be evaluated. For simple macros, the specification |
1107 often looks very similar to the formal argument list of the macro | 1108 often looks very similar to the formal argument list of the macro |
1108 definition, but specifications are much more general than macro | 1109 definition, but specifications are much more general than macro |
1109 arguments. @xref{Defining Macros}, for more explanation of | 1110 arguments. @xref{Defining Macros}, for more explanation of |
1110 the @code{declare} form. | 1111 the @code{declare} form. |
1111 | 1112 |
1133 | 1134 |
1134 @item @code{0} | 1135 @item @code{0} |
1135 None of the arguments is instrumented. | 1136 None of the arguments is instrumented. |
1136 | 1137 |
1137 @item a symbol | 1138 @item a symbol |
1138 The symbol must have an Edebug specification which is used instead. | 1139 The symbol must have an Edebug specification, which is used instead. |
1139 This indirection is repeated until another kind of specification is | 1140 This indirection is repeated until another kind of specification is |
1140 found. This allows you to inherit the specification from another macro. | 1141 found. This allows you to inherit the specification from another macro. |
1141 | 1142 |
1142 @item a list | 1143 @item a list |
1143 The elements of the list describe the types of the arguments of a | 1144 The elements of the list describe the types of the arguments of a |
1144 calling form. The possible elements of a specification list are | 1145 calling form. The possible elements of a specification list are |
1145 described in the following sections. | 1146 described in the following sections. |
1146 @end table | 1147 @end table |
1147 | 1148 |
1148 @vindex edebug-eval-macro-args | |
1149 If a macro has no Edebug specification, neither through a @code{debug} | 1149 If a macro has no Edebug specification, neither through a @code{debug} |
1150 declaration nor through a @code{def-edebug-spec} call, the variable | 1150 declaration nor through a @code{def-edebug-spec} call, the variable |
1151 @code{edebug-eval-macro-args} comes into play. If it is @code{nil}, | 1151 @code{edebug-eval-macro-args} comes into play. |
1152 the default, none of the arguments is instrumented for evaluation. | 1152 |
1153 If it is non-@code{nil}, all arguments are instrumented. | 1153 @defopt edebug-eval-macro-args |
1154 This controls the way Edebug treats macro arguments with no explicit | |
1155 Edebug specification. If it is @code{nil} (the default), none of the | |
1156 arguments is instrumented for evaluation. Otherwise, all arguments | |
1157 are instrumented. | |
1158 @end defopt | |
1154 | 1159 |
1155 @node Specification List | 1160 @node Specification List |
1156 @subsubsection Specification List | 1161 @subsubsection Specification List |
1157 | 1162 |
1158 @cindex Edebug specification list | 1163 @cindex Edebug specification list |
1168 and groups thus subdivide the specification list into a hierarchy of | 1173 and groups thus subdivide the specification list into a hierarchy of |
1169 levels. Specification keywords apply only to the remainder of the | 1174 levels. Specification keywords apply only to the remainder of the |
1170 sublist or group they are contained in. | 1175 sublist or group they are contained in. |
1171 | 1176 |
1172 When a specification list involves alternatives or repetition, matching | 1177 When a specification list involves alternatives or repetition, matching |
1173 it against an actual macro call may require backtracking. | 1178 it against an actual macro call may require backtracking. For more |
1174 @xref{Backtracking}, for more details. | 1179 details, @pxref{Backtracking}. |
1175 | 1180 |
1176 Edebug specifications provide the power of regular expression matching, | 1181 Edebug specifications provide the power of regular expression matching, |
1177 plus some context-free grammar constructs: the matching of sublists with | 1182 plus some context-free grammar constructs: the matching of sublists with |
1178 balanced parentheses, recursive processing of forms, and recursion via | 1183 balanced parentheses, recursive processing of forms, and recursion via |
1179 indirect specifications. | 1184 indirect specifications. |
1189 | 1194 |
1190 @item form | 1195 @item form |
1191 A single evaluated expression, which is instrumented. | 1196 A single evaluated expression, which is instrumented. |
1192 | 1197 |
1193 @item place | 1198 @item place |
1194 @findex edebug-unwrap | 1199 @c I can't see that this index entry is useful without any explanation. |
1200 @c @findex edebug-unwrap | |
1195 A place to store a value, as in the Common Lisp @code{setf} construct. | 1201 A place to store a value, as in the Common Lisp @code{setf} construct. |
1196 | 1202 |
1197 @item body | 1203 @item body |
1198 Short for @code{&rest form}. See @code{&rest} below. | 1204 Short for @code{&rest form}. See @code{&rest} below. |
1199 | 1205 |
1273 | 1279 |
1274 If the symbol has an Edebug specification, this @dfn{indirect | 1280 If the symbol has an Edebug specification, this @dfn{indirect |
1275 specification} should be either a list specification that is used in | 1281 specification} should be either a list specification that is used in |
1276 place of the symbol, or a function that is called to process the | 1282 place of the symbol, or a function that is called to process the |
1277 arguments. The specification may be defined with @code{def-edebug-spec} | 1283 arguments. The specification may be defined with @code{def-edebug-spec} |
1278 just as for macros. See the @code{defun} example. | 1284 just as for macros. See the @code{defun} example. |
1279 | 1285 |
1280 Otherwise, the symbol should be a predicate. The predicate is called | 1286 Otherwise, the symbol should be a predicate. The predicate is called |
1281 with the argument and the specification fails if the predicate returns | 1287 with the argument and the specification fails if the predicate returns |
1282 @code{nil}. In either case, that argument is not instrumented. | 1288 @code{nil}, and the argument is not instrumented. |
1283 | 1289 |
1284 Some suitable predicates include @code{symbolp}, @code{integerp}, | 1290 Some suitable predicates include @code{symbolp}, @code{integerp}, |
1285 @code{stringp}, @code{vectorp}, and @code{atom}. | 1291 @code{stringp}, @code{vectorp}, and @code{atom}. |
1286 | 1292 |
1287 @item [@var{elements}@dots{}] | 1293 @item [@var{elements}@dots{}] |
1353 the definition. Use @code{def-body} for the highest level list of forms | 1359 the definition. Use @code{def-body} for the highest level list of forms |
1354 within the definition. | 1360 within the definition. |
1355 | 1361 |
1356 @item def-form | 1362 @item def-form |
1357 The argument is a single, highest-level form in a definition. This is | 1363 The argument is a single, highest-level form in a definition. This is |
1358 like @code{def-body}, except use this to match a single form rather than | 1364 like @code{def-body}, except it is used to match a single form rather than |
1359 a list of forms. As a special case, @code{def-form} also means that | 1365 a list of forms. As a special case, @code{def-form} also means that |
1360 tracing information is not output when the form is executed. See the | 1366 tracing information is not output when the form is executed. See the |
1361 @code{interactive} example. | 1367 @code{interactive} example. |
1362 @end table | 1368 @end table |
1363 | 1369 |
1372 exhausted. Eventually every element of the argument list must be | 1378 exhausted. Eventually every element of the argument list must be |
1373 matched by some element in the specification, and every required element | 1379 matched by some element in the specification, and every required element |
1374 in the specification must match some argument. | 1380 in the specification must match some argument. |
1375 | 1381 |
1376 When a syntax error is detected, it might not be reported until much | 1382 When a syntax error is detected, it might not be reported until much |
1377 later after higher-level alternatives have been exhausted, and with the | 1383 later, after higher-level alternatives have been exhausted, and with the |
1378 point positioned further from the real error. But if backtracking is | 1384 point positioned further from the real error. But if backtracking is |
1379 disabled when an error occurs, it can be reported immediately. Note | 1385 disabled when an error occurs, it can be reported immediately. Note |
1380 that backtracking is also reenabled automatically in several situations; | 1386 that backtracking is also reenabled automatically in several situations; |
1381 it is reenabled when a new alternative is established by | 1387 when a new alternative is established by @code{&optional}, |
1382 @code{&optional}, @code{&rest}, or @code{&or}, or at the start of | 1388 @code{&rest}, or @code{&or}, or at the start of processing a sublist, |
1383 processing a sublist, group, or indirect specification. The effect of | 1389 group, or indirect specification. The effect of enabling or disabling |
1384 enabling or disabling backtracking is limited to the remainder of the | 1390 backtracking is limited to the remainder of the level currently being |
1385 level currently being processed and lower levels. | 1391 processed and lower levels. |
1386 | 1392 |
1387 Backtracking is disabled while matching any of the | 1393 Backtracking is disabled while matching any of the |
1388 form specifications (that is, @code{form}, @code{body}, @code{def-form}, and | 1394 form specifications (that is, @code{form}, @code{body}, @code{def-form}, and |
1389 @code{def-body}). These specifications will match any form so any error | 1395 @code{def-body}). These specifications will match any form so any error |
1390 must be in the form itself rather than at a higher level. | 1396 must be in the form itself rather than at a higher level. |
1411 A @code{let} special form has a sequence of bindings and a body. Each | 1417 A @code{let} special form has a sequence of bindings and a body. Each |
1412 of the bindings is either a symbol or a sublist with a symbol and | 1418 of the bindings is either a symbol or a sublist with a symbol and |
1413 optional expression. In the specification below, notice the @code{gate} | 1419 optional expression. In the specification below, notice the @code{gate} |
1414 inside of the sublist to prevent backtracking once a sublist is found. | 1420 inside of the sublist to prevent backtracking once a sublist is found. |
1415 | 1421 |
1422 @c FIXME? The actual definition in edebug.el does not have a gate. | |
1416 @example | 1423 @example |
1417 (def-edebug-spec let | 1424 (def-edebug-spec let |
1418 ((&rest | 1425 ((&rest |
1419 &or symbolp (gate symbolp &optional form)) | 1426 &or symbolp (gate symbolp &optional form)) |
1420 body)) | 1427 body)) |
1421 @end example | 1428 @end example |
1422 | 1429 |
1423 Edebug uses the following specifications for @code{defun} and | 1430 Edebug uses the following specifications for @code{defun} and the |
1424 @code{defmacro} and the associated argument list and @code{interactive} | 1431 associated argument list and @code{interactive} specifications. It is |
1425 specifications. It is necessary to handle interactive forms specially | 1432 necessary to handle interactive forms specially since an expression |
1426 since an expression argument is actually evaluated outside of the | 1433 argument is actually evaluated outside of the function body. (The |
1427 function body. | 1434 specification for @code{defmacro} is very similar to that for |
1435 @code{defun}, but allows for the @code{declare} statement.) | |
1428 | 1436 |
1429 @smallexample | 1437 @smallexample |
1430 (def-edebug-spec defmacro defun) ; @r{Indirect ref to @code{defun} spec.} | |
1431 (def-edebug-spec defun | 1438 (def-edebug-spec defun |
1432 (&define name lambda-list | 1439 (&define name lambda-list |
1433 [&optional stringp] ; @r{Match the doc string, if present.} | 1440 [&optional stringp] ; @r{Match the doc string, if present.} |
1434 [&optional ("interactive" interactive)] | 1441 [&optional ("interactive" interactive)] |
1435 def-body)) | 1442 def-body)) |
1445 @end smallexample | 1452 @end smallexample |
1446 | 1453 |
1447 The specification for backquote below illustrates how to match | 1454 The specification for backquote below illustrates how to match |
1448 dotted lists and use @code{nil} to terminate recursion. It also | 1455 dotted lists and use @code{nil} to terminate recursion. It also |
1449 illustrates how components of a vector may be matched. (The actual | 1456 illustrates how components of a vector may be matched. (The actual |
1450 specification defined by Edebug does not support dotted lists because | 1457 specification defined by Edebug is a little different, and does not |
1451 doing so causes very deep recursion that could fail.) | 1458 support dotted lists because doing so causes very deep recursion that |
1459 could fail.) | |
1452 | 1460 |
1453 @smallexample | 1461 @smallexample |
1454 (def-edebug-spec ` (backquote-form)) ; @r{Alias just for clarity.} | 1462 (def-edebug-spec \` (backquote-form)) ; @r{Alias just for clarity.} |
1455 | 1463 |
1456 (def-edebug-spec backquote-form | 1464 (def-edebug-spec backquote-form |
1457 (&or ([&or "," ",@@"] &or ("quote" backquote-form) form) | 1465 (&or ([&or "," ",@@"] &or ("quote" backquote-form) form) |
1458 (backquote-form . [&or nil backquote-form]) | 1466 (backquote-form . [&or nil backquote-form]) |
1459 (vector &rest backquote-form) | 1467 (vector &rest backquote-form) |
1463 | 1471 |
1464 @node Edebug Options | 1472 @node Edebug Options |
1465 @subsection Edebug Options | 1473 @subsection Edebug Options |
1466 | 1474 |
1467 These options affect the behavior of Edebug: | 1475 These options affect the behavior of Edebug: |
1476 @c Previously defopt'd: | |
1477 @c edebug-sit-for-seconds, edebug-print-length, edebug-print-level | |
1478 @c edebug-print-circle, edebug-eval-macro-args | |
1468 | 1479 |
1469 @defopt edebug-setup-hook | 1480 @defopt edebug-setup-hook |
1470 Functions to call before Edebug is used. Each time it is set to a new | 1481 Functions to call before Edebug is used. Each time it is set to a new |
1471 value, Edebug will call those functions once and then | 1482 value, Edebug will call those functions once and then |
1472 @code{edebug-setup-hook} is reset to @code{nil}. You could use this to | 1483 @code{edebug-setup-hook} is reset to @code{nil}. You could use this to |
1511 @defopt edebug-save-displayed-buffer-points | 1522 @defopt edebug-save-displayed-buffer-points |
1512 If this is non-@code{nil}, Edebug saves and restores point in all | 1523 If this is non-@code{nil}, Edebug saves and restores point in all |
1513 displayed buffers. | 1524 displayed buffers. |
1514 | 1525 |
1515 Saving and restoring point in other buffers is necessary if you are | 1526 Saving and restoring point in other buffers is necessary if you are |
1516 debugging code that changes the point of a buffer which is displayed in | 1527 debugging code that changes the point of a buffer that is displayed in |
1517 a non-selected window. If Edebug or the user then selects the window, | 1528 a non-selected window. If Edebug or the user then selects the window, |
1518 point in that buffer will move to the window's value of point. | 1529 point in that buffer will move to the window's value of point. |
1519 | 1530 |
1520 Saving and restoring point in all buffers is expensive, since it | 1531 Saving and restoring point in all buffers is expensive, since it |
1521 requires selecting each window twice, so enable this only if you need | 1532 requires selecting each window twice, so enable this only if you need |
1550 that is executing outside of Edebug. Use this with caution since it is not | 1561 that is executing outside of Edebug. Use this with caution since it is not |
1551 debugged. | 1562 debugged. |
1552 @xref{Edebug Execution Modes}. | 1563 @xref{Edebug Execution Modes}. |
1553 @end defopt | 1564 @end defopt |
1554 | 1565 |
1566 @c FIXME edebug-unwrap-results | |
1567 | |
1555 @defopt edebug-on-error | 1568 @defopt edebug-on-error |
1556 Edebug binds @code{debug-on-error} to this value, if | 1569 Edebug binds @code{debug-on-error} to this value, if |
1557 @code{debug-on-error} was previously @code{nil}. @xref{Trapping | 1570 @code{debug-on-error} was previously @code{nil}. @xref{Trapping |
1558 Errors}. | 1571 Errors}. |
1559 @end defopt | 1572 @end defopt |