diff options
| author | Richard M. Stallman | 1994-04-30 02:19:25 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-04-30 02:19:25 +0000 |
| commit | ae4a385754aa0ab07c9aad929fc87c49c9c07cc6 (patch) | |
| tree | fbc0402f6e2dce0da1e1732d09ca165f637bc9d5 /lispref/debugging.texi | |
| parent | b5b911f995d9c92df4a7518bd7b06504889d82ed (diff) | |
| download | emacs-ae4a385754aa0ab07c9aad929fc87c49c9c07cc6.tar.gz emacs-ae4a385754aa0ab07c9aad929fc87c49c9c07cc6.zip | |
*** empty log message ***
Diffstat (limited to 'lispref/debugging.texi')
| -rw-r--r-- | lispref/debugging.texi | 102 |
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 | |||
| 81 | debugger, set the variable @code{debug-on-error} to non-@code{nil}. | 81 | debugger, set the variable @code{debug-on-error} to non-@code{nil}. |
| 82 | 82 | ||
| 83 | @defopt debug-on-error | 83 | @defopt debug-on-error |
| 84 | This variable determines whether the debugger is called when a error is | 84 | This variable determines whether the debugger is called when an error is |
| 85 | signaled and not handled. If @code{debug-on-error} is @code{t}, all | 85 | signaled and not handled. If @code{debug-on-error} is @code{t}, all |
| 86 | errors call the debugger. If it is @code{nil}, none call the debugger. | 86 | errors 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} |
| 95 | file, use the option @samp{-debug-init}, which binds | 95 | file, 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 |
| 97 | inhibits 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 |
| 99 | lasts only until the end of loading @file{.emacs}. (This is an | 100 | not last past the end of loading @file{.emacs}. (This is an undesirable |
| 100 | undesirable by-product of the @samp{-debug-init} feature.) If you want | 101 | byproduct of the code that implements the @samp{-debug-init} command |
| 101 | @file{.emacs} to set @code{debug-on-error} permanently, use | 102 | line 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 |
| 104 | this: | ||
| 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. | |||
| 121 | looping. To get more information, you can set the variable | 123 | looping. 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 |
| 123 | considered an error, and @code{debug-on-error} has no effect on the | 125 | considered an error, and @code{debug-on-error} has no effect on the |
| 124 | handling of @kbd{C-g}. Contrariwise, @code{debug-on-quit} has no effect | 126 | handling of @kbd{C-g}. Likewise, @code{debug-on-quit} has no effect on |
| 125 | on errors.@refill | 127 | errors. |
| 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, |
| 128 | you can proceed from the debugger using the stepping commands. If you | 130 | you 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 |
| 232 | additional form can be evaluated and its value ignored. (If the value | 233 | additional form can be evaluated and its value ignored. (If the value |
| 233 | isn't ignored, it will alter the execution of the program!) The most | 234 | of @code{(debug)} isn't ignored, it will alter the execution of the |
| 234 | common suitable places are inside a @code{progn} or an implicit | 235 | program!) The most common suitable places are inside a @code{progn} or |
| 235 | @code{progn} (@pxref{Sequencing}). | 236 | an 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 | |||
| 257 | buffer. | 258 | buffer. |
| 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 |
| 261 | executing and their argument values. It also allows you to specify a | 262 | their argument values. It also allows you to specify a stack frame by |
| 262 | stack frame by moving point to the line describing that frame. (A stack | 263 | moving point to the line describing that frame. (A stack frame is the |
| 263 | frame is the place where the Lisp interpreter records information about | 264 | place where the Lisp interpreter records information about a particular |
| 264 | a particular invocation of a function.) The frame whose line point is | 265 | invocation of a function.) The frame whose line point is on is |
| 265 | on is considered the @dfn{current frame}. Some of the debugger commands | 266 | considered the @dfn{current frame}. Some of the debugger commands |
| 266 | operate on the current frame. | 267 | operate 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. | |||
| 342 | Return a value from the debugger. The value is computed by reading an | 343 | Return a value from the debugger. The value is computed by reading an |
| 343 | expression with the minibuffer and evaluating it. | 344 | expression with the minibuffer and evaluating it. |
| 344 | 345 | ||
| 345 | The @kbd{r} command makes a difference when the debugger was invoked due | 346 | The @kbd{r} command is useful when the debugger was invoked due to exit |
| 346 | to exit from a Lisp call frame (as requested with @kbd{b}); then the | 347 | from a Lisp call frame (as requested with @kbd{b}); then the value |
| 347 | value specified in the @kbd{r} command is used as the value of that | 348 | specified in the @kbd{r} command is used as the value of that frame. It |
| 348 | frame. | 349 | is also useful if you call @code{debug} and use its return value. |
| 350 | Otherwise, @kbd{r} has the same effect as @kbd{c}, and the specified | ||
| 351 | return value does not matter. | ||
| 349 | 352 | ||
| 350 | You can't use @kbd{r} when the debugger was entered due to an error. | 353 | You 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 | ||
| 370 | If the first of the @var{debugger-args} passed to @code{debug} is | 373 | If 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 |
| 372 | below), then @code{debeg} displays the rest of its arguments at the the | 375 | below), then @code{debug} displays the rest of its arguments at the the |
| 373 | top of the @samp{*Backtrace*} buffer. This mechanism is used to display | 376 | top of the @samp{*Backtrace*} buffer. This mechanism is used to display |
| 374 | a message to the user. | 377 | a 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 |
| 552 | This function sets the debug-on-exit flag of the stack frame @var{level} | 553 | This function sets the debug-on-exit flag of the stack frame @var{level} |
| 553 | levels, giving it the value @var{flag}. If @var{flag} is | 554 | levels down the stack, giving it the value @var{flag}. If @var{flag} is |
| 554 | non-@code{nil}, this will cause the debugger to be entered when that | 555 | non-@code{nil}, this will cause the debugger to be entered when that |
| 555 | frame later exits. Even a nonlocal exit through that frame will enter | 556 | frame later exits. Even a nonlocal exit through that frame will enter |
| 556 | the debugger. | 557 | the debugger. |
| 557 | 558 | ||
| 558 | Normally, this function is only called by the debugger. | 559 | This 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 | |||
| 564 | bound to @code{nil}. The debugger can set this variable to leave | 565 | bound to @code{nil}. The debugger can set this variable to leave |
| 565 | information for future debugger invocations during the same command. | 566 | information for future debugger invocations during the same command. |
| 566 | 567 | ||
| 567 | The advantage of using this variable rather that defining another global | 568 | The advantage, for the debugger, of using this variable rather than |
| 568 | variable is that the data will never carry over to a subsequent command | 569 | another global variable is that the data will never carry over to a |
| 569 | invocation. | 570 | subsequent 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 | |||
| 581 | already, the value is @code{(t @var{function} | 582 | already, the value is @code{(t @var{function} |
| 582 | @var{arg-values}@dots{})}. | 583 | @var{arg-values}@dots{})}. |
| 583 | 584 | ||
| 584 | In the return value, @var{function} is whatever was supplied as @sc{car} | 585 | In the return value, @var{function} is whatever was supplied as the |
| 585 | of 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 |
| 586 | call. If the function has a @code{&rest} argument, that is represented | 587 | case of a macro call. If the function has a @code{&rest} argument, that |
| 587 | as the tail of the list @var{arg-values}. | 588 | is represented as the tail of the list @var{arg-values}. |
| 588 | 589 | ||
| 589 | If the argument is out of range, @code{backtrace-frame} returns | 590 | If @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 | |||
| 643 | will shift to the right. There is probably a missing close parenthesis, | 644 | will shift to the right. There is probably a missing close parenthesis, |
| 644 | or a superfluous open parenthesis, near that point. (However, don't | 645 | or a superfluous open parenthesis, near that point. (However, don't |
| 645 | assume this is true; study the code to make sure.) Once you have found | 646 | assume this is true; study the code to make sure.) Once you have found |
| 646 | the discrepancy, undo the @kbd{C-M-q}, since the old indentation is | 647 | the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the old |
| 647 | probably appropriate to the intended parentheses. | 648 | indentation 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 |
| 650 | the old indentation actually fit the intended nesting of parentheses, | 651 | the 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 |
| 658 | open parenthesis at the beginning of the file and type @kbd{C-M-f} to | 659 | parenthesis at the beginning of the file, back up over it, and type |
| 659 | find 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 |
| 660 | C-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 |
| 661 | open parenthesis, and finally return to the mark.) | 662 | insertion 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} |
| 664 | at the beginning of the defun. This will leave you somewhere short of | 665 | at 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 | |||
| 670 | probably shift left; if so, the missing open parenthesis or spurious | 671 | probably shift left; if so, the missing open parenthesis or spurious |
| 671 | close parenthesis is probably near the first of those lines. (However, | 672 | close parenthesis is probably near the first of those lines. (However, |
| 672 | don't assume this is true; study the code to make sure.) Once you have | 673 | don't assume this is true; study the code to make sure.) Once you have |
| 673 | found the discrepancy, undo the @kbd{C-M-q}, since the old indentation | 674 | found the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the |
| 674 | is probably appropriate to the intended parentheses. | 675 | old 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 | ||
| 678 | the old indentation actually fit the intended nesting of parentheses, | ||
| 679 | and you have put back those parentheses, @kbd{C-M-q} should not change | ||
| 680 | anything. | ||
| 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 |
| 697 | successfully, then point is located at the end of the form. In this | 703 | successfully, then point is located at the end of the form. In this |
| 698 | case, it can't localize the error precisely, but can still show you | 704 | case, this technique can't localize the error precisely, but can still |
| 699 | which function to check. | 705 | show you which function to check. |
| 700 | 706 | ||
| 701 | @include edebug.texi | 707 | @include edebug.texi |