annotate lisp/emacs-lisp/debug.el @ 53109:420dc7ac8867

(File Attributes): Describe new parameter ID-FORMAT.
author Lars Hansen <larsh@soem.dk>
date Fri, 21 Nov 2003 18:25:20 +0000
parents 695cf19ef79e
children f9293296e0cb 375f2633d815
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
51588
fc00b549e161 (debug): Fix call to message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49598
diff changeset
3 ;; Copyright (C) 1985, 1986, 1994, 2001, 2003 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
43911
afe64ec4637c Require `button'.
Miles Bader <miles@gnu.org>
parents: 43134
diff changeset
31 (require 'button)
afe64ec4637c Require `button'.
Miles Bader <miles@gnu.org>
parents: 43134
diff changeset
32
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
33 (defgroup debugger nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
34 "Debuggers and related commands for Emacs."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
35 :prefix "debugger-"
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
36 :group 'debug)
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
37
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
38 (defcustom debugger-mode-hook nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
39 "*Hooks run when `debugger-mode' is turned on."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
40 :type 'hook
21669
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
41 :group 'debugger
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
42 :version "20.3")
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
43
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
44 (defcustom debugger-batch-max-lines 40
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
45 "*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
46 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
47 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
48 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
49 :type 'integer
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
50 :group 'debugger
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
51 :version "21.1")
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
52
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
53 (defcustom debug-function-list nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
54 "List of functions currently set for debug on entry."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
55 :type '(repeat function)
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
56 :group 'debugger)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
58 (defcustom debugger-step-after-exit nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
59 "Non-nil means \"single-step\" after the debugger exits."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
60 :type 'boolean
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
61 :group 'debugger)
10731
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
62
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
63 (defvar debugger-value nil
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
64 "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
65
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
66 (defvar debugger-old-buffer nil
65e10f44e765 (debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents: 10728
diff changeset
67 "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
68
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
69 (defvar debugger-previous-backtrace nil
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
70 "The contents of the previous backtrace (including text properties).
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
71 This is to optimize `debugger-make-xrefs'.")
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
72
6926
027b7de8a571 (debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents: 6567
diff changeset
73 (defvar debugger-outer-match-data)
11062
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
74 (defvar debugger-outer-load-read-function)
302f676eeca0 (debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10731
diff changeset
75 (defvar debugger-outer-overriding-local-map)
18166
84c0a412aa71 (debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents: 17262
diff changeset
76 (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
77 (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
78 (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
79 (defvar debugger-outer-this-command)
46722
df65863c006a Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 46715
diff changeset
80 ;; unread-command-char is obsolete,
df65863c006a Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 46715
diff changeset
81 ;; but we still save and restore it
df65863c006a Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 46715
diff changeset
82 ;; in case some user program still tries to set it.
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
83 (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
84 (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
85 (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
86 (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
87 (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
88 (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
89 (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
90 (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
91 (defvar debugger-outer-standard-output)
24741
00ef85c8a0ff (debugger-outer-inhibit-redisplay): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 24524
diff changeset
92 (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
93 (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
94
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (setq debugger 'debug)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 (defun debug (&rest debugger-args)
6048
ff40882c5578 (debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5585
diff changeset
99 "Enter debugger. To return, type \\<debugger-mode-map>`\\[debugger-continue]'.
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 Arguments are mainly for use when this is called from the internals
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 of the evaluator.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 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
104 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
105 first will be printed into the backtrace buffer."
11069
ee94cf4fd05a (debug): Now interactive.
Richard M. Stallman <rms@gnu.org>
parents: 11062
diff changeset
106 (interactive)
46715
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
107 (if inhibit-redisplay
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
108 ;; Don't really try to enter debugger within an eval from redisplay.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
109 debugger-value
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
110 (unless noninteractive
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
111 (message "Entering debugger..."))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
112 (let (debugger-value
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
113 (debug-on-error nil)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
114 (debug-on-quit nil)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
115 (debugger-buffer (let ((default-major-mode 'fundamental-mode))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
116 (get-buffer-create "*Backtrace*")))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
117 (debugger-old-buffer (current-buffer))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
118 (debugger-step-after-exit nil)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
119 ;; Don't keep reading from an executing kbd macro!
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
120 (executing-kbd-macro nil)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
121 ;; Save the outer values of these vars for the `e' command
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
122 ;; before we replace the values.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
123 (debugger-outer-match-data (match-data))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
124 (debugger-outer-load-read-function load-read-function)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
125 (debugger-outer-overriding-local-map overriding-local-map)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
126 (debugger-outer-overriding-terminal-local-map
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
127 overriding-terminal-local-map)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
128 (debugger-outer-track-mouse track-mouse)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
129 (debugger-outer-last-command last-command)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
130 (debugger-outer-this-command this-command)
51801
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
131 (debugger-outer-unread-command-char
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
132 (with-no-warnings unread-command-char))
46715
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
133 (debugger-outer-unread-command-events unread-command-events)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
134 (debugger-outer-unread-post-input-method-events
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
135 unread-post-input-method-events)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
136 (debugger-outer-last-input-event last-input-event)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
137 (debugger-outer-last-command-event last-command-event)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
138 (debugger-outer-last-nonmenu-event last-nonmenu-event)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
139 (debugger-outer-last-event-frame last-event-frame)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
140 (debugger-outer-standard-input standard-input)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
141 (debugger-outer-standard-output standard-output)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
142 (debugger-outer-inhibit-redisplay inhibit-redisplay)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
143 (debugger-outer-cursor-in-echo-area cursor-in-echo-area))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
144 ;; Set this instead of binding it, so that `q'
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
145 ;; will not restore it.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
146 (setq overriding-terminal-local-map nil)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
147 ;; Don't let these magic variables affect the debugger itself.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
148 (let ((last-command nil) this-command track-mouse
51801
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
149 unread-command-events
46715
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
150 unread-post-input-method-events
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
151 last-input-event last-command-event last-nonmenu-event
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
152 last-event-frame
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
153 overriding-local-map
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
154 load-read-function
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
155 ;; If we are inside a minibuffer, allow nesting
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
156 ;; so that we don't get an error from the `e' command.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
157 (enable-recursive-minibuffers
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
158 (or enable-recursive-minibuffers (> (minibuffer-depth) 0)))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
159 (standard-input t) (standard-output t)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
160 inhibit-redisplay
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
161 (cursor-in-echo-area nil))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
162 (unwind-protect
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
163 (save-excursion
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
164 (save-window-excursion
51801
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
165 (with-no-warnings
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
166 (setq unread-command-char -1))
46715
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
167 (pop-to-buffer debugger-buffer)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
168 (debugger-mode)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
169 (debugger-setup-buffer debugger-args)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
170 (when noninteractive
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
171 ;; If the backtrace is long, save the beginning
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
172 ;; and the end, but discard the middle.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
173 (when (> (count-lines (point-min) (point-max))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
174 debugger-batch-max-lines)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
175 (goto-char (point-min))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
176 (forward-line (/ 2 debugger-batch-max-lines))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
177 (let ((middlestart (point)))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
178 (goto-char (point-max))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
179 (forward-line (- (/ 2 debugger-batch-max-lines)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
180 debugger-batch-max-lines))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
181 (delete-region middlestart (point)))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
182 (insert "...\n"))
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
183 (goto-char (point-min))
51588
fc00b549e161 (debug): Fix call to message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49598
diff changeset
184 (message "%s" (buffer-string))
46715
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
185 (kill-emacs))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
186 (if (eq (car debugger-args) 'debug)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
187 ;; Skip the frames for backtrace-debug, byte-code, and debug.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
188 (backtrace-debug 3 t))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
189 (debugger-reenable)
5544
ab9c9a611b5a (debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents: 5430
diff changeset
190 (message "")
46715
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
191 (let ((inhibit-trace t)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
192 (standard-output nil)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
193 (buffer-read-only t))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
194 (message "")
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
195 ;; Make sure we unbind buffer-read-only in the right buffer.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
196 (save-excursion
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
197 (recursive-edit)))))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
198 ;; Kill or at least neuter the backtrace buffer, so that users
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
199 ;; don't try to execute debugger commands in an invalid context.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
200 (if (get-buffer-window debugger-buffer 'visible)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
201 ;; Still visible despite the save-window-excursion? Maybe it
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
202 ;; it's in a pop-up frame. It would be annoying to delete and
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
203 ;; recreate it every time the debugger stops, so instead we'll
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
204 ;; erase it but leave it visible.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
205 (save-excursion
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
206 (set-buffer debugger-buffer)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
207 (erase-buffer)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
208 (fundamental-mode))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
209 (kill-buffer debugger-buffer))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
210 (set-match-data debugger-outer-match-data)))
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
211 ;; Put into effect the modified values of these variables
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
212 ;; in case the user set them with the `e' command.
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
213 (setq load-read-function debugger-outer-load-read-function)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
214 (setq overriding-local-map debugger-outer-overriding-local-map)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
215 (setq overriding-terminal-local-map
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
216 debugger-outer-overriding-terminal-local-map)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
217 (setq track-mouse debugger-outer-track-mouse)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
218 (setq last-command debugger-outer-last-command)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
219 (setq this-command debugger-outer-this-command)
51801
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
220 (with-no-warnings
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
221 (setq unread-command-char debugger-outer-unread-command-char))
46715
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
222 (setq unread-command-events debugger-outer-unread-command-events)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
223 (setq unread-post-input-method-events
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
224 debugger-outer-unread-post-input-method-events)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
225 (setq last-input-event debugger-outer-last-input-event)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
226 (setq last-command-event debugger-outer-last-command-event)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
227 (setq last-nonmenu-event debugger-outer-last-nonmenu-event)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
228 (setq last-event-frame debugger-outer-last-event-frame)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
229 (setq standard-input debugger-outer-standard-input)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
230 (setq standard-output debugger-outer-standard-output)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
231 (setq inhibit-redisplay debugger-outer-inhibit-redisplay)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
232 (setq cursor-in-echo-area debugger-outer-cursor-in-echo-area)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
233 (setq debug-on-next-call debugger-step-after-exit)
1320a274ce28 (debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents: 46217
diff changeset
234 debugger-value)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
236 (defun debugger-setup-buffer (debugger-args)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
237 "Initialize the `*Backtrace*' buffer for entry to the debugger.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
238 That buffer should be current already."
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
239 (setq buffer-read-only nil)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
240 (erase-buffer)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
241 (set-buffer-multibyte nil)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
242 (let ((standard-output (current-buffer))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
243 (print-escape-newlines t)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
244 (print-level 8)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
245 (print-length 50))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
246 (backtrace))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
247 (goto-char (point-min))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
248 (delete-region (point)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
249 (progn
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
250 (search-forward "\n debug(")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
251 (forward-line 1)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
252 (point)))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
253 (insert "Debugger entered")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
254 ;; 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
255 ;; debug is for debug-on-entry function called.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
256 (cond ((memq (car debugger-args) '(lambda debug))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
257 (insert "--entering a function:\n")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
258 (if (eq (car debugger-args) 'debug)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
259 (progn
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
260 (delete-char 1)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
261 (insert ?*)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
262 (beginning-of-line))))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
263 ;; Exiting a function.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
264 ((eq (car debugger-args) 'exit)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
265 (insert "--returning value: ")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
266 (setq debugger-value (nth 1 debugger-args))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
267 (prin1 debugger-value (current-buffer))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
268 (insert ?\n)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
269 (delete-char 1)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
270 (insert ? )
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
271 (beginning-of-line))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
272 ;; Debugger entered for an error.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
273 ((eq (car debugger-args) 'error)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
274 (insert "--Lisp error: ")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
275 (prin1 (nth 1 debugger-args) (current-buffer))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
276 (insert ?\n))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
277 ;; 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
278 ((eq (car debugger-args) t)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
279 (insert "--beginning evaluation of function call form:\n"))
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
280 ;; User calls debug directly.
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
281 (t
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
282 (insert ": ")
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
283 (prin1 (if (eq (car debugger-args) 'nil)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
284 (cdr debugger-args) debugger-args)
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
285 (current-buffer))
40583
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
286 (insert ?\n)))
43134
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
287 ;; After any frame that uses eval-buffer,
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
288 ;; insert a line that states the buffer position it's reading at.
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
289 (save-excursion
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
290 (while (re-search-forward "^ eval-buffer(" nil t)
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
291 (end-of-line)
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
292 (insert (format "\n ;;; Reading at buffer position %d"
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
293 (with-current-buffer (nth 2 (backtrace-frame (debugger-frame-number)))
43033
9af85e74c287 (debugger-setup-buffer): When an eval-buffer frame was reading from a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 42304
diff changeset
294 (point))))))
40583
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
295 (debugger-make-xrefs))
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
296
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
297 (defun debugger-make-xrefs (&optional buffer)
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
298 "Attach cross-references to symbol names in the `*Backtrace*' buffer."
40583
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
299 (interactive "b")
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
300 (save-excursion
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
301 (set-buffer (or buffer (current-buffer)))
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
302 (setq buffer (current-buffer))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
303 (let ((buffer-read-only nil)
44517
5496c590d5ad (debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43911
diff changeset
304 (old-end (point-min)) (new-end (point-min)))
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
305 ;; If we saved an old backtrace, find the common part
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
306 ;; between the new and the old.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
307 ;; Compare line by line, starting from the end,
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
308 ;; because that's the part that is likely to be unchanged.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
309 (if debugger-previous-backtrace
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
310 (let (old-start new-start (all-match t))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
311 (goto-char (point-max))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
312 (with-temp-buffer
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
313 (insert debugger-previous-backtrace)
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
314 (while (and all-match (not (bobp)))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
315 (setq old-end (point))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
316 (forward-line -1)
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
317 (setq old-start (point))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
318 (with-current-buffer buffer
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
319 (setq new-end (point))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
320 (forward-line -1)
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
321 (setq new-start (point)))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
322 (if (not (zerop
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
323 (compare-buffer-substrings
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
324 (current-buffer) old-start old-end
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
325 buffer new-start new-end)))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
326 (setq all-match nil))))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
327 ;; Now new-end is the position of the start of the
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
328 ;; unchanged part in the current buffer, and old-end is
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
329 ;; the position of that same text in the saved old
44517
5496c590d5ad (debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43911
diff changeset
330 ;; backtrace. But we must subtract (point-min) since strings are
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
331 ;; indexed in origin 0.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
332
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
333 ;; Replace the unchanged part of the backtrace
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
334 ;; with the text from debugger-previous-backtrace,
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
335 ;; since that already has the proper xrefs.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
336 ;; With this optimization, we only need to scan
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
337 ;; the changed part of the backtrace.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
338 (delete-region new-end (point-max))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
339 (goto-char (point-max))
44517
5496c590d5ad (debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43911
diff changeset
340 (insert (substring debugger-previous-backtrace
5496c590d5ad (debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43911
diff changeset
341 (- old-end (point-min))))
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
342 ;; Make the unchanged part of the backtrace inaccessible
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
343 ;; so it won't be scanned.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
344 (narrow-to-region (point-min) new-end)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46722
diff changeset
345
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
346 ;; Scan the new part of the backtrace, inserting xrefs.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
347 (goto-char (point-min))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
348 (while (progn
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
349 (skip-syntax-forward "^w_")
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
350 (not (eobp)))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
351 (let* ((beg (point))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
352 (end (progn (skip-syntax-forward "w_") (point)))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
353 (sym (intern-soft (buffer-substring-no-properties
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
354 beg end)))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
355 (file (and sym (symbol-file sym))))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
356 (when file
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
357 (goto-char beg)
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
358 ;; help-xref-button needs to operate on something matched
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
359 ;; by a regexp, so set that up for it.
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
360 (re-search-forward "\\(\\(\\sw\\|\\s_\\)+\\)")
42304
8e051a31d2cd (debugger-mode-map): Bind C-m, not `RET'.
Richard M. Stallman <rms@gnu.org>
parents: 42078
diff changeset
361 (help-xref-button 1 'help-function-def sym file)))
8e051a31d2cd (debugger-mode-map): Bind C-m, not `RET'.
Richard M. Stallman <rms@gnu.org>
parents: 42078
diff changeset
362 (forward-line 1))
42063
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
363 (widen))
12577e136b14 (debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents: 40856
diff changeset
364 (setq debugger-previous-backtrace (buffer-string))))
26325
8523249aaee3 (debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents: 24741
diff changeset
365
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (defun debugger-step-through ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 "Proceed, stepping through subexpressions of this expression.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 Enter another debugger on next entry to eval, apply or funcall."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 (setq debugger-step-after-exit t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 (message "Proceeding, will debug on next eval or call.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (defun debugger-continue ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 "Continue, evaluating this expression without stopping."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (interactive)
26948
5385b12ef9a8 (debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents: 26428
diff changeset
377 (unless debugger-may-continue
5385b12ef9a8 (debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents: 26428
diff changeset
378 (error "Cannot continue"))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (message "Continuing.")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 (defun debugger-return-value (val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 "Continue, specifying value to return.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 This is only useful when the value returned from the debugger
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 will be used, such as in a debug on exit from a frame."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (interactive "XReturn value (evaluated): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (setq debugger-value val)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (princ "Returning " t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (prin1 debugger-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 (defun debugger-jump ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 "Continue to exit from this frame, with all debug-on-entry suspended."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 (interactive)
43134
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
395 (debugger-frame)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 ;; Turn off all debug-on-entry functions
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 ;; but leave them in the list.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (debug-on-entry-1 (car list) (symbol-function (car list)) nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (message "Continuing through this frame")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (exit-recursive-edit))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 (defun debugger-reenable ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 "Turn all debug-on-entry functions back on."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (or (consp (symbol-function (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (debug-convert-byte-code (car list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (fset (car list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (debug-on-entry-1 (car list) (symbol-function (car list)) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (setq list (cdr list)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (defun debugger-frame-number ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 "Return number of frames in backtrace before the one point points at."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (save-excursion
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (beginning-of-line)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (let ((opoint (point))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 (count 0))
43134
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
422 (while (not (eq (cadr (backtrace-frame count)) 'debug))
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
423 (setq count (1+ count)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (goto-char (point-min))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 (if (or (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 "Signal")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (equal (buffer-substring (point) (+ (point) 6))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 "Return"))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (search-forward ":")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (forward-sexp 1)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (while (progn
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (forward-char 2)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (if (= (following-char) ?\()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 (forward-sexp 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (forward-sexp 2))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 (forward-line 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (<= (point) opoint))
43033
9af85e74c287 (debugger-setup-buffer): When an eval-buffer frame was reading from a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 42304
diff changeset
440 (if (looking-at " *;;;")
9af85e74c287 (debugger-setup-buffer): When an eval-buffer frame was reading from a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 42304
diff changeset
441 (forward-line 1))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (setq count (1+ count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 count)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (defun debugger-frame ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 "Request entry to debugger when this frame exits.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (interactive)
43034
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
449 (save-excursion
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
450 (beginning-of-line)
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
451 (if (looking-at " *;;;\\|[a-z]")
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
452 (error "This line is not a function call")))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (beginning-of-line)
43134
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
454 (backtrace-debug (debugger-frame-number) t)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (if (= (following-char) ? )
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 (insert ?*)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (defun debugger-frame-clear ()
22114
0fbcff056c0f (debugger-frame-clear): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21669
diff changeset
462 "Do not enter debugger when this frame exits.
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 Applies to the frame whose line point is on in the backtrace."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 (interactive)
43034
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
465 (save-excursion
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
466 (beginning-of-line)
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
467 (if (looking-at " *;;;\\|[a-z]")
c803f1ca9d2b (debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents: 43033
diff changeset
468 (error "This line is not a function call")))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (beginning-of-line)
43134
ecd029f63cc0 (debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents: 43034
diff changeset
470 (backtrace-debug (debugger-frame-number) nil)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (if (= (following-char) ?*)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 (let ((buffer-read-only nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 (delete-char 1)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (insert ? )))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (beginning-of-line))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
477
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
478
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
479 (put 'debugger-env-macro 'lisp-indent-function 0)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
480 (defmacro debugger-env-macro (&rest body)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
481 "Run BODY in original environment."
26428
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
482 `(save-excursion
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
483 (if (null (buffer-name debugger-old-buffer))
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
484 ;; old buffer deleted
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
485 (setq debugger-old-buffer (current-buffer)))
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
486 (set-buffer debugger-old-buffer)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
487 (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
488 (overriding-terminal-local-map
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
489 debugger-outer-overriding-terminal-local-map)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
490 (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
491 (track-mouse debugger-outer-track-mouse)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
492 (last-command debugger-outer-last-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
493 (this-command debugger-outer-this-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
494 (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
495 (unread-post-input-method-events
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
496 debugger-outer-unread-post-input-method-events)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
497 (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
498 (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
499 (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
500 (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
501 (standard-input debugger-outer-standard-input)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
502 (standard-output debugger-outer-standard-output)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
503 (inhibit-redisplay debugger-outer-inhibit-redisplay)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
504 (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
505 (set-match-data debugger-outer-match-data)
51801
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
506 (prog1
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
507 (let ((save-ucc (with-no-warnings unread-command-char)))
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
508 (unwind-protect
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
509 (progn
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
510 (with-no-warnings
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
511 (setq unread-command-char debugger-outer-unread-command-char))
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
512 (prog1 (progn ,@body)
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
513 (with-no-warnings
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
514 (setq debugger-outer-unread-command-char unread-command-char))))
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
515 (with-no-warnings
8da87623aaa3 (debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents: 51588
diff changeset
516 (setq unread-command-char save-ucc))))
26428
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
517 (setq debugger-outer-match-data (match-data))
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
518 (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
519 (setq debugger-outer-overriding-terminal-local-map
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
520 overriding-terminal-local-map)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
521 (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
522 (setq debugger-outer-track-mouse track-mouse)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
523 (setq debugger-outer-last-command last-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
524 (setq debugger-outer-this-command this-command)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
525 (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
526 (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
527 unread-post-input-method-events)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
528 (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
529 (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
530 (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
531 (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
532 (setq debugger-outer-standard-input standard-input)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
533 (setq debugger-outer-standard-output standard-output)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
534 (setq debugger-outer-inhibit-redisplay inhibit-redisplay)
f572944ca41f * emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents: 26325
diff changeset
535 (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
536 ))))
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
537
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 (defun debugger-eval-expression (exp)
6468
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
539 "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
540 (interactive
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
541 (list (read-from-minibuffer "Eval: "
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
542 nil read-expression-map t
b0c731997544 (debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents: 6048
diff changeset
543 'read-expression-history)))
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
544 (debugger-env-macro (eval-expression exp)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 (defvar debugger-mode-map nil)
40583
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
547 (unless debugger-mode-map
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (let ((loop ? ))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (setq debugger-mode-map (make-keymap))
43911
afe64ec4637c Require `button'.
Miles Bader <miles@gnu.org>
parents: 43134
diff changeset
550 (set-keymap-parent debugger-mode-map button-buffer-map)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (suppress-keymap debugger-mode-map)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 (define-key debugger-mode-map "-" 'negative-argument)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (define-key debugger-mode-map "b" 'debugger-frame)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 (define-key debugger-mode-map "c" 'debugger-continue)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 (define-key debugger-mode-map "j" 'debugger-jump)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (define-key debugger-mode-map "r" 'debugger-return-value)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (define-key debugger-mode-map "u" 'debugger-frame-clear)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 (define-key debugger-mode-map "d" 'debugger-step-through)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (define-key debugger-mode-map "l" 'debugger-list-functions)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (define-key debugger-mode-map "h" 'describe-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (define-key debugger-mode-map "q" 'top-level)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (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
563 (define-key debugger-mode-map " " 'next-line)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
564 (define-key debugger-mode-map "R" 'debugger-record-expression)
42304
8e051a31d2cd (debugger-mode-map): Bind C-m, not `RET'.
Richard M. Stallman <rms@gnu.org>
parents: 42078
diff changeset
565 (define-key debugger-mode-map "\C-m" 'help-follow)
40583
87996dd441b7 easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents: 26948
diff changeset
566 (define-key debugger-mode-map [mouse-2] 'push-button)
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
567 ))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
568
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
569
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
570 (defcustom debugger-record-buffer "*Debugger-record*"
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
571 "*Buffer name for expression values, for \\[debugger-record-expression]."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21161
diff changeset
572 :type 'string
21669
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
573 :group 'debugger
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21365
diff changeset
574 :version "20.3")
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
575
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
576 (defun debugger-record-expression (exp)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
577 "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
578 (interactive
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
579 (list (read-from-minibuffer
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
580 "Record Eval: "
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
581 nil
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
582 read-expression-map t
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
583 'read-expression-history)))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
584 (let* ((buffer (get-buffer-create debugger-record-buffer))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
585 (standard-output buffer))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
586 (princ (format "Debugger Eval (%s): " exp))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
587 (princ (debugger-eval-expression exp))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
588 (terpri))
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
589
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
590 (with-current-buffer (get-buffer debugger-record-buffer)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
591 (save-excursion
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
592 (forward-line -1)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
593 (message
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
594 (buffer-substring (point) (progn (end-of-line) (point)))))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 (put 'debugger-mode 'mode-class 'special)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 (defun debugger-mode ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 "Mode for backtrace buffers, selected in debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 \\<debugger-mode-map>
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 A line starts with `*' if exiting that frame will call the debugger.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 When in debugger due to frame being exited,
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 use the \\[debugger-return-value] command to override the value
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 being returned from that frame.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 which functions will enter the debugger when called.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 Complete list of commands:
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 \\{debugger-mode-map}"
20403
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
613 (kill-all-local-variables)
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 (setq major-mode 'debugger-mode)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 (setq mode-name "Debugger")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 (setq truncate-lines t)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 (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
618 (use-local-map debugger-mode-map)
698119867c21 (debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents: 19889
diff changeset
619 (run-hooks 'debugger-mode-hook))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 (defun debug-on-entry (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 "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
624 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
625 This works by modifying the definition of FUNCTION,
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 which must be written in Lisp, not predefined.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 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
628 Redefining FUNCTION also cancels it."
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (interactive "aDebug on entry (to function): ")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 (debugger-reenable)
20404
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
631 ;; Handle a function that has been aliased to some other function.
46217
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
632 (if (and (subrp (symbol-function function))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
633 (eq (cdr (subr-arity (symbol-function function))) 'unevalled))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
634 (error "Function %s is a special form" function))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
635 (if (or (symbolp (symbol-function function))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
636 (subrp (symbol-function function)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
637 ;; Create a wrapper in which we can then add the necessary debug call.
20404
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
638 (fset function `(lambda (&rest debug-on-entry-args)
46217
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
639 ,(interactive-form (symbol-function function))
20404
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
640 (apply ',(symbol-function function)
7cce7f974c78 (debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents: 20403
diff changeset
641 debug-on-entry-args))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 (debug-convert-byte-code function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 (or (consp (symbol-function function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 (error "Definition of %s is not a list" function))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (fset function (debug-on-entry-1 function (symbol-function function) t))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 (or (memq function debug-function-list)
44517
5496c590d5ad (debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43911
diff changeset
648 (push function debug-function-list))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 ;;;###autoload
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 (defun cancel-debug-on-entry (&optional function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 "Undo effect of \\[debug-on-entry] on FUNCTION.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 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
655 (interactive
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
656 (list (let ((name
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
657 (completing-read "Cancel debug on entry (to function): "
45906
cacf84433461 (cancel-debug-on-entry): Don't cons uselessly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44517
diff changeset
658 (mapcar 'symbol-name debug-function-list)
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
659 nil t nil)))
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 473
diff changeset
660 (if name (intern name)))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 (debugger-reenable)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 (if (and function (not (string= function "")))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 (progn
46217
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
664 (let ((f (debug-on-entry-1 function (symbol-function function) nil)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
665 (condition-case nil
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
666 (if (and (equal (nth 1 f) '(&rest debug-on-entry-args))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
667 (eq (car (nth 3 f)) 'apply))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
668 ;; `f' is a wrapper introduced in debug-on-entry.
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
669 ;; Get rid of it since we don't need it any more.
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
670 (setq f (nth 1 (nth 1 (nth 3 f)))))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
671 (error nil))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
672 (fset function f))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 (setq debug-function-list (delq function debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 (message "Cancelling debug-on-entry for all functions")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 (mapcar 'cancel-debug-on-entry debug-function-list)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 (defun debug-convert-byte-code (function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 (let ((defn (symbol-function function)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 (if (not (consp defn))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 ;; Assume a compiled code object.
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 (let* ((contents (append defn nil))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 (body
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 (list (list 'byte-code (nth 1 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 (nth 2 contents) (nth 3 contents)))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 (if (nthcdr 5 contents)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 (setq body (cons (list 'interactive (nth 5 contents)) body)))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 (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
689 ;; 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
690 ;; 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
691 ;; 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
692 (setq body (cons (documentation function) body)))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 (fset function (cons 'lambda (cons (car contents) body)))))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 (defun debug-on-entry-1 (function defn flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 (if (subrp defn)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 (error "%s is a built-in function" function)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 (if (eq (car defn) 'macro)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 (debug-on-entry-1 function (cdr defn) flag)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 (or (eq (car defn) 'lambda)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 (error "%s not user-defined Lisp function" function))
46217
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
702 (let ((tail (cddr defn)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
703 ;; Skip the docstring.
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
704 (if (stringp (car tail)) (setq tail (cdr tail)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
705 ;; Skip the interactive form.
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
706 (if (eq 'interactive (car-safe (car tail))) (setq tail (cdr tail)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
707 (unless (eq flag (equal (car tail) '(debug 'debug)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
708 ;; Add/remove debug statement as needed.
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
709 (if (not flag)
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
710 (progn (setcar tail (cadr tail))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
711 (setcdr tail (cddr tail)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
712 (setcdr tail (cons (car tail) (cdr tail)))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
713 (setcar tail '(debug 'debug))))
4a0f567d3c5f (debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45906
diff changeset
714 defn))))
473
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 (defun debugger-list-functions ()
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 "Display a list of all the functions now set to debug on entry."
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 (interactive)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 (with-output-to-temp-buffer "*Help*"
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 (if (null debug-function-list)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 (princ "No debug-on-entry functions now\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 (princ "Functions set to debug on entry:\n\n")
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 (let ((list debug-function-list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 (while list
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 (prin1 (car list))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 (terpri)
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 (setq list (cdr list))))
999d0b38694e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 (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
729 (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
730 (save-excursion
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
731 (set-buffer standard-output)
b1455d954e44 (debugger-list-functions): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 6926
diff changeset
732 (help-mode))))
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
733
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 18190
diff changeset
734 (provide 'debug)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 18190
diff changeset
735
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51801
diff changeset
736 ;;; arch-tag: b6ec7047-f801-4103-9c63-d69322db9d3b
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 477
diff changeset
737 ;;; debug.el ends here