aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2017-06-28 07:23:47 -0400
committerNoam Postavsky2017-06-29 19:40:23 -0400
commit0ae28c71c739dfecbe94a5ff6786e81021d2d1cf (patch)
treeb34dc588b0e85507b81ea8b3a322f63f4d01daee
parentb567c48869b1484c6b1d263afc5cb67f22e99125 (diff)
downloademacs-0ae28c71c739dfecbe94a5ff6786e81021d2d1cf.tar.gz
emacs-0ae28c71c739dfecbe94a5ff6786e81021d2d1cf.zip
Hide byte code in backtraces (Bug#6991)
* lisp/emacs-lisp/debug.el (debugger-print-function): New defcustom, defaulting to `cl-print'. (debugger-insert-backtrace, debugger-setup-buffer): Use it instead of `prin1'. * etc/NEWS: Announce it.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/emacs-lisp/debug.el26
2 files changed, 23 insertions, 8 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 5e10ca9cb62..319b40f5d1a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -320,6 +320,11 @@ questions, with a handy way to display help texts.
320all call stack frames in a Lisp backtrace buffer as lists. Both 320all call stack frames in a Lisp backtrace buffer as lists. Both
321debug.el and edebug.el have been updated to heed to this variable. 321debug.el and edebug.el have been updated to heed to this variable.
322 322
323---
324** Values in call stack frames are now displayed using 'cl-prin1'.
325The old behaviour of using 'prin1' can be restored by customizing the
326new option 'debugger-print-function'.
327
323+++ 328+++
324** The new variable 'x-ctrl-keysym' has been added to the existing 329** The new variable 'x-ctrl-keysym' has been added to the existing
325roster of X keysyms. It can be used in combination with another 330roster of X keysyms. It can be used in combination with another
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 7db0f91b746..726005af9b1 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -49,6 +49,12 @@ the middle is discarded, and just the beginning and end are displayed."
49 :group 'debugger 49 :group 'debugger
50 :version "21.1") 50 :version "21.1")
51 51
52(defcustom debugger-print-function #'cl-prin1
53 "Function used to print values in the debugger backtraces."
54 :type 'function
55 :options '(cl-prin1 prin1)
56 :version "26.1")
57
52(defcustom debugger-bury-or-kill 'bury 58(defcustom debugger-bury-or-kill 'bury
53 "What to do with the debugger buffer when exiting `debug'. 59 "What to do with the debugger buffer when exiting `debug'.
54The value affects the behavior of operations on any window 60The value affects the behavior of operations on any window
@@ -265,10 +271,13 @@ first will be printed into the backtrace buffer."
265 debugger-value))) 271 debugger-value)))
266 272
267 273
274(defvar cl-print-compiled-button)
275
268(defun debugger-insert-backtrace (frames do-xrefs) 276(defun debugger-insert-backtrace (frames do-xrefs)
269 "Format and insert the backtrace FRAMES at point. 277 "Format and insert the backtrace FRAMES at point.
270Make functions into cross-reference buttons if DO-XREFS is non-nil." 278Make functions into cross-reference buttons if DO-XREFS is non-nil."
271 (let ((standard-output (current-buffer)) 279 (let ((standard-output (current-buffer))
280 (cl-print-compiled-button t)
272 (eval-buffers eval-buffer-list)) 281 (eval-buffers eval-buffer-list))
273 (require 'help-mode) ; Define `help-function-def' button type. 282 (require 'help-mode) ; Define `help-function-def' button type.
274 (pcase-dolist (`(,evald ,fun ,args ,flags) frames) 283 (pcase-dolist (`(,evald ,fun ,args ,flags) frames)
@@ -278,10 +287,10 @@ Make functions into cross-reference buttons if DO-XREFS is non-nil."
278 (fun-pt (point))) 287 (fun-pt (point)))
279 (cond 288 (cond
280 ((and evald (not debugger-stack-frame-as-list)) 289 ((and evald (not debugger-stack-frame-as-list))
281 (prin1 fun) 290 (funcall debugger-print-function fun)
282 (if args (prin1 args) (princ "()"))) 291 (if args (funcall debugger-print-function args) (princ "()")))
283 (t 292 (t
284 (prin1 (cons fun args)) 293 (funcall debugger-print-function (cons fun args))
285 (cl-incf fun-pt))) 294 (cl-incf fun-pt)))
286 (when fun-file 295 (when fun-file
287 (make-text-button fun-pt (+ fun-pt (length (symbol-name fun))) 296 (make-text-button fun-pt (+ fun-pt (length (symbol-name fun)))
@@ -327,7 +336,7 @@ That buffer should be current already."
327 (insert "--returning value: ") 336 (insert "--returning value: ")
328 (setq pos (point)) 337 (setq pos (point))
329 (setq debugger-value (nth 1 args)) 338 (setq debugger-value (nth 1 args))
330 (prin1 debugger-value (current-buffer)) 339 (funcall debugger-print-function debugger-value (current-buffer))
331 (setf (cl-getf (nth 3 (car frames)) :debug-on-exit) nil) 340 (setf (cl-getf (nth 3 (car frames)) :debug-on-exit) nil)
332 (insert ?\n)) 341 (insert ?\n))
333 ;; Watchpoint triggered. 342 ;; Watchpoint triggered.
@@ -352,7 +361,7 @@ That buffer should be current already."
352 (`error 361 (`error
353 (insert "--Lisp error: ") 362 (insert "--Lisp error: ")
354 (setq pos (point)) 363 (setq pos (point))
355 (prin1 (nth 1 args) (current-buffer)) 364 (funcall debugger-print-function (nth 1 args) (current-buffer))
356 (insert ?\n)) 365 (insert ?\n))
357 ;; debug-on-call, when the next thing is an eval. 366 ;; debug-on-call, when the next thing is an eval.
358 (`t 367 (`t
@@ -362,9 +371,10 @@ That buffer should be current already."
362 (_ 371 (_
363 (insert ": ") 372 (insert ": ")
364 (setq pos (point)) 373 (setq pos (point))
365 (prin1 (if (eq (car args) 'nil) 374 (funcall debugger-print-function
366 (cdr args) args) 375 (if (eq (car args) 'nil)
367 (current-buffer)) 376 (cdr args) args)
377 (current-buffer))
368 (insert ?\n))) 378 (insert ?\n)))
369 (debugger-insert-backtrace frames t) 379 (debugger-insert-backtrace frames t)
370 ;; Place point on "stack frame 0" (bug#15101). 380 ;; Place point on "stack frame 0" (bug#15101).