diff options
| author | Alan Mackenzie | 2022-08-11 19:31:09 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2022-08-11 19:31:09 +0000 |
| commit | 48215c41d16fadb69e85121b3baca0dfca82cc44 (patch) | |
| tree | 1c410ce8b1b63d20cc02810078acb337af29a2b1 /doc/lispref/debugging.texi | |
| parent | e7f1d4f6e106576f3d8de4074290dc4e8c7c544f (diff) | |
| download | emacs-48215c41d16fadb69e85121b3baca0dfca82cc44.tar.gz emacs-48215c41d16fadb69e85121b3baca0dfca82cc44.zip | |
New debugging facility: backtraces from errors in Lisp called from redisplay
Setting backtrace-on-redisplay-error to non-nil enables the generation of a
Lisp backtrace in buffer *Redisplay-trace* following an error in Lisp called
from redisplay.
* doc/lispref/debugging.texi (Debugging Redisplay): New subsection.
(Error Debugging): Reference to the new subsection.
* etc/NEWS: New entry for the new facility.
* src/eval.c (redisplay_deep_handler): New variable.
(init_eval): Initialize redisplay_deep_handler.
(call_debugger): Don't throw to top-level after calling debug-early
(internal_condition_case_n): "Bind" redisplay_deep_handler to the current
handler.
(backtrace_yet): New boolean variable.
(signal_or_quit): New code section to handle Lisp errors occurring in
redisplay.
(syms_of_eval): New DEFVAR_BOOL backtrace-on-redisplay-error.
* src/keyboard.c (command_loop_1): Set backtrace_yet to false each time around
the loop.
(safe_run_hooks_error): Allow args to be up to four Lisp_Objects long.
(safe_run_hooks_2): New function.
* src/lisp.h (top level): declare as externs backtrace_yet and
safe_run_hooks_2.
* src/xdisp.c (run_window_scroll_functions): Replace a call to
run_hook_with_args_2 with one to safe_run_hooks_2.
Diffstat (limited to 'doc/lispref/debugging.texi')
| -rw-r--r-- | doc/lispref/debugging.texi | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index 058c9319544..9ae40949d1e 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi | |||
| @@ -77,6 +77,7 @@ debugger recursively. @xref{Recursive Editing}. | |||
| 77 | 77 | ||
| 78 | @menu | 78 | @menu |
| 79 | * Error Debugging:: Entering the debugger when an error happens. | 79 | * Error Debugging:: Entering the debugger when an error happens. |
| 80 | * Debugging Redisplay:: Getting backtraces from redisplay errors. | ||
| 80 | * Infinite Loops:: Stopping and debugging a program that doesn't exit. | 81 | * Infinite Loops:: Stopping and debugging a program that doesn't exit. |
| 81 | * Function Debugging:: Entering it when a certain function is called. | 82 | * Function Debugging:: Entering it when a certain function is called. |
| 82 | * Variable Debugging:: Entering it when a variable is modified. | 83 | * Variable Debugging:: Entering it when a variable is modified. |
| @@ -105,6 +106,10 @@ debugger, set the variable @code{debug-on-error} to non-@code{nil}. | |||
| 105 | (The command @code{toggle-debug-on-error} provides an easy way to do | 106 | (The command @code{toggle-debug-on-error} provides an easy way to do |
| 106 | this.) | 107 | this.) |
| 107 | 108 | ||
| 109 | Note that, for technical reasons, you cannot use the facilities | ||
| 110 | defined in this subsection to debug errors in Lisp that the redisplay | ||
| 111 | code has invoked. @xref{Debugging Redisplay}, for help with these. | ||
| 112 | |||
| 108 | @defopt debug-on-error | 113 | @defopt debug-on-error |
| 109 | This variable determines whether the debugger is called when an error | 114 | This variable determines whether the debugger is called when an error |
| 110 | is signaled and not handled. If @code{debug-on-error} is @code{t}, | 115 | is signaled and not handled. If @code{debug-on-error} is @code{t}, |
| @@ -213,6 +218,45 @@ file, use the option @samp{--debug-init}. This binds | |||
| 213 | bypasses the @code{condition-case} which normally catches errors in the | 218 | bypasses the @code{condition-case} which normally catches errors in the |
| 214 | init file. | 219 | init file. |
| 215 | 220 | ||
| 221 | @node Debugging Redisplay | ||
| 222 | @subsection Debugging Redisplay Errors | ||
| 223 | @cindex redisplay errors | ||
| 224 | @cindex debugging redisplay errors | ||
| 225 | |||
| 226 | When an error occurs in Lisp code which redisplay has invoked, Emacs's | ||
| 227 | usual debugging mechanisms are unusable, for technical reasons. This | ||
| 228 | subsection describes how to get a backtrace from such an error, which | ||
| 229 | should be helpful in debugging it. | ||
| 230 | |||
| 231 | These directions apply to Lisp forms used, for example, in | ||
| 232 | @code{:eval} mode line constructs (@pxref{Mode Line Data}), and in all | ||
| 233 | hooks invoked from redisplay, such as: | ||
| 234 | |||
| 235 | @itemize | ||
| 236 | @item | ||
| 237 | @code{fontification-functions} (@pxref{Auto Faces}). | ||
| 238 | @item | ||
| 239 | @code{window-scroll-functions} (@pxref{Window Hooks}). | ||
| 240 | @end itemize | ||
| 241 | |||
| 242 | Note that if you have had an error in a hook function called from | ||
| 243 | redisplay, the error handling might have removed this function from | ||
| 244 | the hook. You will thus need to reinitialize that hook somehow, | ||
| 245 | perhaps with @code{add-hook}, to be able to replay the bug. | ||
| 246 | |||
| 247 | To generate a backtrace in these circumstances, set the variable | ||
| 248 | @code{backtrace-on-redisplay-error} to non-@code{nil}. When the error | ||
| 249 | occurs, Emacs will dump the backtrace to the buffer | ||
| 250 | @file{*Redisplay-trace*}, but won't automatically display it in a | ||
| 251 | window. This is to avoid needlessly corrupting the redisplay you are | ||
| 252 | debugging. You will thus need to display the buffer yourself, with a | ||
| 253 | command such as @code{switch-to-buffer-other-frame} @key{C-x 5 b}. | ||
| 254 | |||
| 255 | @defvar backtrace-on-redisplay-error | ||
| 256 | Set this variable to non-@code{nil} to enable the generation of a | ||
| 257 | backtrace when an error occurs in any Lisp called from redisplay. | ||
| 258 | @end defvar | ||
| 259 | |||
| 216 | @node Infinite Loops | 260 | @node Infinite Loops |
| 217 | @subsection Debugging Infinite Loops | 261 | @subsection Debugging Infinite Loops |
| 218 | @cindex infinite loops | 262 | @cindex infinite loops |