annotate lisp/emacs-lisp/debug.el @ 10731:65e10f44e765

(debugger-step-after-exit): Variable declared. (debugger-old-buffer, debugger-value): Variables declared.
author Richard M. Stallman <rms@gnu.org>
date Mon, 13 Feb 1995 17:55:17 +0000
parents 48f895a471a2
children 302f676eeca0
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
5545
a908c6a5d8da (debug): Fixed typo.
Roland McGrath <roland@gnu.org>
parents: 5544
diff changeset
3 ;; Copyright (C) 1985, 1986, 1994 Free Software Foundation, Inc.
845
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
10731
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
33 (defvar debugger-step-after-exit nil
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
34 "Non-nil means \"single-step\" after the debugger exits.")
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
35
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
36 (defvar debugger-value nil
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
37 "This is the value for the debugger to return, when it returns.")
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
38
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
39 (defvar debugger-old-buffer nil
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
40 "This is the buffer that was current when the debugger was entered.")
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
41
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
42 (defvar debugger-outer-match-data)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
43 (defvar debugger-outer-track-mouse)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
44 (defvar debugger-outer-last-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
45 (defvar debugger-outer-this-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
46 (defvar debugger-outer-unread-command-char)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
47 (defvar debugger-outer-unread-command-events)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
48 (defvar debugger-outer-last-input-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
49 (defvar debugger-outer-last-command-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
50 (defvar debugger-outer-last-nonmenu-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
51 (defvar debugger-outer-last-event-frame)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
52 (defvar debugger-outer-standard-input)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
53 (defvar debugger-outer-standard-output)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
54 (defvar debugger-outer-cursor-in-echo-area)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
55
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (setq debugger 'debug)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (defun debug (&rest debugger-args)
6048
ff40882c5578 (debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5585
diff changeset
60 "Enter debugger. To return, type \\<debugger-mode-map>`\\[debugger-continue]'.
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 Arguments are mainly for use when this is called from the internals
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 of the evaluator.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 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
65 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
66 first will be printed into the backtrace buffer."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (message "Entering debugger...")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (let (debugger-value
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (debug-on-error nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (debug-on-quit nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (debugger-buffer (let ((default-major-mode 'fundamental-mode))
6567
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
72 (get-buffer-create "*Backtrace*")))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 (debugger-old-buffer (current-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (debugger-step-after-exit nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 ;; Don't keep reading from an executing kbd macro!
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 (executing-macro nil)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
77 ;; Save the outer values of these vars for the `e' command
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
78 ;; before we replace the values.
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
79 (debugger-outer-match-data (match-data))
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
80 (debugger-outer-track-mouse track-mouse)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
81 (debugger-outer-last-command last-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
82 (debugger-outer-this-command this-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
83 (debugger-outer-unread-command-char unread-command-char)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
84 (debugger-outer-unread-command-events unread-command-events)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
85 (debugger-outer-last-input-event last-input-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
86 (debugger-outer-last-command-event last-command-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
87 (debugger-outer-last-nonmenu-event last-nonmenu-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
88 (debugger-outer-last-event-frame last-event-frame)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
89 (debugger-outer-standard-input standard-input)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
90 (debugger-outer-standard-output standard-output)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
91 (debugger-outer-cursor-in-echo-area cursor-in-echo-area))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
92 ;; Don't let these magic variables affect the debugger itself.
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
93 (let ((last-command nil) this-command track-mouse
5585
0c8f4489999d (debug): Bind unread-command-char to -1, not nil.
Richard M. Stallman <rms@gnu.org>
parents: 5545
diff changeset
94 (unread-command-char -1) unread-command-events
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
95 last-input-event last-command-event last-nonmenu-event
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
96 last-event-frame
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
97 (standard-input t) (standard-output t)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
98 (cursor-in-echo-area nil))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
99 (unwind-protect
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
100 (save-excursion
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
101 (save-window-excursion
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
102 (pop-to-buffer debugger-buffer)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
103 (erase-buffer)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
104 (let ((standard-output (current-buffer))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
105 (print-escape-newlines t)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
106 (print-length 50))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
107 (backtrace))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
108 (goto-char (point-min))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
109 (debugger-mode)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
110 (delete-region (point)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
111 (progn
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
112 (search-forward "\n debug(")
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
113 (forward-line 1)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
114 (point)))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
115 (debugger-reenable)
10728
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
116 ;; lambda is for debug-on-call when a function call is next.
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
117 ;; debug is for debug-on-entry function called.
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
118 (cond ((memq (car debugger-args) '(lambda debug))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
119 (insert "Entering:\n")
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
120 (if (eq (car debugger-args) 'debug)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
121 (progn
10728
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
122 ;; Skip the frames for backtrace-debug, byte-code,
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
123 ;; and debug.
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
124 (backtrace-debug 3 t)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
125 (delete-char 1)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
126 (insert ?*)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
127 (beginning-of-line))))
10728
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
128 ;; Exiting a function.
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
129 ((eq (car debugger-args) 'exit)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
130 (insert "Return value: ")
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
131 (setq debugger-value (nth 1 debugger-args))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
132 (prin1 debugger-value (current-buffer))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
133 (insert ?\n)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
134 (delete-char 1)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
135 (insert ? )
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
136 (beginning-of-line))
10728
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
137 ;; Debugger entered for an error.
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
138 ((eq (car debugger-args) 'error)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
139 (insert "Signalling: ")
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
140 (prin1 (nth 1 debugger-args) (current-buffer))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
141 (insert ?\n))
10728
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
142 ;; debug-on-call, when the next thing is an eval.
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
143 ((eq (car debugger-args) t)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
144 (insert "Beginning evaluation of function call form:\n"))
10728
48f895a471a2 (debug): Fix arg to backtrace-debug for debug-on-entry.
Richard M. Stallman <rms@gnu.org>
parents: 10571
diff changeset
145 ;; User calls debug directly.
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
146 (t
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
147 (prin1 (if (eq (car debugger-args) 'nil)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
148 (cdr debugger-args) debugger-args)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
149 (current-buffer))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
150 (insert ?\n)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (message "")
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
152 (let ((inhibit-trace t)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
153 (standard-output nil)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
154 (buffer-read-only t))
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
155 (message "")
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
156 (recursive-edit))))
6567
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
157 ;; Kill or at least neuter the backtrace buffer, so that users
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
158 ;; don't try to execute debugger commands in an invalid context.
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
159 (if (get-buffer-window debugger-buffer 'visible)
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
160 ;; Still visible despite the save-window-excursion? Maybe it
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
161 ;; it's in a pop-up frame. It would be annoying to delete and
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
162 ;; recreate it every time the debugger stops, so instead we'll
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
163 ;; erase it but leave it visible.
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
164 (save-excursion
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
165 (set-buffer debugger-buffer)
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
166 (erase-buffer)
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
167 (fundamental-mode))
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
168 (kill-buffer debugger-buffer))
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
169 (store-match-data debugger-outer-match-data)))
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
170 ;; Put into effect the modified values of these variables
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
171 ;; in case the user set them with the `e' command.
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
172 (setq track-mouse debugger-outer-track-mouse)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
173 (setq last-command debugger-outer-last-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
174 (setq this-command debugger-outer-this-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
175 (setq unread-command-char debugger-outer-unread-command-char)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
176 (setq unread-command-events debugger-outer-unread-command-events)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
177 (setq last-input-event debugger-outer-last-input-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
178 (setq last-command-event debugger-outer-last-command-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
179 (setq last-nonmenu-event debugger-outer-last-nonmenu-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
180 (setq last-event-frame debugger-outer-last-event-frame)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
181 (setq standard-input debugger-outer-standard-input)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
182 (setq standard-output debugger-outer-standard-output)
5545
a908c6a5d8da (debug): Fixed typo.
Roland McGrath <roland@gnu.org>
parents: 5544
diff changeset
183 (setq cursor-in-echo-area debugger-outer-cursor-in-echo-area)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 (setq debug-on-next-call debugger-step-after-exit)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 debugger-value))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (defun debugger-step-through ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 "Proceed, stepping through subexpressions of this expression.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 Enter another debugger on next entry to eval, apply or funcall."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (setq debugger-step-after-exit t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (message "Proceeding, will debug on next eval or call.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (exit-recursive-edit))
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-continue ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 "Continue, evaluating this expression without stopping."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (message "Continuing.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (defun debugger-return-value (val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 "Continue, specifying value to return.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 This is only useful when the value returned from the debugger
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 will be used, such as in a debug on exit from a frame."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (interactive "XReturn value (evaluated): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (setq debugger-value val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (princ "Returning " t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (prin1 debugger-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (defun debugger-jump ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 "Continue to exit from this frame, with all debug-on-entry suspended."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 ;; Compensate for the two extra stack frames for debugger-jump.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (let ((debugger-frame-offset (+ debugger-frame-offset 2)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (debugger-frame))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 ;; Turn off all debug-on-entry functions
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 ;; but leave them in the list.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (debug-on-entry-1 (car list) (symbol-function (car list)) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (message "Continuing through this frame")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (defun debugger-reenable ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 "Turn all debug-on-entry functions back on."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (or (consp (symbol-function (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (debug-convert-byte-code (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (debug-on-entry-1 (car list) (symbol-function (car list)) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (setq list (cdr list)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (defun debugger-frame-number ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 "Return number of frames in backtrace before the one point points at."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (save-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (let ((opoint (point))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (count 0))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (goto-char (point-min))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (if (or (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 "Signal")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 "Return"))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (search-forward ":")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (forward-sexp 1)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (while (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (forward-char 2)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (if (= (following-char) ?\()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (forward-sexp 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (forward-sexp 2))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (<= (point) opoint))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (setq count (1+ count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 ;; Chosen empirically to account for all the frames
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 ;; that will exist when debugger-frame is called
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 ;; within the first one that appears in the backtrace buffer.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 ;; Assumes debugger-frame is called from a key;
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 ;; will be wrong if it is called with Meta-x.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (defconst debugger-frame-offset 8 "")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (defun debugger-frame ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 "Request entry to debugger when this frame exits.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (let ((level (debugger-frame-number)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (backtrace-debug (+ level debugger-frame-offset) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (if (= (following-char) ? )
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (insert ?*)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (defun debugger-frame-clear ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 "Do not enter to debugger when this frame exits.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (let ((level (debugger-frame-number)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (backtrace-debug (+ level debugger-frame-offset) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (if (= (following-char) ?*)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (insert ? )))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (defun debugger-eval-expression (exp)
6468
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
296 "Eval an expression, in an environment like that outside the debugger."
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
297 (interactive
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
298 (list (read-from-minibuffer "Eval: "
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
299 nil read-expression-map t
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
300 'read-expression-history)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 (save-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (if (null (buffer-name debugger-old-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 ;; old buffer deleted
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 (setq debugger-old-buffer (current-buffer)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (set-buffer debugger-old-buffer)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
306 (let ((track-mouse debugger-outer-track-mouse)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
307 (last-command debugger-outer-last-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
308 (this-command debugger-outer-this-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
309 (unread-command-char debugger-outer-unread-command-char)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
310 (unread-command-events debugger-outer-unread-command-events)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
311 (last-input-event debugger-outer-last-input-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
312 (last-command-event debugger-outer-last-command-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
313 (last-nonmenu-event debugger-outer-last-nonmenu-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
314 (last-event-frame debugger-outer-last-event-frame)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
315 (standard-input debugger-outer-standard-input)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
316 (standard-output debugger-outer-standard-output)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
317 (cursor-in-echo-area debugger-outer-cursor-in-echo-area))
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
318 (store-match-data debugger-outer-match-data)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
319 (prog1 (eval-expression exp)
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
320 (setq debugger-outer-match-data (match-data))
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
321 (setq debugger-outer-track-mouse track-mouse)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
322 (setq debugger-outer-last-command last-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
323 (setq debugger-outer-this-command this-command)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
324 (setq debugger-outer-unread-command-char unread-command-char)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
325 (setq debugger-outer-unread-command-events unread-command-events)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
326 (setq debugger-outer-last-input-event last-input-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
327 (setq debugger-outer-last-command-event last-command-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
328 (setq debugger-outer-last-nonmenu-event last-nonmenu-event)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
329 (setq debugger-outer-last-event-frame last-event-frame)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
330 (setq debugger-outer-standard-input standard-input)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
331 (setq debugger-outer-standard-output standard-output)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
332 (setq debugger-outer-cursor-in-echo-area cursor-in-echo-area)))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (defvar debugger-mode-map nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (if debugger-mode-map
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 nil
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (let ((loop ? ))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (setq debugger-mode-map (make-keymap))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (suppress-keymap debugger-mode-map)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (define-key debugger-mode-map "-" 'negative-argument)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (define-key debugger-mode-map "b" 'debugger-frame)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (define-key debugger-mode-map "c" 'debugger-continue)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (define-key debugger-mode-map "j" 'debugger-jump)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (define-key debugger-mode-map "r" 'debugger-return-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (define-key debugger-mode-map "u" 'debugger-frame-clear)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (define-key debugger-mode-map "d" 'debugger-step-through)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 (define-key debugger-mode-map "l" 'debugger-list-functions)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (define-key debugger-mode-map "h" 'describe-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (define-key debugger-mode-map "q" 'top-level)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (define-key debugger-mode-map "e" 'debugger-eval-expression)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (define-key debugger-mode-map " " 'next-line)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (put 'debugger-mode 'mode-class 'special)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (defun debugger-mode ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 "Mode for backtrace buffers, selected in debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 \\<debugger-mode-map>
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 A line starts with `*' if exiting that frame will call the debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 When in debugger due to frame being exited,
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 use the \\[debugger-return-value] command to override the value
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 being returned from that frame.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 which functions will enter the debugger when called.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 Complete list of commands:
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 \\{debugger-mode-map}"
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 (kill-all-local-variables)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 (setq major-mode 'debugger-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (setq mode-name "Debugger")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (setq truncate-lines t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (set-syntax-table emacs-lisp-mode-syntax-table)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (use-local-map debugger-mode-map))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (defun debug-on-entry (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 "Request FUNCTION to invoke debugger each time it is called.
6048
ff40882c5578 (debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5585
diff changeset
380 If you tell the debugger to continue, FUNCTION's execution proceeds.
ff40882c5578 (debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5585
diff changeset
381 This works by modifying the definition of FUNCTION,
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 which must be written in Lisp, not predefined.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 Use \\[cancel-debug-on-entry] to cancel the effect of this command.
6048
ff40882c5578 (debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5585
diff changeset
384 Redefining FUNCTION also cancels it."
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 (interactive "aDebug on entry (to function): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (debugger-reenable)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (if (subrp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (error "Function %s is a primitive" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (debug-convert-byte-code function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 (error "Definition of %s is not a list" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 (fset function (debug-on-entry-1 function (symbol-function function) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 (or (memq function debug-function-list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (setq debug-function-list (cons function debug-function-list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (defun cancel-debug-on-entry (&optional function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 "Undo effect of \\[debug-on-entry] on FUNCTION.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 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
402 (interactive
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
403 (list (let ((name
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
404 (completing-read "Cancel debug on entry (to function): "
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
405 ;; Make an "alist" of the functions
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
406 ;; that now have debug on entry.
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
407 (mapcar 'list
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
408 (mapcar 'symbol-name
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
409 debug-function-list))
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
410 nil t nil)))
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
411 (if name (intern name)))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (debugger-reenable)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (if (and function (not (string= function "")))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (fset function
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (debug-on-entry-1 function (symbol-function function) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (setq debug-function-list (delq function debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (message "Cancelling debug-on-entry for all functions")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (mapcar 'cancel-debug-on-entry debug-function-list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 (defun debug-convert-byte-code (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (let ((defn (symbol-function function)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (if (not (consp defn))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 ;; Assume a compiled code object.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (let* ((contents (append defn nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (body
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (list (list 'byte-code (nth 1 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (nth 2 contents) (nth 3 contents)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (if (nthcdr 5 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (setq body (cons (list 'interactive (nth 5 contents)) body)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (if (nth 4 contents)
10571
0bd8034a4f54 (debug-convert-byte-code): Convert the doc info to a string.
Richard M. Stallman <rms@gnu.org>
parents: 9857
diff changeset
433 ;; Use `documentation' here, to get the actual string,
0bd8034a4f54 (debug-convert-byte-code): Convert the doc info to a string.
Richard M. Stallman <rms@gnu.org>
parents: 9857
diff changeset
434 ;; in case the compiled function has a reference
0bd8034a4f54 (debug-convert-byte-code): Convert the doc info to a string.
Richard M. Stallman <rms@gnu.org>
parents: 9857
diff changeset
435 ;; to the .elc file.
0bd8034a4f54 (debug-convert-byte-code): Convert the doc info to a string.
Richard M. Stallman <rms@gnu.org>
parents: 9857
diff changeset
436 (setq body (cons (documentation function) body)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (fset function (cons 'lambda (cons (car contents) body)))))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (defun debug-on-entry-1 (function defn flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (if (subrp defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (error "%s is a built-in function" function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (if (eq (car defn) 'macro)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (debug-on-entry-1 function (cdr defn) flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (or (eq (car defn) 'lambda)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (error "%s not user-defined Lisp function" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (let (tail prec)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (if (stringp (car (nthcdr 2 defn)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (setq tail (nthcdr 3 defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 prec (list (car defn) (car (cdr defn))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 (car (cdr (cdr defn)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (setq tail (nthcdr 2 defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 prec (list (car defn) (car (cdr defn)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (if (eq flag (equal (car tail) '(debug 'debug)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 defn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (if flag
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (nconc prec (cons '(debug 'debug) tail))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (nconc prec (cdr tail))))))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (defun debugger-list-functions ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 "Display a list of all the functions now set to debug on entry."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 (with-output-to-temp-buffer "*Help*"
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (if (null debug-function-list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 (princ "No debug-on-entry functions now\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 (princ "Functions set to debug on entry:\n\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (prin1 (car list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (terpri)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (princ "Note: if you have redefined a function, then it may no longer\n")
9857
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
472 (princ "be set to debug on entry, even if it is in the list."))
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
473 (save-excursion
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
474 (set-buffer standard-output)
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
475 (help-mode))))
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
476
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
477 ;;; debug.el ends here