aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/debugging.texi
diff options
context:
space:
mode:
authorLute Kamstra2005-03-01 08:41:52 +0000
committerLute Kamstra2005-03-01 08:41:52 +0000
commita1f74898ea7d3f89b4a8e4a3ea10d42246a3075f (patch)
tree3878cec64642311e036ad8c311869a15233dadc2 /lispref/debugging.texi
parent94230abb6aa17c539ccd85f2fd17e004ef80217e (diff)
downloademacs-a1f74898ea7d3f89b4a8e4a3ea10d42246a3075f.tar.gz
emacs-a1f74898ea7d3f89b4a8e4a3ea10d42246a3075f.zip
(Debugging): Fix typo.
(Error Debugging): Document eval-expression-debug-on-error. (Function Debugging): Update example. (Using Debugger): Mention starred stack frames. (Debugger Commands): Document `j' and `l'. (Invoking the Debugger): `d' and `j' exit recursive edit too. Update the messages that the debugger displays. (Internals of Debugger): Add cross reference. Update example. (Excess Open): Minor improvement. (Excess Close): Minor improvement.
Diffstat (limited to 'lispref/debugging.texi')
-rw-r--r--lispref/debugging.texi124
1 files changed, 72 insertions, 52 deletions
diff --git a/lispref/debugging.texi b/lispref/debugging.texi
index e893b77ed84..93f9b6b161b 100644
--- a/lispref/debugging.texi
+++ b/lispref/debugging.texi
@@ -1,6 +1,6 @@
1@c -*-texinfo-*- 1@c -*-texinfo-*-
2@c This is part of the GNU Emacs Lisp Reference Manual. 2@c This is part of the GNU Emacs Lisp Reference Manual.
3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998, 1999 3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998, 1999, 2005
4@c Free Software Foundation, Inc. 4@c Free Software Foundation, Inc.
5@c See the file elisp.texi for copying conditions. 5@c See the file elisp.texi for copying conditions.
6@setfilename ../info/debugging 6@setfilename ../info/debugging
@@ -14,7 +14,7 @@ depending on what you are doing with the program when the problem appears.
14@item 14@item
15If the problem occurs when you run the program, you can use a Lisp 15If the problem occurs when you run the program, you can use a Lisp
16debugger to investigate what is happening during execution. In addition 16debugger to investigate what is happening during execution. In addition
17to the ordinary debugger, Emacs comes with a source level debugger, 17to the ordinary debugger, Emacs comes with a source-level debugger,
18Edebug. This chapter describes both of them. 18Edebug. This chapter describes both of them.
19 19
20@item 20@item
@@ -117,6 +117,15 @@ the error. The easiest way is usually to set
117@code{debug-ignored-errors} to @code{nil}. 117@code{debug-ignored-errors} to @code{nil}.
118@end defopt 118@end defopt
119 119
120@defopt eval-expression-debug-on-error
121If you set this variable to a non-@code{nil} value, then
122@code{debug-on-error} will be set to @code{t} when evaluating with the
123command @code{eval-expression}. If
124@code{eval-expression-debug-on-error} is @code{nil}, then the value of
125@code{debug-on-error} is not changed. @xref{Lisp Eval,, Evaluating
126Emacs-Lisp Expressions, emacs, The GNU Emacs Manual}.
127@end defopt
128
120@defopt debug-on-signal 129@defopt debug-on-signal
121Normally, errors that are caught by @code{condition-case} never run the 130Normally, errors that are caught by @code{condition-case} never run the
122debugger, even if @code{debug-on-error} is non-@code{nil}. In other 131debugger, even if @code{debug-on-error} is non-@code{nil}. In other
@@ -240,14 +249,12 @@ Here's an example to illustrate use of this function:
240 249
241@group 250@group
242------ Buffer: *Backtrace* ------ 251------ Buffer: *Backtrace* ------
243Entering: 252Debugger entered--entering a function:
244* fact(3) 253* fact(3)
245 eval-region(4870 4878 t) 254 eval((fact 3))
246 byte-code("...") 255 eval-last-sexp-1(nil)
247 eval-last-sexp(nil) 256 eval-last-sexp(nil)
248 (let ...) 257 call-interactively(eval-last-sexp)
249 eval-insert-last-sexp(nil)
250* call-interactively(eval-insert-last-sexp)
251------ Buffer: *Backtrace* ------ 258------ Buffer: *Backtrace* ------
252@end group 259@end group
253 260
@@ -317,7 +324,9 @@ moving point to the line describing that frame. (A stack frame is the
317place where the Lisp interpreter records information about a particular 324place where the Lisp interpreter records information about a particular
318invocation of a function.) The frame whose line point is on is 325invocation of a function.) The frame whose line point is on is
319considered the @dfn{current frame}. Some of the debugger commands 326considered the @dfn{current frame}. Some of the debugger commands
320operate on the current frame. 327operate on the current frame. If a line starts with a star, that means
328that exiting that frame will call the debugger again. This is useful
329for examining the return value of a function.
321 330
322 If a function name is underlined, that means the debugger knows 331 If a function name is underlined, that means the debugger knows
323where its source code is located. You can click @kbd{Mouse-2} on that 332where its source code is located. You can click @kbd{Mouse-2} on that
@@ -328,8 +337,6 @@ assumptions about how many stack frames are used for the debugger
328itself. These assumptions are false if the debugger is running 337itself. These assumptions are false if the debugger is running
329interpreted. 338interpreted.
330 339
331@need 3000
332
333@node Debugger Commands 340@node Debugger Commands
334@subsection Debugger Commands 341@subsection Debugger Commands
335@cindex debugger command list 342@cindex debugger command list
@@ -378,6 +385,15 @@ Don't enter the debugger when the current frame is exited. This
378cancels a @kbd{b} command on that frame. The visible effect is to 385cancels a @kbd{b} command on that frame. The visible effect is to
379remove the star from the line in the backtrace buffer. 386remove the star from the line in the backtrace buffer.
380 387
388@item j
389Flag the current frame like @kbd{b}. Then continue execution like
390@kbd{c}, but temporarily disable break-on-entry for all functions that
391are set up to do so by @code{debug-on-entry}. The temporarily disabled
392functions are set up to debug on entry again when the debugger is
393entered or when @code{debug-on-entry} is called;
394@code{cancel-debug-on-entry} also re-enables these functions before it
395disables any functions that its argument says it should disable.
396
381@item e 397@item e
382Read a Lisp expression in the minibuffer, evaluate it, and print the 398Read a Lisp expression in the minibuffer, evaluate it, and print the
383value in the echo area. The debugger alters certain important 399value in the echo area. The debugger alters certain important
@@ -410,6 +426,13 @@ used as the value of that frame. It is also useful if you call
410effect as @kbd{c}, and the specified return value does not matter. 426effect as @kbd{c}, and the specified return value does not matter.
411 427
412You can't use @kbd{r} when the debugger was entered due to an error. 428You can't use @kbd{r} when the debugger was entered due to an error.
429
430@item l
431Display a list of functions that will invoke the debugger when called.
432This is a list of functions that are set to break on entry by means of
433@code{debug-on-entry}. @strong{Warning:} if you redefine such a
434function and thus cancel the effect of @code{debug-on-entry}, it may
435erroneously show up in this list.
413@end table 436@end table
414 437
415@node Invoking the Debugger 438@node Invoking the Debugger
@@ -425,10 +448,10 @@ recursive entry to the debugger, etc.), and fills it with information
425about the stack of Lisp function calls. It then enters a recursive 448about the stack of Lisp function calls. It then enters a recursive
426edit, showing the backtrace buffer in Debugger mode. 449edit, showing the backtrace buffer in Debugger mode.
427 450
428The Debugger mode @kbd{c} and @kbd{r} commands exit the recursive edit; 451The Debugger mode @kbd{c}, @kbd{d}, @kbd{j}, and @kbd{r} commands exit
429then @code{debug} switches back to the previous buffer and returns to 452the recursive edit; then @code{debug} switches back to the previous
430whatever called @code{debug}. This is the only way the function 453buffer and returns to whatever called @code{debug}. This is the only
431@code{debug} can return to its caller. 454way the function @code{debug} can return to its caller.
432 455
433The use of the @var{debugger-args} is that @code{debug} displays the 456The use of the @var{debugger-args} is that @code{debug} displays the
434rest of its arguments at the top of the @samp{*Backtrace*} buffer, so 457rest of its arguments at the top of the @samp{*Backtrace*} buffer, so
@@ -443,41 +466,41 @@ is a table of these special values:
443@table @code 466@table @code
444@item lambda 467@item lambda
445@cindex @code{lambda} in debug 468@cindex @code{lambda} in debug
446A first argument of @code{lambda} means @code{debug} was called because 469A first argument of @code{lambda} means @code{debug} was called
447of entry to a function when @code{debug-on-next-call} was 470because of entry to a function when @code{debug-on-next-call} was
448non-@code{nil}. The debugger displays @samp{Entering:} as a line of 471non-@code{nil}. The debugger displays @samp{Debugger
449text at the top of the buffer. 472entered--entering a function:} as a line of text at the top of the
473buffer.
450 474
451@item debug 475@item debug
452@code{debug} as first argument indicates a call to @code{debug} because 476@code{debug} as first argument indicates a call to @code{debug}
453of entry to a function that was set to debug on entry. The debugger 477because of entry to a function that was set to debug on entry. The
454displays @samp{Entering:}, just as in the @code{lambda} case. It also 478debugger displays @samp{Debugger entered--entering a function:}, just
455marks the stack frame for that function so that it will invoke the 479as in the @code{lambda} case. It also marks the stack frame for that
456debugger when exited. 480function so that it will invoke the debugger when exited.
457 481
458@item t 482@item t
459When the first argument is @code{t}, this indicates a call to 483When the first argument is @code{t}, this indicates a call to
460@code{debug} due to evaluation of a list form when 484@code{debug} due to evaluation of a list form when
461@code{debug-on-next-call} is non-@code{nil}. The debugger displays the 485@code{debug-on-next-call} is non-@code{nil}. The debugger displays
462following as the top line in the buffer: 486@samp{Debugger entered--beginning evaluation of function call form:}
463 487as the top line in the buffer.
464@smallexample
465Beginning evaluation of function call form:
466@end smallexample
467 488
468@item exit 489@item exit
469When the first argument is @code{exit}, it indicates the exit of a stack 490When the first argument is @code{exit}, it indicates the exit of a
470frame previously marked to invoke the debugger on exit. The second 491stack frame previously marked to invoke the debugger on exit. The
471argument given to @code{debug} in this case is the value being returned 492second argument given to @code{debug} in this case is the value being
472from the frame. The debugger displays @samp{Return value:} in the top 493returned from the frame. The debugger displays @samp{Debugger
473line of the buffer, followed by the value being returned. 494entered--returning value:} in the top line of the buffer, followed by
495the value being returned.
474 496
475@item error 497@item error
476@cindex @code{error} in debug 498@cindex @code{error} in debug
477When the first argument is @code{error}, the debugger indicates that 499When the first argument is @code{error}, the debugger indicates that
478it is being entered because an error or @code{quit} was signaled and not 500it is being entered because an error or @code{quit} was signaled and
479handled, by displaying @samp{Signaling:} followed by the error signaled 501not handled, by displaying @samp{Debugger entered--Lisp error:}
480and any arguments to @code{signal}. For example, 502followed by the error signaled and any arguments to @code{signal}.
503For example,
481 504
482@example 505@example
483@group 506@group
@@ -487,7 +510,7 @@ and any arguments to @code{signal}. For example,
487 510
488@group 511@group
489------ Buffer: *Backtrace* ------ 512------ Buffer: *Backtrace* ------
490Signaling: (arith-error) 513Debugger entered--Lisp error: (arith-error)
491 /(1 0) 514 /(1 0)
492... 515...
493------ Buffer: *Backtrace* ------ 516------ Buffer: *Backtrace* ------
@@ -522,7 +545,7 @@ some kind of debugger. The default value of the variable is
522 545
523The first argument that Lisp hands to the function indicates why it 546The first argument that Lisp hands to the function indicates why it
524was called. The convention for arguments is detailed in the description 547was called. The convention for arguments is detailed in the description
525of @code{debug}. 548of @code{debug} (@pxref{Invoking the Debugger}).
526@end defvar 549@end defvar
527 550
528@deffn Command backtrace 551@deffn Command backtrace
@@ -567,17 +590,14 @@ forms are elided.
567 (save-excursion ...) 590 (save-excursion ...)
568 (let ...) 591 (let ...)
569 (with-output-to-temp-buffer ...) 592 (with-output-to-temp-buffer ...)
570 eval-region(1973 2142 #<buffer *scratch*>) 593 eval((with-output-to-temp-buffer ...))
571 byte-code("... for eval-print-last-sexp ...") 594 eval-last-sexp-1(nil)
572@group 595@group
573 eval-print-last-sexp(nil) 596 eval-last-sexp(nil)
574* call-interactively(eval-print-last-sexp) 597 call-interactively(eval-last-sexp)
575----------- Buffer: backtrace-output ------------ 598----------- Buffer: backtrace-output ------------
576@end group 599@end group
577@end smallexample 600@end smallexample
578
579The character @samp{*} indicates a frame whose debug-on-exit flag is
580set.
581@end deffn 601@end deffn
582 602
583@ignore @c Not worth mentioning 603@ignore @c Not worth mentioning
@@ -687,8 +707,8 @@ find the mismatch.)
687 707
688 The first step is to find the defun that is unbalanced. If there is 708 The first step is to find the defun that is unbalanced. If there is
689an excess open parenthesis, the way to do this is to go to the end of 709an excess open parenthesis, the way to do this is to go to the end of
690the file and type @kbd{C-u C-M-u}. This will move you to the beginning 710the file and type @kbd{C-u C-M-u}. This will move you to the
691of the defun that is unbalanced. 711beginning of the first defun that is unbalanced.
692 712
693 The next step is to determine precisely what is wrong. There is no 713 The next step is to determine precisely what is wrong. There is no
694way to be sure of this except by studying the program, but often the 714way to be sure of this except by studying the program, but often the
@@ -719,9 +739,9 @@ anything.
719@node Excess Close 739@node Excess Close
720@subsection Excess Close Parentheses 740@subsection Excess Close Parentheses
721 741
722 To deal with an excess close parenthesis, first go to the beginning of 742 To deal with an excess close parenthesis, first go to the beginning
723the file, then type @kbd{C-u -1 C-M-u} to find the end of the unbalanced 743of the file, then type @kbd{C-u -1 C-M-u} to find the end of the first
724defun. 744unbalanced defun.
725 745
726 Then find the actual matching close parenthesis by typing @kbd{C-M-f} 746 Then find the actual matching close parenthesis by typing @kbd{C-M-f}
727at the beginning of that defun. This will leave you somewhere short of 747at the beginning of that defun. This will leave you somewhere short of