aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGemini Lasswell2018-07-18 08:30:45 -0700
committerGemini Lasswell2018-08-03 08:54:08 -0700
commit83af893fc0e7cc87c0fb0626fb48ef96e00b3f8b (patch)
treea20e2e5731a619f1268519deb2392d39f5bcfe87
parentca98377280005344fb07c816997b9bc2a737056a (diff)
downloademacs-83af893fc0e7cc87c0fb0626fb48ef96e00b3f8b.tar.gz
emacs-83af893fc0e7cc87c0fb0626fb48ef96e00b3f8b.zip
Move 'backtrace' from subr.el to backtrace.el
* lisp/subr.el (backtrace, backtrace--print-frame): Remove functions. * lisp/emacs-lisp/backtrace.el (backtrace-backtrace): Remove function. (backtrace): New function. (backtrace-to-string): Make argument optional. * doc/lispref/debugging.texi (Internals of Debugger): Update description of 'backtrace' function.
-rw-r--r--doc/lispref/debugging.texi19
-rw-r--r--lisp/emacs-lisp/backtrace.el12
-rw-r--r--lisp/subr.el19
3 files changed, 17 insertions, 33 deletions
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 87429a67ba9..841b16eaf95 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -678,20 +678,19 @@ of @code{debug} (@pxref{Invoking the Debugger}).
678@cindex run time stack 678@cindex run time stack
679@cindex call stack 679@cindex call stack
680This function prints a trace of Lisp function calls currently active. 680This function prints a trace of Lisp function calls currently active.
681This is the function used by @code{debug} to fill up the 681The trace is identical to the one that @code{debug} would show in the
682@file{*Backtrace*} buffer. It is written in C, since it must have access 682@file{*Backtrace*} buffer. The return value is always nil.
683to the stack to determine which function calls are active. The return
684value is always @code{nil}.
685 683
686In the following example, a Lisp expression calls @code{backtrace} 684In the following example, a Lisp expression calls @code{backtrace}
687explicitly. This prints the backtrace to the stream 685explicitly. This prints the backtrace to the stream
688@code{standard-output}, which, in this case, is the buffer 686@code{standard-output}, which, in this case, is the buffer
689@samp{backtrace-output}. 687@samp{backtrace-output}.
690 688
691Each line of the backtrace represents one function call. The line shows 689Each line of the backtrace represents one function call. The line
692the values of the function's arguments if they are all known; if they 690shows the function followed by a list of the values of the function's
693are still being computed, the line says so. The arguments of special 691arguments if they are all known; if they are still being computed, the
694forms are elided. 692line consists of a list containing the function and its unevaluated
693arguments. Long lists or deeply nested structures may be elided.
695 694
696@smallexample 695@smallexample
697@group 696@group
@@ -708,7 +707,7 @@ forms are elided.
708@group 707@group
709----------- Buffer: backtrace-output ------------ 708----------- Buffer: backtrace-output ------------
710 backtrace() 709 backtrace()
711 (list ...computing arguments...) 710 (list 'testing (backtrace))
712@end group 711@end group
713 (progn ...) 712 (progn ...)
714 eval((progn (1+ var) (list 'testing (backtrace)))) 713 eval((progn (1+ var) (list 'testing (backtrace))))
@@ -739,7 +738,7 @@ example would look as follows:
739@group 738@group
740----------- Buffer: backtrace-output ------------ 739----------- Buffer: backtrace-output ------------
741 (backtrace) 740 (backtrace)
742 (list ...computing arguments...) 741 (list 'testing (backtrace))
743@end group 742@end group
744 (progn ...) 743 (progn ...)
745 (eval (progn (1+ var) (list 'testing (backtrace)))) 744 (eval (progn (1+ var) (list 'testing (backtrace))))
diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index 5169c305035..d162983c017 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -891,14 +891,18 @@ followed by `backtrace-print-frame', once for each stack frame."
891 891
892;;; Backtrace printing 892;;; Backtrace printing
893 893
894(defun backtrace-backtrace () 894;;;###autoload
895(defun backtrace ()
895 "Print a trace of Lisp function calls currently active. 896 "Print a trace of Lisp function calls currently active.
896Output stream used is value of `standard-output'." 897Output stream used is value of `standard-output'."
897 (princ (backtrace-to-string (backtrace-get-frames 'backtrace-backtrace)))) 898 (princ (backtrace-to-string (backtrace-get-frames 'backtrace)))
899 nil)
898 900
899(defun backtrace-to-string(frames) 901(defun backtrace-to-string(&optional frames)
900 "Format FRAMES, a list of `backtrace-frame' objects, for output. 902 "Format FRAMES, a list of `backtrace-frame' objects, for output.
901Return the result as a string." 903Return the result as a string. If FRAMES is nil, use all
904function calls currently active."
905 (unless frames (setq frames (backtrace-get-frames 'backtrace-to-string)))
902 (let ((backtrace-fontify nil)) 906 (let ((backtrace-fontify nil))
903 (with-temp-buffer 907 (with-temp-buffer
904 (backtrace-mode) 908 (backtrace-mode)
diff --git a/lisp/subr.el b/lisp/subr.el
index f8c19efc379..fbb3e49a35c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4687,25 +4687,6 @@ The properties used on SYMBOL are `composefunc', `sendfunc',
4687 (put symbol 'hookvar (or hookvar 'mail-send-hook))) 4687 (put symbol 'hookvar (or hookvar 'mail-send-hook)))
4688 4688
4689 4689
4690(defun backtrace--print-frame (evald func args flags)
4691 "Print a trace of a single stack frame to `standard-output'.
4692EVALD, FUNC, ARGS, FLAGS are as in `mapbacktrace'."
4693 (princ (if (plist-get flags :debug-on-exit) "* " " "))
4694 (cond
4695 ((and evald (not debugger-stack-frame-as-list))
4696 (cl-prin1 func)
4697 (if args (cl-prin1 args) (princ "()")))
4698 (t
4699 (cl-prin1 (cons func args))))
4700 (princ "\n"))
4701
4702(defun backtrace ()
4703 "Print a trace of Lisp function calls currently active.
4704Output stream used is value of `standard-output'."
4705 (let ((print-level (or print-level 8))
4706 (print-escape-control-characters t))
4707 (mapbacktrace #'backtrace--print-frame 'backtrace)))
4708
4709(defun backtrace-frames (&optional base) 4690(defun backtrace-frames (&optional base)
4710 "Collect all frames of current backtrace into a list. 4691 "Collect all frames of current backtrace into a list.
4711If non-nil, BASE should be a function, and frames before its 4692If non-nil, BASE should be a function, and frames before its