annotate lisp/emacs-lisp/debug.el @ 3267:ac18ead9965d

(cancel-function-timers): Renamed from spurious duplicate definition of cancel-timer.
author Richard M. Stallman <rms@gnu.org>
date Sat, 29 May 1993 20:43:41 +0000
parents 10e417efb12a
children db0ab86f381a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
1 ;;; debug.el --- debuggers and related commands for Emacs
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
2
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
3 ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
5 ;; Maintainer: FSF
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 845
diff changeset
6 ;; Keywords: lisp, tools, maint
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
7
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; any later version.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
24 ;;; Commentary:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
25
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
26 ;; This is a major mode documented in the Emacs manual.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
27
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
28 ;;; Code:
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 (defvar debug-function-list nil
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 "List of functions currently set for debug on entry.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 (setq debugger 'debug)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 (defun debug (&rest debugger-args)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 "Enter debugger. Returns if user says \"continue\".
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 Arguments are mainly for use when this is called from the internals
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 of the evaluator.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 You may call with no args, or you may pass nil as the first arg and
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 any other args you like. In that case, the list of args after the
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 first will be printed into the backtrace buffer."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 (message "Entering debugger...")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 (let (debugger-value
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 (debugger-match-data (match-data))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 (debug-on-error nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (debug-on-quit nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (debugger-buffer (let ((default-major-mode 'fundamental-mode))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 (generate-new-buffer "*Backtrace*")))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (debugger-old-buffer (current-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (debugger-step-after-exit nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 ;; Don't keep reading from an executing kbd macro!
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (executing-macro nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (cursor-in-echo-area nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (unwind-protect
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (save-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (save-window-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (pop-to-buffer debugger-buffer)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (erase-buffer)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (let ((standard-output (current-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 (print-escape-newlines t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (print-length 50))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 (backtrace))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 (goto-char (point-min))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 (debugger-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (delete-region (point)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (search-forward "\n debug(")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (point)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (debugger-reenable)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 (cond ((memq (car debugger-args) '(lambda debug))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (insert "Entering:\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 (if (eq (car debugger-args) 'debug)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 (backtrace-debug 4 t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 (insert ?*)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (beginning-of-line))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 ((eq (car debugger-args) 'exit)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (insert "Return value: ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (setq debugger-value (nth 1 debugger-args))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 (prin1 debugger-value (current-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (insert ?\n)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 (insert ? )
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 ((eq (car debugger-args) 'error)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 (insert "Signalling: ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 (prin1 (nth 1 debugger-args) (current-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 (insert ?\n))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 ((eq (car debugger-args) t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (insert "Beginning evaluation of function call form:\n"))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 (t
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (prin1 (if (eq (car debugger-args) 'nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 (cdr debugger-args) debugger-args)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 (current-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (insert ?\n)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (message "")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (let ((inhibit-trace t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (standard-output nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (buffer-read-only t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (message "")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 (recursive-edit))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 ;; So that users do not try to execute debugger commands
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 ;; in an invalid context
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 (kill-buffer debugger-buffer)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (store-match-data debugger-match-data))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (setq debug-on-next-call debugger-step-after-exit)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 debugger-value))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (defun debugger-step-through ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 "Proceed, stepping through subexpressions of this expression.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 Enter another debugger on next entry to eval, apply or funcall."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (setq debugger-step-after-exit t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (message "Proceeding, will debug on next eval or call.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (defun debugger-continue ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 "Continue, evaluating this expression without stopping."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (message "Continuing.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (defun debugger-return-value (val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 "Continue, specifying value to return.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 This is only useful when the value returned from the debugger
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 will be used, such as in a debug on exit from a frame."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 (interactive "XReturn value (evaluated): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (setq debugger-value val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (princ "Returning " t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (prin1 debugger-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (defun debugger-jump ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 "Continue to exit from this frame, with all debug-on-entry suspended."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 ;; Compensate for the two extra stack frames for debugger-jump.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (let ((debugger-frame-offset (+ debugger-frame-offset 2)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (debugger-frame))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 ;; Turn off all debug-on-entry functions
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 ;; but leave them in the list.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (debug-on-entry-1 (car list) (symbol-function (car list)) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (message "Continuing through this frame")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (defun debugger-reenable ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 "Turn all debug-on-entry functions back on."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (or (consp (symbol-function (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 (debug-convert-byte-code (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (debug-on-entry-1 (car list) (symbol-function (car list)) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 (setq list (cdr list)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (defun debugger-frame-number ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 "Return number of frames in backtrace before the one point points at."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 (save-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (let ((opoint (point))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (count 0))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (goto-char (point-min))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (if (or (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 "Signal")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 "Return"))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (search-forward ":")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (forward-sexp 1)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (while (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (forward-char 2)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (if (= (following-char) ?\()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (forward-sexp 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (forward-sexp 2))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 (<= (point) opoint))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (setq count (1+ count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 ;; Chosen empirically to account for all the frames
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 ;; that will exist when debugger-frame is called
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 ;; within the first one that appears in the backtrace buffer.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 ;; Assumes debugger-frame is called from a key;
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 ;; will be wrong if it is called with Meta-x.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (defconst debugger-frame-offset 8 "")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (defun debugger-frame ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 "Request entry to debugger when this frame exits.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (let ((level (debugger-frame-number)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (backtrace-debug (+ level debugger-frame-offset) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (if (= (following-char) ? )
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (insert ?*)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (defun debugger-frame-clear ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 "Do not enter to debugger when this frame exits.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (let ((level (debugger-frame-number)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (backtrace-debug (+ level debugger-frame-offset) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (if (= (following-char) ?*)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (insert ? )))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (defun debugger-eval-expression (exp)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (interactive "xEval: ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (save-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (if (null (buffer-name debugger-old-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 ;; old buffer deleted
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (setq debugger-old-buffer (current-buffer)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (set-buffer debugger-old-buffer)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (eval-expression exp)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (defvar debugger-mode-map nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (if debugger-mode-map
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 nil
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (let ((loop ? ))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (setq debugger-mode-map (make-keymap))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (suppress-keymap debugger-mode-map)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (define-key debugger-mode-map "-" 'negative-argument)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (define-key debugger-mode-map "b" 'debugger-frame)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (define-key debugger-mode-map "c" 'debugger-continue)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (define-key debugger-mode-map "j" 'debugger-jump)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (define-key debugger-mode-map "r" 'debugger-return-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (define-key debugger-mode-map "u" 'debugger-frame-clear)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (define-key debugger-mode-map "d" 'debugger-step-through)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (define-key debugger-mode-map "l" 'debugger-list-functions)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (define-key debugger-mode-map "h" 'describe-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 (define-key debugger-mode-map "q" 'top-level)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 (define-key debugger-mode-map "e" 'debugger-eval-expression)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (define-key debugger-mode-map " " 'next-line)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (put 'debugger-mode 'mode-class 'special)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (defun debugger-mode ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 "Mode for backtrace buffers, selected in debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 \\<debugger-mode-map>
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 A line starts with `*' if exiting that frame will call the debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 When in debugger due to frame being exited,
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 use the \\[debugger-return-value] command to override the value
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 being returned from that frame.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 which functions will enter the debugger when called.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 Complete list of commands:
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 \\{debugger-mode-map}"
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (kill-all-local-variables)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (setq major-mode 'debugger-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (setq mode-name "Debugger")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (setq truncate-lines t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 (set-syntax-table emacs-lisp-mode-syntax-table)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (use-local-map debugger-mode-map))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (defun debug-on-entry (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 "Request FUNCTION to invoke debugger each time it is called.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 If the user continues, FUNCTION's execution proceeds.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 Works by modifying the definition of FUNCTION,
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 which must be written in Lisp, not predefined.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 Use \\[cancel-debug-on-entry] to cancel the effect of this command.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 Redefining FUNCTION also does that."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (interactive "aDebug on entry (to function): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (debugger-reenable)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (if (subrp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (error "Function %s is a primitive" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (debug-convert-byte-code function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (error "Definition of %s is not a list" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (fset function (debug-on-entry-1 function (symbol-function function) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (or (memq function debug-function-list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (setq debug-function-list (cons function debug-function-list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (defun cancel-debug-on-entry (&optional function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 "Undo effect of \\[debug-on-entry] on FUNCTION.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 If argument is nil or an empty string, cancel for all functions."
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
298 (interactive
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
299 (list (let ((name
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
300 (completing-read "Cancel debug on entry (to function): "
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
301 ;; Make an "alist" of the functions
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
302 ;; that now have debug on entry.
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
303 (mapcar 'list
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
304 (mapcar 'symbol-name
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
305 debug-function-list))
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
306 nil t nil)))
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
307 (if name (intern name)))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 (debugger-reenable)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (if (and function (not (string= function "")))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (fset function
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (debug-on-entry-1 function (symbol-function function) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (setq debug-function-list (delq function debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (message "Cancelling debug-on-entry for all functions")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (mapcar 'cancel-debug-on-entry debug-function-list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (defun debug-convert-byte-code (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (let ((defn (symbol-function function)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (if (not (consp defn))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 ;; Assume a compiled code object.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (let* ((contents (append defn nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (body
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (list (list 'byte-code (nth 1 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (nth 2 contents) (nth 3 contents)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (if (nthcdr 5 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (setq body (cons (list 'interactive (nth 5 contents)) body)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (if (nth 4 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (setq body (cons (nth 4 contents) body)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (fset function (cons 'lambda (cons (car contents) body)))))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 (defun debug-on-entry-1 (function defn flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (if (subrp defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (error "%s is a built-in function" function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (if (eq (car defn) 'macro)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (debug-on-entry-1 function (cdr defn) flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (or (eq (car defn) 'lambda)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (error "%s not user-defined Lisp function" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (let (tail prec)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (if (stringp (car (nthcdr 2 defn)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (setq tail (nthcdr 3 defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 prec (list (car defn) (car (cdr defn))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (car (cdr (cdr defn)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (setq tail (nthcdr 2 defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 prec (list (car defn) (car (cdr defn)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (if (eq flag (equal (car tail) '(debug 'debug)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 defn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (if flag
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (nconc prec (cons '(debug 'debug) tail))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (nconc prec (cdr tail))))))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (defun debugger-list-functions ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 "Display a list of all the functions now set to debug on entry."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (with-output-to-temp-buffer "*Help*"
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 (if (null debug-function-list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 (princ "No debug-on-entry functions now\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 (princ "Functions set to debug on entry:\n\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 (prin1 (car list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 (terpri)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 (princ "Note: if you have redefined a function, then it may no longer\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (princ "be set to debug on entry, even if it is in the list."))))
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
366
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
367 ;;; debug.el ends here