Here we describe fully the function used to invoke the debugger.
This function enters the debugger. It switches buffers to a buffer named ‘*Backtrace*’ (or ‘*Backtrace*<2>’ if it is the second recursive entry to the debugger, etc.), and fills it with information about the stack of Lisp function calls. It then enters a recursive edit, showing the backtrace buffer in Debugger mode.
The Debugger mode c and r commands exit the recursive edit; then
debugswitches back to the previous buffer and returns to whatever calleddebug. This is the only way the functiondebugcan return to its caller.If the first of the debugger-args passed to
debugisnil(or if it is not one of the special values in the table below), thendebugdisplays the rest of its arguments at the top of the ‘*Backtrace*’ buffer. This mechanism is used to display a message to the user.However, if the first argument passed to
debugis one of the following special values, then it has special significance. Normally, these values are passed todebugonly by the internals of XEmacs and the debugger, and not by programmers callingdebug.The special values are:
lambda- A first argument of
lambdameansdebugwas called because of entry to a function whendebug-on-next-callwas non-nil. The debugger displays ‘Entering:’ as a line of text at the top of the buffer.debugdebugas first argument indicates a call todebugbecause of entry to a function that was set to debug on entry. The debugger displays ‘Entering:’, just as in thelambdacase. It also marks the stack frame for that function so that it will invoke the debugger when exited.t- When the first argument is
t, this indicates a call todebugdue to evaluation of a list form whendebug-on-next-callis non-nil. The debugger displays the following as the top line in the buffer:Beginning evaluation of function call form:exit- When the first argument is
exit, it indicates the exit of a stack frame previously marked to invoke the debugger on exit. The second argument given todebugin this case is the value being returned from the frame. The debugger displays ‘Return value:’ on the top line of the buffer, followed by the value being returned.error- When the first argument is
error, the debugger indicates that it is being entered because an error orquitwas signaled and not handled, by displaying ‘Signaling:’ followed by the error signaled and any arguments tosignal. For example,(let ((debug-on-error t)) (/ 1 0)) ------ Buffer: *Backtrace* ------ Signaling: (arith-error) /(1 0) ... ------ Buffer: *Backtrace* ------If an error was signaled, presumably the variable
debug-on-erroris non-nil. Ifquitwas signaled, then presumably the variabledebug-on-quitis non-nil.nil- Use
nilas the first of the debugger-args when you want to enter the debugger explicitly. The rest of the debugger-args are printed on the top line of the buffer. You can use this feature to display messages—for example, to remind yourself of the conditions under whichdebugis called.