annotate lisp/emacs-lisp/debug.el @ 28872:2284937b58f4

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Thu, 11 May 2000 12:23:55 +0000
parents 5385b12ef9a8
children 87996dd441b7
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13955
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13955
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13955
diff changeset
23 ;; Boston, MA 02111-1307, USA.
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
25 ;;; Commentary:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
26
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
27 ;; 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
28
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
29 ;;; Code:
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
31 (defgroup debugger nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
32 "Debuggers and related commands for Emacs."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
33 :prefix "debugger-"
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
34 :group 'debug)
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
35
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
36 (defcustom debugger-mode-hook nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
37 "*Hooks run when `debugger-mode' is turned on."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
38 :type 'hook
21669
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
39 :group 'debugger
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
40 :version "20.3")
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
41
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
42 (defcustom debugger-batch-max-lines 40
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
43 "*Maximum lines to show in debugger buffer in a noninteractive Emacs.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
44 When the debugger is entered and Emacs is running in batch mode,
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
45 if the backtrace text has more than this many lines,
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
46 the middle is discarded, and just the beginning and end are displayed."
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
47 :type 'integer
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
48 :group 'debugger
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
49 :version "21.1")
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
50
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
51 (defcustom debug-function-list nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
52 "List of functions currently set for debug on entry."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
53 :type '(repeat function)
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
54 :group 'debugger)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
56 (defcustom debugger-step-after-exit nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
57 "Non-nil means \"single-step\" after the debugger exits."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
58 :type 'boolean
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
59 :group 'debugger)
10731
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
60
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
61 (defvar debugger-value nil
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
62 "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
63
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
64 (defvar debugger-old-buffer nil
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
65 "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
66
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
67 (defvar debugger-outer-match-data)
11062
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
68 (defvar debugger-outer-load-read-function)
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
69 (defvar debugger-outer-overriding-local-map)
18166
84c0a412aa71 (debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents: 17262
diff changeset
70 (defvar debugger-outer-overriding-terminal-local-map)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
71 (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
72 (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
73 (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
74 (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
75 (defvar debugger-outer-unread-command-events)
22921
48b85e4a4dd3 (debugger-outer-unread-post-input-method-events): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22114
diff changeset
76 (defvar debugger-outer-unread-post-input-method-events)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
77 (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
78 (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
79 (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
80 (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
81 (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
82 (defvar debugger-outer-standard-output)
24741
00ef85c8a0ff (debugger-outer-inhibit-redisplay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24524
diff changeset
83 (defvar debugger-outer-inhibit-redisplay)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
84 (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
85
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 (setq debugger 'debug)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 (defun debug (&rest debugger-args)
6048
ff40882c5578 (debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5585
diff changeset
90 "Enter debugger. To return, type \\<debugger-mode-map>`\\[debugger-continue]'.
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 Arguments are mainly for use when this is called from the internals
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 of the evaluator.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 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
95 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
96 first will be printed into the backtrace buffer."
11069
ee94cf4fd05a (debug): Now interactive.
Richard M. Stallman <rms@gnu.org>
parents: 11062
diff changeset
97 (interactive)
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
98 (unless noninteractive
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
99 (message "Entering debugger..."))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (let (debugger-value
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (debug-on-error nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (debug-on-quit nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (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
104 (get-buffer-create "*Backtrace*")))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 (debugger-old-buffer (current-buffer))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (debugger-step-after-exit nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 ;; Don't keep reading from an executing kbd macro!
15302
c23c9712ef5c Use executing-kbd-macro, not executing-macro.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
108 (executing-kbd-macro nil)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
109 ;; 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
110 ;; before we replace the values.
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
111 (debugger-outer-match-data (match-data))
11062
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
112 (debugger-outer-load-read-function load-read-function)
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
113 (debugger-outer-overriding-local-map overriding-local-map)
18166
84c0a412aa71 (debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents: 17262
diff changeset
114 (debugger-outer-overriding-terminal-local-map
84c0a412aa71 (debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents: 17262
diff changeset
115 overriding-terminal-local-map)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
116 (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
117 (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
118 (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
119 (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
120 (debugger-outer-unread-command-events unread-command-events)
22921
48b85e4a4dd3 (debugger-outer-unread-post-input-method-events): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22114
diff changeset
121 (debugger-outer-unread-post-input-method-events
48b85e4a4dd3 (debugger-outer-unread-post-input-method-events): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22114
diff changeset
122 unread-post-input-method-events)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
123 (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
124 (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
125 (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
126 (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
127 (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
128 (debugger-outer-standard-output standard-output)
24741
00ef85c8a0ff (debugger-outer-inhibit-redisplay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24524
diff changeset
129 (debugger-outer-inhibit-redisplay inhibit-redisplay)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
130 (debugger-outer-cursor-in-echo-area cursor-in-echo-area))
18190
bca8e581535a (debug): Set overriding-terminal-local-map to nil,
Richard M. Stallman <rms@gnu.org>
parents: 18166
diff changeset
131 ;; Set this instead of binding it, so that `q'
bca8e581535a (debug): Set overriding-terminal-local-map to nil,
Richard M. Stallman <rms@gnu.org>
parents: 18166
diff changeset
132 ;; will not restore it.
26428
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
133 (setq overriding-terminal-local-map nil)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
134 ;; 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
135 (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
136 (unread-command-char -1) unread-command-events
22921
48b85e4a4dd3 (debugger-outer-unread-post-input-method-events): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22114
diff changeset
137 unread-post-input-method-events
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
138 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
139 last-event-frame
11062
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
140 overriding-local-map
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
141 load-read-function
19889
3e6802bae367 (debug): Allow recursive minibuffers if we're in a minibuffer already.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
142 ;; If we are inside a minibuffer, allow nesting
3e6802bae367 (debug): Allow recursive minibuffers if we're in a minibuffer already.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
143 ;; so that we don't get an error from the `e' command.
23988
571d2c4f3edf (debug): Leave recursive minibuffer enabled
Andreas Schwab <schwab@suse.de>
parents: 22921
diff changeset
144 (enable-recursive-minibuffers
571d2c4f3edf (debug): Leave recursive minibuffer enabled
Andreas Schwab <schwab@suse.de>
parents: 22921
diff changeset
145 (or enable-recursive-minibuffers (> (minibuffer-depth) 0)))
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
146 (standard-input t) (standard-output t)
24741
00ef85c8a0ff (debugger-outer-inhibit-redisplay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24524
diff changeset
147 inhibit-redisplay
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
148 (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
149 (unwind-protect
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
150 (save-excursion
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
151 (save-window-excursion
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
152 (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
153 (debugger-mode)
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
154 (debugger-setup-buffer debugger-args)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
155 (when noninteractive
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
156 ;; If the backtrace is long, save the beginning
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
157 ;; and the end, but discard the middle.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
158 (when (> (count-lines (point-min) (point-max))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
159 debugger-batch-max-lines)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
160 (goto-char (point-min))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
161 (forward-line (/ 2 debugger-batch-max-lines))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
162 (let ((middlestart (point)))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
163 (goto-char (point-max))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
164 (forward-line (- (/ 2 debugger-batch-max-lines)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
165 debugger-batch-max-lines))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
166 (delete-region middlestart (point)))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
167 (insert "...\n"))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
168 (goto-char (point-min))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
169 (message (buffer-string))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
170 (kill-emacs))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
171 (if (eq (car debugger-args) 'debug)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
172 ;; Skip the frames for backtrace-debug, byte-code, and debug.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
173 (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
174 (debugger-reenable)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (message "")
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
176 (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
177 (standard-output nil)
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
178 (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
179 (message "")
17262
76bfab081263 (debug): Use save-excursion inside the binding of buffer-read-only.
Richard M. Stallman <rms@gnu.org>
parents: 17003
diff changeset
180 ;; Make sure we unbind buffer-read-only in the right buffer.
76bfab081263 (debug): Use save-excursion inside the binding of buffer-read-only.
Richard M. Stallman <rms@gnu.org>
parents: 17003
diff changeset
181 (save-excursion
76bfab081263 (debug): Use save-excursion inside the binding of buffer-read-only.
Richard M. Stallman <rms@gnu.org>
parents: 17003
diff changeset
182 (recursive-edit)))))
6567
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
183 ;; 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
184 ;; 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
185 (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
186 ;; 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
187 ;; 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
188 ;; 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
189 ;; 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
190 (save-excursion
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
191 (set-buffer debugger-buffer)
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
192 (erase-buffer)
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
193 (fundamental-mode))
baf8fe0c51e3 (debug): Behave sensibly if pop-up-frames is set.
Karl Heuer <kwzh@gnu.org>
parents: 6468
diff changeset
194 (kill-buffer debugger-buffer))
21161
37f271ee9f6f (debug, debugger-env-macro): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents: 20885
diff changeset
195 (set-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
196 ;; 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
197 ;; in case the user set them with the `e' command.
11062
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
198 (setq load-read-function debugger-outer-load-read-function)
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
199 (setq overriding-local-map debugger-outer-overriding-local-map)
18166
84c0a412aa71 (debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents: 17262
diff changeset
200 (setq overriding-terminal-local-map
84c0a412aa71 (debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents: 17262
diff changeset
201 debugger-outer-overriding-terminal-local-map)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
202 (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
203 (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
204 (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
205 (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
206 (setq unread-command-events debugger-outer-unread-command-events)
22921
48b85e4a4dd3 (debugger-outer-unread-post-input-method-events): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22114
diff changeset
207 (setq unread-post-input-method-events
48b85e4a4dd3 (debugger-outer-unread-post-input-method-events): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22114
diff changeset
208 debugger-outer-unread-post-input-method-events)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
209 (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
210 (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
211 (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
212 (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
213 (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
214 (setq standard-output debugger-outer-standard-output)
24741
00ef85c8a0ff (debugger-outer-inhibit-redisplay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24524
diff changeset
215 (setq inhibit-redisplay debugger-outer-inhibit-redisplay)
5545
a908c6a5d8da (debug): Fixed typo.
Roland McGrath <roland@gnu.org>
parents: 5544
diff changeset
216 (setq cursor-in-echo-area debugger-outer-cursor-in-echo-area)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (setq debug-on-next-call debugger-step-after-exit)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 debugger-value))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
220 (defun debugger-setup-buffer (debugger-args)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
221 "Initialize the `*Backtrace*' buffer for entry to the debugger.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
222 That buffer should be current already."
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
223 (setq buffer-read-only nil)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
224 (erase-buffer)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
225 (set-buffer-multibyte nil)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
226 (let ((standard-output (current-buffer))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
227 (print-escape-newlines t)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
228 (print-level 8)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
229 (print-length 50))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
230 (backtrace))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
231 (goto-char (point-min))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
232 (delete-region (point)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
233 (progn
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
234 (search-forward "\n debug(")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
235 (forward-line 1)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
236 (point)))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
237 (insert "Debugger entered")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
238 ;; lambda is for debug-on-call when a function call is next.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
239 ;; debug is for debug-on-entry function called.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
240 (cond ((memq (car debugger-args) '(lambda debug))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
241 (insert "--entering a function:\n")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
242 (if (eq (car debugger-args) 'debug)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
243 (progn
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
244 (delete-char 1)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
245 (insert ?*)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
246 (beginning-of-line))))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
247 ;; Exiting a function.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
248 ((eq (car debugger-args) 'exit)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
249 (insert "--returning value: ")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
250 (setq debugger-value (nth 1 debugger-args))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
251 (prin1 debugger-value (current-buffer))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
252 (insert ?\n)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
253 (delete-char 1)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
254 (insert ? )
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
255 (beginning-of-line))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
256 ;; Debugger entered for an error.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
257 ((eq (car debugger-args) 'error)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
258 (insert "--Lisp error: ")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
259 (prin1 (nth 1 debugger-args) (current-buffer))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
260 (insert ?\n))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
261 ;; debug-on-call, when the next thing is an eval.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
262 ((eq (car debugger-args) t)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
263 (insert "--beginning evaluation of function call form:\n"))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
264 ;; User calls debug directly.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
265 (t
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
266 (insert ": ")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
267 (prin1 (if (eq (car debugger-args) 'nil)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
268 (cdr debugger-args) debugger-args)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
269 (current-buffer))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
270 (insert ?\n))))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
271
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (defun debugger-step-through ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 "Proceed, stepping through subexpressions of this expression.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 Enter another debugger on next entry to eval, apply or funcall."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (setq debugger-step-after-exit t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (message "Proceeding, will debug on next eval or call.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (defun debugger-continue ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 "Continue, evaluating this expression without stopping."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (interactive)
26948
5385b12ef9a8 (debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents: 26428
diff changeset
283 (unless debugger-may-continue
5385b12ef9a8 (debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents: 26428
diff changeset
284 (error "Cannot continue"))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (message "Continuing.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (defun debugger-return-value (val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 "Continue, specifying value to return.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 This is only useful when the value returned from the debugger
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 will be used, such as in a debug on exit from a frame."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (interactive "XReturn value (evaluated): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (setq debugger-value val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (princ "Returning " t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (prin1 debugger-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
298 ;; Chosen empirically to account for all the frames
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
299 ;; that will exist when debugger-frame is called
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
300 ;; within the first one that appears in the backtrace buffer.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
301 ;; Assumes debugger-frame is called from a key;
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
302 ;; will be wrong if it is called with Meta-x.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
303 (defconst debugger-frame-offset 8 "")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
304
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (defun debugger-jump ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 "Continue to exit from this frame, with all debug-on-entry suspended."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 ;; Compensate for the two extra stack frames for debugger-jump.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (let ((debugger-frame-offset (+ debugger-frame-offset 2)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (debugger-frame))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 ;; Turn off all debug-on-entry functions
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 ;; but leave them in the list.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (debug-on-entry-1 (car list) (symbol-function (car list)) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (message "Continuing through this frame")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (defun debugger-reenable ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 "Turn all debug-on-entry functions back on."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (or (consp (symbol-function (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (debug-convert-byte-code (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (debug-on-entry-1 (car list) (symbol-function (car list)) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (setq list (cdr list)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (defun debugger-frame-number ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 "Return number of frames in backtrace before the one point points at."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (save-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (let ((opoint (point))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (count 0))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (goto-char (point-min))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (if (or (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 "Signal")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 "Return"))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (search-forward ":")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (forward-sexp 1)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (while (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 (forward-char 2)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (if (= (following-char) ?\()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (forward-sexp 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (forward-sexp 2))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (<= (point) opoint))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (setq count (1+ count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 (defun debugger-frame ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 "Request entry to debugger when this frame exits.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 (let ((level (debugger-frame-number)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 (backtrace-debug (+ level debugger-frame-offset) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 (if (= (following-char) ? )
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (insert ?*)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 (defun debugger-frame-clear ()
22114
0fbcff056c0f (debugger-frame-clear): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21669
diff changeset
370 "Do not enter debugger when this frame exits.
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (let ((level (debugger-frame-number)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (backtrace-debug (+ level debugger-frame-offset) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (if (= (following-char) ?*)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (insert ? )))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
382
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
383
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
384 (put 'debugger-env-macro 'lisp-indent-function 0)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
385 (defmacro debugger-env-macro (&rest body)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
386 "Run BODY in original environment."
26428
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
387 `(save-excursion
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
388 (if (null (buffer-name debugger-old-buffer))
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
389 ;; old buffer deleted
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
390 (setq debugger-old-buffer (current-buffer)))
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
391 (set-buffer debugger-old-buffer)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
392 (let ((load-read-function debugger-outer-load-read-function)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
393 (overriding-terminal-local-map
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
394 debugger-outer-overriding-terminal-local-map)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
395 (overriding-local-map debugger-outer-overriding-local-map)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
396 (track-mouse debugger-outer-track-mouse)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
397 (last-command debugger-outer-last-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
398 (this-command debugger-outer-this-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
399 (unread-command-char debugger-outer-unread-command-char)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
400 (unread-command-events debugger-outer-unread-command-events)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
401 (unread-post-input-method-events
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
402 debugger-outer-unread-post-input-method-events)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
403 (last-input-event debugger-outer-last-input-event)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
404 (last-command-event debugger-outer-last-command-event)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
405 (last-nonmenu-event debugger-outer-last-nonmenu-event)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
406 (last-event-frame debugger-outer-last-event-frame)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
407 (standard-input debugger-outer-standard-input)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
408 (standard-output debugger-outer-standard-output)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
409 (inhibit-redisplay debugger-outer-inhibit-redisplay)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
410 (cursor-in-echo-area debugger-outer-cursor-in-echo-area))
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
411 (set-match-data debugger-outer-match-data)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
412 (prog1 (progn ,@body)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
413 (setq debugger-outer-match-data (match-data))
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
414 (setq debugger-outer-load-read-function load-read-function)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
415 (setq debugger-outer-overriding-terminal-local-map
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
416 overriding-terminal-local-map)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
417 (setq debugger-outer-overriding-local-map overriding-local-map)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
418 (setq debugger-outer-track-mouse track-mouse)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
419 (setq debugger-outer-last-command last-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
420 (setq debugger-outer-this-command this-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
421 (setq debugger-outer-unread-command-char unread-command-char)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
422 (setq debugger-outer-unread-command-events unread-command-events)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
423 (setq debugger-outer-unread-post-input-method-events
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
424 unread-post-input-method-events)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
425 (setq debugger-outer-last-input-event last-input-event)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
426 (setq debugger-outer-last-command-event last-command-event)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
427 (setq debugger-outer-last-nonmenu-event last-nonmenu-event)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
428 (setq debugger-outer-last-event-frame last-event-frame)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
429 (setq debugger-outer-standard-input standard-input)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
430 (setq debugger-outer-standard-output standard-output)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
431 (setq debugger-outer-inhibit-redisplay inhibit-redisplay)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
432 (setq debugger-outer-cursor-in-echo-area cursor-in-echo-area)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
433 ))))
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
434
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (defun debugger-eval-expression (exp)
6468
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
436 "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
437 (interactive
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
438 (list (read-from-minibuffer "Eval: "
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
439 nil read-expression-map t
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
440 'read-expression-history)))
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
441 (debugger-env-macro (eval-expression exp)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (defvar debugger-mode-map nil)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (if debugger-mode-map
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 nil
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (let ((loop ? ))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (setq debugger-mode-map (make-keymap))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (suppress-keymap debugger-mode-map)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (define-key debugger-mode-map "-" 'negative-argument)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 (define-key debugger-mode-map "b" 'debugger-frame)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (define-key debugger-mode-map "c" 'debugger-continue)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (define-key debugger-mode-map "j" 'debugger-jump)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (define-key debugger-mode-map "r" 'debugger-return-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 (define-key debugger-mode-map "u" 'debugger-frame-clear)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (define-key debugger-mode-map "d" 'debugger-step-through)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (define-key debugger-mode-map "l" 'debugger-list-functions)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (define-key debugger-mode-map "h" 'describe-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 (define-key debugger-mode-map "q" 'top-level)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (define-key debugger-mode-map "e" 'debugger-eval-expression)
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
460 (define-key debugger-mode-map " " 'next-line)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
461 (define-key debugger-mode-map "R" 'debugger-record-expression)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
462 ))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
463
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
464
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
465 (defcustom debugger-record-buffer "*Debugger-record*"
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
466 "*Buffer name for expression values, for \\[debugger-record-expression]."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
467 :type 'string
21669
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
468 :group 'debugger
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
469 :version "20.3")
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
470
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
471 (defun debugger-record-expression (exp)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
472 "Display a variable's value and record it in `*Backtrace-record*' buffer."
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
473 (interactive
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
474 (list (read-from-minibuffer
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
475 "Record Eval: "
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
476 nil
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
477 read-expression-map t
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
478 'read-expression-history)))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
479 (let* ((buffer (get-buffer-create debugger-record-buffer))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
480 (standard-output buffer))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
481 (princ (format "Debugger Eval (%s): " exp))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
482 (princ (debugger-eval-expression exp))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
483 (terpri))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
484
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
485 (with-current-buffer (get-buffer debugger-record-buffer)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
486 (save-excursion
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
487 (forward-line -1)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
488 (message
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
489 (buffer-substring (point) (progn (end-of-line) (point)))))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 (put 'debugger-mode 'mode-class 'special)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 (defun debugger-mode ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 "Mode for backtrace buffers, selected in debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 \\<debugger-mode-map>
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 A line starts with `*' if exiting that frame will call the debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 When in debugger due to frame being exited,
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 use the \\[debugger-return-value] command to override the value
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 being returned from that frame.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 which functions will enter the debugger when called.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 Complete list of commands:
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 \\{debugger-mode-map}"
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
508 (kill-all-local-variables)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (setq major-mode 'debugger-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 (setq mode-name "Debugger")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (setq truncate-lines t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 (set-syntax-table emacs-lisp-mode-syntax-table)
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
513 (use-local-map debugger-mode-map)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
514 (run-hooks 'debugger-mode-hook))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (defun debug-on-entry (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 "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
519 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
520 This works by modifying the definition of FUNCTION,
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 which must be written in Lisp, not predefined.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 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
523 Redefining FUNCTION also cancels it."
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (interactive "aDebug on entry (to function): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (debugger-reenable)
20404
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
526 ;; Handle a function that has been aliased to some other function.
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
527 (if (symbolp (symbol-function function))
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
528 (fset function `(lambda (&rest debug-on-entry-args)
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
529 (apply ',(symbol-function function)
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
530 debug-on-entry-args))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 (if (subrp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (error "Function %s is a primitive" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 (debug-convert-byte-code function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 (error "Definition of %s is not a list" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 (fset function (debug-on-entry-1 function (symbol-function function) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 (or (memq function debug-function-list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 (setq debug-function-list (cons function debug-function-list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 (defun cancel-debug-on-entry (&optional function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 "Undo effect of \\[debug-on-entry] on FUNCTION.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 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
546 (interactive
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
547 (list (let ((name
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
548 (completing-read "Cancel debug on entry (to function): "
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
549 ;; Make an "alist" of the functions
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
550 ;; that now have debug on entry.
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
551 (mapcar 'list
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
552 (mapcar 'symbol-name
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
553 debug-function-list))
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
554 nil t nil)))
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
555 (if name (intern name)))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (debugger-reenable)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (if (and function (not (string= function "")))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (fset function
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (debug-on-entry-1 function (symbol-function function) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (setq debug-function-list (delq function debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 (message "Cancelling debug-on-entry for all functions")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 (mapcar 'cancel-debug-on-entry debug-function-list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 (defun debug-convert-byte-code (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 (let ((defn (symbol-function function)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 (if (not (consp defn))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 ;; Assume a compiled code object.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (let* ((contents (append defn nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 (body
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 (list (list 'byte-code (nth 1 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (nth 2 contents) (nth 3 contents)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 (if (nthcdr 5 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 (setq body (cons (list 'interactive (nth 5 contents)) body)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 (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
577 ;; 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
578 ;; 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
579 ;; 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
580 (setq body (cons (documentation function) body)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (fset function (cons 'lambda (cons (car contents) body)))))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 (defun debug-on-entry-1 (function defn flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (if (subrp defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (error "%s is a built-in function" function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (if (eq (car defn) 'macro)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 (debug-on-entry-1 function (cdr defn) flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (or (eq (car defn) 'lambda)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 (error "%s not user-defined Lisp function" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 (let (tail prec)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 (if (stringp (car (nthcdr 2 defn)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 (setq tail (nthcdr 3 defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 prec (list (car defn) (car (cdr defn))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (car (cdr (cdr defn)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 (setq tail (nthcdr 2 defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 prec (list (car defn) (car (cdr defn)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 (if (eq flag (equal (car tail) '(debug 'debug)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 defn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 (if flag
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 (nconc prec (cons '(debug 'debug) tail))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 (nconc prec (cdr tail))))))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 (defun debugger-list-functions ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 "Display a list of all the functions now set to debug on entry."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (with-output-to-temp-buffer "*Help*"
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 (if (null debug-function-list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 (princ "No debug-on-entry functions now\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (princ "Functions set to debug on entry:\n\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 (prin1 (car list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 (terpri)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 (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
616 (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
617 (save-excursion
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
618 (set-buffer standard-output)
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
619 (help-mode))))
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
620
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 18190
diff changeset
621 (provide 'debug)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 18190
diff changeset
622
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
623 ;;; debug.el ends here