aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2018-04-02 00:23:20 -0400
committerStefan Monnier2018-04-02 00:23:20 -0400
commit7228488effa78dcb75284cb6d247b24804e0e7f5 (patch)
treed18b1d62f339842a6bc8efe07dce4f26ff668b38
parent7bedc8812bd7ca1d9cf36636322068b28b690a85 (diff)
downloademacs-7228488effa78dcb75284cb6d247b24804e0e7f5.tar.gz
emacs-7228488effa78dcb75284cb6d247b24804e0e7f5.zip
* lisp/emacs-lisp/debug.el (debug): Don't hang upon error in initial-frame.
-rw-r--r--lisp/emacs-lisp/debug.el28
1 files changed, 24 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index f3a927f31cd..e8a3015b8fb 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -145,9 +145,29 @@ You may call with no args, or you may pass nil as the first arg and
145any other args you like. In that case, the list of args after the 145any other args you like. In that case, the list of args after the
146first will be printed into the backtrace buffer." 146first will be printed into the backtrace buffer."
147 (interactive) 147 (interactive)
148 (if inhibit-redisplay 148 (cond
149 ;; Don't really try to enter debugger within an eval from redisplay. 149 (inhibit-redisplay
150 debugger-value 150 ;; Don't really try to enter debugger within an eval from redisplay.
151 debugger-value)
152 ((and (eq t (framep (selected-frame)))
153 (equal "initial_terminal" (terminal-name)))
154 ;; We're in the initial-frame (where `message' just outputs to stdout) so
155 ;; there's no tty or GUI frame to display the backtrace and interact with
156 ;; it: just dump a backtrace to stdout.
157 ;; This happens for example while handling an error in code from
158 ;; early-init.el with --debug-init.
159 (message "Error: %S" args)
160 (let ((print-escape-newlines t)
161 (print-escape-control-characters t)
162 (print-level 8)
163 (print-length 50)
164 (skip t)) ;Skip the first frame (i.e. the `debug' frame)!
165 (mapbacktrace (lambda (_evald func args _flags)
166 (if skip
167 (setq skip nil)
168 (message " %S" (cons func args))))
169 'debug)))
170 (t
151 (unless noninteractive 171 (unless noninteractive
152 (message "Entering debugger...")) 172 (message "Entering debugger..."))
153 (let (debugger-value 173 (let (debugger-value
@@ -272,7 +292,7 @@ first will be printed into the backtrace buffer."
272 (with-timeout-unsuspend debugger-with-timeout-suspend) 292 (with-timeout-unsuspend debugger-with-timeout-suspend)
273 (set-match-data debugger-outer-match-data))) 293 (set-match-data debugger-outer-match-data)))
274 (setq debug-on-next-call debugger-step-after-exit) 294 (setq debug-on-next-call debugger-step-after-exit)
275 debugger-value))) 295 debugger-value))))
276 296
277(defun debugger--print (obj &optional stream) 297(defun debugger--print (obj &optional stream)
278 (condition-case err 298 (condition-case err