diff options
| author | Lute Kamstra | 2005-03-01 08:41:52 +0000 |
|---|---|---|
| committer | Lute Kamstra | 2005-03-01 08:41:52 +0000 |
| commit | a1f74898ea7d3f89b4a8e4a3ea10d42246a3075f (patch) | |
| tree | 3878cec64642311e036ad8c311869a15233dadc2 /lispref/debugging.texi | |
| parent | 94230abb6aa17c539ccd85f2fd17e004ef80217e (diff) | |
| download | emacs-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.texi | 124 |
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 |
| 15 | If the problem occurs when you run the program, you can use a Lisp | 15 | If the problem occurs when you run the program, you can use a Lisp |
| 16 | debugger to investigate what is happening during execution. In addition | 16 | debugger to investigate what is happening during execution. In addition |
| 17 | to the ordinary debugger, Emacs comes with a source level debugger, | 17 | to the ordinary debugger, Emacs comes with a source-level debugger, |
| 18 | Edebug. This chapter describes both of them. | 18 | Edebug. 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 | ||
| 121 | If 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 | ||
| 123 | command @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 | ||
| 126 | Emacs-Lisp Expressions, emacs, The GNU Emacs Manual}. | ||
| 127 | @end defopt | ||
| 128 | |||
| 120 | @defopt debug-on-signal | 129 | @defopt debug-on-signal |
| 121 | Normally, errors that are caught by @code{condition-case} never run the | 130 | Normally, errors that are caught by @code{condition-case} never run the |
| 122 | debugger, even if @code{debug-on-error} is non-@code{nil}. In other | 131 | debugger, 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* ------ |
| 243 | Entering: | 252 | Debugger 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 | |||
| 317 | place where the Lisp interpreter records information about a particular | 324 | place where the Lisp interpreter records information about a particular |
| 318 | invocation of a function.) The frame whose line point is on is | 325 | invocation of a function.) The frame whose line point is on is |
| 319 | considered the @dfn{current frame}. Some of the debugger commands | 326 | considered the @dfn{current frame}. Some of the debugger commands |
| 320 | operate on the current frame. | 327 | operate on the current frame. If a line starts with a star, that means |
| 328 | that exiting that frame will call the debugger again. This is useful | ||
| 329 | for 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 |
| 323 | where its source code is located. You can click @kbd{Mouse-2} on that | 332 | where 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 | |||
| 328 | itself. These assumptions are false if the debugger is running | 337 | itself. These assumptions are false if the debugger is running |
| 329 | interpreted. | 338 | interpreted. |
| 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 | |||
| 378 | cancels a @kbd{b} command on that frame. The visible effect is to | 385 | cancels a @kbd{b} command on that frame. The visible effect is to |
| 379 | remove the star from the line in the backtrace buffer. | 386 | remove the star from the line in the backtrace buffer. |
| 380 | 387 | ||
| 388 | @item j | ||
| 389 | Flag the current frame like @kbd{b}. Then continue execution like | ||
| 390 | @kbd{c}, but temporarily disable break-on-entry for all functions that | ||
| 391 | are set up to do so by @code{debug-on-entry}. The temporarily disabled | ||
| 392 | functions are set up to debug on entry again when the debugger is | ||
| 393 | entered or when @code{debug-on-entry} is called; | ||
| 394 | @code{cancel-debug-on-entry} also re-enables these functions before it | ||
| 395 | disables any functions that its argument says it should disable. | ||
| 396 | |||
| 381 | @item e | 397 | @item e |
| 382 | Read a Lisp expression in the minibuffer, evaluate it, and print the | 398 | Read a Lisp expression in the minibuffer, evaluate it, and print the |
| 383 | value in the echo area. The debugger alters certain important | 399 | value 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 | |||
| 410 | effect as @kbd{c}, and the specified return value does not matter. | 426 | effect as @kbd{c}, and the specified return value does not matter. |
| 411 | 427 | ||
| 412 | You can't use @kbd{r} when the debugger was entered due to an error. | 428 | You can't use @kbd{r} when the debugger was entered due to an error. |
| 429 | |||
| 430 | @item l | ||
| 431 | Display a list of functions that will invoke the debugger when called. | ||
| 432 | This 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 | ||
| 434 | function and thus cancel the effect of @code{debug-on-entry}, it may | ||
| 435 | erroneously 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 | |||
| 425 | about the stack of Lisp function calls. It then enters a recursive | 448 | about the stack of Lisp function calls. It then enters a recursive |
| 426 | edit, showing the backtrace buffer in Debugger mode. | 449 | edit, showing the backtrace buffer in Debugger mode. |
| 427 | 450 | ||
| 428 | The Debugger mode @kbd{c} and @kbd{r} commands exit the recursive edit; | 451 | The Debugger mode @kbd{c}, @kbd{d}, @kbd{j}, and @kbd{r} commands exit |
| 429 | then @code{debug} switches back to the previous buffer and returns to | 452 | the recursive edit; then @code{debug} switches back to the previous |
| 430 | whatever called @code{debug}. This is the only way the function | 453 | buffer and returns to whatever called @code{debug}. This is the only |
| 431 | @code{debug} can return to its caller. | 454 | way the function @code{debug} can return to its caller. |
| 432 | 455 | ||
| 433 | The use of the @var{debugger-args} is that @code{debug} displays the | 456 | The use of the @var{debugger-args} is that @code{debug} displays the |
| 434 | rest of its arguments at the top of the @samp{*Backtrace*} buffer, so | 457 | rest 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 |
| 446 | A first argument of @code{lambda} means @code{debug} was called because | 469 | A first argument of @code{lambda} means @code{debug} was called |
| 447 | of entry to a function when @code{debug-on-next-call} was | 470 | because of entry to a function when @code{debug-on-next-call} was |
| 448 | non-@code{nil}. The debugger displays @samp{Entering:} as a line of | 471 | non-@code{nil}. The debugger displays @samp{Debugger |
| 449 | text at the top of the buffer. | 472 | entered--entering a function:} as a line of text at the top of the |
| 473 | buffer. | ||
| 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} |
| 453 | of entry to a function that was set to debug on entry. The debugger | 477 | because of entry to a function that was set to debug on entry. The |
| 454 | displays @samp{Entering:}, just as in the @code{lambda} case. It also | 478 | debugger displays @samp{Debugger entered--entering a function:}, just |
| 455 | marks the stack frame for that function so that it will invoke the | 479 | as in the @code{lambda} case. It also marks the stack frame for that |
| 456 | debugger when exited. | 480 | function so that it will invoke the debugger when exited. |
| 457 | 481 | ||
| 458 | @item t | 482 | @item t |
| 459 | When the first argument is @code{t}, this indicates a call to | 483 | When 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 |
| 462 | following as the top line in the buffer: | 486 | @samp{Debugger entered--beginning evaluation of function call form:} |
| 463 | 487 | as the top line in the buffer. | |
| 464 | @smallexample | ||
| 465 | Beginning evaluation of function call form: | ||
| 466 | @end smallexample | ||
| 467 | 488 | ||
| 468 | @item exit | 489 | @item exit |
| 469 | When the first argument is @code{exit}, it indicates the exit of a stack | 490 | When the first argument is @code{exit}, it indicates the exit of a |
| 470 | frame previously marked to invoke the debugger on exit. The second | 491 | stack frame previously marked to invoke the debugger on exit. The |
| 471 | argument given to @code{debug} in this case is the value being returned | 492 | second argument given to @code{debug} in this case is the value being |
| 472 | from the frame. The debugger displays @samp{Return value:} in the top | 493 | returned from the frame. The debugger displays @samp{Debugger |
| 473 | line of the buffer, followed by the value being returned. | 494 | entered--returning value:} in the top line of the buffer, followed by |
| 495 | the value being returned. | ||
| 474 | 496 | ||
| 475 | @item error | 497 | @item error |
| 476 | @cindex @code{error} in debug | 498 | @cindex @code{error} in debug |
| 477 | When the first argument is @code{error}, the debugger indicates that | 499 | When the first argument is @code{error}, the debugger indicates that |
| 478 | it is being entered because an error or @code{quit} was signaled and not | 500 | it is being entered because an error or @code{quit} was signaled and |
| 479 | handled, by displaying @samp{Signaling:} followed by the error signaled | 501 | not handled, by displaying @samp{Debugger entered--Lisp error:} |
| 480 | and any arguments to @code{signal}. For example, | 502 | followed by the error signaled and any arguments to @code{signal}. |
| 503 | For 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* ------ |
| 490 | Signaling: (arith-error) | 513 | Debugger 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 | ||
| 523 | The first argument that Lisp hands to the function indicates why it | 546 | The first argument that Lisp hands to the function indicates why it |
| 524 | was called. The convention for arguments is detailed in the description | 547 | was called. The convention for arguments is detailed in the description |
| 525 | of @code{debug}. | 548 | of @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 | |||
| 579 | The character @samp{*} indicates a frame whose debug-on-exit flag is | ||
| 580 | set. | ||
| 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 |
| 689 | an excess open parenthesis, the way to do this is to go to the end of | 709 | an excess open parenthesis, the way to do this is to go to the end of |
| 690 | the file and type @kbd{C-u C-M-u}. This will move you to the beginning | 710 | the file and type @kbd{C-u C-M-u}. This will move you to the |
| 691 | of the defun that is unbalanced. | 711 | beginning 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 |
| 694 | way to be sure of this except by studying the program, but often the | 714 | way 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 |
| 723 | the file, then type @kbd{C-u -1 C-M-u} to find the end of the unbalanced | 743 | of the file, then type @kbd{C-u -1 C-M-u} to find the end of the first |
| 724 | defun. | 744 | unbalanced 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} |
| 727 | at the beginning of that defun. This will leave you somewhere short of | 747 | at the beginning of that defun. This will leave you somewhere short of |