[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/handler-bind 453f977d642 11/12: misc debug-early.el (incl. debug
From: |
Stefan Monnier |
Subject: |
scratch/handler-bind 453f977d642 11/12: misc debug-early.el (incl. debug-early-muted) |
Date: |
Mon, 25 Dec 2023 23:56:51 -0500 (EST) |
branch: scratch/handler-bind
commit 453f977d642bc2adebddfe74360c39fb7cd59464
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
misc debug-early.el (incl. debug-early-muted)
(debug-early-backtrace): Exclude oneself from the backtrace.
(debug-early-muted): New function.
---
lisp/emacs-lisp/debug-early.el | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/debug-early.el b/lisp/emacs-lisp/debug-early.el
index 2e56d5ab321..01206bde86d 100644
--- a/lisp/emacs-lisp/debug-early.el
+++ b/lisp/emacs-lisp/debug-early.el
@@ -27,12 +27,15 @@
;; This file dumps a backtrace on stderr when an error is thrown. It
;; has no dependencies on any Lisp libraries and is thus used for
;; generating backtraces for bugs in the early parts of bootstrapping.
-;; It is also always used in batch model. It was introduced in Emacs
+;; It is also always used in batch mode. It was introduced in Emacs
;; 29, before which there was no backtrace available during early
;; bootstrap.
;;; Code:
+;; For bootstrap reasons, we cannot use any macros here since they're
+;; not defined yet.
+
(defalias 'debug-early-backtrace
#'(lambda ()
"Print a trace of Lisp function calls currently active.
@@ -68,9 +71,10 @@ of the build process."
(funcall prin1 (car args))
(setq args (cdr args)))
(princ " ")))
- (princ ")\n")))))))
+ (princ ")\n")))
+ #'debug-early))))
-(defalias 'debug-early
+(defalias 'debug-early ;Called from C.
#'(lambda (&rest args)
"Print an error message with a backtrace of active Lisp function calls.
The output stream used is the value of `standard-output'.
@@ -98,4 +102,20 @@ available before `debug' was usable.)"
#'(lambda (err)
(if backtrace-on-error-noninteractive (debug-early 'error err))))
+(defalias 'debug-early--muted ;Called from C.
+ #'(lambda (err)
+ (if backtrace-on-redisplay-error
+ (save-current-buffer
+ (set-buffer (get-buffer-create "*Redisplay-trace*"))
+ ;; FIXME: The C code tested `backtrace_yet'.
+ (goto-char (point-max))
+ (if (bobp) nil
+ (insert "\n\n\n\n")) ;; Separates things in *Redisplay-trace*
+ (insert "-- Caught at " (current-time-string) "\n")
+ (let ((standard-output (current-buffer)))
+ (debug-early--handler err))
+ (setq delayed-warnings-list
+ (cons "Error in a redisplay Lisp hook. See buffer
*Redisplay-trace*"
+ delayed-warnings-list))))))
+
;;; debug-early.el ends here.
- scratch/handler-bind 23479891db8 01/12: New special form `handler-bind`, (continued)
- scratch/handler-bind 23479891db8 01/12: New special form `handler-bind`, Stefan Monnier, 2023/12/25
- scratch/handler-bind 7da237eb092 03/12: edebug.el: Use `handler-bind` instead of `signal-hook-function`, Stefan Monnier, 2023/12/25
- scratch/handler-bind 089c87c61db 02/12: (eval-expression): Fix bug#67196, Stefan Monnier, 2023/12/25
- scratch/handler-bind a97a2363e39 04/12: ert.el: Use `handler-bind` to record backtraces, Stefan Monnier, 2023/12/25
- scratch/handler-bind 8f090cd421d 05/12: tramp.el: Use `handler-bind` instead of `signal-hook-function`, Stefan Monnier, 2023/12/25
- scratch/handler-bind 2f6f38ddc79 07/12: Move batch backtrace code to `top_level_2`, Stefan Monnier, 2023/12/25
- scratch/handler-bind e7c19f33112 09/12: (edebug-format): Make it obsolete, Stefan Monnier, 2023/12/25
- scratch/handler-bind 071ea552e6b 10/12: Add `redisplay-counter` to catched nested redisplays and abort outer one, Stefan Monnier, 2023/12/25
- scratch/handler-bind 68c95fc6682 06/12: startup.el: Use `handler-bind` to implement `--debug-init`, Stefan Monnier, 2023/12/25
- scratch/handler-bind 1fcb76b0465 08/12: Allow the `error-message` property to be a function, Stefan Monnier, 2023/12/25
- scratch/handler-bind 453f977d642 11/12: misc debug-early.el (incl. debug-early-muted),
Stefan Monnier <=
- scratch/handler-bind 933bc573c60 12/12: (macroexp--with-extended-form-stack): Use plain `let`, Stefan Monnier, 2023/12/25