aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2025-08-23 13:44:23 +0300
committerEli Zaretskii2025-08-23 13:44:23 +0300
commitb3ed4876b63cc61ef803775cfbb6af4776203a2d (patch)
treeddef4b9012078e5327b06722a69e92430a235628
parentfdad3417dcfc9e1925e96a035e52fdcad3248f68 (diff)
downloademacs-b3ed4876b63cc61ef803775cfbb6af4776203a2d.tar.gz
emacs-b3ed4876b63cc61ef803775cfbb6af4776203a2d.zip
; Improve documentation of Edebug
* doc/lispref/edebug.texi (Edebug Execution Modes, Jumping) (Edebug Misc, Breaks, Breakpoints, Global Break Condition) (Source Breakpoints, Edebug Views, Edebug Eval, Eval List) (Printing in Edebug, Trace Buffer, Coverage Testing) (Checking Whether to Stop, Edebug Display Update) (Edebug Recursive Edit, Edebug and Macros) (Instrumenting Macro Calls, Specification List, Edebug Options): Improve indexing and cross-references.
-rw-r--r--doc/lispref/edebug.texi179
1 files changed, 136 insertions, 43 deletions
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi
index 0effe48e9a3..813a0d85633 100644
--- a/doc/lispref/edebug.texi
+++ b/doc/lispref/edebug.texi
@@ -256,38 +256,47 @@ commands; all except for @kbd{S} resume execution of the program, at
256least for a certain distance. 256least for a certain distance.
257 257
258@table @kbd 258@table @kbd
259@findex edebug-stop
259@item S 260@item S
260Stop: don't execute any more of the program, but wait for more 261Stop: don't execute any more of the program, but wait for more
261Edebug commands (@code{edebug-stop}). 262Edebug commands (@code{edebug-stop}).
262@c FIXME Does not work. https://debbugs.gnu.org/9764 263@c FIXME Does not work. https://debbugs.gnu.org/9764
263 264
265@findex edebug-step-mode
264@item @key{SPC} 266@item @key{SPC}
265Step: stop at the next stop point encountered (@code{edebug-step-mode}). 267Step: stop at the next stop point encountered (@code{edebug-step-mode}).
266 268
269@findex edebug-next-mode
267@item n 270@item n
268Next: stop at the next stop point encountered after an expression 271Next: stop at the next stop point encountered after an expression
269(@code{edebug-next-mode}). Also see @code{edebug-forward-sexp} in 272(@code{edebug-next-mode}). Also see @code{edebug-forward-sexp} in
270@ref{Jumping}. 273@ref{Jumping}.
271 274
275@findex edebug-trace-mode
272@item t 276@item t
273Trace: pause (normally one second) at each Edebug stop point 277Trace: pause (normally one second) at each Edebug stop point
274(@code{edebug-trace-mode}). 278(@code{edebug-trace-mode}).
275 279
280@findex edebug-Trace-fast-mode
276@item T 281@item T
277Rapid trace: update the display at each stop point, but don't actually 282Rapid trace: update the display at each stop point, but don't actually
278pause (@code{edebug-Trace-fast-mode}). 283pause (@code{edebug-Trace-fast-mode}).
279 284
285@findex edebug-go-mode
280@item g 286@item g
281Go: run until the next breakpoint (@code{edebug-go-mode}). @xref{Breakpoints}. 287Go: run until the next breakpoint (@code{edebug-go-mode}). @xref{Breakpoints}.
282 288
289@findex edebug-continue-mode
283@item c 290@item c
284Continue: pause one second at each breakpoint, and then continue 291Continue: pause one second at each breakpoint, and then continue
285(@code{edebug-continue-mode}). 292(@code{edebug-continue-mode}).
286 293
294@findex edebug-Continue-fast-mode
287@item C 295@item C
288Rapid continue: move point to each breakpoint, but don't pause 296Rapid continue: move point to each breakpoint, but don't pause
289(@code{edebug-Continue-fast-mode}). 297(@code{edebug-Continue-fast-mode}).
290 298
299@findex edebug-Go-nonstop-mode
291@item G 300@item G
292Go non-stop: ignore breakpoints (@code{edebug-Go-nonstop-mode}). You 301Go non-stop: ignore breakpoints (@code{edebug-Go-nonstop-mode}). You
293can still stop the program by typing @kbd{S}, or any editing command. 302can still stop the program by typing @kbd{S}, or any editing command.
@@ -345,25 +354,30 @@ in trace mode or continue mode. The default is 1 second.
345 354
346 The commands described in this section execute until they reach a 355 The commands described in this section execute until they reach a
347specified location. All except @kbd{i} make a temporary breakpoint to 356specified location. All except @kbd{i} make a temporary breakpoint to
348establish the place to stop, then switch to go mode. Any other 357establish the place to stop, then switch to go mode (@pxref{Edebug
349breakpoint reached before the intended stop point will also stop 358Execution Modes}). Any other breakpoint reached before the intended
350execution. @xref{Breakpoints}, for the details on breakpoints. 359stop point will also stop execution. @xref{Breakpoints}, for the
360details on breakpoints.
351 361
352 These commands may fail to work as expected in case of nonlocal exit, 362 These commands may fail to work as expected in case of nonlocal exit,
353as that can bypass the temporary breakpoint where you expected the 363as that can bypass the temporary breakpoint where you expected the
354program to stop. 364program to stop.
355 365
356@table @kbd 366@table @kbd
367@findex edebug-goto-here
357@item h 368@item h
358Proceed to the stop point near where point is (@code{edebug-goto-here}). 369Proceed to the stop point near where point is (@code{edebug-goto-here}).
359 370
371@findex edebug-forward-sexp
360@item f 372@item f
361Run the program for one expression 373Run the program for one expression
362(@code{edebug-forward-sexp}). 374(@code{edebug-forward-sexp}).
363 375
376@findex edebug-step-out
364@item o 377@item o
365Run the program until the end of the containing sexp (@code{edebug-step-out}). 378Run the program until the end of the containing sexp (@code{edebug-step-out}).
366 379
380@findex edebug-step-in
367@item i 381@item i
368Step into the function or macro called by the form after point 382Step into the function or macro called by the form after point
369(@code{edebug-step-in}). 383(@code{edebug-step-in}).
@@ -397,7 +411,7 @@ containing sexp is a function definition itself, @kbd{o} continues until
397just before the last sexp in the definition. If that is where you are 411just before the last sexp in the definition. If that is where you are
398now, it returns from the function and then stops. In other words, this 412now, it returns from the function and then stops. In other words, this
399command does not exit the currently executing function unless you are 413command does not exit the currently executing function unless you are
400positioned after the last sexp. 414positioned after the last sexp of that function.
401 415
402Normally, the @kbd{h}, @kbd{f}, and @kbd{o} commands display ``Break'' 416Normally, the @kbd{h}, @kbd{f}, and @kbd{o} commands display ``Break''
403and pause for @code{edebug-sit-for-seconds} before showing the result 417and pause for @code{edebug-sit-for-seconds} before showing the result
@@ -421,14 +435,17 @@ arrange to deinstrument it.
421 Some miscellaneous Edebug commands are described here. 435 Some miscellaneous Edebug commands are described here.
422 436
423@table @kbd 437@table @kbd
438@findex edebug-help
424@item ? 439@item ?
425Display the help message for Edebug (@code{edebug-help}). 440Display the help message for Edebug (@code{edebug-help}).
426 441
442@findex abort-recursive-edit @r{(Edebug)}
427@item a 443@item a
428@itemx C-] 444@itemx C-]
429Abort one level back to the previous command level 445Abort one level back to the previous command level
430(@code{abort-recursive-edit}). 446(@code{abort-recursive-edit}). @xref{Recursive Editing}.
431 447
448@findex top-level @r{(Edebug)}
432@item q 449@item q
433Return to the top level editor command loop (@code{top-level}). This 450Return to the top level editor command loop (@code{top-level}). This
434exits all recursive editing levels, including all levels of Edebug 451exits all recursive editing levels, including all levels of Edebug
@@ -436,14 +453,17 @@ activity. However, instrumented code protected with
436@code{unwind-protect} or @code{condition-case} forms may resume 453@code{unwind-protect} or @code{condition-case} forms may resume
437debugging. 454debugging.
438 455
456@findex edebug-top-level-nonstop
439@item Q 457@item Q
440Like @kbd{q}, but don't stop even for protected code 458Like @kbd{q}, but don't stop even for protected code
441(@code{edebug-top-level-nonstop}). 459(@code{edebug-top-level-nonstop}).
442 460
461@findex edebug-previous-result
443@item r 462@item r
444Redisplay the most recently known expression result in the echo area 463Redisplay the most recently known expression result in the echo area
445(@code{edebug-previous-result}). 464(@code{edebug-previous-result}).
446 465
466@findex edebug-pop-to-backtrace
447@item d 467@item d
448Display a backtrace, excluding Edebug's own functions for clarity 468Display a backtrace, excluding Edebug's own functions for clarity
449(@code{edebug-pop-to-backtrace}). 469(@code{edebug-pop-to-backtrace}).
@@ -473,9 +493,10 @@ display a backtrace of all the pending evaluations with @kbd{d}.
473@node Breaks 493@node Breaks
474@subsection Breaks 494@subsection Breaks
475 495
476Edebug's step mode stops execution when the next stop point is reached. 496Edebug's step mode (@pxref{Edebug Execution Modes}) stops execution when
477There are three other ways to stop Edebug execution once it has started: 497the next stop point is reached. There are three other ways to stop
478breakpoints, the global break condition, and source breakpoints. 498Edebug execution once it has started: breakpoints, the global break
499condition, and source breakpoints.
479 500
480@menu 501@menu
481* Breakpoints:: Breakpoints at stop points. 502* Breakpoints:: Breakpoints at stop points.
@@ -495,6 +516,9 @@ the first one at or after point in the source code buffer. Here are the
495Edebug commands for breakpoints: 516Edebug commands for breakpoints:
496 517
497@table @kbd 518@table @kbd
519@findex edebug-set-breakpoint
520@vindex edebug-enabled-breakpoint @r{(face)}
521@vindex edebug-disabled-breakpoint @r{(face)}
498@item b 522@item b
499Set a breakpoint at the stop point at or after point 523Set a breakpoint at the stop point at or after point
500(@code{edebug-set-breakpoint}). If you use a prefix argument, the 524(@code{edebug-set-breakpoint}). If you use a prefix argument, the
@@ -502,26 +526,34 @@ breakpoint is temporary---it turns off the first time it stops the
502program. An overlay with the @code{edebug-enabled-breakpoint} or 526program. An overlay with the @code{edebug-enabled-breakpoint} or
503@code{edebug-disabled-breakpoint} faces is put at the breakpoint. 527@code{edebug-disabled-breakpoint} faces is put at the breakpoint.
504 528
529@findex edebug-unset-breakpoint
505@item u 530@item u
506Unset the breakpoint (if any) at the stop point at or after 531Unset the breakpoint (if any) at the stop point at or after
507point (@code{edebug-unset-breakpoint}). 532point (@code{edebug-unset-breakpoint}).
508 533
534@findex edebug-unset-breakpoints
509@item U 535@item U
510Unset any breakpoints in the current form 536Unset any breakpoints in the current form
511(@code{edebug-unset-breakpoints}). 537(@code{edebug-unset-breakpoints}).
512 538
539@findex edebug-toggle-disable-breakpoint
513@item D 540@item D
514Toggle whether to disable the breakpoint near point 541Toggle whether to disable the breakpoint near point
515(@code{edebug-toggle-disable-breakpoint}). This command is mostly 542(@code{edebug-toggle-disable-breakpoint}). This command is mostly
516useful if the breakpoint is conditional and it would take some work to 543useful if the breakpoint is conditional and it would take some work to
517recreate the condition. 544recreate the condition.
518 545
546@findex edebug-set-conditional-breakpoint
519@item x @var{condition} @key{RET} 547@item x @var{condition} @key{RET}
520Set a conditional breakpoint which stops the program only if 548Set a conditional breakpoint which stops the program only if
521evaluating @var{condition} produces a non-@code{nil} value 549evaluating @var{condition} produces a non-@code{nil} value
522(@code{edebug-set-conditional-breakpoint}). With a prefix argument, 550(@code{edebug-set-conditional-breakpoint}). With a prefix argument,
523the breakpoint is temporary. 551the breakpoint is temporary.
524 552
553@item X @var{condition} @key{RET}
554Set @code{edebug-global-break-condition} to @var{condition}.
555
556@findex edebug-next-breakpoint
525@item B 557@item B
526Move point to the next breakpoint in the current definition 558Move point to the next breakpoint in the current definition
527(@code{edebug-next-breakpoint}). 559(@code{edebug-next-breakpoint}).
@@ -542,6 +574,8 @@ conditional breakpoint, use @kbd{x}, and specify the condition
542expression in the minibuffer. Setting a conditional breakpoint at a 574expression in the minibuffer. Setting a conditional breakpoint at a
543stop point that has a previously established conditional breakpoint puts 575stop point that has a previously established conditional breakpoint puts
544the previous condition expression in the minibuffer so you can edit it. 576the previous condition expression in the minibuffer so you can edit it.
577(You can also use @kbd{X} to set the global break condition, to be
578evaluated at every stop point, @pxref{Global Break Condition}.)
545 579
546You can make a conditional or unconditional breakpoint 580You can make a conditional or unconditional breakpoint
547@dfn{temporary} by using a prefix argument with the command to set the 581@dfn{temporary} by using a prefix argument with the command to set the
@@ -566,8 +600,9 @@ point in the buffer.
566condition is satisfied, no matter where that may occur. Edebug 600condition is satisfied, no matter where that may occur. Edebug
567evaluates the global break condition at every stop point; if it 601evaluates the global break condition at every stop point; if it
568evaluates to a non-@code{nil} value, then execution stops or pauses 602evaluates to a non-@code{nil} value, then execution stops or pauses
569depending on the execution mode, as if a breakpoint had been hit. If 603depending on the execution mode (@pxref{Edebug Execution Modes}), as if
570evaluating the condition gets an error, execution does not stop. 604a breakpoint had been hit. If evaluating the condition gets an error,
605execution does not stop.
571 606
572@findex edebug-set-global-break-condition 607@findex edebug-set-global-break-condition
573 The condition expression is stored in 608 The condition expression is stored in
@@ -603,7 +638,8 @@ argument reaches zero:
603 638
604 When the @code{fac} definition is instrumented and the function is 639 When the @code{fac} definition is instrumented and the function is
605called, the call to @code{edebug} acts as a breakpoint. Depending on 640called, the call to @code{edebug} acts as a breakpoint. Depending on
606the execution mode, Edebug stops or pauses there. 641the execution mode (@pxref{Edebug Execution Modes}), Edebug stops or
642pauses there.
607 643
608 If no instrumented code is being executed when @code{edebug} is called, 644 If no instrumented code is being executed when @code{edebug} is called,
609that function calls @code{debug}. 645that function calls @code{debug}.
@@ -640,17 +676,20 @@ configuration is the collection of windows and contents that were in
640effect outside of Edebug. 676effect outside of Edebug.
641 677
642@table @kbd 678@table @kbd
679@findex edebug-view-outside
643@item P 680@item P
644@itemx v 681@itemx v
645Switch to viewing the outside window configuration 682Switch to viewing the outside window configuration
646(@code{edebug-view-outside}). Type @kbd{C-x X w} to return to Edebug. 683(@code{edebug-view-outside}). Type @kbd{C-x X w} to return to Edebug.
647 684
685@findex edebug-bounce-point
648@item p 686@item p
649Temporarily display the outside current buffer with point at its 687Temporarily display the outside current buffer with point at its
650outside position (@code{edebug-bounce-point}), pausing for one second 688outside position (@code{edebug-bounce-point}), pausing for one second
651before returning to Edebug. With a prefix argument @var{n}, pause for 689before returning to Edebug. With a prefix argument @var{n}, pause for
652@var{n} seconds instead. 690@var{n} seconds instead.
653 691
692@findex edebug-where
654@item w 693@item w
655Move point back to the current stop point in the source code buffer 694Move point back to the current stop point in the source code buffer
656(@code{edebug-where}). 695(@code{edebug-where}).
@@ -659,6 +698,7 @@ If you use this command in a different window displaying the same
659buffer, that window will be used instead to display the current 698buffer, that window will be used instead to display the current
660definition in the future. 699definition in the future.
661 700
701@findex edebug-toggle-save-windows
662@item W 702@item W
663@c Its function is not simply to forget the saved configuration -- dan 703@c Its function is not simply to forget the saved configuration -- dan
664Toggle whether Edebug saves and restores the outside window 704Toggle whether Edebug saves and restores the outside window
@@ -697,6 +737,7 @@ explicitly saves and restores. @xref{The Outside Context}, for details
697on this process. 737on this process.
698 738
699@table @kbd 739@table @kbd
740@findex edebug-eval-expression
700@item e @var{exp} @key{RET} 741@item e @var{exp} @key{RET}
701Evaluate expression @var{exp} in the context outside of Edebug 742Evaluate expression @var{exp} in the context outside of Edebug
702(@code{edebug-eval-expression}). That is, Edebug tries to minimize 743(@code{edebug-eval-expression}). That is, Edebug tries to minimize
@@ -707,37 +748,47 @@ pretty-print the result there.
707By default, this command 748By default, this command
708suppresses the debugger during evaluation, so that an error in the 749suppresses the debugger during evaluation, so that an error in the
709evaluated expression won't add a new error on top of the existing one. 750evaluated expression won't add a new error on top of the existing one.
710Set the @code{debug-allow-recursive-debug} user option to a 751Set the @code{debug-allow-recursive-debug} user option (@pxref{Error
711non-@code{nil} value to override this. 752Debugging}) to a non-@code{nil} value to override this.
712 753
754@findex eval-expression @r{(Edebug)}
713@item M-: @var{exp} @key{RET} 755@item M-: @var{exp} @key{RET}
714Evaluate expression @var{exp} in the context of Edebug itself 756Evaluate expression @var{exp} in the context of Edebug itself
715(@code{eval-expression}). 757(@code{eval-expression}).
716 758
759@findex edebug-eval-last-sexp
717@item C-x C-e 760@item C-x C-e
718Evaluate the expression before point, in the context outside of Edebug 761Evaluate the expression before point, in the context outside of Edebug
719(@code{edebug-eval-last-sexp}). With the prefix argument of zero 762(@code{edebug-eval-last-sexp}) and show the value in the minibuffer.
720(@kbd{C-u 0 C-x C-e}), don't shorten long items (like strings and 763With the prefix argument of zero (@kbd{C-u 0 C-x C-e}), don't shorten
721lists). Any other prefix will result in the value being 764long items (like strings and lists) when showing the value, due to
722pretty-printed in a separate buffer. 765@code{edebug-print-length} and @code{edebug-print-level}
766(@pxref{Printing in Edebug}). Any other prefix will result in the value
767being pretty-printed in a separate buffer instead of the minibuffer.
723@end table 768@end table
724 769
770@xref{Eval List}, for additional Edebug features related to evaluating
771lists of expressions interactively.
772
725@cindex lexical binding (Edebug) 773@cindex lexical binding (Edebug)
774@findex cl-macrolet @r{(Edebug)}
775@findex cl-symbol-macrolet @r{(Edebug)}
726 Edebug supports evaluation of expressions containing references to 776 Edebug supports evaluation of expressions containing references to
727lexically bound symbols created by the following constructs in 777lexically bound symbols created by the following constructs in
728@file{cl.el}: @code{lexical-let}, @code{macrolet}, and 778@file{cl-lib.el}: @code{cl-macrolet} and @code{cl-symbol-macrolet}.
729@code{symbol-macrolet}.
730@c FIXME? What about lexical-binding = t? 779@c FIXME? What about lexical-binding = t?
731 780
732@node Eval List 781@node Eval List
733@subsection Evaluation List Buffer 782@subsection Evaluation List Buffer
734 783
784@cindex evaluation list buffer
735 You can use the @dfn{evaluation list buffer}, called @file{*edebug*}, to 785 You can use the @dfn{evaluation list buffer}, called @file{*edebug*}, to
736evaluate expressions interactively. You can also set up the 786evaluate expressions interactively. You can also set up the
737@dfn{evaluation list} of expressions to be evaluated automatically each 787@dfn{evaluation list} of expressions to be evaluated automatically each
738time Edebug updates the display. 788time Edebug updates the display.
739 789
740@table @kbd 790@table @kbd
791@findex edebug-visit-eval-list
741@item E 792@item E
742Switch to the evaluation list buffer @file{*edebug*} 793Switch to the evaluation list buffer @file{*edebug*}
743(@code{edebug-visit-eval-list}). 794(@code{edebug-visit-eval-list}).
@@ -748,20 +799,25 @@ Interaction mode (@pxref{Lisp Interaction,,, emacs, The GNU Emacs
748Manual}) as well as these special commands: 799Manual}) as well as these special commands:
749 800
750@table @kbd 801@table @kbd
802@findex edebug-eval-print-last-sexp
751@item C-j 803@item C-j
752Evaluate the expression before point, in the outside context, and 804Evaluate the expression before point, in the outside context, and
753insert the value in the buffer (@code{edebug-eval-print-last-sexp}). 805insert the value in the buffer (@code{edebug-eval-print-last-sexp}).
754With prefix argument of zero (@kbd{C-u 0 C-j}), don't shorten long 806With prefix argument of zero (@kbd{C-u 0 C-j}), don't shorten long
755items (like strings and lists). 807items (like strings and lists) due to @code{edebug-print-length} and
808@code{edebug-print-level} (@pxref{Printing in Edebug}).
756 809
810@findex edebug-eval-last-sexp
757@item C-x C-e 811@item C-x C-e
758Evaluate the expression before point, in the context outside of Edebug 812Evaluate the expression before point, in the context outside of Edebug
759(@code{edebug-eval-last-sexp}). 813(@code{edebug-eval-last-sexp}).
760 814
815@findex edebug-update-eval-list
761@item C-c C-u 816@item C-c C-u
762Build a new evaluation list from the contents of the buffer 817Build a new evaluation list from the contents of the buffer
763(@code{edebug-update-eval-list}). 818(@code{edebug-update-eval-list}).
764 819
820@findex edebug-delete-eval-item
765@item C-c C-d 821@item C-c C-d
766Delete the evaluation list group that point is in 822Delete the evaluation list group that point is in
767(@code{edebug-delete-eval-item}). 823(@code{edebug-delete-eval-item}).
@@ -804,24 +860,36 @@ not interrupt your debugging.
804several expressions have been added to it: 860several expressions have been added to it:
805 861
806@smallexample 862@smallexample
863@group
807(current-buffer) 864(current-buffer)
808#<buffer *scratch*> 865#<buffer *scratch*>
809;--------------------------------------------------------------- 866;---------------------------------------------------------------
867@end group
868@group
810(selected-window) 869(selected-window)
811#<window 16 on *scratch*> 870#<window 16 on *scratch*>
812;--------------------------------------------------------------- 871;---------------------------------------------------------------
872@end group
873@group
813(point) 874(point)
814196 875196
815;--------------------------------------------------------------- 876;---------------------------------------------------------------
877@end group
878@group
816bad-var 879bad-var
817"Symbol's value as variable is void: bad-var" 880"Symbol's value as variable is void: bad-var"
818;--------------------------------------------------------------- 881;---------------------------------------------------------------
882@end group
883@group
819(recursion-depth) 884(recursion-depth)
8200 8850
821;--------------------------------------------------------------- 886;---------------------------------------------------------------
887@end group
888@group
822this-command 889this-command
823eval-last-sexp 890eval-last-sexp
824;--------------------------------------------------------------- 891;---------------------------------------------------------------
892@end group
825@end smallexample 893@end smallexample
826 894
827To delete a group, move point into it and type @kbd{C-c C-d}, or simply 895To delete a group, move point into it and type @kbd{C-c C-d}, or simply
@@ -832,8 +900,9 @@ the expression at a suitable place, insert a new comment line, then type
832contents don't matter. 900contents don't matter.
833 901
834After selecting @file{*edebug*}, you can return to the source code 902After selecting @file{*edebug*}, you can return to the source code
835buffer with @kbd{C-c C-w}. The @file{*edebug*} buffer is killed when 903buffer with @kbd{C-c C-w} (@pxref{Edebug Views}). The @file{*edebug*}
836you continue execution, and recreated next time it is needed. 904buffer is killed when you continue execution, and recreated next time it
905is needed.
837 906
838@node Printing in Edebug 907@node Printing in Edebug
839@subsection Printing in Edebug 908@subsection Printing in Edebug
@@ -867,8 +936,10 @@ to a non-@code{nil} value.
867 Here is an example of code that creates a circular structure: 936 Here is an example of code that creates a circular structure:
868 937
869@example 938@example
939@group
870(setq a (list 'x 'y)) 940(setq a (list 'x 'y))
871(setcar a a) 941(setcar a a)
942@end group
872@end example 943@end example
873 944
874@noindent 945@noindent
@@ -890,11 +961,14 @@ printing results. The default value is @code{t}.
890@node Trace Buffer 961@node Trace Buffer
891@subsection Trace Buffer 962@subsection Trace Buffer
892@cindex trace buffer 963@cindex trace buffer
964@cindex Edebug trace buffer
965@cindex tracing in Edebug
893 966
894 Edebug can record an execution trace, storing it in a buffer named 967 Edebug can record an execution trace, storing it in a buffer named
895@file{*edebug-trace*}. This is a log of function calls and returns, 968@file{*edebug-trace*}. This is a log of function calls and returns,
896showing the function names and their arguments and values. To enable 969showing the function names and their arguments and values. To enable
897trace recording, set @code{edebug-trace} to a non-@code{nil} value. 970trace recording, set @code{edebug-trace} to a non-@code{nil} value
971(@pxref{Edebug Options}).
898 972
899 Making a trace buffer is not the same thing as using trace execution 973 Making a trace buffer is not the same thing as using trace execution
900mode (@pxref{Edebug Execution Modes}). 974mode (@pxref{Edebug Execution Modes}).
@@ -925,7 +999,7 @@ value of the last form in @var{body}.
925 999
926@defun edebug-trace format-string &rest format-args 1000@defun edebug-trace format-string &rest format-args
927This function inserts text in the trace buffer. It computes the text 1001This function inserts text in the trace buffer. It computes the text
928with @code{(apply 'format @var{format-string} @var{format-args})}. 1002with @w{@code{(apply 'format @var{format-string} @var{format-args})}}.
929It also appends a newline to separate entries. 1003It also appends a newline to separate entries.
930@end defun 1004@end defun
931 1005
@@ -952,10 +1026,10 @@ correctly; Edebug will tell you when you have tried enough different
952conditions that each form has returned two different values. 1026conditions that each form has returned two different values.
953 1027
954 Coverage testing makes execution slower, so it is only done if 1028 Coverage testing makes execution slower, so it is only done if
955@code{edebug-test-coverage} is non-@code{nil}. Frequency counting is 1029@code{edebug-test-coverage} is non-@code{nil} (@pxref{Edebug Options}).
956performed for all executions of an instrumented function, even if the 1030Frequency counting is performed for all executions of an instrumented
957execution mode is Go-nonstop, and regardless of whether coverage testing 1031function, even if the execution mode is Go-nonstop, and regardless of
958is enabled. 1032whether coverage testing is enabled.
959 1033
960@kindex C-x X = 1034@kindex C-x X =
961@findex edebug-temp-display-freq-count 1035@findex edebug-temp-display-freq-count
@@ -988,6 +1062,7 @@ breakpoint, and setting @code{edebug-test-coverage} to @code{t}, when
988the breakpoint is reached, the frequency data looks like this: 1062the breakpoint is reached, the frequency data looks like this:
989 1063
990@example 1064@example
1065@group
991(defun fac (n) 1066(defun fac (n)
992 (if (= n 0) (edebug)) 1067 (if (= n 0) (edebug))
993;#6 1 = =5 1068;#6 1 = =5
@@ -996,7 +1071,8 @@ the breakpoint is reached, the frequency data looks like this:
996 (* n (fac (1- n))) 1071 (* n (fac (1- n)))
997;# 5 0 1072;# 5 0
998 1)) 1073 1))
999;# 0 1074a;# 0
1075@end group
1000@end example 1076@end example
1001 1077
1002The comment lines show that @code{fac} was called 6 times. The 1078The comment lines show that @code{fac} was called 6 times. The
@@ -1037,15 +1113,19 @@ using Edebug. You can also enlarge the value of
1037@code{edebug-max-depth} if Edebug reaches the limit of recursion depth 1113@code{edebug-max-depth} if Edebug reaches the limit of recursion depth
1038instrumenting code that contains very large quoted lists. 1114instrumenting code that contains very large quoted lists.
1039 1115
1116@vindex executing-kbd-macro @r{(Edebug)}
1040@item 1117@item
1041The state of keyboard macro execution is saved and restored. While 1118The state of keyboard macro execution is saved and restored. While
1042Edebug is active, @code{executing-kbd-macro} is bound to @code{nil} 1119Edebug is active, @code{executing-kbd-macro} is bound to @code{nil}
1043unless @code{edebug-continue-kbd-macro} is non-@code{nil}. 1120unless @code{edebug-continue-kbd-macro} is non-@code{nil} (@pxref{Edebug
1121Options}).
1044@end itemize 1122@end itemize
1045 1123
1046 1124
1047@node Edebug Display Update 1125@node Edebug Display Update
1048@subsubsection Edebug Display Update 1126@subsubsection Edebug Display Update
1127@cindex Edebug and display updates
1128@cindex display updates, and Edebug
1049 1129
1050@c This paragraph is not filled, because LaLiberte's conversion script 1130@c This paragraph is not filled, because LaLiberte's conversion script
1051@c needs an xref to be on just one line. 1131@c needs an xref to be on just one line.
@@ -1066,13 +1146,13 @@ following data (though some of them are deliberately not restored if an
1066error or quit signal occurs). 1146error or quit signal occurs).
1067 1147
1068@itemize @bullet 1148@itemize @bullet
1069@item
1070@cindex current buffer point and mark (Edebug) 1149@cindex current buffer point and mark (Edebug)
1150@item
1071Which buffer is current, and the positions of point and the mark in the 1151Which buffer is current, and the positions of point and the mark in the
1072current buffer, are saved and restored. 1152current buffer, are saved and restored.
1073 1153
1074@item
1075@cindex window configuration (Edebug) 1154@cindex window configuration (Edebug)
1155@item
1076The outside window configuration is saved and restored if 1156The outside window configuration is saved and restored if
1077@code{edebug-save-windows} is non-@code{nil} (@pxref{Edebug Options}). 1157@code{edebug-save-windows} is non-@code{nil} (@pxref{Edebug Options}).
1078If the value of @code{edebug-save-windows} is a list, only the listed 1158If the value of @code{edebug-save-windows} is a list, only the listed
@@ -1086,7 +1166,7 @@ The window start and horizontal scrolling of the source code buffer are
1086not restored, however, so that the display remains coherent within Edebug. 1166not restored, however, so that the display remains coherent within Edebug.
1087 1167
1088@cindex buffer point changed by Edebug 1168@cindex buffer point changed by Edebug
1089@cindex edebug overwrites buffer point position 1169@cindex Edebug overwrites buffer point position
1090Saving and restoring the outside window configuration can sometimes 1170Saving and restoring the outside window configuration can sometimes
1091change the positions of point in the buffers on which the Lisp program 1171change the positions of point in the buffers on which the Lisp program
1092you are debugging operates, especially if your program moves point. 1172you are debugging operates, especially if your program moves point.
@@ -1098,11 +1178,14 @@ set @code{edebug-save-windows} to @code{nil}
1098The value of point in each displayed buffer is saved and restored if 1178The value of point in each displayed buffer is saved and restored if
1099@code{edebug-save-displayed-buffer-points} is non-@code{nil}. 1179@code{edebug-save-displayed-buffer-points} is non-@code{nil}.
1100 1180
1181@vindex overlay-arrow-position @r{(Edebug)}
1182@vindex overlay-arrow-string @r{(Edebug)}
1101@item 1183@item
1102The variables @code{overlay-arrow-position} and 1184The variables @code{overlay-arrow-position} and
1103@code{overlay-arrow-string} are saved and restored, so you can safely 1185@code{overlay-arrow-string} are saved and restored, so you can safely
1104invoke Edebug from the recursive edit elsewhere in the same buffer. 1186invoke Edebug from the recursive edit elsewhere in the same buffer.
1105 1187
1188@vindex cursor-in-echo-area @r{(Edebug)}
1106@item 1189@item
1107@code{cursor-in-echo-area} is locally bound to @code{nil} so that 1190@code{cursor-in-echo-area} is locally bound to @code{nil} so that
1108the cursor shows up in the window. 1191the cursor shows up in the window.
@@ -1110,6 +1193,8 @@ the cursor shows up in the window.
1110 1193
1111@node Edebug Recursive Edit 1194@node Edebug Recursive Edit
1112@subsubsection Edebug Recursive Edit 1195@subsubsection Edebug Recursive Edit
1196@cindex Edebug and recursive edit
1197@cindex recursive edit, and Edebug
1113 1198
1114When Edebug is entered and actually reads commands from the user, it 1199When Edebug is entered and actually reads commands from the user, it
1115saves (and later restores) these additional data: 1200saves (and later restores) these additional data:
@@ -1156,6 +1241,8 @@ Edebug is active, @code{defining-kbd-macro} is bound to
1156 1241
1157@node Edebug and Macros 1242@node Edebug and Macros
1158@subsection Edebug and Macros 1243@subsection Edebug and Macros
1244@cindex Edebug and macros
1245@cindex macros, debugging with Edebug
1159 1246
1160To make Edebug properly instrument expressions that call macros, some 1247To make Edebug properly instrument expressions that call macros, some
1161extra care is needed. This subsection explains the details. 1248extra care is needed. This subsection explains the details.
@@ -1179,23 +1266,26 @@ time later.)
1179 1266
1180 Therefore, you must define an Edebug specification for each macro 1267 Therefore, you must define an Edebug specification for each macro
1181that Edebug will encounter, to explain the format of calls to that 1268that Edebug will encounter, to explain the format of calls to that
1182macro. To do this, add a @code{debug} declaration to the macro 1269macro. To do this, add a @code{debug} declaration (@pxref{Declare
1183definition. Here is a simple example that shows the specification for 1270Form}) to the macro definition. Here is a simple example that shows the
1184the @code{for} example macro (@pxref{Argument Evaluation}). 1271specification for the @code{for} example macro (@pxref{Argument
1272Evaluation}).
1185 1273
1186@smallexample 1274@smallexample
1275@group
1187(defmacro for (var from init to final do &rest body) 1276(defmacro for (var from init to final do &rest body)
1188 "Execute a simple \"for\" loop. 1277 "Execute a simple \"for\" loop.
1189For example, (for i from 1 to 10 do (print i))." 1278For example, (for i from 1 to 10 do (print i))."
1190 (declare (debug (symbolp "from" form "to" form "do" &rest form))) 1279 (declare (debug (symbolp "from" form "to" form "do" &rest form)))
1191 ...) 1280 ...)
1281@end group
1192@end smallexample 1282@end smallexample
1193 1283
1194 The Edebug specification says which parts of a call to the macro are 1284 The Edebug specification says which parts of a call to the macro are
1195forms to be evaluated. For simple macros, the specification 1285forms to be evaluated. For simple macros, the specification
1196often looks very similar to the formal argument list of the macro 1286often looks very similar to the formal argument list of the macro
1197definition, but specifications are much more general than macro 1287definition, but specifications are much more general than macro
1198arguments. @xref{Defining Macros}, for more explanation of 1288arguments. @xref{Declare Form}, for more details about
1199the @code{declare} form. 1289the @code{declare} form.
1200 1290
1201@c See, e.g., https://debbugs.gnu.org/10577 1291@c See, e.g., https://debbugs.gnu.org/10577
@@ -1259,6 +1349,7 @@ are instrumented.
1259@subsubsection Specification List 1349@subsubsection Specification List
1260 1350
1261@cindex Edebug specification list 1351@cindex Edebug specification list
1352@cindex specification list, Edebug
1262A @dfn{specification list} is required for an Edebug specification if 1353A @dfn{specification list} is required for an Edebug specification if
1263some arguments of a macro call are evaluated while others are not. Some 1354some arguments of a macro call are evaluated while others are not. Some
1264elements in a specification list match one or more arguments, but others 1355elements in a specification list match one or more arguments, but others
@@ -1365,12 +1456,12 @@ This is successful when there are no more arguments to match at the
1365current argument list level; otherwise it fails. See sublist 1456current argument list level; otherwise it fails. See sublist
1366specifications and the backquote example. 1457specifications and the backquote example.
1367 1458
1459@cindex preventing backtracking, in Edebug specification list
1368@item gate 1460@item gate
1369@cindex preventing backtracking
1370No argument is matched but backtracking through the gate is disabled 1461No argument is matched but backtracking through the gate is disabled
1371while matching the remainder of the specifications at this level. This 1462while matching the remainder of the specifications at this level. This
1372is primarily used to generate more specific syntax error messages. See 1463is primarily used to generate more specific syntax error messages.
1373@ref{Backtracking}, for more details. Also see the @code{let} example. 1464@xref{Backtracking}, for more details. Also see the @code{let} example.
1374 1465
1375@item &error 1466@item &error
1376@code{&error} should be followed by a string, an error message, in the 1467@code{&error} should be followed by a string, an error message, in the
@@ -1392,8 +1483,8 @@ sexps whose first element is a symbol and then lets
1392with that head symbol according to @code{pcase--match-pat-args} and 1483with that head symbol according to @code{pcase--match-pat-args} and
1393pass them to the @var{pf} it received as argument. 1484pass them to the @var{pf} it received as argument.
1394 1485
1395@item @var{other-symbol}
1396@cindex indirect specifications 1486@cindex indirect specifications
1487@item @var{other-symbol}
1397Any other symbol in a specification list may be a predicate or an 1488Any other symbol in a specification list may be a predicate or an
1398indirect specification. 1489indirect specification.
1399 1490
@@ -1415,8 +1506,8 @@ specification fails and the argument is not instrumented.
1415Some suitable predicates include @code{symbolp}, @code{integerp}, 1506Some suitable predicates include @code{symbolp}, @code{integerp},
1416@code{stringp}, @code{vectorp}, and @code{atom}. 1507@code{stringp}, @code{vectorp}, and @code{atom}.
1417 1508
1418@item [@var{elements}@dots{}]
1419@cindex [@dots{}] (Edebug) 1509@cindex [@dots{}] (Edebug)
1510@item [@var{elements}@dots{}]
1420A vector of elements groups the elements into a single @dfn{group 1511A vector of elements groups the elements into a single @dfn{group
1421specification}. Its meaning has nothing to do with vectors. 1512specification}. Its meaning has nothing to do with vectors.
1422 1513
@@ -1477,8 +1568,8 @@ The argument, a symbol, is the name of an argument of the defining form.
1477However, lambda-list keywords (symbols starting with @samp{&}) 1568However, lambda-list keywords (symbols starting with @samp{&})
1478are not allowed. 1569are not allowed.
1479 1570
1480@item lambda-list
1481@cindex lambda-list (Edebug) 1571@cindex lambda-list (Edebug)
1572@item lambda-list
1482This matches a lambda list---the argument list of a lambda expression. 1573This matches a lambda list---the argument list of a lambda expression.
1483 1574
1484@item def-body 1575@item def-body
@@ -1798,6 +1889,7 @@ a breakpoint. Set to @code{nil} to prevent the pause, non-@code{nil}
1798to allow it. 1889to allow it.
1799@end defopt 1890@end defopt
1800 1891
1892@cindex Edebug, changing behavior with instrumented code
1801@defopt edebug-behavior-alist 1893@defopt edebug-behavior-alist
1802By default, this alist contains one entry with the key @code{edebug} 1894By default, this alist contains one entry with the key @code{edebug}
1803and a list of three functions, which are the default implementations 1895and a list of three functions, which are the default implementations
@@ -1805,6 +1897,7 @@ of the functions inserted in instrumented code: @code{edebug-enter},
1805@code{edebug-before} and @code{edebug-after}. To change Edebug's 1897@code{edebug-before} and @code{edebug-after}. To change Edebug's
1806behavior globally, modify the default entry. 1898behavior globally, modify the default entry.
1807 1899
1900@vindex edebug-behavior, symbol property
1808Edebug's behavior may also be changed on a per-definition basis by 1901Edebug's behavior may also be changed on a per-definition basis by
1809adding an entry to this alist, with a key of your choice and three 1902adding an entry to this alist, with a key of your choice and three
1810functions. Then set the @code{edebug-behavior} symbol property of an 1903functions. Then set the @code{edebug-behavior} symbol property of an