Function: debug-on-entry

debug-on-entry is an autoloaded, interactive and byte-compiled function defined in debug.el.gz.

Signature

(debug-on-entry FUNCTION)

Documentation

Request FUNCTION to invoke debugger each time it is called.

When called interactively, prompt for FUNCTION in the minibuffer.

This works by modifying the definition of FUNCTION. If you tell the debugger to continue, FUNCTION's execution proceeds. If FUNCTION is a normal function or a macro written in Lisp, you can also step through its execution. FUNCTION can also be a primitive that is not a special form, in which case stepping is not possible. Break-on-entry for primitive functions only works when that function is called from Lisp.

Use M-x cancel-debug-on-entry (cancel-debug-on-entry) to cancel the effect of this command. Redefining FUNCTION also cancels it.

View in manual

Probably introduced at or before Emacs version 1.2.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/debug.el.gz
;;;###autoload
(defun debug-on-entry (function)
  "Request FUNCTION to invoke debugger each time it is called.

When called interactively, prompt for FUNCTION in the minibuffer.

This works by modifying the definition of FUNCTION.  If you tell the
debugger to continue, FUNCTION's execution proceeds.  If FUNCTION is a
normal function or a macro written in Lisp, you can also step through
its execution.  FUNCTION can also be a primitive that is not a special
form, in which case stepping is not possible.  Break-on-entry for
primitive functions only works when that function is called from Lisp.

Use \\[cancel-debug-on-entry] to cancel the effect of this command.
Redefining FUNCTION also cancels it."
  (interactive
   (let ((fn (function-called-at-point)) val)
     (when (special-form-p fn)
       (setq fn nil))
     (setq val (completing-read
                (format-prompt "Debug on entry to function" fn)
		obarray
		#'(lambda (symbol)
		    (and (fboundp symbol)
			 (not (special-form-p symbol))))
		'confirm nil nil (symbol-name fn)))
     (list (if (equal val "") fn (intern val)))))
  (advice-add function :before #'debug--implement-debug-on-entry
              '((depth . -100)))
  function)