Mercurial > emacs
annotate lisp/emacs-lisp/debug.el @ 63092:80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 06 Jun 2005 19:47:05 +0000 |
parents | b9209f1855ae |
children | 95e4ef649d27 |
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 |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1994, 2001, 2003, 2005 |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
845 | 5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
6 ;; Maintainer: FSF |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
7 ;; Keywords: lisp, tools, maint |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
8 |
473 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
473 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
473 | 25 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
26 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
27 |
60316
c2f592ab6807
(debug-on-entry-1): Reimplement to make sure that debug-entry-code can
Lute Kamstra <lute@gnu.org>
parents:
60308
diff
changeset
|
28 ;; This is a major mode documented in the Emacs Lisp manual. |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
29 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
30 ;;; Code: |
473 | 31 |
43911 | 32 (require 'button) |
33 | |
21365 | 34 (defgroup debugger nil |
35 "Debuggers and related commands for Emacs." | |
36 :prefix "debugger-" | |
37 :group 'debug) | |
38 | |
39 (defcustom debugger-mode-hook nil | |
40 "*Hooks run when `debugger-mode' is turned on." | |
41 :type 'hook | |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
42 :group 'debugger |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
43 :version "20.3") |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
44 |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
45 (defcustom debugger-batch-max-lines 40 |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
46 "*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
|
47 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
|
48 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
|
49 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
|
50 :type 'integer |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
51 :group 'debugger |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
52 :version "21.1") |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
53 |
60374
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
54 (defvar debug-function-list nil |
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
55 "List of functions currently set for debug on entry.") |
473 | 56 |
60374
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
57 (defvar debugger-step-after-exit nil |
e68c831d220c
(debugger-step-after-exit): Make it a defvar.
Lute Kamstra <lute@gnu.org>
parents:
60350
diff
changeset
|
58 "Non-nil means \"single-step\" after the debugger exits.") |
10731
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
59 |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
60 (defvar debugger-value nil |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
61 "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
|
62 |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
63 (defvar debugger-old-buffer nil |
65e10f44e765
(debugger-step-after-exit): Variable declared.
Richard M. Stallman <rms@gnu.org>
parents:
10728
diff
changeset
|
64 "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
|
65 |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
66 (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
|
67 "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
|
68 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
|
69 |
6926
027b7de8a571
(debug, debugger-eval-expression): Preserve match-data.
Karl Heuer <kwzh@gnu.org>
parents:
6567
diff
changeset
|
70 (defvar debugger-outer-match-data) |
11062
302f676eeca0
(debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10731
diff
changeset
|
71 (defvar debugger-outer-load-read-function) |
302f676eeca0
(debugger-outer-load-read-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10731
diff
changeset
|
72 (defvar debugger-outer-overriding-local-map) |
18166
84c0a412aa71
(debug, debugger-eval-expression):
Richard M. Stallman <rms@gnu.org>
parents:
17262
diff
changeset
|
73 (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
|
74 (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
|
75 (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
|
76 (defvar debugger-outer-this-command) |
46722 | 77 ;; unread-command-char is obsolete, |
78 ;; but we still save and restore it | |
79 ;; 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
|
80 (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
|
81 (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
|
82 (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
|
83 (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
|
84 (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
|
85 (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
|
86 (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
|
87 (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
|
88 (defvar debugger-outer-standard-output) |
24741
00ef85c8a0ff
(debugger-outer-inhibit-redisplay): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
24524
diff
changeset
|
89 (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
|
90 (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
|
91 |
60350
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
92 (defvar inhibit-debug-on-entry nil |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
93 "Non-nil means that debug-on-entry is disabled.") |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
94 |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
95 (defvar debugger-jumping-flag nil |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
96 "Non-nil means that debug-on-entry is disabled. |
60519
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
97 This variable is used by `debugger-jump', `debugger-step-through', |
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
98 and `debugger-reenable' to temporarily disable debug-on-entry.") |
60308
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
99 |
63058
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
100 (defvar debugger-window nil |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
101 "If non-nil, the last window used by the debugger for its buffer. |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
102 The next call to the debugger reuses the same window, if it is still live. |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
103 That case would normally occur when the window is in a separate frame.") |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
104 |
473 | 105 ;;;###autoload |
106 (setq debugger 'debug) | |
107 ;;;###autoload | |
108 (defun debug (&rest debugger-args) | |
6048
ff40882c5578
(debug, debug-on-entry): Doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5585
diff
changeset
|
109 "Enter debugger. To return, type \\<debugger-mode-map>`\\[debugger-continue]'. |
473 | 110 Arguments are mainly for use when this is called from the internals |
111 of the evaluator. | |
112 | |
113 You may call with no args, or you may pass nil as the first arg and | |
114 any other args you like. In that case, the list of args after the | |
115 first will be printed into the backtrace buffer." | |
11069
ee94cf4fd05a
(debug): Now interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11062
diff
changeset
|
116 (interactive) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
117 (if inhibit-redisplay |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
118 ;; 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
|
119 debugger-value |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
120 (unless noninteractive |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
121 (message "Entering debugger...")) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
122 (let (debugger-value |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
123 (debug-on-error nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
124 (debug-on-quit nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
125 (debugger-buffer (let ((default-major-mode 'fundamental-mode)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
126 (get-buffer-create "*Backtrace*"))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
127 (debugger-old-buffer (current-buffer)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
128 (debugger-step-after-exit nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
129 ;; 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
|
130 (executing-kbd-macro nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
131 ;; 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
|
132 ;; before we replace the values. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
133 (debugger-outer-match-data (match-data)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
134 (debugger-outer-load-read-function load-read-function) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
135 (debugger-outer-overriding-local-map overriding-local-map) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
136 (debugger-outer-overriding-terminal-local-map |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
137 overriding-terminal-local-map) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
138 (debugger-outer-track-mouse track-mouse) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
139 (debugger-outer-last-command last-command) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
140 (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
|
141 (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
|
142 (with-no-warnings unread-command-char)) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
143 (debugger-outer-unread-command-events unread-command-events) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
144 (debugger-outer-unread-post-input-method-events |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
145 unread-post-input-method-events) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
146 (debugger-outer-last-input-event last-input-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
147 (debugger-outer-last-command-event last-command-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
148 (debugger-outer-last-nonmenu-event last-nonmenu-event) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
149 (debugger-outer-last-event-frame last-event-frame) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
150 (debugger-outer-standard-input standard-input) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
151 (debugger-outer-standard-output standard-output) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
152 (debugger-outer-inhibit-redisplay inhibit-redisplay) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
153 (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
|
154 ;; 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
|
155 ;; will not restore it. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
156 (setq overriding-terminal-local-map nil) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
157 ;; 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
|
158 (let ((last-command nil) this-command track-mouse |
60308
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
159 (inhibit-trace t) |
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
160 (inhibit-debug-on-entry t) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
161 unread-command-events |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
162 unread-post-input-method-events |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
163 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
|
164 last-event-frame |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
165 overriding-local-map |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
166 load-read-function |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
167 ;; If we are inside a minibuffer, allow nesting |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
168 ;; 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
|
169 (enable-recursive-minibuffers |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
170 (or enable-recursive-minibuffers (> (minibuffer-depth) 0))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
171 (standard-input t) (standard-output t) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
172 inhibit-redisplay |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
173 (cursor-in-echo-area nil)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
174 (unwind-protect |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
175 (save-excursion |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
176 (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
|
177 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
178 (setq unread-command-char -1)) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
179 (when (eq (car debugger-args) 'debug) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
180 ;; Skip the frames for backtrace-debug, byte-code, |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
181 ;; and implement-debug-on-entry. |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
182 (backtrace-debug 4 t) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
183 ;; Place an extra debug-on-exit for macro's. |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
184 (when (eq 'lambda (car-safe (cadr (backtrace-frame 4)))) |
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
185 (backtrace-debug 5 t))) |
63058
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
186 (if (and debugger-window |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
187 (window-live-p debugger-window)) |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
188 (progn |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
189 (set-window-buffer debugger-window debugger-buffer) |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
190 (select-window debugger-window)) |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
191 (pop-to-buffer debugger-buffer)) |
b9209f1855ae
(debugger-window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
61084
diff
changeset
|
192 (setq debugger-window (selected-window)) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
193 (debugger-mode) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
194 (debugger-setup-buffer debugger-args) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
195 (when noninteractive |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
196 ;; If the backtrace is long, save the beginning |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
197 ;; and the end, but discard the middle. |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
198 (when (> (count-lines (point-min) (point-max)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
199 debugger-batch-max-lines) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
200 (goto-char (point-min)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
201 (forward-line (/ 2 debugger-batch-max-lines)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
202 (let ((middlestart (point))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
203 (goto-char (point-max)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
204 (forward-line (- (/ 2 debugger-batch-max-lines) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
205 debugger-batch-max-lines)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
206 (delete-region middlestart (point))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
207 (insert "...\n")) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
208 (goto-char (point-min)) |
51588
fc00b549e161
(debug): Fix call to message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
209 (message "%s" (buffer-string)) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
210 (kill-emacs)) |
5544
ab9c9a611b5a
(debug): Bind a bunch of vars, like last-command, to
Richard M. Stallman <rms@gnu.org>
parents:
5430
diff
changeset
|
211 (message "") |
60308
9bc793e5120d
(inhibit-debug-on-entry): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60279
diff
changeset
|
212 (let ((standard-output nil) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
213 (buffer-read-only t)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
214 (message "") |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
215 ;; 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
|
216 (save-excursion |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
217 (recursive-edit))))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
218 ;; 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
|
219 ;; don't try to execute debugger commands in an invalid context. |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
220 (if (get-buffer-window debugger-buffer 0) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
221 ;; 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
|
222 ;; 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
|
223 ;; recreate it every time the debugger stops, so instead we'll |
63092
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
224 ;; erase it (and maybe hide it) but keep it alive. |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
225 (with-current-buffer debugger-buffer |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
226 (erase-buffer) |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
227 (fundamental-mode) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
228 (with-selected-window (get-buffer-window debugger-buffer 0) |
63092
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
229 (when (window-dedicated-p (selected-window)) |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
230 ;; If the window is not dedicated, burying the buffer |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
231 ;; will mean that the frame created for it is left |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
232 ;; around showing smoe random buffer, and next time we |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
233 ;; pop to the debugger buffer we'll create yet |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
234 ;; another frame. |
80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63058
diff
changeset
|
235 (bury-buffer)))) |
46715
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
236 (kill-buffer debugger-buffer)) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
237 (set-match-data debugger-outer-match-data))) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
238 ;; 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
|
239 ;; 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
|
240 (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
|
241 (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
|
242 (setq overriding-terminal-local-map |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
243 debugger-outer-overriding-terminal-local-map) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
244 (setq track-mouse debugger-outer-track-mouse) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
245 (setq last-command debugger-outer-last-command) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
246 (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
|
247 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
248 (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
|
249 (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
|
250 (setq unread-post-input-method-events |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
251 debugger-outer-unread-post-input-method-events) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
252 (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
|
253 (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
|
254 (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
|
255 (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
|
256 (setq standard-input debugger-outer-standard-input) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
257 (setq standard-output debugger-outer-standard-output) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
258 (setq inhibit-redisplay debugger-outer-inhibit-redisplay) |
1320a274ce28
(debug): If redisplaying, just return.
Richard M. Stallman <rms@gnu.org>
parents:
46217
diff
changeset
|
259 (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
|
260 (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
|
261 debugger-value))) |
473 | 262 |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
263 (defun debugger-setup-buffer (debugger-args) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
264 "Initialize the `*Backtrace*' buffer for entry to the debugger. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
265 That buffer should be current already." |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
266 (setq buffer-read-only nil) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
267 (erase-buffer) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
268 (set-buffer-multibyte nil) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
269 (let ((standard-output (current-buffer)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
270 (print-escape-newlines t) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
271 (print-level 8) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
272 (print-length 50)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
273 (backtrace)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
274 (goto-char (point-min)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
275 (delete-region (point) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
276 (progn |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
277 (search-forward "\n debug(") |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
278 (forward-line (if (eq (car debugger-args) 'debug) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
279 2 ; Remove implement-debug-on-entry frame. |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
280 1)) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
281 (point))) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
282 (insert "Debugger entered") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
283 ;; 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
|
284 ;; debug is for debug-on-entry function called. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
285 (cond ((memq (car debugger-args) '(lambda debug)) |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
286 (insert "--entering a function:\n")) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
287 ;; Exiting a function. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
288 ((eq (car debugger-args) 'exit) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
289 (insert "--returning value: ") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
290 (setq debugger-value (nth 1 debugger-args)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
291 (prin1 debugger-value (current-buffer)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
292 (insert ?\n) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
293 (delete-char 1) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
294 (insert ? ) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
295 (beginning-of-line)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
296 ;; Debugger entered for an error. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
297 ((eq (car debugger-args) 'error) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
298 (insert "--Lisp error: ") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
299 (prin1 (nth 1 debugger-args) (current-buffer)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
300 (insert ?\n)) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
301 ;; 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
|
302 ((eq (car debugger-args) t) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
303 (insert "--beginning evaluation of function call form:\n")) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
304 ;; User calls debug directly. |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
305 (t |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
306 (insert ": ") |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
307 (prin1 (if (eq (car debugger-args) 'nil) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
308 (cdr debugger-args) debugger-args) |
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
309 (current-buffer)) |
40583
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
310 (insert ?\n))) |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
311 ;; After any frame that uses eval-buffer, |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
312 ;; 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
|
313 (save-excursion |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
314 (while (re-search-forward "^ eval-buffer(" nil t) |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
315 (end-of-line) |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
316 (insert (format "\n ;;; Reading at buffer position %d" |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
317 (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
|
318 (point)))))) |
40583
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
319 (debugger-make-xrefs)) |
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
320 |
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
321 (defun debugger-make-xrefs (&optional buffer) |
60600
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
322 "Attach cross-references to function names in the `*Backtrace*' buffer." |
40583
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
323 (interactive "b") |
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
324 (save-excursion |
87996dd441b7
easy source access from the *debugger* buffer
Sam Steingold <sds@gnu.org>
parents:
26948
diff
changeset
|
325 (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
|
326 (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
|
327 (let ((buffer-read-only nil) |
44517
5496c590d5ad
(debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43911
diff
changeset
|
328 (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
|
329 ;; 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
|
330 ;; 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
|
331 ;; 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
|
332 ;; 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
|
333 (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
|
334 (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
|
335 (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
|
336 (with-temp-buffer |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
337 (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
|
338 (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
|
339 (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
|
340 (forward-line -1) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
341 (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
|
342 (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
|
343 (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
|
344 (forward-line -1) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
345 (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
|
346 (if (not (zerop |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
347 (compare-buffer-substrings |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
348 (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
|
349 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
|
350 (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
|
351 ;; 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
|
352 ;; 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
|
353 ;; 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
|
354 ;; 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
|
355 ;; 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
|
356 |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
357 ;; 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
|
358 ;; 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
|
359 ;; 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
|
360 ;; 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
|
361 ;; 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
|
362 (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
|
363 (goto-char (point-max)) |
44517
5496c590d5ad
(debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43911
diff
changeset
|
364 (insert (substring debugger-previous-backtrace |
5496c590d5ad
(debug-on-entry): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43911
diff
changeset
|
365 (- 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
|
366 ;; 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
|
367 ;; 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
|
368 (narrow-to-region (point-min) new-end))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46722
diff
changeset
|
369 |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
370 ;; 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
|
371 (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
|
372 (while (progn |
60600
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
373 (goto-char (+ (point) 2)) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
374 (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
|
375 (not (eobp))) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
376 (let* ((beg (point)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
377 (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
|
378 (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
|
379 beg end))) |
59123
f9293296e0cb
(debugger-make-xrefs): Call symbol-file with `defun'.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
380 (file (and sym (symbol-file sym 'defun)))) |
42063
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
381 (when file |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
382 (goto-char beg) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
383 ;; 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
|
384 ;; by a regexp, so set that up for it. |
60600
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
385 (re-search-forward "\\(\\sw\\|\\s_\\)+") |
4cc59db6dfeb
(debugger-make-xrefs): Docstring fix. Ignore a `*' at the beginning
Lute Kamstra <lute@gnu.org>
parents:
60587
diff
changeset
|
386 (help-xref-button 0 'help-function-def sym file))) |
42304
8e051a31d2cd
(debugger-mode-map): Bind C-m, not `RET'.
Richard M. Stallman <rms@gnu.org>
parents:
42078
diff
changeset
|
387 (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
|
388 (widen)) |
12577e136b14
(debugger-make-xrefs): Optimize by (1) using skip-syntax-forward
Richard M. Stallman <rms@gnu.org>
parents:
40856
diff
changeset
|
389 (setq debugger-previous-backtrace (buffer-string)))) |
26325
8523249aaee3
(debug): If noninteractive, display the
Gerd Moellmann <gerd@gnu.org>
parents:
24741
diff
changeset
|
390 |
473 | 391 (defun debugger-step-through () |
392 "Proceed, stepping through subexpressions of this expression. | |
393 Enter another debugger on next entry to eval, apply or funcall." | |
394 (interactive) | |
395 (setq debugger-step-after-exit t) | |
60519
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
396 (setq debugger-jumping-flag t) |
2433720b755c
(debugger-step-through): Make sure that stepping into the debugger's
Lute Kamstra <lute@gnu.org>
parents:
60490
diff
changeset
|
397 (add-hook 'post-command-hook 'debugger-reenable) |
473 | 398 (message "Proceeding, will debug on next eval or call.") |
399 (exit-recursive-edit)) | |
400 | |
401 (defun debugger-continue () | |
402 "Continue, evaluating this expression without stopping." | |
403 (interactive) | |
26948
5385b12ef9a8
(debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents:
26428
diff
changeset
|
404 (unless debugger-may-continue |
5385b12ef9a8
(debugger-continue): Don't continue If
Gerd Moellmann <gerd@gnu.org>
parents:
26428
diff
changeset
|
405 (error "Cannot continue")) |
473 | 406 (message "Continuing.") |
407 (exit-recursive-edit)) | |
408 | |
409 (defun debugger-return-value (val) | |
410 "Continue, specifying value to return. | |
411 This is only useful when the value returned from the debugger | |
412 will be used, such as in a debug on exit from a frame." | |
413 (interactive "XReturn value (evaluated): ") | |
414 (setq debugger-value val) | |
415 (princ "Returning " t) | |
416 (prin1 debugger-value) | |
417 (exit-recursive-edit)) | |
418 | |
419 (defun debugger-jump () | |
420 "Continue to exit from this frame, with all debug-on-entry suspended." | |
421 (interactive) | |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
422 (debugger-frame) |
60350
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
423 (setq debugger-jumping-flag t) |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
424 (add-hook 'post-command-hook 'debugger-reenable) |
473 | 425 (message "Continuing through this frame") |
426 (exit-recursive-edit)) | |
427 | |
428 (defun debugger-reenable () | |
60350
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
429 "Turn all debug-on-entry functions back on. |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
430 This function is put on `post-command-hook' by `debugger-jump' and |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
431 removes itself from that hook." |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
432 (setq debugger-jumping-flag nil) |
ba6305a0c74a
(inhibit-debug-on-entry): Add docstring.
Lute Kamstra <lute@gnu.org>
parents:
60329
diff
changeset
|
433 (remove-hook 'post-command-hook 'debugger-reenable)) |
473 | 434 |
435 (defun debugger-frame-number () | |
436 "Return number of frames in backtrace before the one point points at." | |
437 (save-excursion | |
438 (beginning-of-line) | |
439 (let ((opoint (point)) | |
440 (count 0)) | |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
441 (while (not (eq (cadr (backtrace-frame count)) 'debug)) |
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
442 (setq count (1+ count))) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
443 ;; Skip implement-debug-on-entry frame. |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
444 (when (eq 'implement-debug-on-entry (cadr (backtrace-frame (1+ count)))) |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
445 (setq count (1+ count))) |
473 | 446 (goto-char (point-min)) |
60329
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
447 (when (looking-at "Debugger entered--\\(Lisp error\\|returning value\\):") |
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
448 (goto-char (match-end 0)) |
d913e02f38ae
(debug): Skip one more frame in case of debug on entry.
Lute Kamstra <lute@gnu.org>
parents:
60316
diff
changeset
|
449 (forward-sexp 1)) |
473 | 450 (forward-line 1) |
451 (while (progn | |
452 (forward-char 2) | |
453 (if (= (following-char) ?\() | |
454 (forward-sexp 1) | |
455 (forward-sexp 2)) | |
456 (forward-line 1) | |
457 (<= (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
|
458 (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
|
459 (forward-line 1)) |
473 | 460 (setq count (1+ count))) |
461 count))) | |
462 | |
463 (defun debugger-frame () | |
464 "Request entry to debugger when this frame exits. | |
465 Applies to the frame whose line point is on in the backtrace." | |
466 (interactive) | |
43034
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
467 (save-excursion |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
468 (beginning-of-line) |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
469 (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
|
470 (error "This line is not a function call"))) |
473 | 471 (beginning-of-line) |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
472 (backtrace-debug (debugger-frame-number) t) |
473 | 473 (if (= (following-char) ? ) |
474 (let ((buffer-read-only nil)) | |
475 (delete-char 1) | |
476 (insert ?*))) | |
477 (beginning-of-line)) | |
478 | |
479 (defun debugger-frame-clear () | |
22114
0fbcff056c0f
(debugger-frame-clear): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
21669
diff
changeset
|
480 "Do not enter debugger when this frame exits. |
473 | 481 Applies to the frame whose line point is on in the backtrace." |
482 (interactive) | |
43034
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
483 (save-excursion |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
484 (beginning-of-line) |
c803f1ca9d2b
(debugger-frame-clear, debugger-frame): Error on non-frame line.
Richard M. Stallman <rms@gnu.org>
parents:
43033
diff
changeset
|
485 (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
|
486 (error "This line is not a function call"))) |
473 | 487 (beginning-of-line) |
43134
ecd029f63cc0
(debugger-frame-offset): Var deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43034
diff
changeset
|
488 (backtrace-debug (debugger-frame-number) nil) |
473 | 489 (if (= (following-char) ?*) |
490 (let ((buffer-read-only nil)) | |
491 (delete-char 1) | |
492 (insert ? ))) | |
493 (beginning-of-line)) | |
494 | |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
495 (put 'debugger-env-macro 'lisp-indent-function 0) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
496 (defmacro debugger-env-macro (&rest body) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
497 "Run BODY in original environment." |
26428
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
498 `(save-excursion |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
499 (if (null (buffer-name debugger-old-buffer)) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
500 ;; old buffer deleted |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
501 (setq debugger-old-buffer (current-buffer))) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
502 (set-buffer debugger-old-buffer) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
503 (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
|
504 (overriding-terminal-local-map |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
505 debugger-outer-overriding-terminal-local-map) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
506 (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
|
507 (track-mouse debugger-outer-track-mouse) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
508 (last-command debugger-outer-last-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
509 (this-command debugger-outer-this-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
510 (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
|
511 (unread-post-input-method-events |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
512 debugger-outer-unread-post-input-method-events) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
513 (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
|
514 (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
|
515 (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
|
516 (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
|
517 (standard-input debugger-outer-standard-input) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
518 (standard-output debugger-outer-standard-output) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
519 (inhibit-redisplay debugger-outer-inhibit-redisplay) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
520 (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
|
521 (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
|
522 (prog1 |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
523 (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
|
524 (unwind-protect |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
525 (progn |
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
526 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
527 (setq unread-command-char debugger-outer-unread-command-char)) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
528 (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
|
529 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
530 (setq debugger-outer-unread-command-char unread-command-char)))) |
51801
8da87623aaa3
(debug, debugger-env-macro): Use with-no-warnings while accessing and
Richard M. Stallman <rms@gnu.org>
parents:
51588
diff
changeset
|
531 (with-no-warnings |
60587
dbd707c470de
(debug): Set debug-on-exit before calling debugger-setup-buffer so
Lute Kamstra <lute@gnu.org>
parents:
60545
diff
changeset
|
532 (setq unread-command-char save-ucc)))) |
26428
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
533 (setq debugger-outer-match-data (match-data)) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
534 (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
|
535 (setq debugger-outer-overriding-terminal-local-map |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
536 overriding-terminal-local-map) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
537 (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
|
538 (setq debugger-outer-track-mouse track-mouse) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
539 (setq debugger-outer-last-command last-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
540 (setq debugger-outer-this-command this-command) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
541 (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
|
542 (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
|
543 unread-post-input-method-events) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
544 (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
|
545 (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
|
546 (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
|
547 (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
|
548 (setq debugger-outer-standard-input standard-input) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
549 (setq debugger-outer-standard-output standard-output) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
550 (setq debugger-outer-inhibit-redisplay inhibit-redisplay) |
f572944ca41f
* emacs-lisp/debug.el (debugger-env-macro):
Sam Steingold <sds@gnu.org>
parents:
26325
diff
changeset
|
551 (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
|
552 )))) |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
553 |
473 | 554 (defun debugger-eval-expression (exp) |
6468
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
555 "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
|
556 (interactive |
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
557 (list (read-from-minibuffer "Eval: " |
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
558 nil read-expression-map t |
b0c731997544
(debugger-eval-expression): Use a history list.
Richard M. Stallman <rms@gnu.org>
parents:
6048
diff
changeset
|
559 'read-expression-history))) |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
560 (debugger-env-macro (eval-expression exp))) |
473 | 561 |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
562 (defvar debugger-mode-map |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
563 (let ((map (make-keymap))) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
564 (set-keymap-parent map button-buffer-map) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
565 (suppress-keymap map) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
566 (define-key map "-" 'negative-argument) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
567 (define-key map "b" 'debugger-frame) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
568 (define-key map "c" 'debugger-continue) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
569 (define-key map "j" 'debugger-jump) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
570 (define-key map "r" 'debugger-return-value) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
571 (define-key map "u" 'debugger-frame-clear) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
572 (define-key map "d" 'debugger-step-through) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
573 (define-key map "l" 'debugger-list-functions) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
574 (define-key map "h" 'describe-mode) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
575 (define-key map "q" 'top-level) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
576 (define-key map "e" 'debugger-eval-expression) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
577 (define-key map " " 'next-line) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
578 (define-key map "R" 'debugger-record-expression) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
579 (define-key map "\C-m" 'help-follow) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
580 (define-key map [mouse-2] 'push-button) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
581 map)) |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
582 |
21365 | 583 (defcustom debugger-record-buffer "*Debugger-record*" |
584 "*Buffer name for expression values, for \\[debugger-record-expression]." | |
585 :type 'string | |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
586 :group 'debugger |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21365
diff
changeset
|
587 :version "20.3") |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
588 |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
589 (defun debugger-record-expression (exp) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
590 "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
|
591 (interactive |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
592 (list (read-from-minibuffer |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
593 "Record Eval: " |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
594 nil |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
595 read-expression-map t |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
596 'read-expression-history))) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
597 (let* ((buffer (get-buffer-create debugger-record-buffer)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
598 (standard-output buffer)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
599 (princ (format "Debugger Eval (%s): " exp)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
600 (princ (debugger-eval-expression exp)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
601 (terpri)) |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
602 |
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
603 (with-current-buffer (get-buffer debugger-record-buffer) |
60972
d874c232323c
(debugger-record-expression): Add a missing format to `message'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60600
diff
changeset
|
604 (message "%s" |
d874c232323c
(debugger-record-expression): Add a missing format to `message'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60600
diff
changeset
|
605 (buffer-substring (line-beginning-position 0) |
d874c232323c
(debugger-record-expression): Add a missing format to `message'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60600
diff
changeset
|
606 (line-end-position 0))))) |
473 | 607 |
608 (put 'debugger-mode 'mode-class 'special) | |
609 | |
610 (defun debugger-mode () | |
611 "Mode for backtrace buffers, selected in debugger. | |
612 \\<debugger-mode-map> | |
613 A line starts with `*' if exiting that frame will call the debugger. | |
614 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'. | |
615 | |
616 When in debugger due to frame being exited, | |
617 use the \\[debugger-return-value] command to override the value | |
618 being returned from that frame. | |
619 | |
620 Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control | |
621 which functions will enter the debugger when called. | |
622 | |
623 Complete list of commands: | |
624 \\{debugger-mode-map}" | |
20403
698119867c21
(debugger-mode-hook): New user variable.
Karl Heuer <kwzh@gnu.org>
parents:
19889
diff
changeset
|
625 (kill-all-local-variables) |
473 | 626 (setq major-mode 'debugger-mode) |
627 (setq mode-name "Debugger") | |
628 (setq truncate-lines t) | |
629 (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
|
630 (use-local-map debugger-mode-map) |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
631 (run-mode-hooks 'debugger-mode-hook)) |
473 | 632 |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
633 ;; When you change this, you may also need to change the number of |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
634 ;; frames that the debugger skips. |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
635 (defun implement-debug-on-entry () |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
636 "Conditionally call the debugger. |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
637 A call to this function is inserted by `debug-on-entry' to cause |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
638 functions to break on entry." |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
639 (if (or inhibit-debug-on-entry debugger-jumping-flag) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
640 nil |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
641 (funcall debugger 'debug))) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
642 |
473 | 643 ;;;###autoload |
644 (defun debug-on-entry (function) | |
645 "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
|
646 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
|
647 This works by modifying the definition of FUNCTION, |
473 | 648 which must be written in Lisp, not predefined. |
649 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
|
650 Redefining FUNCTION also cancels it." |
473 | 651 (interactive "aDebug on entry (to function): ") |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
652 (when (and (subrp (symbol-function function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
653 (eq (cdr (subr-arity (symbol-function function))) 'unevalled)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
654 (error "Function %s is a special form" function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
655 (if (or (symbolp (symbol-function function)) |
46217
4a0f567d3c5f
(debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45906
diff
changeset
|
656 (subrp (symbol-function function))) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
657 ;; The function is built-in or aliased to another function. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
658 ;; Create a wrapper in which we can add the debug call. |
20404
7cce7f974c78
(debug-on-entry): If definition is a symbol,
Karl Heuer <kwzh@gnu.org>
parents:
20403
diff
changeset
|
659 (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
|
660 ,(interactive-form (symbol-function function)) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
661 (apply ',(symbol-function function) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
662 debug-on-entry-args))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
663 (when (eq (car-safe (symbol-function function)) 'autoload) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
664 ;; The function is autoloaded. Load its real definition. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
665 (load (cadr (symbol-function function)) nil noninteractive nil t)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
666 (when (or (not (consp (symbol-function function))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
667 (and (eq (car (symbol-function function)) 'macro) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
668 (not (consp (cdr (symbol-function function)))))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
669 ;; The function is byte-compiled. Create a wrapper in which |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
670 ;; we can add the debug call. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
671 (debug-convert-byte-code function))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
672 (unless (consp (symbol-function function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
673 (error "Definition of %s is not a list" function)) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
674 (fset function (debug-on-entry-1 function t)) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
675 (unless (memq function debug-function-list) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
676 (push function debug-function-list)) |
473 | 677 function) |
678 | |
679 ;;;###autoload | |
680 (defun cancel-debug-on-entry (&optional function) | |
681 "Undo effect of \\[debug-on-entry] on FUNCTION. | |
682 If argument is nil or an empty string, cancel for all functions." | |
477 | 683 (interactive |
684 (list (let ((name | |
685 (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
|
686 (mapcar 'symbol-name debug-function-list) |
477 | 687 nil t nil))) |
688 (if name (intern name))))) | |
473 | 689 (if (and function (not (string= function ""))) |
690 (progn | |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
691 (let ((defn (debug-on-entry-1 function nil))) |
46217
4a0f567d3c5f
(debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45906
diff
changeset
|
692 (condition-case nil |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
693 (when (and (equal (nth 1 defn) '(&rest debug-on-entry-args)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
694 (eq (car (nth 3 defn)) 'apply)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
695 ;; `defn' is a wrapper introduced in debug-on-entry. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
696 ;; Get rid of it since we don't need it any more. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
697 (setq defn (nth 1 (nth 1 (nth 3 defn))))) |
46217
4a0f567d3c5f
(debug-on-entry): Fix the wrapper used for
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45906
diff
changeset
|
698 (error nil)) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
699 (fset function defn)) |
473 | 700 (setq debug-function-list (delq function debug-function-list)) |
701 function) | |
702 (message "Cancelling debug-on-entry for all functions") | |
703 (mapcar 'cancel-debug-on-entry debug-function-list))) | |
704 | |
705 (defun debug-convert-byte-code (function) | |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
706 (let* ((defn (symbol-function function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
707 (macro (eq (car-safe defn) 'macro))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
708 (when macro (setq defn (cdr defn))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
709 (unless (consp defn) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
710 ;; Assume a compiled code object. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
711 (let* ((contents (append defn nil)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
712 (body |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
713 (list (list 'byte-code (nth 1 contents) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
714 (nth 2 contents) (nth 3 contents))))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
715 (if (nthcdr 5 contents) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
716 (setq body (cons (list 'interactive (nth 5 contents)) body))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
717 (if (nth 4 contents) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
718 ;; Use `documentation' here, to get the actual string, |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
719 ;; in case the compiled function has a reference |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
720 ;; to the .elc file. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
721 (setq body (cons (documentation function) body))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
722 (setq defn (cons 'lambda (cons (car contents) body)))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
723 (when macro (setq defn (cons 'macro defn))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
724 (fset function defn)))) |
473 | 725 |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
726 (defun debug-on-entry-1 (function flag) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
727 (let* ((defn (symbol-function function)) |
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
728 (tail defn)) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
729 (when (eq (car-safe tail) 'macro) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
730 (setq tail (cdr tail))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
731 (if (not (eq (car-safe tail) 'lambda)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
732 ;; Only signal an error when we try to set debug-on-entry. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
733 ;; When we try to clear debug-on-entry, we are now done. |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
734 (when flag |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
735 (error "%s is not a user-defined Lisp function" function)) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
736 (setq tail (cdr tail)) |
60490
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
737 ;; Skip the docstring. |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
738 (when (and (stringp (cadr tail)) (cddr tail)) |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
739 (setq tail (cdr tail))) |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
740 ;; Skip the interactive form. |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
741 (when (eq 'interactive (car-safe (cadr tail))) |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
742 (setq tail (cdr tail))) |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
743 (unless (eq flag (equal (cadr tail) '(implement-debug-on-entry))) |
60490
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
744 ;; Add/remove debug statement as needed. |
2e5cfcc774b9
(debug-on-entry-1): Fix handling of macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60374
diff
changeset
|
745 (if flag |
60545
f7baf4c9472b
(debug-entry-code): Delete it.
Lute Kamstra <lute@gnu.org>
parents:
60519
diff
changeset
|
746 (setcdr tail (cons '(implement-debug-on-entry) (cdr tail))) |
61084
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
747 (setcdr tail (cddr tail))))) |
e5ed594355d5
(debug-on-entry): Handle autoloaded functions and compiled macros.
Lute Kamstra <lute@gnu.org>
parents:
60972
diff
changeset
|
748 defn)) |
473 | 749 |
750 (defun debugger-list-functions () | |
751 "Display a list of all the functions now set to debug on entry." | |
752 (interactive) | |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
753 (require 'help-mode) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
754 (help-setup-xref '(debugger-list-functions) (interactive-p)) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
755 (with-output-to-temp-buffer (help-buffer) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
756 (with-current-buffer standard-output |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
757 (if (null debug-function-list) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
758 (princ "No debug-on-entry functions now\n") |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
759 (princ "Functions set to debug on entry:\n\n") |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
760 (dolist (fun debug-function-list) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
761 (make-text-button (point) (progn (prin1 fun) (point)) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
762 'type 'help-function |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
763 'help-args (list fun)) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
764 (terpri)) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
765 (terpri) |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
766 (princ "Note: if you have redefined a function, then it may no longer\n") |
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
767 (princ "be set to debug on entry, even if it is in the list."))))) |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
477
diff
changeset
|
768 |
18383 | 769 (provide 'debug) |
770 | |
60256
62670df9ca97
(debug): Hide the buffer if it's not killed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59123
diff
changeset
|
771 ;; arch-tag: b6ec7047-f801-4103-9c63-d69322db9d3b |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
477
diff
changeset
|
772 ;;; debug.el ends here |