diff lispref/debugging.texi @ 22138:d4ac295a98b3

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Tue, 19 May 1998 03:45:57 +0000
parents 90da2489c498
children 40089afa2b1d
line wrap: on
line diff
--- a/lispref/debugging.texi	Tue May 19 03:41:25 1998 +0000
+++ b/lispref/debugging.texi	Tue May 19 03:45:57 1998 +0000
@@ -3,7 +3,7 @@
 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998 Free Software Foundation, Inc. 
 @c See the file elisp.texi for copying conditions.
 @setfilename ../info/debugging
-@node Debugging, Read and Print, Advising, Top
+@node Debugging, Read and Print, Advising Functions, Top
 @chapter Debugging Lisp Programs
 
   There are three ways to investigate a problem in an Emacs Lisp program,
@@ -12,8 +12,9 @@
 @itemize @bullet
 @item
 If the problem occurs when you run the program, you can use a Lisp
-debugger (either the default debugger or Edebug) to investigate what is
-happening during execution.
+debugger to investigate what is happening during execution.  In addition
+to the ordinary debugger, Emacs comes with a source level debugger,
+Edebug.  This chapter describes both of them.
 
 @item
 If the problem is syntactic, so that Lisp cannot even read the program,
@@ -26,9 +27,9 @@
 
 @menu
 * Debugger::            How the Emacs Lisp debugger is implemented.
+* Edebug::		A source-level Emacs Lisp debugger.
 * Syntax Errors::       How to find syntax errors.
 * Compilation Errors::  How to find errors that show up in byte compilation.
-* Edebug::		A source-level Emacs Lisp debugger.
 @end menu
 
   Another useful debugging tool is the dribble file.  When a dribble
@@ -45,13 +46,13 @@
 @cindex Lisp debugger
 @cindex break
 
-  The @dfn{Lisp debugger} provides the ability to suspend evaluation of
-a form.  While evaluation is suspended (a state that is commonly known
-as a @dfn{break}), you may examine the run time stack, examine the
-values of local or global variables, or change those values.  Since a
-break is a recursive edit, all the usual editing facilities of Emacs are
-available; you can even run programs that will enter the debugger
-recursively.  @xref{Recursive Editing}.
+  The ordinary @dfn{Lisp debugger} provides the ability to suspend
+evaluation of a form.  While evaluation is suspended (a state that is
+commonly known as a @dfn{break}), you may examine the run time stack,
+examine the values of local or global variables, or change those values.
+Since a break is a recursive edit, all the usual editing facilities of
+Emacs are available; you can even run programs that will enter the
+debugger recursively.  @xref{Recursive Editing}.
 
 @menu
 * Error Debugging::       Entering the debugger when an error happens.
@@ -74,25 +75,28 @@
 error.
 
   However, entry to the debugger is not a normal consequence of an
-error.  Many commands frequently get Lisp errors when invoked in
-inappropriate contexts (such as @kbd{C-f} at the end of the buffer) and
-during ordinary editing it would be very unpleasant to enter the
-debugger each time this happens.  If you want errors to enter the
-debugger, set the variable @code{debug-on-error} to non-@code{nil}.
+error.  Many commands frequently cause Lisp errors when invoked
+inappropriately (such as @kbd{C-f} at the end of the buffer), and during
+ordinary editing it would be very inconvenient to enter the debugger
+each time this happens.  So if you want errors to enter the debugger, set
+the variable @code{debug-on-error} to non-@code{nil}.  (The command
+@code{toggle-debug-on-error} provides an easy way to do this.)
 
 @defopt debug-on-error
 This variable determines whether the debugger is called when an error is
 signaled and not handled.  If @code{debug-on-error} is @code{t}, all
-errors call the debugger.  If it is @code{nil}, none call the debugger.
+kinds of errors call the debugger (except those listed in
+@code{debug-ignored-errors}).  If it is @code{nil}, none call the
+debugger.
 
 The value can also be a list of error conditions that should call the
 debugger.  For example, if you set it to the list
 @code{(void-variable)}, then only errors about a variable that has no
 value invoke the debugger.
 
-When this variable is non-@code{nil}, Emacs does not catch errors that
-happen in process filter functions and sentinels.  Therefore, these
-errors also can invoke the debugger.  @xref{Processes}.
+When this variable is non-@code{nil}, Emacs does not create an error
+handler around process filter functions and sentinels.  Therefore,
+errors in these functions also invoke the debugger.  @xref{Processes}.
 @end defopt
 
 @defopt debug-ignored-errors
@@ -117,10 +121,10 @@
 words, @code{condition-case} gets a chance to handle the error before
 the debugger gets a chance.
 
-If you set @code{debug-on-signal} non-@code{nil}, then the debugger gets
-first chance at every error; an error will invoke the debugger
-regardless of any @code{condition-case}, if the fits the criterion
-specified by the values of @code{debug-on-error} and
+If you set @code{debug-on-signal} to a non-@code{nil} value, then the
+debugger gets the first chance at every error; an error will invoke the
+debugger regardless of any @code{condition-case}, if it fits the
+criterion specified by the values of @code{debug-on-error} and
 @code{debug-ignored-errors}.
 
 @strong{Warning:} This variable is strong medicine!  Various parts of
@@ -134,13 +138,14 @@
 @end defopt
 
   To debug an error that happens during loading of the @file{.emacs}
-file, use the option @samp{-debug-init}, which binds
-@code{debug-on-error} to @code{t} while @file{.emacs} is loaded and
-inhibits use of @code{condition-case} to catch init-file errors.
+file, use the option @samp{--debug-init}, which binds
+@code{debug-on-error} to @code{t} while @file{.emacs} is loaded, and
+bypasses the @code{condition-case} which normally catches errors in the
+init-file.
 
   If your @file{.emacs} file sets @code{debug-on-error}, the effect may
 not last past the end of loading @file{.emacs}.  (This is an undesirable
-byproduct of the code that implements the @samp{-debug-init} command
+byproduct of the code that implements the @samp{--debug-init} command
 line option.)  The best way to make @file{.emacs} set
 @code{debug-on-error} permanently is with @code{after-init-hook}, like
 this:
@@ -269,8 +274,9 @@
   You can cause the debugger to be called at a certain point in your
 program by writing the expression @code{(debug)} at that point.  To do
 this, visit the source file, insert the text @samp{(debug)} at the
-proper place, and type @kbd{C-M-x}.  Be sure to undo this insertion
-before you save the file!
+proper place, and type @kbd{C-M-x}.  @strong{Warning:} if you do this
+for temporary debugging purposes, be sure to undo this insertion before
+you save the file!
 
   The place where you insert @samp{(debug)} must be a place where an
 additional form can be evaluated and its value ignored.  (If the value
@@ -339,8 +345,8 @@
 @item c
 Exit the debugger and continue execution.  When continuing is possible,
 it resumes execution of the program as if the debugger had never been
-entered (aside from the effect of any variables or data structures you
-may have changed while inside the debugger).
+entered (aside from any side-effects that you caused by changing
+variable values or data structures while inside the debugger).
 
 Continuing is possible after entry to the debugger due to function entry
 or exit, explicit invocation, or quitting.  You cannot continue if the
@@ -371,10 +377,10 @@
 Read a Lisp expression in the minibuffer, evaluate it, and print the
 value in the echo area.  The debugger alters certain important
 variables, and the current buffer, as part of its operation; @kbd{e}
-temporarily restores their outside-the-debugger values so you can
-examine them.  This makes the debugger more transparent.  By contrast,
-@kbd{M-:} does nothing special in the debugger; it shows you the
-variable values within the debugger.
+temporarily restores their values from outside the debugger, so you can
+examine and change them.  This makes the debugger more transparent.  By
+contrast, @kbd{M-:} does nothing special in the debugger; it shows you
+the variable values within the debugger.
 
 @item R
 Like @kbd{e}, but also save the result of evaluation in the
@@ -404,7 +410,8 @@
 @node Invoking the Debugger
 @subsection Invoking the Debugger
 
-  Here we describe fully the function used to invoke the debugger.
+  Here we describe in full detail the function @code{debug} that is used
+to invoke the debugger.
 
 @defun debug &rest debugger-args
 This function enters the debugger.  It switches buffers to a buffer
@@ -418,18 +425,15 @@
 whatever called @code{debug}.  This is the only way the function
 @code{debug} can return to its caller.
 
-If the first of the @var{debugger-args} passed to @code{debug} is
-@code{nil} (or if it is not one of the special values in the table
-below), then @code{debug} displays the rest of its arguments at the
-top of the @samp{*Backtrace*} buffer.  This mechanism is used to display
-a message to the user.
+The use of the @var{debugger-args} is that @code{debug} displays the
+rest of its arguments at the top of the @samp{*Backtrace*} buffer, so
+that the user can see them.  Except as described below, this is the
+@emph{only} way these arguments are used.
 
-However, if the first argument passed to @code{debug} is one of the
-following special values, then it has special significance.  Normally,
-these values are passed to @code{debug} only by the internals of Emacs
-and the debugger, and not by programmers calling @code{debug}.
-
-The special values are:
+However, certain values for first argument to @code{debug} have a
+special significance.  (Normally, these values are used only by the
+internals of Emacs, and not by programmers calling @code{debug}.)  Here
+is a table of these special values:
 
 @table @code
 @item lambda
@@ -640,6 +644,8 @@
 @code{nil}.
 @end defun
 
+@include edebug.texi
+
 @node Syntax Errors
 @section Debugging Invalid Lisp Syntax
 
@@ -658,7 +664,9 @@
 not, there is a problem in that defun.
 
   However, unmatched parentheses are the most common syntax errors in
-Lisp, and we can give further advice for those cases.
+Lisp, and we can give further advice for those cases.  (In addition,
+just moving point through the code with Show Paren mode enabled might
+find the mismatch.)
 
 @menu
 * Excess Open::     How to find a spurious open paren or missing close.
@@ -753,5 +761,3 @@
 successfully, then point is located at the end of the form.  In this
 case, this technique can't localize the error precisely, but can still
 show you which function to check.
-
-@include edebug.texi