17.2 debug-on-entry

A recent GNU Emacs starts the debugger automatically when your
function has an error.

Incidentally, you can start the debugger manually for all versions of
Emacs; the advantage is that the debugger runs even if you do not have
a bug in your code. Sometimes your code will be free of bugs!

You can enter the debugger when you call the function by calling
debug-on-entry.

Type:

M-x debug-on-entry RET triangle-bugged RET

Now, evaluate the following:

(triangle-bugged 5)

All versions of Emacs will create a *Backtrace* buffer and tell
you that it is beginning to evaluate the triangle-bugged
function: