Function: debugger-frame-number

debugger-frame-number is a byte-compiled function defined in debug.el.gz.

Signature

(debugger-frame-number)

Documentation

Return number of frames in backtrace before the one point points at.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/debug.el.gz
(defun debugger-frame-number ()
  "Return number of frames in backtrace before the one point points at."
  (let ((index (backtrace-get-index)))
    (unless index
      (error "This line is not a function call"))
    ;; We have 3 representations of the backtrace: the real in C in `specpdl',
    ;; the one stored in `backtrace-frames' and the textual version in
    ;; the buffer.  Check here that the one from `backtrace-frames' is in sync
    ;; with the one from `specpdl'.
    (cl-assert (equal (backtrace-frame-fun (nth index backtrace-frames))
                      (nth 1 (backtrace-frame (1+ index)
                                              (debugger--backtrace-base)))))
    ;; The `base' frame is the one that gets index 0 and it is the entry to
    ;; the debugger, so the first non-debugger frame is 1.
    ;; This `+1' skips the same frame as the `cdr' in
    ;; `debugger-setup-buffer'.
    (1+ index)))