aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/debugging.texi
diff options
context:
space:
mode:
authorRichard M. Stallman1994-04-30 02:19:25 +0000
committerRichard M. Stallman1994-04-30 02:19:25 +0000
commitae4a385754aa0ab07c9aad929fc87c49c9c07cc6 (patch)
treefbc0402f6e2dce0da1e1732d09ca165f637bc9d5 /lispref/debugging.texi
parentb5b911f995d9c92df4a7518bd7b06504889d82ed (diff)
downloademacs-ae4a385754aa0ab07c9aad929fc87c49c9c07cc6.tar.gz
emacs-ae4a385754aa0ab07c9aad929fc87c49c9c07cc6.zip
*** empty log message ***
Diffstat (limited to 'lispref/debugging.texi')
-rw-r--r--lispref/debugging.texi102
1 files changed, 54 insertions, 48 deletions
diff --git a/lispref/debugging.texi b/lispref/debugging.texi
index b16c5407c93..5b4905c30a5 100644
--- a/lispref/debugging.texi
+++ b/lispref/debugging.texi
@@ -81,7 +81,7 @@ debugger each time this happens. If you want errors to enter the
81debugger, set the variable @code{debug-on-error} to non-@code{nil}. 81debugger, set the variable @code{debug-on-error} to non-@code{nil}.
82 82
83@defopt debug-on-error 83@defopt debug-on-error
84This variable determines whether the debugger is called when a error is 84This variable determines whether the debugger is called when an error is
85signaled and not handled. If @code{debug-on-error} is @code{t}, all 85signaled and not handled. If @code{debug-on-error} is @code{t}, all
86errors call the debugger. If it is @code{nil}, none call the debugger. 86errors call the debugger. If it is @code{nil}, none call the debugger.
87 87
@@ -93,13 +93,15 @@ value invoke the debugger.
93 93
94 To debug an error that happens during loading of the @file{.emacs} 94 To debug an error that happens during loading of the @file{.emacs}
95file, use the option @samp{-debug-init}, which binds 95file, use the option @samp{-debug-init}, which binds
96@code{debug-on-error} to @code{t} while @file{.emacs} is loaded. 96@code{debug-on-error} to @code{t} while @file{.emacs} is loaded and
97inhibits use of @code{condition-case} to catch init file errors.
97 98
98 If your @file{.emacs} file sets @code{debug-on-error}, the effect 99 If your @file{.emacs} file sets @code{debug-on-error}, the effect may
99lasts only until the end of loading @file{.emacs}. (This is an 100not last past the end of loading @file{.emacs}. (This is an undesirable
100undesirable by-product of the @samp{-debug-init} feature.) If you want 101byproduct of the code that implements the @samp{-debug-init} command
101@file{.emacs} to set @code{debug-on-error} permanently, use 102line option.) The best way to make @file{.emacs} set
102@code{after-init-hook}, like this: 103@code{debug-on-error} permanently is with @code{after-init-hook}, like
104this:
103 105
104@example 106@example
105(add-hook 'after-init-hook 107(add-hook 'after-init-hook
@@ -121,8 +123,8 @@ with @kbd{C-g}, which causes quit.
121looping. To get more information, you can set the variable 123looping. To get more information, you can set the variable
122@code{debug-on-quit} to non-@code{nil}. Quitting with @kbd{C-g} is not 124@code{debug-on-quit} to non-@code{nil}. Quitting with @kbd{C-g} is not
123considered an error, and @code{debug-on-error} has no effect on the 125considered an error, and @code{debug-on-error} has no effect on the
124handling of @kbd{C-g}. Contrariwise, @code{debug-on-quit} has no effect 126handling of @kbd{C-g}. Likewise, @code{debug-on-quit} has no effect on
125on errors.@refill 127errors.
126 128
127 Once you have the debugger running in the middle of the infinite loop, 129 Once you have the debugger running in the middle of the infinite loop,
128you can proceed from the debugger using the stepping commands. If you 130you can proceed from the debugger using the stepping commands. If you
@@ -184,7 +186,6 @@ on it, the code to enter the debugger is lost.
184@end group 186@end group
185@group 187@group
186(fact 3) 188(fact 3)
187 @result{} 6
188@end group 189@end group
189 190
190@group 191@group
@@ -230,9 +231,9 @@ before you save the file!
230 231
231 The place where you insert @samp{(debug)} must be a place where an 232 The place where you insert @samp{(debug)} must be a place where an
232additional form can be evaluated and its value ignored. (If the value 233additional form can be evaluated and its value ignored. (If the value
233isn't ignored, it will alter the execution of the program!) The most 234of @code{(debug)} isn't ignored, it will alter the execution of the
234common suitable places are inside a @code{progn} or an implicit 235program!) The most common suitable places are inside a @code{progn} or
235@code{progn} (@pxref{Sequencing}). 236an implicit @code{progn} (@pxref{Sequencing}).
236 237
237@node Using Debugger 238@node Using Debugger
238@subsection Using the Debugger 239@subsection Using the Debugger
@@ -257,12 +258,12 @@ the debugger gets out of the recursive edit and kills the backtrace
257buffer. 258buffer.
258 259
259@cindex current stack frame 260@cindex current stack frame
260 The contents of the backtrace buffer show you the functions that are 261 The backtrace buffer shows you the functions that are executing and
261executing and their argument values. It also allows you to specify a 262their argument values. It also allows you to specify a stack frame by
262stack frame by moving point to the line describing that frame. (A stack 263moving point to the line describing that frame. (A stack frame is the
263frame is the place where the Lisp interpreter records information about 264place where the Lisp interpreter records information about a particular
264a particular invocation of a function.) The frame whose line point is 265invocation of a function.) The frame whose line point is on is
265on is considered the @dfn{current frame}. Some of the debugger commands 266considered the @dfn{current frame}. Some of the debugger commands
266operate on the current frame. 267operate on the current frame.
267 268
268 The debugger itself must be run byte-compiled, since it makes 269 The debugger itself must be run byte-compiled, since it makes
@@ -342,10 +343,12 @@ to quit, and not debug, use the @kbd{q} command.
342Return a value from the debugger. The value is computed by reading an 343Return a value from the debugger. The value is computed by reading an
343expression with the minibuffer and evaluating it. 344expression with the minibuffer and evaluating it.
344 345
345The @kbd{r} command makes a difference when the debugger was invoked due 346The @kbd{r} command is useful when the debugger was invoked due to exit
346to exit from a Lisp call frame (as requested with @kbd{b}); then the 347from a Lisp call frame (as requested with @kbd{b}); then the value
347value specified in the @kbd{r} command is used as the value of that 348specified in the @kbd{r} command is used as the value of that frame. It
348frame. 349is also useful if you call @code{debug} and use its return value.
350Otherwise, @kbd{r} has the same effect as @kbd{c}, and the specified
351return value does not matter.
349 352
350You can't use @kbd{r} when the debugger was entered due to an error. 353You can't use @kbd{r} when the debugger was entered due to an error.
351@end table 354@end table
@@ -369,7 +372,7 @@ whatever called @code{debug}. This is the only way the function
369 372
370If the first of the @var{debugger-args} passed to @code{debug} is 373If the first of the @var{debugger-args} passed to @code{debug} is
371@code{nil} (or if it is not one of the special values in the table 374@code{nil} (or if it is not one of the special values in the table
372below), then @code{debeg} displays the rest of its arguments at the the 375below), then @code{debug} displays the rest of its arguments at the the
373top of the @samp{*Backtrace*} buffer. This mechanism is used to display 376top of the @samp{*Backtrace*} buffer. This mechanism is used to display
374a message to the user. 377a message to the user.
375 378
@@ -447,8 +450,6 @@ under which @code{debug} is called.
447@end table 450@end table
448@end defun 451@end defun
449 452
450@need 5000
451
452@node Internals of Debugger 453@node Internals of Debugger
453@subsection Internals of the Debugger 454@subsection Internals of the Debugger
454 455
@@ -550,12 +551,12 @@ The @kbd{d} command in the debugger works by setting this variable.
550 551
551@defun backtrace-debug level flag 552@defun backtrace-debug level flag
552This function sets the debug-on-exit flag of the stack frame @var{level} 553This function sets the debug-on-exit flag of the stack frame @var{level}
553levels, giving it the value @var{flag}. If @var{flag} is 554levels down the stack, giving it the value @var{flag}. If @var{flag} is
554non-@code{nil}, this will cause the debugger to be entered when that 555non-@code{nil}, this will cause the debugger to be entered when that
555frame later exits. Even a nonlocal exit through that frame will enter 556frame later exits. Even a nonlocal exit through that frame will enter
556the debugger. 557the debugger.
557 558
558Normally, this function is only called by the debugger. 559This function is used only by the debugger.
559@end defun 560@end defun
560 561
561@defvar command-debug-status 562@defvar command-debug-status
@@ -564,9 +565,9 @@ command. Each time a command is called interactively, this variable is
564bound to @code{nil}. The debugger can set this variable to leave 565bound to @code{nil}. The debugger can set this variable to leave
565information for future debugger invocations during the same command. 566information for future debugger invocations during the same command.
566 567
567The advantage of using this variable rather that defining another global 568The advantage, for the debugger, of using this variable rather than
568variable is that the data will never carry over to a subsequent command 569another global variable is that the data will never carry over to a
569invocation. 570subsequent command invocation.
570@end defvar 571@end defvar
571 572
572@defun backtrace-frame frame-number 573@defun backtrace-frame frame-number
@@ -581,12 +582,12 @@ If that frame has evaluated its arguments and called its function
581already, the value is @code{(t @var{function} 582already, the value is @code{(t @var{function}
582@var{arg-values}@dots{})}. 583@var{arg-values}@dots{})}.
583 584
584In the return value, @var{function} is whatever was supplied as @sc{car} 585In the return value, @var{function} is whatever was supplied as the
585of evaluated list, or a @code{lambda} expression in the case of a macro 586@sc{car} of the evaluated list, or a @code{lambda} expression in the
586call. If the function has a @code{&rest} argument, that is represented 587case of a macro call. If the function has a @code{&rest} argument, that
587as the tail of the list @var{arg-values}. 588is represented as the tail of the list @var{arg-values}.
588 589
589If the argument is out of range, @code{backtrace-frame} returns 590If @var{frame-number} is out of range, @code{backtrace-frame} returns
590@code{nil}. 591@code{nil}.
591@end defun 592@end defun
592 593
@@ -643,8 +644,8 @@ Usually all the lines from a certain point to the end of the function
643will shift to the right. There is probably a missing close parenthesis, 644will shift to the right. There is probably a missing close parenthesis,
644or a superfluous open parenthesis, near that point. (However, don't 645or a superfluous open parenthesis, near that point. (However, don't
645assume this is true; study the code to make sure.) Once you have found 646assume this is true; study the code to make sure.) Once you have found
646the discrepancy, undo the @kbd{C-M-q}, since the old indentation is 647the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the old
647probably appropriate to the intended parentheses. 648indentation is probably appropriate to the intended parentheses.
648 649
649 After you think you have fixed the problem, use @kbd{C-M-q} again. If 650 After you think you have fixed the problem, use @kbd{C-M-q} again. If
650the old indentation actually fit the intended nesting of parentheses, 651the old indentation actually fit the intended nesting of parentheses,
@@ -654,11 +655,11 @@ anything.
654@node Excess Close 655@node Excess Close
655@subsection Excess Close Parentheses 656@subsection Excess Close Parentheses
656 657
657 To deal with an excess close parenthesis, first insert an 658 To deal with an excess close parenthesis, first insert an open
658open parenthesis at the beginning of the file and type @kbd{C-M-f} to 659parenthesis at the beginning of the file, back up over it, and type
659find the end of the unbalanced defun. (Then type @kbd{C-@key{SPC} C-_ 660@kbd{C-M-f} to find the end of the unbalanced defun. (Then type
660C-u C-@key{SPC}} to set the mark there, undo the insertion of the 661@kbd{C-@key{SPC} C-_ C-u C-@key{SPC}} to set the mark there, undo the
661open parenthesis, and finally return to the mark.) 662insertion of the open parenthesis, and finally return to the mark.)
662 663
663 Then find the actual matching close parenthesis by typing @kbd{C-M-f} 664 Then find the actual matching close parenthesis by typing @kbd{C-M-f}
664at the beginning of the defun. This will leave you somewhere short of 665at the beginning of the defun. This will leave you somewhere short of
@@ -670,10 +671,15 @@ type @kbd{C-M-q} at the beginning of the defun. A range of lines will
670probably shift left; if so, the missing open parenthesis or spurious 671probably shift left; if so, the missing open parenthesis or spurious
671close parenthesis is probably near the first of those lines. (However, 672close parenthesis is probably near the first of those lines. (However,
672don't assume this is true; study the code to make sure.) Once you have 673don't assume this is true; study the code to make sure.) Once you have
673found the discrepancy, undo the @kbd{C-M-q}, since the old indentation 674found the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the
674is probably appropriate to the intended parentheses. 675old indentation is probably appropriate to the intended parentheses.
676
677 After you think you have fixed the problem, use @kbd{C-M-q} again. If
678the old indentation actually fit the intended nesting of parentheses,
679and you have put back those parentheses, @kbd{C-M-q} should not change
680anything.
675 681
676@node Compilation Errors 682@node Compilation Errors, Edebug, Syntax Errors, Debugging
677@section Debugging Problems in Compilation 683@section Debugging Problems in Compilation
678 684
679 When an error happens during byte compilation, it is normally due to 685 When an error happens during byte compilation, it is normally due to
@@ -695,7 +701,7 @@ the error.
695 701
696 If the error was detected while compiling a form that had been read 702 If the error was detected while compiling a form that had been read
697successfully, then point is located at the end of the form. In this 703successfully, then point is located at the end of the form. In this
698case, it can't localize the error precisely, but can still show you 704case, this technique can't localize the error precisely, but can still
699which function to check. 705show you which function to check.
700 706
701@include edebug.texi 707@include edebug.texi