1 ;;; debug.el --- debuggers and related commands for Emacs
3 ;; Copyright (C) 1985, 1986, 1994, 2001, 2003, 2005
4 ;; Free Software Foundation, Inc.
7 ;; Keywords: lisp, tools, maint
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This is a major mode documented in the Emacs manual.
34 (defgroup debugger nil
35 "Debuggers and related commands for Emacs."
39 (defcustom debugger-mode-hook nil
40 "*Hooks run when `debugger-mode' is turned on."
45 (defcustom debugger-batch-max-lines 40
46 "*Maximum lines to show in debugger buffer in a noninteractive Emacs.
47 When the debugger is entered and Emacs is running in batch mode,
48 if the backtrace text has more than this many lines,
49 the middle is discarded, and just the beginning and end are displayed."
54 (defcustom debug-function-list nil
55 "List of functions currently set for debug on entry."
56 :type '(repeat function)
59 (defcustom debugger-step-after-exit nil
60 "Non-nil means \"single-step\" after the debugger exits."
64 (defvar debugger-value nil
65 "This is the value for the debugger to return, when it returns.")
67 (defvar debugger-old-buffer nil
68 "This is the buffer that was current when the debugger was entered.")
70 (defvar debugger-previous-backtrace nil
71 "The contents of the previous backtrace (including text properties).
72 This is to optimize `debugger-make-xrefs'.")
74 (defvar debugger-outer-match-data)
75 (defvar debugger-outer-load-read-function)
76 (defvar debugger-outer-overriding-local-map)
77 (defvar debugger-outer-overriding-terminal-local-map)
78 (defvar debugger-outer-track-mouse)
79 (defvar debugger-outer-last-command)
80 (defvar debugger-outer-this-command)
81 ;; unread-command-char is obsolete,
82 ;; but we still save and restore it
83 ;; in case some user program still tries to set it.
84 (defvar debugger-outer-unread-command-char)
85 (defvar debugger-outer-unread-command-events)
86 (defvar debugger-outer-unread-post-input-method-events)
87 (defvar debugger-outer-last-input-event)
88 (defvar debugger-outer-last-command-event)
89 (defvar debugger-outer-last-nonmenu-event)
90 (defvar debugger-outer-last-event-frame)
91 (defvar debugger-outer-standard-input)
92 (defvar debugger-outer-standard-output)
93 (defvar debugger-outer-inhibit-redisplay)
94 (defvar debugger-outer-cursor-in-echo-area)
97 (setq debugger 'debug)
99 (defun debug (&rest debugger-args)
100 "Enter debugger. To return, type \\<debugger-mode-map>`\\[debugger-continue]'.
101 Arguments are mainly for use when this is called from the internals
104 You may call with no args, or you may pass nil as the first arg and
105 any other args you like. In that case, the list of args after the
106 first will be printed into the backtrace buffer."
108 (if inhibit-redisplay
109 ;; Don't really try to enter debugger within an eval from redisplay.
111 (unless noninteractive
112 (message "Entering debugger..."))
116 (debugger-buffer (let ((default-major-mode 'fundamental-mode))
117 (get-buffer-create "*Backtrace*")))
118 (debugger-old-buffer (current-buffer))
119 (debugger-step-after-exit nil)
120 ;; Don't keep reading from an executing kbd macro!
121 (executing-kbd-macro nil)
122 ;; Save the outer values of these vars for the `e' command
123 ;; before we replace the values.
124 (debugger-outer-match-data (match-data))
125 (debugger-outer-load-read-function load-read-function)
126 (debugger-outer-overriding-local-map overriding-local-map)
127 (debugger-outer-overriding-terminal-local-map
128 overriding-terminal-local-map)
129 (debugger-outer-track-mouse track-mouse)
130 (debugger-outer-last-command last-command)
131 (debugger-outer-this-command this-command)
132 (debugger-outer-unread-command-char
133 (with-no-warnings unread-command-char))
134 (debugger-outer-unread-command-events unread-command-events)
135 (debugger-outer-unread-post-input-method-events
136 unread-post-input-method-events)
137 (debugger-outer-last-input-event last-input-event)
138 (debugger-outer-last-command-event last-command-event)
139 (debugger-outer-last-nonmenu-event last-nonmenu-event)
140 (debugger-outer-last-event-frame last-event-frame)
141 (debugger-outer-standard-input standard-input)
142 (debugger-outer-standard-output standard-output)
143 (debugger-outer-inhibit-redisplay inhibit-redisplay)
144 (debugger-outer-cursor-in-echo-area cursor-in-echo-area))
145 ;; Set this instead of binding it, so that `q'
146 ;; will not restore it.
147 (setq overriding-terminal-local-map nil)
148 ;; Don't let these magic variables affect the debugger itself.
149 (let ((last-command nil) this-command track-mouse
150 unread-command-events
151 unread-post-input-method-events
152 last-input-event last-command-event last-nonmenu-event
156 ;; If we are inside a minibuffer, allow nesting
157 ;; so that we don't get an error from the `e' command.
158 (enable-recursive-minibuffers
159 (or enable-recursive-minibuffers (> (minibuffer-depth) 0)))
160 (standard-input t) (standard-output t)
162 (cursor-in-echo-area nil))
165 (save-window-excursion
167 (setq unread-command-char -1))
168 (pop-to-buffer debugger-buffer)
170 (debugger-setup-buffer debugger-args)
172 ;; If the backtrace is long, save the beginning
173 ;; and the end, but discard the middle.
174 (when (> (count-lines (point-min) (point-max))
175 debugger-batch-max-lines)
176 (goto-char (point-min))
177 (forward-line (/ 2 debugger-batch-max-lines))
178 (let ((middlestart (point)))
179 (goto-char (point-max))
180 (forward-line (- (/ 2 debugger-batch-max-lines)
181 debugger-batch-max-lines))
182 (delete-region middlestart (point)))
184 (goto-char (point-min))
185 (message "%s" (buffer-string))
187 (if (eq (car debugger-args) 'debug)
188 ;; Skip the frames for backtrace-debug, byte-code, and debug.
189 (backtrace-debug 3 t))
192 (let ((inhibit-trace t)
193 (standard-output nil)
194 (buffer-read-only t))
196 ;; Make sure we unbind buffer-read-only in the right buffer.
199 ;; Kill or at least neuter the backtrace buffer, so that users
200 ;; don't try to execute debugger commands in an invalid context.
201 (if (get-buffer-window debugger-buffer 0)
202 ;; Still visible despite the save-window-excursion? Maybe it
203 ;; it's in a pop-up frame. It would be annoying to delete and
204 ;; recreate it every time the debugger stops, so instead we'll
205 ;; erase it and hide it but keep it alive.
206 (with-current-buffer debugger-buffer
209 (with-selected-window (get-buffer-window debugger-buffer 0)
211 (kill-buffer debugger-buffer))
212 (set-match-data debugger-outer-match-data)))
213 ;; Put into effect the modified values of these variables
214 ;; in case the user set them with the `e' command.
215 (setq load-read-function debugger-outer-load-read-function)
216 (setq overriding-local-map debugger-outer-overriding-local-map)
217 (setq overriding-terminal-local-map
218 debugger-outer-overriding-terminal-local-map)
219 (setq track-mouse debugger-outer-track-mouse)
220 (setq last-command debugger-outer-last-command)
221 (setq this-command debugger-outer-this-command)
223 (setq unread-command-char debugger-outer-unread-command-char))
224 (setq unread-command-events debugger-outer-unread-command-events)
225 (setq unread-post-input-method-events
226 debugger-outer-unread-post-input-method-events)
227 (setq last-input-event debugger-outer-last-input-event)
228 (setq last-command-event debugger-outer-last-command-event)
229 (setq last-nonmenu-event debugger-outer-last-nonmenu-event)
230 (setq last-event-frame debugger-outer-last-event-frame)
231 (setq standard-input debugger-outer-standard-input)
232 (setq standard-output debugger-outer-standard-output)
233 (setq inhibit-redisplay debugger-outer-inhibit-redisplay)
234 (setq cursor-in-echo-area debugger-outer-cursor-in-echo-area)
235 (setq debug-on-next-call debugger-step-after-exit)
238 (defun debugger-setup-buffer (debugger-args)
239 "Initialize the `*Backtrace*' buffer for entry to the debugger.
240 That buffer should be current already."
241 (setq buffer-read-only nil)
243 (set-buffer-multibyte nil)
244 (let ((standard-output (current-buffer))
245 (print-escape-newlines t)
249 (goto-char (point-min))
250 (delete-region (point)
252 (search-forward "\n debug(")
255 (insert "Debugger entered")
256 ;; lambda is for debug-on-call when a function call is next.
257 ;; debug is for debug-on-entry function called.
258 (cond ((memq (car debugger-args) '(lambda debug))
259 (insert "--entering a function:\n")
260 (if (eq (car debugger-args) 'debug)
264 (beginning-of-line))))
265 ;; Exiting a function.
266 ((eq (car debugger-args) 'exit)
267 (insert "--returning value: ")
268 (setq debugger-value (nth 1 debugger-args))
269 (prin1 debugger-value (current-buffer))
274 ;; Debugger entered for an error.
275 ((eq (car debugger-args) 'error)
276 (insert "--Lisp error: ")
277 (prin1 (nth 1 debugger-args) (current-buffer))
279 ;; debug-on-call, when the next thing is an eval.
280 ((eq (car debugger-args) t)
281 (insert "--beginning evaluation of function call form:\n"))
282 ;; User calls debug directly.
285 (prin1 (if (eq (car debugger-args) 'nil)
286 (cdr debugger-args) debugger-args)
289 ;; After any frame that uses eval-buffer,
290 ;; insert a line that states the buffer position it's reading at.
292 (while (re-search-forward "^ eval-buffer(" nil t)
294 (insert (format "\n ;;; Reading at buffer position %d"
295 (with-current-buffer (nth 2 (backtrace-frame (debugger-frame-number)))
297 (debugger-make-xrefs))
299 (defun debugger-make-xrefs (&optional buffer)
300 "Attach cross-references to symbol names in the `*Backtrace*' buffer."
303 (set-buffer (or buffer (current-buffer)))
304 (setq buffer (current-buffer))
305 (let ((buffer-read-only nil)
306 (old-end (point-min)) (new-end (point-min)))
307 ;; If we saved an old backtrace, find the common part
308 ;; between the new and the old.
309 ;; Compare line by line, starting from the end,
310 ;; because that's the part that is likely to be unchanged.
311 (if debugger-previous-backtrace
312 (let (old-start new-start (all-match t))
313 (goto-char (point-max))
315 (insert debugger-previous-backtrace)
316 (while (and all-match (not (bobp)))
317 (setq old-end (point))
319 (setq old-start (point))
320 (with-current-buffer buffer
321 (setq new-end (point))
323 (setq new-start (point)))
325 (compare-buffer-substrings
326 (current-buffer) old-start old-end
327 buffer new-start new-end)))
328 (setq all-match nil))))
329 ;; Now new-end is the position of the start of the
330 ;; unchanged part in the current buffer, and old-end is
331 ;; the position of that same text in the saved old
332 ;; backtrace. But we must subtract (point-min) since strings are
333 ;; indexed in origin 0.
335 ;; Replace the unchanged part of the backtrace
336 ;; with the text from debugger-previous-backtrace,
337 ;; since that already has the proper xrefs.
338 ;; With this optimization, we only need to scan
339 ;; the changed part of the backtrace.
340 (delete-region new-end (point-max))
341 (goto-char (point-max))
342 (insert (substring debugger-previous-backtrace
343 (- old-end (point-min))))
344 ;; Make the unchanged part of the backtrace inaccessible
345 ;; so it won't be scanned.
346 (narrow-to-region (point-min) new-end)))
348 ;; Scan the new part of the backtrace, inserting xrefs.
349 (goto-char (point-min))
351 (skip-syntax-forward "^w_")
354 (end (progn (skip-syntax-forward "w_") (point)))
355 (sym (intern-soft (buffer-substring-no-properties
357 (file (and sym (symbol-file sym 'defun))))
360 ;; help-xref-button needs to operate on something matched
361 ;; by a regexp, so set that up for it.
362 (re-search-forward "\\(\\(\\sw\\|\\s_\\)+\\)")
363 (help-xref-button 1 'help-function-def sym file)))
366 (setq debugger-previous-backtrace (buffer-string))))
368 (defun debugger-step-through ()
369 "Proceed, stepping through subexpressions of this expression.
370 Enter another debugger on next entry to eval, apply or funcall."
372 (setq debugger-step-after-exit t)
373 (message "Proceeding, will debug on next eval or call.")
374 (exit-recursive-edit))
376 (defun debugger-continue ()
377 "Continue, evaluating this expression without stopping."
379 (unless debugger-may-continue
380 (error "Cannot continue"))
381 (message "Continuing.")
382 (exit-recursive-edit))
384 (defun debugger-return-value (val)
385 "Continue, specifying value to return.
386 This is only useful when the value returned from the debugger
387 will be used, such as in a debug on exit from a frame."
388 (interactive "XReturn value (evaluated): ")
389 (setq debugger-value val)
390 (princ "Returning " t)
391 (prin1 debugger-value)
392 (exit-recursive-edit))
394 (defun debugger-jump ()
395 "Continue to exit from this frame, with all debug-on-entry suspended."
398 ;; Turn off all debug-on-entry functions
399 ;; but leave them in the list.
400 (let ((list debug-function-list))
403 (debug-on-entry-1 (car list) (symbol-function (car list)) nil))
404 (setq list (cdr list))))
405 (message "Continuing through this frame")
406 (exit-recursive-edit))
408 (defun debugger-reenable ()
409 "Turn all debug-on-entry functions back on."
410 (let ((list debug-function-list))
412 (or (consp (symbol-function (car list)))
413 (debug-convert-byte-code (car list)))
415 (debug-on-entry-1 (car list) (symbol-function (car list)) t))
416 (setq list (cdr list)))))
418 (defun debugger-frame-number ()
419 "Return number of frames in backtrace before the one point points at."
422 (let ((opoint (point))
424 (while (not (eq (cadr (backtrace-frame count)) 'debug))
425 (setq count (1+ count)))
426 (goto-char (point-min))
427 (if (or (equal (buffer-substring (point) (+ (point) 6))
429 (equal (buffer-substring (point) (+ (point) 6))
437 (if (= (following-char) ?\()
442 (if (looking-at " *;;;")
444 (setq count (1+ count)))
447 (defun debugger-frame ()
448 "Request entry to debugger when this frame exits.
449 Applies to the frame whose line point is on in the backtrace."
453 (if (looking-at " *;;;\\|[a-z]")
454 (error "This line is not a function call")))
456 (backtrace-debug (debugger-frame-number) t)
457 (if (= (following-char) ? )
458 (let ((buffer-read-only nil))
463 (defun debugger-frame-clear ()
464 "Do not enter debugger when this frame exits.
465 Applies to the frame whose line point is on in the backtrace."
469 (if (looking-at " *;;;\\|[a-z]")
470 (error "This line is not a function call")))
472 (backtrace-debug (debugger-frame-number) nil)
473 (if (= (following-char) ?*)
474 (let ((buffer-read-only nil))
481 (put 'debugger-env-macro 'lisp-indent-function 0)
482 (defmacro debugger-env-macro (&rest body)
483 "Run BODY in original environment."
485 (if (null (buffer-name debugger-old-buffer))
486 ;; old buffer deleted
487 (setq debugger-old-buffer (current-buffer)))
488 (set-buffer debugger-old-buffer)
489 (let ((load-read-function debugger-outer-load-read-function)
490 (overriding-terminal-local-map
491 debugger-outer-overriding-terminal-local-map)
492 (overriding-local-map debugger-outer-overriding-local-map)
493 (track-mouse debugger-outer-track-mouse)
494 (last-command debugger-outer-last-command)
495 (this-command debugger-outer-this-command)
496 (unread-command-events debugger-outer-unread-command-events)
497 (unread-post-input-method-events
498 debugger-outer-unread-post-input-method-events)
499 (last-input-event debugger-outer-last-input-event)
500 (last-command-event debugger-outer-last-command-event)
501 (last-nonmenu-event debugger-outer-last-nonmenu-event)
502 (last-event-frame debugger-outer-last-event-frame)
503 (standard-input debugger-outer-standard-input)
504 (standard-output debugger-outer-standard-output)
505 (inhibit-redisplay debugger-outer-inhibit-redisplay)
506 (cursor-in-echo-area debugger-outer-cursor-in-echo-area))
507 (set-match-data debugger-outer-match-data)
509 (let ((save-ucc (with-no-warnings unread-command-char)))
513 (setq unread-command-char debugger-outer-unread-command-char))
514 (prog1 (progn ,@body)
516 (setq debugger-outer-unread-command-char unread-command-char))))
518 (setq unread-command-char save-ucc))))
519 (setq debugger-outer-match-data (match-data))
520 (setq debugger-outer-load-read-function load-read-function)
521 (setq debugger-outer-overriding-terminal-local-map
522 overriding-terminal-local-map)
523 (setq debugger-outer-overriding-local-map overriding-local-map)
524 (setq debugger-outer-track-mouse track-mouse)
525 (setq debugger-outer-last-command last-command)
526 (setq debugger-outer-this-command this-command)
527 (setq debugger-outer-unread-command-events unread-command-events)
528 (setq debugger-outer-unread-post-input-method-events
529 unread-post-input-method-events)
530 (setq debugger-outer-last-input-event last-input-event)
531 (setq debugger-outer-last-command-event last-command-event)
532 (setq debugger-outer-last-nonmenu-event last-nonmenu-event)
533 (setq debugger-outer-last-event-frame last-event-frame)
534 (setq debugger-outer-standard-input standard-input)
535 (setq debugger-outer-standard-output standard-output)
536 (setq debugger-outer-inhibit-redisplay inhibit-redisplay)
537 (setq debugger-outer-cursor-in-echo-area cursor-in-echo-area)
540 (defun debugger-eval-expression (exp)
541 "Eval an expression, in an environment like that outside the debugger."
543 (list (read-from-minibuffer "Eval: "
544 nil read-expression-map t
545 'read-expression-history)))
546 (debugger-env-macro (eval-expression exp)))
548 (defvar debugger-mode-map
549 (let ((map (make-keymap)))
550 (set-keymap-parent map button-buffer-map)
551 (suppress-keymap map)
552 (define-key map "-" 'negative-argument)
553 (define-key map "b" 'debugger-frame)
554 (define-key map "c" 'debugger-continue)
555 (define-key map "j" 'debugger-jump)
556 (define-key map "r" 'debugger-return-value)
557 (define-key map "u" 'debugger-frame-clear)
558 (define-key map "d" 'debugger-step-through)
559 (define-key map "l" 'debugger-list-functions)
560 (define-key map "h" 'describe-mode)
561 (define-key map "q" 'top-level)
562 (define-key map "e" 'debugger-eval-expression)
563 (define-key map " " 'next-line)
564 (define-key map "R" 'debugger-record-expression)
565 (define-key map "\C-m" 'help-follow)
566 (define-key map [mouse-2] 'push-button)
569 (defcustom debugger-record-buffer "*Debugger-record*"
570 "*Buffer name for expression values, for \\[debugger-record-expression]."
575 (defun debugger-record-expression (exp)
576 "Display a variable's value and record it in `*Backtrace-record*' buffer."
578 (list (read-from-minibuffer
581 read-expression-map t
582 'read-expression-history)))
583 (let* ((buffer (get-buffer-create debugger-record-buffer))
584 (standard-output buffer))
585 (princ (format "Debugger Eval (%s): " exp))
586 (princ (debugger-eval-expression exp))
589 (with-current-buffer (get-buffer debugger-record-buffer)
593 (buffer-substring (point) (progn (end-of-line) (point)))))))
595 (put 'debugger-mode 'mode-class 'special)
597 (defun debugger-mode ()
598 "Mode for backtrace buffers, selected in debugger.
599 \\<debugger-mode-map>
600 A line starts with `*' if exiting that frame will call the debugger.
601 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'.
603 When in debugger due to frame being exited,
604 use the \\[debugger-return-value] command to override the value
605 being returned from that frame.
607 Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control
608 which functions will enter the debugger when called.
610 Complete list of commands:
611 \\{debugger-mode-map}"
612 (kill-all-local-variables)
613 (setq major-mode 'debugger-mode)
614 (setq mode-name "Debugger")
615 (setq truncate-lines t)
616 (set-syntax-table emacs-lisp-mode-syntax-table)
617 (use-local-map debugger-mode-map)
618 (run-mode-hooks 'debugger-mode-hook))
621 (defun debug-on-entry (function)
622 "Request FUNCTION to invoke debugger each time it is called.
623 If you tell the debugger to continue, FUNCTION's execution proceeds.
624 This works by modifying the definition of FUNCTION,
625 which must be written in Lisp, not predefined.
626 Use \\[cancel-debug-on-entry] to cancel the effect of this command.
627 Redefining FUNCTION also cancels it."
628 (interactive "aDebug on entry (to function): ")
630 ;; Handle a function that has been aliased to some other function.
631 (if (and (subrp (symbol-function function))
632 (eq (cdr (subr-arity (symbol-function function))) 'unevalled))
633 (error "Function %s is a special form" function))
634 (if (or (symbolp (symbol-function function))
635 (subrp (symbol-function function)))
636 ;; Create a wrapper in which we can then add the necessary debug call.
637 (fset function `(lambda (&rest debug-on-entry-args)
638 ,(interactive-form (symbol-function function))
639 (apply ',(symbol-function function)
640 debug-on-entry-args))))
641 (or (consp (symbol-function function))
642 (debug-convert-byte-code function))
643 (or (consp (symbol-function function))
644 (error "Definition of %s is not a list" function))
645 (fset function (debug-on-entry-1 function (symbol-function function) t))
646 (or (memq function debug-function-list)
647 (push function debug-function-list))
651 (defun cancel-debug-on-entry (&optional function)
652 "Undo effect of \\[debug-on-entry] on FUNCTION.
653 If argument is nil or an empty string, cancel for all functions."
656 (completing-read "Cancel debug on entry (to function): "
657 (mapcar 'symbol-name debug-function-list)
659 (if name (intern name)))))
661 (if (and function (not (string= function "")))
663 (let ((f (debug-on-entry-1 function (symbol-function function) nil)))
665 (if (and (equal (nth 1 f) '(&rest debug-on-entry-args))
666 (eq (car (nth 3 f)) 'apply))
667 ;; `f' is a wrapper introduced in debug-on-entry.
668 ;; Get rid of it since we don't need it any more.
669 (setq f (nth 1 (nth 1 (nth 3 f)))))
672 (setq debug-function-list (delq function debug-function-list))
674 (message "Cancelling debug-on-entry for all functions")
675 (mapcar 'cancel-debug-on-entry debug-function-list)))
677 (defun debug-convert-byte-code (function)
678 (let ((defn (symbol-function function)))
679 (if (not (consp defn))
680 ;; Assume a compiled code object.
681 (let* ((contents (append defn nil))
683 (list (list 'byte-code (nth 1 contents)
684 (nth 2 contents) (nth 3 contents)))))
685 (if (nthcdr 5 contents)
686 (setq body (cons (list 'interactive (nth 5 contents)) body)))
688 ;; Use `documentation' here, to get the actual string,
689 ;; in case the compiled function has a reference
691 (setq body (cons (documentation function) body)))
692 (fset function (cons 'lambda (cons (car contents) body)))))))
694 (defun debug-on-entry-1 (function defn flag)
696 (error "%s is a built-in function" function)
697 (if (eq (car defn) 'macro)
698 (debug-on-entry-1 function (cdr defn) flag)
699 (or (eq (car defn) 'lambda)
700 (error "%s not user-defined Lisp function" function))
701 (let ((tail (cddr defn)))
702 ;; Skip the docstring.
703 (if (stringp (car tail)) (setq tail (cdr tail)))
704 ;; Skip the interactive form.
705 (if (eq 'interactive (car-safe (car tail))) (setq tail (cdr tail)))
706 (unless (eq flag (equal (car tail) '(debug 'debug)))
707 ;; Add/remove debug statement as needed.
709 (progn (setcar tail (cadr tail))
710 (setcdr tail (cddr tail)))
711 (setcdr tail (cons (car tail) (cdr tail)))
712 (setcar tail '(debug 'debug))))
715 (defun debugger-list-functions ()
716 "Display a list of all the functions now set to debug on entry."
719 (help-setup-xref '(debugger-list-functions) (interactive-p))
720 (with-output-to-temp-buffer (help-buffer)
721 (with-current-buffer standard-output
722 (if (null debug-function-list)
723 (princ "No debug-on-entry functions now\n")
724 (princ "Functions set to debug on entry:\n\n")
725 (dolist (fun debug-function-list)
726 (make-text-button (point) (progn (prin1 fun) (point))
728 'help-args (list fun))
731 (princ "Note: if you have redefined a function, then it may no longer\n")
732 (princ "be set to debug on entry, even if it is in the list.")))))
736 ;; arch-tag: b6ec7047-f801-4103-9c63-d69322db9d3b
737 ;;; debug.el ends here