Function: backtrace--frames-from-thread

backtrace--frames-from-thread is a function defined in eval.c.

Signature

(backtrace--frames-from-thread THREAD)

Documentation

Return the list of backtrace frames from current execution point in THREAD.

If a frame has not evaluated the arguments yet (or is a special form), the value of the list element is (nil FUNCTION ARG-FORMS...). If a frame has evaluated its arguments and called its function already, the value of the list element is (t FUNCTION ARG-VALUES...). A &rest arg is represented as the tail of the list ARG-VALUES. FUNCTION is whatever was supplied as car of evaluated list, or a lambda expression for macro calls.

Source Code

// Defined in /usr/src/emacs/src/eval.c
{
  struct thread_state *tstate;
  CHECK_THREAD (thread);
  tstate = XTHREAD (thread);

  union specbinding *pdl = backtrace_thread_top (tstate);
  Lisp_Object list = Qnil;

  while (backtrace_thread_p (tstate, pdl))
    {
      Lisp_Object frame;
      if (backtrace_nargs (pdl) == UNEVALLED)
	frame = Fcons (Qnil,
		      Fcons (backtrace_function (pdl), *backtrace_args (pdl)));
      else
	{
	  Lisp_Object tem = Flist (backtrace_nargs (pdl), backtrace_args (pdl));
	  frame = Fcons (Qt, Fcons (backtrace_function (pdl), tem));
	}
      list = Fcons (frame, list);
      pdl = backtrace_thread_next (tstate, pdl);
    }
  return Fnreverse (list);
}