]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/debug.el: Don't bail on errors inside cl-print
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 14 Oct 2017 02:45:41 +0000 (22:45 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 14 Oct 2017 02:45:41 +0000 (22:45 -0400)
(debugger--print): New function.
(debugger-insert-backtrace, debugger-setup-buffer): Use it.

lisp/emacs-lisp/debug.el

index 0247179a843f9e8fc618f16df8befdba8bfca16f..473ead12f5a86511de4f2c3b144118684e0737e3 100644 (file)
@@ -270,6 +270,12 @@ first will be printed into the backtrace buffer."
       (setq debug-on-next-call debugger-step-after-exit)
       debugger-value)))
 \f
+(defun debugger--print (obj &optional stream)
+  (condition-case err
+      (funcall debugger-print-function obj stream)
+    (error
+     (message "Error in debug printer: %S" err)
+     (prin1 obj stream))))
 
 (defun debugger-insert-backtrace (frames do-xrefs)
   "Format and insert the backtrace FRAMES at point.
@@ -284,10 +290,10 @@ Make functions into cross-reference buttons if DO-XREFS is non-nil."
             (fun-pt (point)))
         (cond
          ((and evald (not debugger-stack-frame-as-list))
-          (funcall debugger-print-function fun)
-          (if args (funcall debugger-print-function args) (princ "()")))
+          (debugger--print fun)
+          (if args (debugger--print args) (princ "()")))
          (t
-          (funcall debugger-print-function (cons fun args))
+          (debugger--print (cons fun args))
           (cl-incf fun-pt)))
         (when fun-file
           (make-text-button fun-pt (+ fun-pt (length (symbol-name fun)))
@@ -333,7 +339,7 @@ That buffer should be current already."
        (insert "--returning value: ")
        (setq pos (point))
        (setq debugger-value (nth 1 args))
-       (funcall debugger-print-function debugger-value (current-buffer))
+       (debugger--print debugger-value (current-buffer))
        (setf (cl-getf (nth 3 (car frames)) :debug-on-exit) nil)
        (insert ?\n))
       ;; Watchpoint triggered.
@@ -358,7 +364,7 @@ That buffer should be current already."
       (`error
        (insert "--Lisp error: ")
        (setq pos (point))
-       (funcall debugger-print-function (nth 1 args) (current-buffer))
+       (debugger--print (nth 1 args) (current-buffer))
        (insert ?\n))
       ;; debug-on-call, when the next thing is an eval.
       (`t
@@ -368,7 +374,7 @@ That buffer should be current already."
       (_
        (insert ": ")
        (setq pos (point))
-       (funcall debugger-print-function
+       (debugger--print
                 (if (eq (car args) 'nil)
                     (cdr args) args)
                 (current-buffer))