elisp: Infinite Loops
17.1.2 Debugging Infinite Loops
-------------------------------
When a program loops infinitely and fails to return, your first problem
is to stop the loop. On most operating systems, you can do this with
‘C-g’, which causes a “quit”. Quitting.
Ordinary quitting gives no information about why the program was
looping. To get more information, you can set the variable
‘debug-on-quit’ to non-‘nil’. Once you have the debugger running in the
middle of the infinite loop, you can proceed from the debugger using the
stepping commands. If you step through the entire loop, you may get
enough information to solve the problem.
Quitting with ‘C-g’ is not considered an error, and ‘debug-on-error’
has no effect on the handling of ‘C-g’. Likewise, ‘debug-on-quit’ has
no effect on errors.
-- User Option: debug-on-quit
This variable determines whether the debugger is called when ‘quit’
is signaled and not handled. If ‘debug-on-quit’ is non-‘nil’, then
the debugger is called whenever you quit (that is, type ‘C-g’). If
‘debug-on-quit’ is ‘nil’ (the default), then the debugger is not
called when you quit.