aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/debugging.texi
diff options
context:
space:
mode:
authorRichard M. Stallman1998-04-20 17:43:57 +0000
committerRichard M. Stallman1998-04-20 17:43:57 +0000
commit969fe9b5696c9d9d31f2faf1ca2e8af107013dcb (patch)
tree5d7d0399caf410b5c4849aa9d43352b18f68d4c9 /lispref/debugging.texi
parentb933f645ac70a31659f364cabf7da730d27eb244 (diff)
downloademacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.tar.gz
emacs-969fe9b5696c9d9d31f2faf1ca2e8af107013dcb.zip
*** empty log message ***
Diffstat (limited to 'lispref/debugging.texi')
-rw-r--r--lispref/debugging.texi86
1 files changed, 48 insertions, 38 deletions
diff --git a/lispref/debugging.texi b/lispref/debugging.texi
index 99e5e034358..9c7a4fd7be7 100644
--- a/lispref/debugging.texi
+++ b/lispref/debugging.texi
@@ -3,7 +3,7 @@
3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998 Free Software Foundation, Inc. 3@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998 Free Software Foundation, Inc.
4@c See the file elisp.texi for copying conditions. 4@c See the file elisp.texi for copying conditions.
5@setfilename ../info/debugging 5@setfilename ../info/debugging
6@node Debugging, Read and Print, Byte Compilation, Top 6@node Debugging, Read and Print, Advising, Top
7@chapter Debugging Lisp Programs 7@chapter Debugging Lisp Programs
8 8
9 There are three ways to investigate a problem in an Emacs Lisp program, 9 There are three ways to investigate a problem in an Emacs Lisp program,
@@ -104,14 +104,18 @@ that error does not enter the debugger, regardless of the value of
104@code{debug-on-error}. 104@code{debug-on-error}.
105 105
106The normal value of this variable lists several errors that happen often 106The normal value of this variable lists several errors that happen often
107during editing but rarely result from bugs in Lisp programs. 107during editing but rarely result from bugs in Lisp programs. However,
108``rarely'' is not ``never''; if your program fails with an error that
109matches this list, you will need to change this list in order to debug
110the error. The easiest way is usually to set
111@code{debug-ignored-errors} to @code{nil}.
108@end defopt 112@end defopt
109 113
110@defopt debug-on-signal 114@defopt debug-on-signal
111Normally, errors that are caught by @code{condition-case} never run the 115Normally, errors that are caught by @code{condition-case} never run the
112debugger, even if @code{debug-on-error} is non-@code{nil}. In other 116debugger, even if @code{debug-on-error} is non-@code{nil}. In other
113words, @code{condition-case} gets a chance to catch the error before the 117words, @code{condition-case} gets a chance to handle the error before
114debugger gets a chance. 118the debugger gets a chance.
115 119
116If you set @code{debug-on-signal} non-@code{nil}, then the debugger gets 120If you set @code{debug-on-signal} non-@code{nil}, then the debugger gets
117first chance at every error; an error will invoke the debugger 121first chance at every error; an error will invoke the debugger
@@ -119,7 +123,7 @@ regardless of any @code{condition-case}, if the fits the criterion
119specified by the values of @code{debug-on-error} and 123specified by the values of @code{debug-on-error} and
120@code{debug-ignored-errors}. 124@code{debug-ignored-errors}.
121 125
122@strong{Warning:} This variable is strong medecine! Various parts of 126@strong{Warning:} This variable is strong medicine! Various parts of
123Emacs handle errors in the normal course of affairs, and you may not 127Emacs handle errors in the normal course of affairs, and you may not
124even realize that errors happen there. If you set 128even realize that errors happen there. If you set
125@code{debug-on-signal} to a non-@code{nil} value, those errors will 129@code{debug-on-signal} to a non-@code{nil} value, those errors will
@@ -132,7 +136,7 @@ enter the debugger.
132 To debug an error that happens during loading of the @file{.emacs} 136 To debug an error that happens during loading of the @file{.emacs}
133file, use the option @samp{-debug-init}, which binds 137file, use the option @samp{-debug-init}, which binds
134@code{debug-on-error} to @code{t} while @file{.emacs} is loaded and 138@code{debug-on-error} to @code{t} while @file{.emacs} is loaded and
135inhibits use of @code{condition-case} to catch init file errors. 139inhibits use of @code{condition-case} to catch init-file errors.
136 140
137 If your @file{.emacs} file sets @code{debug-on-error}, the effect may 141 If your @file{.emacs} file sets @code{debug-on-error}, the effect may
138not last past the end of loading @file{.emacs}. (This is an undesirable 142not last past the end of loading @file{.emacs}. (This is an undesirable
@@ -190,26 +194,25 @@ called shortly before the problem, step quickly over the call to that
190function, and then step through its caller. 194function, and then step through its caller.
191 195
192@deffn Command debug-on-entry function-name 196@deffn Command debug-on-entry function-name
193 This function requests @var{function-name} to invoke the debugger each time 197This function requests @var{function-name} to invoke the debugger each time
194it is called. It works by inserting the form @code{(debug 'debug)} into 198it is called. It works by inserting the form @code{(debug 'debug)} into
195the function definition as the first form. 199the function definition as the first form.
196 200
197 Any function defined as Lisp code may be set to break on entry, 201Any function defined as Lisp code may be set to break on entry,
198regardless of whether it is interpreted code or compiled code. If the 202regardless of whether it is interpreted code or compiled code. If the
199function is a command, it will enter the debugger when called from Lisp 203function is a command, it will enter the debugger when called from Lisp
200and when called interactively (after the reading of the arguments). You 204and when called interactively (after the reading of the arguments). You
201can't debug primitive functions (i.e., those written in C) this way. 205can't debug primitive functions (i.e., those written in C) this way.
202 206
203 When @code{debug-on-entry} is called interactively, it prompts 207When @code{debug-on-entry} is called interactively, it prompts for
204for @var{function-name} in the minibuffer. 208@var{function-name} in the minibuffer. If the function is already set
209up to invoke the debugger on entry, @code{debug-on-entry} does nothing.
210@code{debug-on-entry} always returns @var{function-name}.
205 211
206 If the function is already set up to invoke the debugger on entry, 212@strong{Note:} if you redefine a function after using
207@code{debug-on-entry} does nothing. 213@code{debug-on-entry} on it, the code to enter the debugger is discarded
208 214by the redefinition. In effect, redefining the function cancels
209 @strong{Note:} if you redefine a function after using 215the break-on-entry feature for that function.
210@code{debug-on-entry} on it, the code to enter the debugger is lost.
211
212 @code{debug-on-entry} returns @var{function-name}.
213 216
214@example 217@example
215@group 218@group
@@ -252,11 +255,12 @@ Entering:
252This function undoes the effect of @code{debug-on-entry} on 255This function undoes the effect of @code{debug-on-entry} on
253@var{function-name}. When called interactively, it prompts for 256@var{function-name}. When called interactively, it prompts for
254@var{function-name} in the minibuffer. If @var{function-name} is 257@var{function-name} in the minibuffer. If @var{function-name} is
255@code{nil} or the empty string, it cancels debugging for all functions. 258@code{nil} or the empty string, it cancels break-on-entry for all
259functions.
256 260
257If @code{cancel-debug-on-entry} is called more than once on the same 261Calling @code{cancel-debug-on-entry} does nothing to a function which is
258function, the second call does nothing. @code{cancel-debug-on-entry} 262not currently set up to break on entry. It always returns
259returns @var{function-name}. 263@var{function-name}.
260@end deffn 264@end deffn
261 265
262@node Explicit Debug 266@node Explicit Debug
@@ -326,8 +330,8 @@ code, so that you can see how control flows. The debugger can step
326through the control structures of an interpreted function, but cannot do 330through the control structures of an interpreted function, but cannot do
327so in a byte-compiled function. If you would like to step through a 331so in a byte-compiled function. If you would like to step through a
328byte-compiled function, replace it with an interpreted definition of the 332byte-compiled function, replace it with an interpreted definition of the
329same function. (To do this, visit the source file for the function and 333same function. (To do this, visit the source for the function and type
330type @kbd{C-M-x} on its definition.) 334@kbd{C-M-x} on its definition.)
331 335
332 Here is a list of Debugger mode commands: 336 Here is a list of Debugger mode commands:
333 337
@@ -360,7 +364,8 @@ in the backtrace buffer.
360 364
361@item u 365@item u
362Don't enter the debugger when the current frame is exited. This 366Don't enter the debugger when the current frame is exited. This
363cancels a @kbd{b} command on that frame. 367cancels a @kbd{b} command on that frame. The visible effect is to
368remove the star from the line in the backtrace buffer.
364 369
365@item e 370@item e
366Read a Lisp expression in the minibuffer, evaluate it, and print the 371Read a Lisp expression in the minibuffer, evaluate it, and print the
@@ -371,6 +376,10 @@ examine them. This makes the debugger more transparent. By contrast,
371@kbd{M-:} does nothing special in the debugger; it shows you the 376@kbd{M-:} does nothing special in the debugger; it shows you the
372variable values within the debugger. 377variable values within the debugger.
373 378
379@item R
380Like @kbd{e}, but also save the result of evaluation in the
381buffer @samp{*Debugger-record*}.
382
374@item q 383@item q
375Terminate the program being debugged; return to top-level Emacs 384Terminate the program being debugged; return to top-level Emacs
376command execution. 385command execution.
@@ -383,11 +392,11 @@ Return a value from the debugger. The value is computed by reading an
383expression with the minibuffer and evaluating it. 392expression with the minibuffer and evaluating it.
384 393
385The @kbd{r} command is useful when the debugger was invoked due to exit 394The @kbd{r} command is useful when the debugger was invoked due to exit
386from a Lisp call frame (as requested with @kbd{b}); then the value 395from a Lisp call frame (as requested with @kbd{b} or by entering the
387specified in the @kbd{r} command is used as the value of that frame. It 396frame with @kbd{d}); then the value specified in the @kbd{r} command is
388is also useful if you call @code{debug} and use its return value. 397used as the value of that frame. It is also useful if you call
389Otherwise, @kbd{r} has the same effect as @kbd{c}, and the specified 398@code{debug} and use its return value. Otherwise, @kbd{r} has the same
390return value does not matter. 399effect as @kbd{c}, and the specified return value does not matter.
391 400
392You can't use @kbd{r} when the debugger was entered due to an error. 401You can't use @kbd{r} when the debugger was entered due to an error.
393@end table 402@end table
@@ -448,11 +457,11 @@ Beginning evaluation of function call form:
448@end smallexample 457@end smallexample
449 458
450@item exit 459@item exit
451When the first argument is @code{exit}, it indicates the exit of a 460When the first argument is @code{exit}, it indicates the exit of a stack
452stack frame previously marked to invoke the debugger on exit. The 461frame previously marked to invoke the debugger on exit. The second
453second argument given to @code{debug} in this case is the value being 462argument given to @code{debug} in this case is the value being returned
454returned from the frame. The debugger displays @samp{Return value:} on 463from the frame. The debugger displays @samp{Return value:} in the top
455the top line of the buffer, followed by the value being returned. 464line of the buffer, followed by the value being returned.
456 465
457@item error 466@item error
458@cindex @code{error} in debug 467@cindex @code{error} in debug
@@ -605,8 +614,8 @@ bound to @code{nil}. The debugger can set this variable to leave
605information for future debugger invocations during the same command 614information for future debugger invocations during the same command
606invocation. 615invocation.
607 616
608The advantage, for the debugger, of using this variable rather than 617The advantage, for the debugger, of using this variable rather than an
609another global variable is that the data will never carry over to a 618ordinary global variable is that the data will never carry over to a
610subsequent command invocation. 619subsequent command invocation.
611@end defvar 620@end defvar
612 621
@@ -671,7 +680,8 @@ close parenthesis, and finally return to the mark.)
671way to be sure of this except by studying the program, but often the 680way to be sure of this except by studying the program, but often the
672existing indentation is a clue to where the parentheses should have 681existing indentation is a clue to where the parentheses should have
673been. The easiest way to use this clue is to reindent with @kbd{C-M-q} 682been. The easiest way to use this clue is to reindent with @kbd{C-M-q}
674and see what moves. 683and see what moves. @strong{But don't do this yet!} Keep reading,
684first.
675 685
676 Before you do this, make sure the defun has enough close parentheses. 686 Before you do this, make sure the defun has enough close parentheses.
677Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest 687Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest
@@ -702,7 +712,7 @@ parenthesis at the beginning of the file, back up over it, and type
702insertion of the open parenthesis, and finally return to the mark.) 712insertion of the open parenthesis, and finally return to the mark.)
703 713
704 Then find the actual matching close parenthesis by typing @kbd{C-M-f} 714 Then find the actual matching close parenthesis by typing @kbd{C-M-f}
705at the beginning of the defun. This will leave you somewhere short of 715at the beginning of that defun. This will leave you somewhere short of
706the place where the defun ought to end. It is possible that you will 716the place where the defun ought to end. It is possible that you will
707find a spurious close parenthesis in that vicinity. 717find a spurious close parenthesis in that vicinity.
708 718