Function: mapbacktrace

mapbacktrace is a function defined in eval.c.

Signature

(mapbacktrace FUNCTION &optional BASE)

Documentation

Call FUNCTION for each frame in backtrace.

If BASE is non-nil, it should be a function and iteration will start from its nearest activation frame. FUNCTION is called with 4 arguments: EVALD, FUNC, ARGS, and FLAGS. If a frame has not evaluated its arguments yet or is a special form, EVALD is nil and ARGS is a list of forms. If a frame has evaluated its arguments and called its function already, EVALD is t and ARGS is a list of values. FLAGS is a plist of properties of the current frame: currently, the only supported property is :debug-on-exit. mapbacktrace always returns nil.

View in manual

Probably introduced at or before Emacs version 26.1.

Source Code

// Defined in /usr/src/emacs/src/eval.c
{
  union specbinding *pdl = get_backtrace_starting_at (base);

  while (backtrace_p (pdl))
    {
      ptrdiff_t i = pdl - specpdl;
      backtrace_frame_apply (function, pdl);
      /* Beware! PDL is no longer valid here because FUNCTION might
         have caused grow_specpdl to reallocate pdlvec.  We must use
         the saved index, cf. Bug#27258.  */
      pdl = backtrace_next (&specpdl[i]);
    }

  return Qnil;
}