diff options
| author | Gemini Lasswell | 2018-08-03 10:28:28 -0700 |
|---|---|---|
| committer | Gemini Lasswell | 2018-08-03 10:28:28 -0700 |
| commit | da0054c30729e58259c1e7251cb03c8ef13ff943 (patch) | |
| tree | f3fd4b5256aa6c6786d0ac4f80fb1d87dcc2e401 /doc | |
| parent | e65ec81fc3e556719fae8d8b4b42f571c7e9f4fc (diff) | |
| parent | 95b2ab3dccdc756614b4c8f45a7b206d61753705 (diff) | |
| download | emacs-da0054c30729e58259c1e7251cb03c8ef13ff943.tar.gz emacs-da0054c30729e58259c1e7251cb03c8ef13ff943.zip | |
Merge branch 'scratch/backtrace-mode'
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/debugging.texi | 115 | ||||
| -rw-r--r-- | doc/lispref/edebug.texi | 12 | ||||
| -rw-r--r-- | doc/misc/ert.texi | 8 |
3 files changed, 99 insertions, 36 deletions
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index 1b1f87465db..9b3ba6cf7ee 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi | |||
| @@ -81,7 +81,8 @@ debugger recursively. @xref{Recursive Editing}. | |||
| 81 | * Function Debugging:: Entering it when a certain function is called. | 81 | * Function Debugging:: Entering it when a certain function is called. |
| 82 | * Variable Debugging:: Entering it when a variable is modified. | 82 | * Variable Debugging:: Entering it when a variable is modified. |
| 83 | * Explicit Debug:: Entering it at a certain point in the program. | 83 | * Explicit Debug:: Entering it at a certain point in the program. |
| 84 | * Using Debugger:: What the debugger does; what you see while in it. | 84 | * Using Debugger:: What the debugger does. |
| 85 | * Backtraces:: What you see while in the debugger. | ||
| 85 | * Debugger Commands:: Commands used while in the debugger. | 86 | * Debugger Commands:: Commands used while in the debugger. |
| 86 | * Invoking the Debugger:: How to call the function @code{debug}. | 87 | * Invoking the Debugger:: How to call the function @code{debug}. |
| 87 | * Internals of Debugger:: Subroutines of the debugger, and global variables. | 88 | * Internals of Debugger:: Subroutines of the debugger, and global variables. |
| @@ -392,32 +393,82 @@ this is not what you want, you can either set | |||
| 392 | @code{eval-expression-debug-on-error} to @code{nil}, or set | 393 | @code{eval-expression-debug-on-error} to @code{nil}, or set |
| 393 | @code{debug-on-error} to @code{nil} in @code{debugger-mode-hook}. | 394 | @code{debug-on-error} to @code{nil} in @code{debugger-mode-hook}. |
| 394 | 395 | ||
| 396 | The debugger itself must be run byte-compiled, since it makes | ||
| 397 | assumptions about the state of the Lisp interpreter. These | ||
| 398 | assumptions are false if the debugger is running interpreted. | ||
| 399 | |||
| 400 | @node Backtraces | ||
| 401 | @subsection Backtraces | ||
| 402 | @cindex backtrace buffer | ||
| 403 | |||
| 404 | Debugger mode is derived from Backtrace mode, which is also used to | ||
| 405 | show backtraces by Edebug and ERT. (@pxref{Edebug}, and @ref{Top,the | ||
| 406 | ERT manual,, ert, ERT: Emacs Lisp Regression Testing}.) | ||
| 407 | |||
| 408 | @cindex stack frame | ||
| 409 | The backtrace buffer shows you the functions that are executing and | ||
| 410 | their argument values. When a backtrace buffer is created, it shows | ||
| 411 | each stack frame on one, possibly very long, line. (A stack frame is | ||
| 412 | the place where the Lisp interpreter records information about a | ||
| 413 | particular invocation of a function.) The most recently called | ||
| 414 | function will be at the top. | ||
| 415 | |||
| 395 | @cindex current stack frame | 416 | @cindex current stack frame |
| 396 | The backtrace buffer shows you the functions that are executing and | 417 | In a backtrace you can specify a stack frame by moving point to a line |
| 397 | their argument values. It also allows you to specify a stack frame by | 418 | describing that frame. The frame whose line point is on is considered |
| 398 | moving point to the line describing that frame. (A stack frame is the | 419 | the @dfn{current frame}. |
| 399 | place where the Lisp interpreter records information about a particular | 420 | |
| 400 | invocation of a function.) The frame whose line point is on is | 421 | If a function name is underlined, that means Emacs knows where its |
| 401 | considered the @dfn{current frame}. Some of the debugger commands | 422 | source code is located. You can click with the mouse on that name, or |
| 402 | operate on the current frame. If a line starts with a star, that means | 423 | move to it and type @key{RET}, to visit the source code. You can also |
| 403 | that exiting that frame will call the debugger again. This is useful | 424 | type @key{RET} while point is on any name of a function or variable |
| 404 | for examining the return value of a function. | 425 | which is not underlined, to see help information for that symbol in a |
| 405 | 426 | help buffer, if any exists. The @code{xref-find-definitions} command, | |
| 406 | If a function name is underlined, that means the debugger knows | 427 | bound to @key{M-.}, can also be used on any identifier in a backtrace |
| 407 | where its source code is located. You can click with the mouse on | 428 | (@pxref{Looking Up Identifiers,,,emacs, The GNU Emacs Manual}). |
| 408 | that name, or move to it and type @key{RET}, to visit the source code. | 429 | |
| 430 | In backtraces, the tails of long lists and the ends of long strings, | ||
| 431 | vectors or structures, as well as objects which are deeply nested, | ||
| 432 | will be printed as underlined ``...''. You can click with the mouse | ||
| 433 | on a ``...'', or type @key{RET} while point is on it, to show the part | ||
| 434 | of the object that was hidden. To control how much abbreviation is | ||
| 435 | done, customize @code{backtrace-line-length}. | ||
| 436 | |||
| 437 | Here is a list of commands for navigating and viewing backtraces: | ||
| 409 | 438 | ||
| 410 | The debugger itself must be run byte-compiled, since it makes | 439 | @table @kbd |
| 411 | assumptions about how many stack frames are used for the debugger | 440 | @item v |
| 412 | itself. These assumptions are false if the debugger is running | 441 | Toggle the display of local variables of the current stack frame. |
| 413 | interpreted. | 442 | |
| 443 | @item p | ||
| 444 | Move to the beginning of the frame, or to the beginning | ||
| 445 | of the previous frame. | ||
| 446 | |||
| 447 | @item n | ||
| 448 | Move to the beginning of the next frame. | ||
| 449 | |||
| 450 | @item + | ||
| 451 | Add line breaks and indentation to the top-level Lisp form at point to | ||
| 452 | make it more readable. | ||
| 453 | |||
| 454 | @item - | ||
| 455 | Collapse the top-level Lisp form at point back to a single line. | ||
| 456 | |||
| 457 | @item # | ||
| 458 | Toggle @code{print-circle} for the frame at point. | ||
| 459 | |||
| 460 | @item . | ||
| 461 | Expand all the forms abbreviated with ``...'' in the frame at point. | ||
| 462 | |||
| 463 | @end table | ||
| 414 | 464 | ||
| 415 | @node Debugger Commands | 465 | @node Debugger Commands |
| 416 | @subsection Debugger Commands | 466 | @subsection Debugger Commands |
| 417 | @cindex debugger command list | 467 | @cindex debugger command list |
| 418 | 468 | ||
| 419 | The debugger buffer (in Debugger mode) provides special commands in | 469 | The debugger buffer (in Debugger mode) provides special commands in |
| 420 | addition to the usual Emacs commands. The most important use of | 470 | addition to the usual Emacs commands and to the Backtrace mode commands |
| 471 | described in the previous section. The most important use of | ||
| 421 | debugger commands is for stepping through code, so that you can see | 472 | debugger commands is for stepping through code, so that you can see |
| 422 | how control flows. The debugger can step through the control | 473 | how control flows. The debugger can step through the control |
| 423 | structures of an interpreted function, but cannot do so in a | 474 | structures of an interpreted function, but cannot do so in a |
| @@ -427,6 +478,11 @@ the same function. (To do this, visit the source for the function and | |||
| 427 | type @kbd{C-M-x} on its definition.) You cannot use the Lisp debugger | 478 | type @kbd{C-M-x} on its definition.) You cannot use the Lisp debugger |
| 428 | to step through a primitive function. | 479 | to step through a primitive function. |
| 429 | 480 | ||
| 481 | Some of the debugger commands operate on the current frame. If a | ||
| 482 | frame starts with a star, that means that exiting that frame will call the | ||
| 483 | debugger again. This is useful for examining the return value of a | ||
| 484 | function. | ||
| 485 | |||
| 430 | @c FIXME: Add @findex for the following commands? --xfq | 486 | @c FIXME: Add @findex for the following commands? --xfq |
| 431 | Here is a list of Debugger mode commands: | 487 | Here is a list of Debugger mode commands: |
| 432 | 488 | ||
| @@ -502,8 +558,6 @@ Display a list of functions that will invoke the debugger when called. | |||
| 502 | This is a list of functions that are set to break on entry by means of | 558 | This is a list of functions that are set to break on entry by means of |
| 503 | @code{debug-on-entry}. | 559 | @code{debug-on-entry}. |
| 504 | 560 | ||
| 505 | @item v | ||
| 506 | Toggle the display of local variables of the current stack frame. | ||
| 507 | @end table | 561 | @end table |
| 508 | 562 | ||
| 509 | @node Invoking the Debugger | 563 | @node Invoking the Debugger |
| @@ -624,20 +678,19 @@ of @code{debug} (@pxref{Invoking the Debugger}). | |||
| 624 | @cindex run time stack | 678 | @cindex run time stack |
| 625 | @cindex call stack | 679 | @cindex call stack |
| 626 | This function prints a trace of Lisp function calls currently active. | 680 | This function prints a trace of Lisp function calls currently active. |
| 627 | This is the function used by @code{debug} to fill up the | 681 | The trace is identical to the one that @code{debug} would show in the |
| 628 | @file{*Backtrace*} buffer. It is written in C, since it must have access | 682 | @file{*Backtrace*} buffer. The return value is always nil. |
| 629 | to the stack to determine which function calls are active. The return | ||
| 630 | value is always @code{nil}. | ||
| 631 | 683 | ||
| 632 | In the following example, a Lisp expression calls @code{backtrace} | 684 | In the following example, a Lisp expression calls @code{backtrace} |
| 633 | explicitly. This prints the backtrace to the stream | 685 | explicitly. This prints the backtrace to the stream |
| 634 | @code{standard-output}, which, in this case, is the buffer | 686 | @code{standard-output}, which, in this case, is the buffer |
| 635 | @samp{backtrace-output}. | 687 | @samp{backtrace-output}. |
| 636 | 688 | ||
| 637 | Each line of the backtrace represents one function call. The line shows | 689 | Each line of the backtrace represents one function call. The line |
| 638 | the values of the function's arguments if they are all known; if they | 690 | shows the function followed by a list of the values of the function's |
| 639 | are still being computed, the line says so. The arguments of special | 691 | arguments if they are all known; if they are still being computed, the |
| 640 | forms are elided. | 692 | line consists of a list containing the function and its unevaluated |
| 693 | arguments. Long lists or deeply nested structures may be elided. | ||
| 641 | 694 | ||
| 642 | @smallexample | 695 | @smallexample |
| 643 | @group | 696 | @group |
| @@ -654,7 +707,7 @@ forms are elided. | |||
| 654 | @group | 707 | @group |
| 655 | ----------- Buffer: backtrace-output ------------ | 708 | ----------- Buffer: backtrace-output ------------ |
| 656 | backtrace() | 709 | backtrace() |
| 657 | (list ...computing arguments...) | 710 | (list 'testing (backtrace)) |
| 658 | @end group | 711 | @end group |
| 659 | (progn ...) | 712 | (progn ...) |
| 660 | eval((progn (1+ var) (list 'testing (backtrace)))) | 713 | eval((progn (1+ var) (list 'testing (backtrace)))) |
| @@ -685,7 +738,7 @@ example would look as follows: | |||
| 685 | @group | 738 | @group |
| 686 | ----------- Buffer: backtrace-output ------------ | 739 | ----------- Buffer: backtrace-output ------------ |
| 687 | (backtrace) | 740 | (backtrace) |
| 688 | (list ...computing arguments...) | 741 | (list 'testing (backtrace)) |
| 689 | @end group | 742 | @end group |
| 690 | (progn ...) | 743 | (progn ...) |
| 691 | (eval (progn (1+ var) (list 'testing (backtrace)))) | 744 | (eval (progn (1+ var) (list 'testing (backtrace)))) |
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi index b9cc1d5afc2..54200b99903 100644 --- a/doc/lispref/edebug.texi +++ b/doc/lispref/edebug.texi | |||
| @@ -442,8 +442,16 @@ Redisplay the most recently known expression result in the echo area | |||
| 442 | Display a backtrace, excluding Edebug's own functions for clarity | 442 | Display a backtrace, excluding Edebug's own functions for clarity |
| 443 | (@code{edebug-backtrace}). | 443 | (@code{edebug-backtrace}). |
| 444 | 444 | ||
| 445 | You cannot use debugger commands in the backtrace buffer in Edebug as | 445 | @xref{Backtraces}, for a description of backtraces |
| 446 | you would in the standard debugger. | 446 | and the commands which work on them. |
| 447 | |||
| 448 | If you would like to see Edebug's functions in the backtrace, | ||
| 449 | use @kbd{M-x edebug-backtrace-show-instrumentation}. To hide them | ||
| 450 | again use @kbd{M-x edebug-backtrace-hide-instrumentation}. | ||
| 451 | |||
| 452 | If a backtrace frame starts with @samp{>} that means that Edebug knows | ||
| 453 | where the source code for the frame is located. Use @kbd{s} to jump | ||
| 454 | to the source code for the current frame. | ||
| 447 | 455 | ||
| 448 | The backtrace buffer is killed automatically when you continue | 456 | The backtrace buffer is killed automatically when you continue |
| 449 | execution. | 457 | execution. |
diff --git a/doc/misc/ert.texi b/doc/misc/ert.texi index 82e0e27ed1c..6a34f5c5722 100644 --- a/doc/misc/ert.texi +++ b/doc/misc/ert.texi | |||
| @@ -273,9 +273,11 @@ moving point to it and typing @kbd{@key{RET}} jumps to its definition. | |||
| 273 | @cindex backtrace of a failed test | 273 | @cindex backtrace of a failed test |
| 274 | Pressing @kbd{r} re-runs the test near point on its own. Pressing | 274 | Pressing @kbd{r} re-runs the test near point on its own. Pressing |
| 275 | @kbd{d} re-runs it with the debugger enabled. @kbd{.} jumps to the | 275 | @kbd{d} re-runs it with the debugger enabled. @kbd{.} jumps to the |
| 276 | definition of the test near point (@kbd{@key{RET}} has the same effect if | 276 | definition of the test near point (@kbd{@key{RET}} has the same effect |
| 277 | point is on the name of the test). On a failed test, @kbd{b} shows | 277 | if point is on the name of the test). On a failed test, @kbd{b} shows |
| 278 | the backtrace of the failure. | 278 | the backtrace of the failure. @xref{Debugging,, Backtraces, elisp, |
| 279 | GNU Emacs Lisp Reference Manual}, for more information about | ||
| 280 | backtraces. | ||
| 279 | 281 | ||
| 280 | @kindex l@r{, in ert results buffer} | 282 | @kindex l@r{, in ert results buffer} |
| 281 | @kbd{l} shows the list of @code{should} forms executed in the test. | 283 | @kbd{l} shows the list of @code{should} forms executed in the test. |