annotate lisp/edebug/edebug.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; edebug.el --- a source-level debugger for Emacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1988,'89,'90,'91,'92,'93,'94,'95 Free Software Foundation, Inc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: lisp, tools, maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; edebug|Daniel LaLiberte|liberte@cs.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; |A source level debugger for Emacs Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; |$Date: 1996/12/18 03:33:28 $|$Revision: 1.1.1.1 $|~/modes/edebug.el|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; This minor mode allows programmers to step through Emacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; source code while executing functions. You can also set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; breakpoints, trace (stopping at each expression), evaluate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; expressions as if outside Edebug, reevaluate and display a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; expressions, trap errors normally caught by debug, and display a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; debug style backtrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;; Installation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; =============
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; Put edebug.el in some directory in your load-path and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; byte-compile it. Also read the beginning of edebug-epoch.el,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; cl-specs.el, and edebug-cl-read.el if they apply to you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; Unless you are using Emacs 19 which is already set up to use Edebug,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; put the following forms in your .emacs file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; (define-key emacs-lisp-mode-map "\C-xx" 'edebug-eval-top-level-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; (autoload 'edebug-eval-top-level-form "edebug")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; If you wish to change the default edebug global command prefix, change:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; (setq edebug-global-prefix "\C-xX")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; Other options, are described in the manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; In previous versions of Edebug, users were directed to set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; `debugger' to `edebug-debug'. This is no longer necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; since Edebug automatically sets it whenever Edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;;; Minimal Instructions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; =====================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; First evaluate a defun with C-xx, then run the function. Step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; through the code with SPC, mark breakpoints with b, go until a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; breakpoint is reached with g, and quit execution with q. Use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; "?" command in edebug to describe other commands. See edebug.tex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; or the Emacs 19 Lisp Reference Manual for more instructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; Send me your enhancements, ideas, bugs, or fixes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; For bugs, you can call edebug-submit-bug-report if you have reporter.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; There is an edebug mailing list if you want to keep up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; with the latest developments. Requests to: edebug-request@cs.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; Daniel LaLiberte 217-398-4114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; University of Illinois, Urbana-Champaign
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; Department of Computer Science
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; 1304 W Springfield
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; Urbana, IL 61801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; uiucdcs!liberte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; liberte@cs.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; For the early revision history, see edebug-history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defconst edebug-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (let ((raw-version "$Revision: 1.1.1.1 $"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (substring raw-version (string-match "[0-9.]*" raw-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (require 'backquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; Emacs 18 doesnt have defalias.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (or (fboundp 'defalias) (fset 'defalias 'fset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;;; Bug reporting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; ==============
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defconst edebug-maintainer-address "liberte@cs.uiuc.edu")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defun edebug-submit-bug-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "Submit, via mail, a bug report on edebug."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (and (y-or-n-p "Do you really want to submit a report on edebug? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 edebug-maintainer-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (concat "edebug.el " edebug-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (list 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 'edebug-all-defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 'edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 'edebug-eval-macro-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 'edebug-stop-before-symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 'edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 'edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 'edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 'edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 'edebug-test-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 'edebug-continue-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 'edebug-print-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 'edebug-print-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 'edebug-print-circle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;;; Options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defvar edebug-setup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "*Functions to call before edebug is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 Each time it is set to a new value, Edebug will call those functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 once and then `edebug-setup-hook' is reset to nil. You could use this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 to load up Edebug specifications associated with a package you are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 using but only when you also use Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (defvar edebug-all-defs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 "*If non-nil, evaluation of any defining forms will instrument for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 This applies to `eval-defun', `eval-region', `eval-buffer', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 `eval-current-buffer'. `eval-region' is also called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 `eval-last-sexp', and `eval-print-last-sexp'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 You can use the command `edebug-all-defs' to toggle the value of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 variable. You may wish to make it local to each buffer with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 \(make-local-variable 'edebug-all-defs) in your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 `emacs-lisp-mode-hook'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defvar edebug-all-forms nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "*Non-nil evaluation of all forms will instrument for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 This doesn't apply to loading or evaluations in the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Use the command `edebug-all-forms' to toggle the value of this option.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defvar edebug-eval-macro-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "*Non-nil means all macro call arguments may be evaluated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 If this variable is nil, the default, Edebug will *not* wrap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 macro call arguments as if they will be evaluated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 For each macro, a `edebug-form-spec' overrides this option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 So to specify exceptions for macros that have some arguments evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 and some not, you should specify an `edebug-form-spec'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 This option is going away soon.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defvar edebug-stop-before-symbols nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "*Non-nil causes Edebug to stop before symbols as well as after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 In any case, a breakpoint or interrupt may stop before a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 This option is going away soon.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defvar edebug-save-windows t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "*If non-nil, Edebug saves and restores the window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 That takes some time, so if your program does not care what happens to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 the window configurations, it is better to set this variable to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 If the value is a list, only the listed windows are saved and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 restored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 `edebug-toggle-save-windows' may be used to change this variable.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defvar edebug-save-displayed-buffer-points nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "*If non-nil, save and restore point in all displayed buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 Saving and restoring point in other buffers is necessary if you are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 debugging code that changes the point of a buffer which is displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 in a non-selected window. If Edebug or the user then selects the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 window, the buffer's point will be changed to the window's point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 Saving and restoring point in all buffers is expensive, since it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 requires selecting each window twice, so enable this only if you need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defvar edebug-initial-mode 'step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "*Initial execution mode for Edebug, if non-nil. If this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 is non-@code{nil}, it specifies the initial execution mode for Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 when it is first activated. Possible values are step, next, go,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 Go-nonstop, trace, Trace-fast, continue, and Continue-fast.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defvar edebug-trace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 "*Non-nil means display a trace of function entry and exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 Tracing output is displayed in a buffer named `*edebug-trace*', one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 function entry or exit per line, indented by the recursion level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 You can customize by replacing functions `edebug-print-trace-before'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 and `edebug-print-trace-after'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defvar edebug-test-coverage nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 "*If non-nil, Edebug tests coverage of all expressions debugged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 This is done by comparing the result of each expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 with the previous result. Coverage is considered OK if two different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 results are found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 Use `edebug-display-freq-count' to display the frequency count and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 coverage information for a definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defvar edebug-continue-kbd-macro nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "*If non-nil, continue defining or executing any keyboard macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 Use this with caution since it is not debugged.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (defvar edebug-print-length 50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 "*Default value of `print-length' to use while printing results in Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defvar edebug-print-level 50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "*Default value of `print-level' to use while printing results in Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defvar edebug-print-circle t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 "*Default value of `print-circle' to use while printing results in Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defvar edebug-unwrap-results nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "*Non-nil if Edebug should unwrap results of expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 This is useful when debugging macros where the results of expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 are instrumented expressions. But don't do this when results might be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 circular or an infinite loop will result.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (defvar edebug-on-error t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "*Value bound to `debug-on-error' while Edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 If `debug-on-error' is non-nil, that value is still used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 If the value is a list of signal names, Edebug will stop when any of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 these errors are signaled from Lisp code whether or not the signal is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 handled by a `condition-case'. This option is useful for debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 signals that *are* handled since they would otherwise be missed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 After execution is resumed, the error is signaled again.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defvar edebug-on-quit t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "*Value bound to `debug-on-quit' while Edebug is active.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (defvar edebug-global-break-condition nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 "*If non-nil, an expression to test for at every stop point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 If the result is non-nil, then break. Errors are ignored.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;;; Form spec utilities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (defmacro def-edebug-spec (symbol spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "Set the edebug-form-spec property of SYMBOL according to SPEC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 Both SYMBOL and SPEC are unevaluated. The SPEC can be 0, t, a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 \(naming a function), or a list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (` (put (quote (, symbol)) 'edebug-form-spec (quote (, spec)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defmacro def-edebug-form-spec (symbol spec-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "For compatibility with old version. Use `def-edebug-spec' instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (message "Obsolete: use def-edebug-spec instead.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (def-edebug-spec symbol (eval spec-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (defun get-edebug-spec (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; Get the spec of symbol resolving all indirection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (let ((edebug-form-spec (get symbol 'edebug-form-spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 indirect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (while (and (symbolp edebug-form-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq indirect (get edebug-form-spec 'edebug-form-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; (edebug-trace "indirection: %s" edebug-form-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (setq edebug-form-spec indirect))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 edebug-form-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;;; Utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; Define edebug-gensym - from old cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defvar edebug-gensym-index 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "Integer used by `edebug-gensym' to produce new names.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defun edebug-gensym (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "Generate a fresh uninterned symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 There is an optional argument, PREFIX. PREFIX is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 string that begins the new name. Most people take just the default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 except when debugging needs suggest otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (if (null prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq prefix "G"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (let ((newsymbol nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (newname ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (while (not newsymbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq newname (concat prefix (int-to-string edebug-gensym-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (setq edebug-gensym-index (+ edebug-gensym-index 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (if (not (intern-soft newname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq newsymbol (make-symbol newname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 newsymbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; Only used by CL-like code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defun edebug-keywordp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "Return t if OBJECT is a keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 A keyword is a symbol that starts with `:'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (= ?: (aref (symbol-name object) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defun edebug-lambda-list-keywordp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "Return t if OBJECT is a lambda list keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 A lambda list keyword is a symbol that starts with `&'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (= ?& (aref (symbol-name object) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defun edebug-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; Return the last sexp before point in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;; Assumes Emacs Lisp syntax is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (read-from-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (forward-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defun edebug-window-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Return a list of windows, in order of `next-window'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; This doesnt work for epoch.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (window-list (list first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (next (next-window first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (while (not (eq next first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (setq window-list (cons next window-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq next (next-window next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (nreverse window-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (defun edebug-window-live-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "Return non-nil if WINDOW is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (next (next-window first-window t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (while (not (or (eq next window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (eq next first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (setq next (next-window next t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (eq next window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; Not used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 '(defun edebug-two-window-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Return t if there are two windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (and (not (one-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (eq (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (next-window (next-window (selected-window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defsubst edebug-lookup-function (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (while (and (symbolp object) (fboundp object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (setq object (symbol-function object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defun edebug-macrop (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "Return the macro named by OBJECT, or nil if it is not a macro."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (setq object (edebug-lookup-function object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (if (and (listp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (eq 'macro (car object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (edebug-functionp (cdr object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (defun edebug-functionp (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 "Returns the function named by OBJECT, or nil if it is not a function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (setq object (edebug-lookup-function object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (if (or (subrp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (byte-code-function-p object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (and (listp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (eq (car object) 'lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (listp (car (cdr object)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun edebug-sort-alist (alist function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; Return the ALIST sorted with comparison function FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;; This uses 'sort so the sorting is destructive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (sort alist (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (lambda (e1 e2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (funcall function (car e1) (car e2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;;(def-edebug-spec edebug-save-restriction t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;; Not used. If it is used, def-edebug-spec must be defined before use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 '(defmacro edebug-save-restriction (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 "Evaluate BODY while saving the current buffers restriction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 BODY may change buffer outside of current restriction, unlike
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 save-restriction. BODY may change the current buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 and the restriction will be restored to the original buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 and the current buffer remains current.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 Return the result of the last expression in BODY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (` (let ((edebug:s-r-beg (point-min-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (edebug:s-r-end (point-max-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (progn (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (set-buffer (marker-buffer edebug:s-r-beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (narrow-to-region edebug:s-r-beg edebug:s-r-end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;;;; Display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;;; ============
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (defconst edebug-trace-buffer "*edebug-trace*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 "Name of the buffer to put trace info in.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (defun edebug-pop-to-buffer (buffer &optional window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; Like pop-to-buffer, but select window where BUFFER was last shown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;; Select WINDOW if it provided and it still exists. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; if buffer is currently shown in several windows, choose one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;; Otherwise, find a new window, possibly splitting one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq window (if (and (windowp window) (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (eq (window-buffer window) buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (eq (window-buffer (selected-window)) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (edebug-get-buffer-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (if (one-window-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (split-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;; (message "next window: %s" (next-window)) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (if (eq (get-buffer-window edebug-trace-buffer) (next-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; Dont select trace window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (select-window (next-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (set-window-buffer (selected-window) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (set-window-hscroll (selected-window) 0);; should this be??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; Selecting the window does not set the buffer until command loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;;(set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (defun edebug-get-displayed-buffer-points ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; Return a list of buffer point pairs, for all displayed buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (let* ((first-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (next (next-window first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (buffer-point-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (while (not (eq next first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (set-buffer (setq buffer (window-buffer next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (setq buffer-point-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (cons (cons buffer (point)) buffer-point-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (setq next (next-window next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 buffer-point-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun edebug-set-buffer-points (buffer-points)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; Restore the buffer-points created by edebug-get-displayed-buffer-points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (let ((current-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (mapcar (function (lambda (buf-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if (buffer-name (car buf-point)) ; still exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (set-buffer (car buf-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (goto-char (cdr buf-point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 buffer-points)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (set-buffer current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (defun edebug-current-windows (which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;; Get either a full window configuration or some window information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if (listp which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (mapcar (function (lambda (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (if (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (list window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (window-buffer window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (window-point window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (window-start window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (window-hscroll window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 which-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (defun edebug-set-windows (window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; Set either a full window configuration or some window information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if (listp window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (lambda (one-window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (if one-window-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (apply (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (lambda (window buffer point start hscroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (if (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (set-window-buffer window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (set-window-point window point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (set-window-start window start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (set-window-hscroll window hscroll)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 one-window-info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 window-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (set-window-configuration window-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defalias 'edebug-get-buffer-window 'get-buffer-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (defalias 'edebug-sit-for 'sit-for)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (defalias 'edebug-input-pending-p 'input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;;; Redefine read and eval functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;;; =================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;;; read is redefined to maybe instrument forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;;; eval-defun is redefined to check edebug-all-forms and edebug-all-defs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;;; Use the Lisp version of eval-region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (require 'eval-reg "eval-reg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;; Save the original read function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (or (fboundp 'edebug-original-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (defalias 'edebug-original-read (symbol-function 'read)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defun edebug-read (&optional stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 "Read one Lisp expression as text from STREAM, return as Lisp object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 If STREAM is nil, use the value of `standard-input' (which see).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 STREAM or the value of `standard-input' may be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 a buffer (read from point and advance it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 a marker (read from where it points and advance it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 a function (call it with no arguments for each character,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 call it with a char as argument to push a char back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 a string (takes text from string, starting at the beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 t (read text line using minibuffer and use it).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 This version, from Edebug, maybe instruments the expression. But the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 STREAM must be the current buffer to do so. Whether it instuments is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 also dependent on the values of `edebug-all-defs' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 `edebug-all-forms'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (or stream (setq stream standard-input))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (if (eq stream (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (edebug-read-and-maybe-wrap-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (edebug-original-read stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (or (fboundp 'edebug-original-eval-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (defalias 'edebug-original-eval-defun (symbol-function 'eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (defun edebug-eval-defun (edebug-it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 "Evaluate the top-level form containing point, or after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 This version, from Edebug, has the following differences: With a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 prefix argument instrument the code for Edebug. If `edebug-all-defs' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 non-nil, then the code is instrumented *unless* there is a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 argument. If instrumenting, it prints: `Edebug: FUNCTIONNAME'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 Otherwise, it prints in the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (let ((edebugging (not (eq (not edebug-it) (not edebug-all-defs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (edebug-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (setq edebug-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (eval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (let ((edebug-all-forms edebugging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (edebug-all-defs (eq edebug-all-defs (not edebug-it))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (edebug-read-top-level-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (if (not edebugging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (princ edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 edebug-result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (defalias 'edebug-defun 'edebug-eval-top-level-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (defun edebug-eval-top-level-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 "Evaluate a top level form, such as a defun or defmacro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 This is like `eval-defun', but the code is always instrumented for Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 Print its name in the minibuffer and leave point where it is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 or if an error occurs, leave point after it with mark at the original point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (eval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ;; Bind edebug-all-forms only while reading, not while evaling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; but this causes problems while edebugging edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (let ((edebug-all-forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (edebug-all-defs t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (edebug-read-top-level-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defun edebug-read-top-level-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (let ((starting-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (end-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (edebug-read-and-maybe-wrap-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;; Recover point, but only if no error occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (goto-char starting-point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; Compatibility with old versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defalias 'edebug-all-defuns 'edebug-all-defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (defun edebug-all-defs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "Toggle edebugging of all definitions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (setq edebug-all-defs (not edebug-all-defs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (message "Edebugging all definitions is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (if edebug-all-defs "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun edebug-all-forms ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "Toggle edebugging of all forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (setq edebug-all-forms (not edebug-all-forms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (message "Edebugging all forms is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (if edebug-all-forms "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (defun edebug-install-read-eval-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; Don't install if already installed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (if (eq (symbol-function 'read) 'edebug-read) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (elisp-eval-region-install)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (defalias 'read 'edebug-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defalias 'eval-defun 'edebug-eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (defun edebug-uninstall-read-eval-functions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (elisp-eval-region-uninstall)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (defalias 'read (symbol-function 'edebug-original-read))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (defalias 'eval-defun (symbol-function 'edebug-original-eval-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;;;; Edebug internal data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ;;; The internal data that is needed for edebugging is kept in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;;; buffer-local variable `edebug-form-data'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;; XEmacs change?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (defconst edebug-form-data nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (make-variable-buffer-local 'edebug-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; A list of entries associating symbols with buffer regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;; This is an automatic buffer local variable. Each entry looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; @code{(@var{symbol} @var{begin-marker} @var{end-marker}). The markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; are at the beginning and end of an entry level form and @var{symbol} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; a symbol that holds all edebug related information for the form on its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; In the future, the symbol will be irrelevant and edebug data will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; be stored in the definitions themselves rather than in the property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; list of a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (defun edebug-make-form-data-entry (symbol begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (list symbol begin end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (defsubst edebug-form-data-name (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (car entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (defsubst edebug-form-data-begin (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (nth 1 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (defsubst edebug-form-data-end (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (nth 2 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (defsubst edebug-set-form-data-entry (entry name begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (setcar entry name);; in case name is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (set-marker (nth 1 entry) begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (set-marker (nth 2 entry) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (defun edebug-get-form-data-entry (pnt &optional end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;; Find the edebug form data entry which is closest to PNT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;; If END-POINT is supplied, match must be exact.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;; Return `nil' if none found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (let ((rest edebug-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 closest-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (closest-dist 999999)) ;; need maxint here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (while (and rest (< 0 closest-dist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (let* ((entry (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (begin (edebug-form-data-begin entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (dist (- pnt begin)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (setq rest (cdr rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if (and (<= 0 dist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (< dist closest-dist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (or (not end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (= end-point (edebug-form-data-end entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (<= pnt (edebug-form-data-end entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (setq closest-dist dist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 closest-entry entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 closest-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; Also need to find all contained entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; and find an entry given a symbol, which should be just assq.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (defun edebug-form-data-symbol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; Return the edebug data symbol of the form where point is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ;; If point is not inside a edebuggable form, cause error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (or (edebug-form-data-name (edebug-get-form-data-entry (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (error "Not inside instrumented form")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (defun edebug-make-top-form-data-entry (new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;; Make NEW-ENTRY the first element in the `edebug-form-data' list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (edebug-clear-form-data-entry new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (setq edebug-form-data (cons new-entry edebug-form-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (defun edebug-clear-form-data-entry (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;; If non-nil, clear ENTRY out of the form data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 ;; Maybe clear the markers and delete the symbol's edebug property?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (if entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 ;; Instead of this, we could just find all contained forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;; (put (car entry) 'edebug nil) ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;; (mapcar 'edebug-clear-form-data-entry ; dangerous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; (get (car entry) 'edebug-dependents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; (set-marker (nth 1 entry) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 ;; (set-marker (nth 2 entry) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (setq edebug-form-data (delq entry edebug-form-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ;;;; Parser utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (defun edebug-syntax-error (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ;; Signal an invalid-read-syntax with ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (signal 'invalid-read-syntax args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (defconst edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;; Lookup table for significant characters indicating the class of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;; token that follows. This is not a \"real\" syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (let ((table (make-vector 256 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (while (< i ?!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (aset table i 'space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (aset table ?\( 'lparen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (aset table ?\) 'rparen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (aset table ?\' 'quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (aset table ?\" 'string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (aset table ?\? 'char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (aset table ?\[ 'lbracket)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (aset table ?\] 'rbracket)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (aset table ?\. 'dot)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (aset table ?\# 'hash)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ;; We treat numbers as symbols, because of confusion with -, -1, and 1-.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 ;; We dont care about any other chars since they wont be seen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (defun edebug-next-token-class ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; Move to the next token and return its class. We only care about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;; lparen, rparen, dot, quote, string, char, vector, or symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (edebug-skip-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (aref edebug-read-syntax-table (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (defun edebug-skip-whitespace ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;; Leave point before the next token, skipping white space and comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (skip-chars-forward " \t\r\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (while (= (following-char) ?\;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;; \r is counted as a comment terminator to support selective display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (skip-chars-forward "^\n\r") ; skip the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (skip-chars-forward " \t\r\n\f")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 ;; Mostly obsolete reader; still used in one case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (defun edebug-read-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;; Read one sexp from the current buffer starting at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ;; Leave point immediately after it. A sexp can be a list or atom.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ;; An atom is a symbol (or number), character, string, or vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ;; This works for reading anything legitimate, but it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 ;; is gummed up by parser inconsistencies (bugs?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (let ((class (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;; read goes one too far if a (possibly quoted) string or symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;; is immediately followed by non-whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ((eq class 'symbol) (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (if (not (eq (aref edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (preceding-char)) 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ((eq class 'string) (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (if (/= (preceding-char) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ((eq class 'quote) (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (list 'quote (edebug-read-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (t ; anything else, just read it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (edebug-original-read (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ;;;; Offsets for reader
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ;;; ==============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ;; Define a structure to represent offset positions of expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ;; Each offset structure looks like: (before . after) for constituents,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ;; or for structures that have elements: (before <subexpressions> . after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;; where the <subexpressions> are the offset structures for subexpressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;; including the head of a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (defconst edebug-offsets nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; Stack of offset structures in reverse order of the nesting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;; This is used to get back to previous levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (defconst edebug-offsets-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (defconst edebug-current-offset nil) ; Top of the stack, for convenience.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ;; We must store whether we just read a list with a dotted form that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 ;; is itself a list. This structure will be condensed, so the offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; must also be condensed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (defconst edebug-read-dotted-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defsubst edebug-initialize-offsets ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; Reinitialize offset recording.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (setq edebug-current-offset nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (defun edebug-store-before-offset (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 ;; Add a new offset pair with POINT as the before offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (let ((new-offset (list point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (if edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (setcdr edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (cons new-offset (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;; Otherwise, we are at the top level, so initialize.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (setq edebug-offsets new-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 edebug-offsets-stack nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 edebug-read-dotted-list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;; Cons the new offset to the front of the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (setq edebug-offsets-stack (cons new-offset edebug-offsets-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 edebug-current-offset new-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (defun edebug-store-after-offset (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 ;; Finalize the current offset struct by reversing it and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; store POINT as the after offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (if (not edebug-read-dotted-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ;; Just reverse the offsets of all subexpressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (setcdr edebug-current-offset (nreverse (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;; We just read a list after a dot, which will be abbreviated out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (setq edebug-read-dotted-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;; Drop the corresponding offset pair.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ;; That is, nconc the reverse of the rest of the offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; with the cdr of last offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (setcdr edebug-current-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (nconc (nreverse (cdr (cdr edebug-current-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (cdr (car (cdr edebug-current-offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; Now append the point using nconc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (setq edebug-current-offset (nconc edebug-current-offset point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; Pop the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (setq edebug-offsets-stack (cdr edebug-offsets-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 edebug-current-offset (car edebug-offsets-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (defun edebug-ignore-offset ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; Ignore the last created offset pair.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setcdr edebug-current-offset (cdr (cdr edebug-current-offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (def-edebug-spec edebug-storing-offsets (form body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (put 'edebug-storing-offsets 'lisp-indent-hook 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (defmacro edebug-storing-offsets (point &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (` (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (edebug-store-before-offset (, point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (edebug-store-after-offset (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;;;; Reader for Emacs Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;;; ==========================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 ;; Uses edebug-next-token-class (and edebug-skip-whitespace) above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (defconst edebug-read-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 '((symbol . edebug-read-symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (lparen . edebug-read-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (string . edebug-read-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (quote . edebug-read-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (lbracket . edebug-read-vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (hash . edebug-read-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (defun edebug-read-storing-offsets (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (let ((class (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 edebug-read-dotted-list) ; see edebug-store-after-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (edebug-storing-offsets (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (if (setq func (assq class edebug-read-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (funcall (cdr func) stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ;; anything else, just read it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (edebug-original-read stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (defun edebug-read-symbol (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (edebug-original-read stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; loses for escaped chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (if (not (eq (aref edebug-read-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (preceding-char)) 'symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (defun edebug-read-string (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (edebug-original-read stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (if (/= (preceding-char) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (defun edebug-read-quote (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; Turn 'thing into (quote thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (edebug-storing-offsets (point) 'quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (edebug-read-storing-offsets stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (defun edebug-read-function (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 ;; Turn #'thing into (function thing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (if (/= ?\' (following-char)) (edebug-syntax-error "Bad char"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (edebug-storing-offsets (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (if (featurep 'cl) 'function* 'function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (edebug-read-storing-offsets stream)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (defun edebug-read-list (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (forward-char 1) ; skip \(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (let ((elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (while (not (memq (edebug-next-token-class) '(rparen dot)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (setq elements (cons (edebug-read-storing-offsets stream) elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (setq elements (nreverse elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (if (eq 'dot (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (let (dotted-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (forward-char 1) ; skip \.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (setq dotted-form (edebug-read-storing-offsets stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 elements (nconc elements dotted-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (if (not (eq (edebug-next-token-class) 'rparen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (edebug-syntax-error "Expected `)'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (setq edebug-read-dotted-list (listp dotted-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 elements)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (forward-char 1) ; skip \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (defun edebug-read-vector (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (forward-char 1) ; skip \[
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (let ((elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (while (not (eq 'rbracket (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (setq elements (cons (edebug-read-storing-offsets stream) elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (apply 'vector (nreverse elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (forward-char 1) ; skip \]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ;;;; Cursors for traversal of list and vector elements with offsets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ;;;====================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (defvar edebug-dotted-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (defun edebug-new-cursor (expressions offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; Return a new cursor for EXPRESSIONS with OFFSETS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (if (vectorp expressions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (setq expressions (append expressions nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (cons expressions offsets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (defsubst edebug-set-cursor (cursor expressions offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; Set the CURSOR's EXPRESSIONS and OFFSETS to the given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ;; Return the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (setcar cursor expressions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (setcdr cursor offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 '(defun edebug-copy-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;; Copy the cursor using the same object and offsets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (cons (car cursor) (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (defsubst edebug-cursor-expressions (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (car cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (defsubst edebug-cursor-offsets (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (cdr cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (defsubst edebug-empty-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ;; Return non-nil if CURSOR is empty - meaning no more elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (null (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (defsubst edebug-top-element (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; Return the top element at the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; Assumes not empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (car (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (defun edebug-top-element-required (cursor &rest error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 ;; Check if a dotted form is required.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (if edebug-dotted-spec (edebug-no-match cursor "Dot expected."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; Check if there is at least one more argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (if (edebug-empty-cursor cursor) (apply 'edebug-no-match cursor error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 ;; Return that top element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (edebug-top-element cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (defsubst edebug-top-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;; Return the top offset pair corresponding to the top element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (car (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (defun edebug-move-cursor (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 ;; Advance and return the cursor to the next element and offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;; throw no-match if empty before moving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;; This is a violation of the cursor encapsulation, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;; there is plenty of that going on while matching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;; The following test should always fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (if (edebug-empty-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (edebug-no-match cursor "Not enough arguments."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (setcar cursor (cdr (car cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (setcdr cursor (cdr (cdr cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (defun edebug-before-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;; Return the before offset of the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ;; If there is nothing left in the offsets,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;; return one less than the offset itself,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; which is the after offset for a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (let ((offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (if (consp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (car (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (1- offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (defun edebug-after-offset (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 ;; Return the after offset of the cursor object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (let ((offset (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (while (consp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (setq offset (cdr offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 ;;;; The Parser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ;;; The top level function for parsing forms is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;;; edebug-read-and-maybe-wrap-form; it calls all the rest. It checks the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;;; syntax a bit and leaves point at any error it finds, but otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;;; should appear to work like eval-defun.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 ;;; The basic plan is to surround each expression with a call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ;;; the edebug debugger together with indexes into a table of positions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ;;; all expressions. Thus an expression "exp" becomes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;;; (edebug-after (edebug-before 1) 2 exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 ;;; When this is evaluated, first point is moved to the beginning of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ;;; exp at offset 1 of the current function. The expression is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 ;;; evaluated, which may cause more edebug calls, and then point is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 ;;; moved to offset 2 after the end of exp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ;;; The highest level expressions of the function are wrapped in a call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;;; edebug-enter, which supplies the function name and the actual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 ;;; arguments to the function. See functions edebug-enter, edebug-before,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 ;;; and edebug-after for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 ;; Dynamically bound vars, left unbound, but globally declared.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 ;; This is to quiet the byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 ;; Window data of the highest definition being wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 ;; This data is shared by all embedded definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (defvar edebug-top-window-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (defvar edebug-&optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (defvar edebug-&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (defvar edebug-gate nil) ;; whether no-match forces an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (defconst edebug-def-name nil) ; name of definition, used by interactive-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (defconst edebug-old-def-name nil) ; previous name of containing definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (defconst edebug-error-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (defconst edebug-best-error nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (defun edebug-read-and-maybe-wrap-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ;; Read a form and wrap it with edebug calls, if the conditions are right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 ;; Here we just catch any no-match not caught below and signal an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 ;; Run the setup hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (run-hooks 'edebug-setup-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (setq edebug-setup-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (let (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 edebug-def-name;; make sure it is locally nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 ;; I dont like these here!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 edebug-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 edebug-gate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 ;; Do this once here instead of several times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (max-lisp-eval-depth (+ 800 max-lisp-eval-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (max-specpdl-size (+ 2000 max-specpdl-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (setq no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (setq result (edebug-read-and-maybe-wrap-form1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (if no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (apply 'edebug-syntax-error no-match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (defun edebug-read-and-maybe-wrap-form1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (let (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 def-kind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 ;; These offset things dont belong here, but to support recursive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 ;; calls to edebug-read, they need to be here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 edebug-offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 edebug-offsets-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 edebug-current-offset ; reset to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (if (and (eq 'lparen (edebug-next-token-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (eq 'symbol (progn (forward-char 1) (edebug-next-token-class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;; Find out if this is a defining form from first symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (setq def-kind (edebug-original-read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 spec (and (symbolp def-kind) (get-edebug-spec def-kind))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 defining-form-p (and (listp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ;; This is incorrect in general!! But OK most of the time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 def-name (if (and defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (eq 'name (car (cdr spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (eq 'symbol (edebug-next-token-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (edebug-original-read (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;;;(message "all defs: %s all forms: %s" edebug-all-defs edebug-all-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (defining-form-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (if (or edebug-all-defs edebug-all-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ;; If it is a defining form and we are edebugging defs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 ;; then let edebug-list-form start it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (let ((cursor (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (list (edebug-read-storing-offsets (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (list edebug-offsets))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (1- (edebug-after-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (list (cons (symbol-name def-kind) (cdr spec))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 ;; Not edebugging this form, so reset the symbol's edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 ;; property to be just a marker at the definition's source code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 ;; This only works for defs with simple names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (put def-name 'edebug (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;; Also nil out dependent defs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 '(mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (lambda (def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (put def-name 'edebug nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (get def-name 'edebug-dependents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (edebug-read-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 ;; If all forms are being edebugged, explicitly wrap it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (let ((cursor (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (list (edebug-read-storing-offsets (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (list edebug-offsets))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ;; Not a defining form, and not edebugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (t (edebug-read-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (defvar edebug-def-args) ; args of defining form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (defvar edebug-def-interactive) ; is it an emacs interactive function?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (defvar edebug-inside-func) ;; whether code is inside function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; Currently def-form sets this to nil; def-body sets it to t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (defun edebug-interactive-p-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;; Return a unique symbol for the variable used to store the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 ;; status of interactive-p for this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (intern (format "edebug-%s-interactive-p" edebug-def-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (defun edebug-wrap-def-body (forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 "Wrap the FORMS of a definition body."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (if edebug-def-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (` (let (((, (edebug-interactive-p-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (interactive-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (, (edebug-make-enter-wrapper forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (edebug-make-enter-wrapper forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (defun edebug-make-enter-wrapper (forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; Generate the enter wrapper for some forms of a definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;; This is not to be used for the body of other forms, e.g. `while',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; since it wraps the list of forms with a call to `edebug-enter'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 ;; Do this after parsing since that may find a name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (` (edebug-enter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (quote (, edebug-def-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (, (if edebug-inside-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (` (list (,@
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; Doesnt work with more than one def-body!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ;; But the list will just be reversed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (nreverse edebug-def-args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 'nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (function (lambda () (,@ forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (defvar edebug-form-begin-marker) ; the mark for def being instrumented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (defvar edebug-offset-index) ; the next available offset index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (defvar edebug-offset-list) ; the list of offset positions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (defun edebug-inc-offset (offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; modifies edebug-offset-index and edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 ;; accesses edebug-func-marc and buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 edebug-offset-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (setq edebug-offset-list (cons (- offset edebug-form-begin-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 edebug-offset-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 edebug-offset-index (1+ edebug-offset-index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (defun edebug-make-before-and-after-form (before-index form after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ;; Return the edebug form for the current function at offset BEFORE-INDEX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 ;; given FORM. Looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;; (edebug-after (edebug-before BEFORE-INDEX) AFTER-INDEX FORM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 ;; Also increment the offset index for subsequent use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; if (not edebug-stop-before-symbols) and form is a symbol,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ;; then dont call edebug-before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (list 'edebug-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (list 'edebug-before before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 after-index form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (defun edebug-make-after-form (form after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; Like edebug-make-before-and-after-form, but only after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (list 'edebug-after 0 after-index form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (defun edebug-unwrap (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 "Return the unwrapped SEXP or return it as is if it is not wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 The SEXP might be the result of wrapping a body, which is a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 expressions; a `progn' form will be returned enclosing these forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (if (consp sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ((eq 'edebug-after (car sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (nth 3 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ((eq 'edebug-enter (car sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (let ((forms (nthcdr 2 (nth 1 (nth 3 sexp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (if (> (length forms) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (cons 'progn forms) ;; could return (values forms) instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (car forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (t sexp);; otherwise it is not wrapped, so just return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (defun edebug-unwrap* (sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 "Return the sexp recursively unwrapped."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (let ((new-sexp (edebug-unwrap sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (while (not (eq sexp new-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (setq sexp new-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 new-sexp (edebug-unwrap sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (if (consp new-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (mapcar 'edebug-unwrap* new-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 new-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (defun edebug-defining-form (cursor form-begin form-end speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;; Process the defining form, starting outside the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 ;; The speclist is a generated list spec that looks like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ;; (("def-symbol" defining-form-spec-sans-&define))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; Skip the first offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (edebug-set-cursor cursor (edebug-cursor-expressions cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (cdr (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 form-begin (1- form-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 speclist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (defun edebug-make-form-wrapper (cursor form-begin form-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 &optional speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; Wrap a form, usually a defining form, but any evaluated one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 ;; If speclist is non-nil, this is being called by edebug-defining-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ;; Otherwise it is being called from edebug-read-and-maybe-wrap-form1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;; This is a hack, but I havent figured out a simpler way yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (let* ((form-data-entry (edebug-get-form-data-entry form-begin form-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 ;; Set this marker before parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (if form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (edebug-form-data-begin form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ;; Buffer must be current-buffer for this to work:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (set-marker (make-marker) form-begin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (let (edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (edebug-offset-index 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 ;; For definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ;; (edebug-containing-def-name edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ;; Get name from form-data, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (edebug-old-def-name (edebug-form-data-name form-data-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 edebug-def-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 edebug-def-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 edebug-inside-func;; whether wrapped code executes inside a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (if speclist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (edebug-match cursor speclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 ;; else wrap as an enter-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (edebug-make-enter-wrapper (list (edebug-form cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 ;; Set the name here if it was not set by edebug-make-enter-wrapper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ;; Add this def as a dependent of containing def. Buggy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 '(if (and edebug-containing-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (not (get edebug-containing-def-name 'edebug-dependents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (put edebug-containing-def-name 'edebug-dependents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (cons edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (get edebug-containing-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 'edebug-dependents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 ;; Create a form-data-entry or modify existing entry's markers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ;; In the latter case, pointers to the entry remain eq.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (if (not form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (setq form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (edebug-make-form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;; Buffer must be current-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (set-marker (make-marker) form-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (edebug-set-form-data-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 form-data-entry edebug-def-name ;; in case name is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 form-begin form-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 ;; (message "defining: %s" edebug-def-name) (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (edebug-make-top-form-data-entry form-data-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (message "Edebug: %s" edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 ;;(debug edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 ;; Destructively reverse edebug-offset-list and make vector from it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (setq edebug-offset-list (vconcat (nreverse edebug-offset-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 ;; Side effects on the property list of edebug-def-name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (edebug-clear-frequency-count edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (edebug-clear-coverage edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 ;; Set up the initial window data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (if (not edebug-top-window-data) ;; if not already set, do it now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (let ((window ;; Find the best window for this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (or (get-buffer-window (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (setq edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (cons window (window-start window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 ;; Store the edebug data in symbol's property list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (put edebug-def-name 'edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 ;; A struct or vector would be better here!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (list edebug-form-begin-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 nil ; clear breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 edebug-offset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 edebug-top-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (defun edebug-clear-frequency-count (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 ;; Create initial frequency count vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 ;; For each stop point, the counter is incremented each time it is visited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (put name 'edebug-freq-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (make-vector (length edebug-offset-list) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (defun edebug-clear-coverage (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 ;; Create initial coverage vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 ;; Only need one per expression, but it is simpler to use stop points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (put name 'edebug-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (make-vector (length edebug-offset-list) 'unknown)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (defun edebug-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; Return the instrumented form for the following form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ;; Add the point offsets to the edebug-offset-list for the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (let* ((form (edebug-top-element-required cursor "Expected form"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (offset (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ((consp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ;; The first offset for a list form is for the list form itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (if (eq 'quote (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (let* ((head (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (spec (and (symbolp head) (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (new-cursor (edebug-new-cursor form offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 ;; Find out if this is a defining form from first symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 ;; An indirect spec would not work here, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (if (and (consp spec) (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (car offset);; before the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (cons (symbol-name head) (cdr spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 ;; Wrap a regular form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (edebug-make-before-and-after-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (edebug-inc-offset (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (edebug-list-form new-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 ;; After processing the list form, the new-cursor is left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 ;; with the offset after the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (edebug-inc-offset (edebug-cursor-offsets new-cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 ((symbolp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 ;; Check for constant symbols that dont get wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 ((or (memq form '(t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (and (fboundp 'edebug-keywordp) (edebug-keywordp form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 ;; This option may go away.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (edebug-stop-before-symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (edebug-make-before-and-after-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (edebug-inc-offset (car offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (edebug-inc-offset (cdr offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (t ;; just a variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (edebug-make-after-form form (edebug-inc-offset (cdr offset))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 ;; Anything else is self-evaluating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (t form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (edebug-move-cursor cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (defsubst edebug-forms (cursor) (edebug-match cursor '(&rest form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (defsubst edebug-sexps (cursor) (edebug-match cursor '(&rest sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (defsubst edebug-list-form-args (head cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 ;; Process the arguments of a list form given that head of form is a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 ;; Helper for edebug-list-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (let ((spec (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 ((consp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; It is a speclist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (let (edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 edebug-error-point);; This may not be needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (edebug-match-sublist cursor spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ((eq t spec) (edebug-forms cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ((eq 0 spec) (edebug-sexps cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 ((symbolp spec) (funcall spec cursor));; Not used by edebug,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 ; but leave it in for compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 ;; No edebug-form-spec provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 ((edebug-macrop head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (if edebug-eval-macro-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (edebug-forms cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (edebug-sexps cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (t ;; Otherwise it is a function call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (edebug-forms cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (defun edebug-list-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 ;; Return an instrumented form built from the list form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 ;; The after offset will be left in the cursor after processing the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (let ((head (edebug-top-element-required cursor "Expected elements"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 ;; Prevent backtracking whenever instrumenting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 ;; A list form is never optional because it matches anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (edebug-&optional nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (edebug-&rest nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; Skip the first offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (edebug-set-cursor cursor (edebug-cursor-expressions cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (cdr (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ((null head) nil) ; () is legal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 ((symbolp head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 ((null head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (edebug-syntax-error "nil head"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 ((eq head 'interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ;; Special case: replace (interactive-p) with variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (setq edebug-def-interactive 'check-it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (edebug-interactive-p-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (cons head (edebug-list-form-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 head (edebug-move-cursor cursor))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 ((consp head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (if (and (listp head) (eq (car head) ',))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (edebug-match cursor '(("," def-form) body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 ;; Process anonymous function and args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 ;; This assumes no anonymous macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (edebug-match-specs cursor '(lambda-expr body) 'edebug-match-specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (t (edebug-syntax-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 "Head of list form must be a symbol or lambda expression.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;;;; Matching of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 ;;; ===================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (defvar edebug-after-dotted-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (defvar edebug-matching-depth 0) ;; initial value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (defconst edebug-max-depth 150) ;; maximum number of matching recursions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;;;; Failure to match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;;; ==================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 ;; This throws to no-match, if there are higher alternatives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ;; Otherwise it signals an error. The place of the error is found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ;; with the two before- and after-offset functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (defun edebug-no-match (cursor &rest edebug-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;; Throw a no-match, or signal an error immediately if gate is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;; Remember this point in case we need to report this error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (setq edebug-error-point (or edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (edebug-before-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 edebug-best-error (or edebug-best-error edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (if (and edebug-gate (not edebug-&optional))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (if edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (goto-char edebug-error-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (apply 'edebug-syntax-error edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (funcall 'throw 'no-match edebug-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (defun edebug-match (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 ;; Top level spec matching function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ;; Used also at each lower level of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (let (edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 edebug-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (edebug-gate edebug-gate) ;; locally bound to limit effect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (edebug-match-specs cursor specs 'edebug-match-specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (defun edebug-match-one-spec (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; Match one spec, which is not a keyword &-spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 ((symbolp spec) (edebug-match-symbol cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 ((vectorp spec) (edebug-match cursor (append spec nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 ((stringp spec) (edebug-match-string cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ((listp spec) (edebug-match-list cursor spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (defun edebug-match-specs (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 ;; Append results of matching the list of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 ;; The first spec is handled and the remainder-handler handles the rest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (let ((edebug-matching-depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (if (> edebug-matching-depth edebug-max-depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (error "too deep - perhaps infinite loop in spec?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (1+ edebug-matching-depth))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 ((null specs) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;; Is the spec dotted?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ((atom specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (let ((edebug-dotted-spec t));; Containing spec list was dotted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (edebug-match-specs cursor (list specs) remainder-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ;; Is the form dotted?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 ((not (listp (edebug-cursor-expressions cursor)));; allow nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (if (not edebug-dotted-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (edebug-no-match cursor "Dotted spec required."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 ;; Cancel dotted spec and dotted form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (let ((edebug-dotted-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 ;; Wrap the form in a list, (by changing the cursor??)...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (edebug-set-cursor cursor (list this-form) this-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 ;; and process normally, then unwrap the result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (car (edebug-match-specs cursor specs remainder-handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (t;; Process normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (let* ((spec (car specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (first-char (and (symbolp spec) (aref (symbol-name spec) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;;(message "spec = %s first char = %s" spec first-char) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ((eq ?& first-char);; "&" symbols take all following specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (funcall (get-edebug-spec spec) cursor (cdr specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ((eq ?: first-char);; ":" symbols take one following spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (setq rest (cdr (cdr specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 (funcall (get-edebug-spec spec) cursor (car (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (t;; Any other normal spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (setq rest (cdr specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (edebug-match-one-spec cursor spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (funcall remainder-handler cursor rest remainder-handler)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ;; Define specs for all the symbol specs with functions used to process them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 ;; Perhaps we shouldnt be doing this with edebug-form-specs since the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ;; user may want to define macros or functions with the same names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ;; We could use an internal obarray for these primitive specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (function (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (put (car pair) 'edebug-form-spec (cdr pair))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 '((&optional . edebug-match-&optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (&rest . edebug-match-&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (&or . edebug-match-&or)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (form . edebug-match-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (sexp . edebug-match-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (body . edebug-match-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (&define . edebug-match-&define)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (name . edebug-match-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (:name . edebug-match-colon-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (arg . edebug-match-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (def-body . edebug-match-def-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (def-form . edebug-match-def-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 ;; Less frequently used:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;; (function . edebug-match-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (lambda-expr . edebug-match-lambda-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (&not . edebug-match-&not)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (&key . edebug-match-&key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (place . edebug-match-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (gate . edebug-match-gate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 ;; (nil . edebug-match-nil) not this one - special case it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (defun edebug-match-symbol (cursor symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 ;; Match a symbol spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (let* ((spec (get-edebug-spec symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (if (consp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 ;; It is an indirect spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (edebug-match cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 ;; Otherwise it should be the symbol name of a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 ;; There could be a bug here - maybe need to do edebug-match bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (funcall spec cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ((null symbol) ;; special case this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (edebug-match-nil cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 ((fboundp symbol) ; is it a predicate?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (let ((sexp (edebug-top-element-required cursor "Expected" symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;; Special case for edebug-`.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (if (and (listp sexp) (eq (car sexp) ',))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (edebug-match cursor '(("," def-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (if (not (funcall symbol sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (edebug-no-match cursor symbol "failed"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (list sexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (t (error "%s is not a form-spec or function" symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (defun edebug-match-sexp (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (list (prog1 (edebug-top-element-required cursor "Expected sexp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (edebug-move-cursor cursor))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (defun edebug-match-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (list (edebug-form cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (defalias 'edebug-match-place 'edebug-match-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 ;; Currently identical to edebug-match-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 ;; This is for common lisp setf-style place arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (defsubst edebug-match-body (cursor) (edebug-forms cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (defun edebug-match-&optional (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 ;; Keep matching until one spec fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (edebug-&optional-wrapper cursor specs 'edebug-&optional-wrapper))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (defun edebug-&optional-wrapper (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (let (result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (edebug-&optional specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (edebug-gate nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (if (null (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (edebug-match-specs cursor specs remainder-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 ;; Returning nil means no no-match was thrown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;; no-match, but don't fail; just reset cursor and return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (edebug-set-cursor cursor this-form this-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (defun edebug-&rest-wrapper (cursor specs remainder-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (if (null specs) (setq specs edebug-&rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 ;; Reuse the &optional handler with this as the remainder handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (edebug-&optional-wrapper cursor specs remainder-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (defun edebug-match-&rest (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 ;; Repeatedly use specs until failure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (let ((edebug-&rest specs) ;; remember these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 edebug-error-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (edebug-&rest-wrapper cursor specs 'edebug-&rest-wrapper)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (defun edebug-match-&or (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 ;; Keep matching until one spec succeeds, and return its results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 ;; If none match, fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;; This needs to be optimized since most specs spend time here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (let ((original-specs specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (this-form (edebug-cursor-expressions cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (this-offset (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (catch 'matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (while specs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (throw 'matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (let (edebug-gate ;; only while matching each spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 edebug-error-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 ;; Doesnt support e.g. &or symbolp &rest form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (edebug-match-one-spec cursor (car specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 ;; Match failed, so reset and try again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (setq specs (cdr specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 ;; Reset the cursor for the next match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (edebug-set-cursor cursor this-form this-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; All failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (apply 'edebug-no-match cursor "Expected one of" original-specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (defun edebug-match-&not (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 ;; If any specs match, then fail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (if (null (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (let ((edebug-gate nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (edebug-match-&or cursor specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 ;; This means something matched, so it is a no match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (edebug-no-match cursor "Unexpected"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 ;; This means nothing matched, so it is OK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 nil) ;; So, return nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (def-edebug-spec &key edebug-match-&key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (defun edebug-match-&key (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 ;; Following specs must look like (<name> <spec>) ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 ;; where <name> is the name of a keyword, and spec is its spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ;; This really doesnt save much over the expanded form and takes time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (edebug-match-&rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (cons '&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (mapcar (function (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (vector (format ":%s" (car pair))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (car (cdr pair)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (defun edebug-match-gate (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; Simply set the gate to prevent backtracking at this level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (defun edebug-match-list (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 ;; The spec is a list, but what kind of list, and what context?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (if edebug-dotted-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ;; After dotted spec but form did not contain dot,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 ;; so match list spec elements as if spliced in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (let ((edebug-dotted-spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (edebug-match-specs cursor specs 'edebug-match-specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 ;; If it matched, really clear the dotted-spec flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (setq edebug-dotted-spec nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (let ((spec (car specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (form (edebug-top-element-required cursor "Expected" specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ((eq 'quote spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (let ((spec (car (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 ((symbolp spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ;; Special case: spec quotes a symbol to match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ;; Change in future. Use "..." instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (if (not (eq spec form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (edebug-no-match cursor "Expected" spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (error "Bad spec: %s" specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ((listp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (list (edebug-match-sublist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ;; First offset is for the list form itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ;; Treat nil as empty list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (edebug-new-cursor form (cdr (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (edebug-move-cursor cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 ((and (eq 'vector spec) (vectorp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 ;; Special case: match a vector with the specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (let ((result (edebug-match-sublist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (edebug-new-cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 form (cdr (edebug-top-offset cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (cdr specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (list (apply 'vector result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (t (edebug-no-match cursor "Expected" specs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (defun edebug-match-sublist (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ;; Match a sublist of specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (let (edebug-&optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 ;;edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 ;;edebug-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 ;; match with edebug-match-specs so edebug-best-error is not bound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (edebug-match-specs cursor specs 'edebug-match-specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (if (not (edebug-empty-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (if edebug-best-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (apply 'edebug-no-match cursor edebug-best-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 ;; A failed &rest or &optional spec may leave some args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (edebug-no-match cursor "Failed matching" specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (defun edebug-match-string (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (let ((sexp (edebug-top-element-required cursor "Expected" spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (if (not (eq (intern spec) sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (edebug-no-match cursor "Expected" spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;; Since it matched, failure means immediate error, unless &optional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (setq edebug-gate t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (list sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (defun edebug-match-nil (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 ;; There must be nothing left to match a nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (if (not (edebug-empty-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (edebug-no-match cursor "Unmatched argument(s)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (defun edebug-match-function (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (error "Use function-form instead of function in edebug spec"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (defun edebug-match-&define (cursor specs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 ;; Match a defining form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 ;; Normally, &define is interpretted specially other places.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 ;; This should only be called inside of a spec list to match the remainder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ;; of the current list. e.g. ("lambda" &define args def-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 (edebug-make-form-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (edebug-before-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ;; Find the last offset in the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (let ((offsets (edebug-cursor-offsets cursor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (while (consp offsets) (setq offsets (cdr offsets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 specs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (defun edebug-match-lambda-expr (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 ;; The expression must be a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 ;; This will match any list form that begins with a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ;; that has an edebug-form-spec beginning with &define. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ;; practice, only lambda expressions should be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 ;; I could add a &lambda specification to avoid confusion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (let* ((sexp (edebug-top-element-required
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 cursor "Expected lambda expression"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (offset (edebug-top-offset cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (head (and (consp sexp) (car sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (spec (and (symbolp head) (get-edebug-spec head)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (edebug-inside-func nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ;; Find out if this is a defining form from first symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (if (and (consp spec) (eq '&define (car spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (edebug-new-cursor sexp offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (car offset);; before the sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (edebug-after-offset cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (cons (symbol-name head) (cdr spec))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (edebug-move-cursor cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (edebug-no-match cursor "Expected lambda expression")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (defun edebug-match-name (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 ;; Set the edebug-def-name bound in edebug-defining-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (let ((name (edebug-top-element-required cursor "Expected name")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 ;; Maybe strings and numbers could be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (if (not (symbolp name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (edebug-no-match cursor "Symbol expected for name of definition"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (if edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 ;; Construct a new name by appending to previous name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (intern (format "%s@%s" edebug-def-name name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (list name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (defun edebug-match-colon-name (cursor spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 ;; Set the edebug-def-name to the spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (setq edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (if edebug-def-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 ;; Construct a new name by appending to previous name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (intern (format "%s@%s" edebug-def-name spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 spec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (defun edebug-match-arg (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 ;; set the def-args bound in edebug-defining-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (let ((edebug-arg (edebug-top-element-required cursor "Expected arg")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (if (or (not (symbolp edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (edebug-lambda-list-keywordp edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (edebug-no-match cursor "Bad argument:" edebug-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (edebug-move-cursor cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (setq edebug-def-args (cons edebug-arg edebug-def-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (list edebug-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (defun edebug-match-def-form (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 ;; Like form but the form is wrapped in edebug-enter form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 ;; The form is assumed to be executing outside of the function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 ;; This is a hack for now, since a def-form might execute inside as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 ;; Not to be used otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (let ((edebug-inside-func nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (list (edebug-make-enter-wrapper (list (edebug-form cursor))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (defun edebug-match-def-body (cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 ;; Like body but body is wrapped in edebug-enter form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 ;; The body is assumed to be executing inside of the function context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 ;; Not to be used otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (let ((edebug-inside-func t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (list (edebug-wrap-def-body (edebug-forms cursor)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 ;;;; Edebug Form Specs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 ;;; ==========================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 ;;; See cl-specs.el for common lisp specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 ;;;;* Spec for def-edebug-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 ;;; Out of date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (defun edebug-spec-p (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 "Return non-nil if OBJECT is a symbol with an edebug-form-spec property."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (and (symbolp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (get object 'edebug-form-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (def-edebug-spec def-edebug-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 ;; Top level is different from lower levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 (&define :name edebug-spec name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 &or "nil" edebug-spec-p "t" "0" (&rest edebug-spec)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (def-edebug-spec edebug-spec-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 ;; A list must have something in it, or it is nil, a symbolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 ((edebug-spec . [&or nil edebug-spec])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (def-edebug-spec edebug-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (vector &rest edebug-spec) ; matches a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 ("vector" &rest edebug-spec) ; matches a vector spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 ("quote" symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 edebug-spec-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 stringp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 [edebug-lambda-list-keywordp &rest edebug-spec]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 ;; [edebug-keywordp gate edebug-spec] ;; need edebug-keywordp for this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 edebug-spec-p ;; Including all the special ones e.g. form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 symbolp;; a predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 ;;;;* Emacs special forms and some functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 ;; quote expects only one argument, although it allows any number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (def-edebug-spec quote sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 ;; The standard defining forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (def-edebug-spec defconst defvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (def-edebug-spec defvar (symbolp &optional form stringp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (def-edebug-spec defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (&define name lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (def-edebug-spec defmacro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (&define name lambda-list def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (def-edebug-spec arglist lambda-list) ;; denegrated - use lambda-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (def-edebug-spec lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (([&rest arg]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 [&optional ["&optional" arg &rest arg]]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 &optional ["&rest" arg]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (def-edebug-spec interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (&optional &or stringp def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 ;; A function-form is for an argument that may be a function or a form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 ;; This specially recognizes anonymous functions quoted with quote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (def-edebug-spec function-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 ;; form at the end could also handle "function",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 ;; but recognize it specially to avoid wrapping function forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (&or ([&or "quote" "function"] &or symbolp lambda-expr) form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 ;; function expects a symbol or a lambda or macro expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 ;; A macro is allowed by Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (def-edebug-spec function (&or symbolp lambda-expr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 ;; lambda is a macro in emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (def-edebug-spec lambda (&define lambda-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 ;; A macro expression is a lambda expression with "macro" prepended.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (def-edebug-spec macro (&define "lambda" lambda-list def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 ;; (def-edebug-spec anonymous-form ((&or ["lambda" lambda] ["macro" macro])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 ;; Standard functions that take function-forms arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (def-edebug-spec mapcar (function-form form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (def-edebug-spec mapconcat (function-form form form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (def-edebug-spec mapatoms (function-form &optional form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (def-edebug-spec apply (function-form &rest form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (def-edebug-spec funcall (function-form &rest form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (def-edebug-spec let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 ((&rest &or (symbolp &optional form) symbolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (def-edebug-spec let* let)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (def-edebug-spec setq (&rest symbolp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (def-edebug-spec setq-default setq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (def-edebug-spec cond (&rest (&rest form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (def-edebug-spec condition-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (symbolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 &rest (symbolp body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (def-edebug-spec \` (backquote-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 ;; Supports quotes inside backquotes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 ;; but only at the top level inside unquotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (def-edebug-spec backquote-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (&or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 ([&or "," ",@"] &or ("quote" backquote-form) form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (backquote-form &rest backquote-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 ;; If you use dotted forms in backquotes, replace the previous line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 ;; with the following. This takes quite a bit more stack space, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ;; (backquote-form . [&or nil backquote-form])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (vector &rest backquote-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 ;; Special version of backquote that instruments backquoted forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 ;; destined to be evaluated, usually as the result of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 ;; macroexpansion. Backquoted code can only have unquotes (, and ,@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 ;; in places where list forms are allowed, and predicates. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 ;; backquote is used in a macro, unquoted code that come from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 ;; arguments must be instrumented, if at all, with def-form not def-body.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 ;; We could assume that all forms (not nested in other forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 ;; in arguments of macros should be def-forms, whether or not the macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 ;; are defined with edebug-` but this would be expensive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 ;; ,@ might have some problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (defalias 'edebug-\` '\`) ;; same macro as regular backquote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (def-edebug-spec edebug-\` (def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 ;; Assume immediate quote in unquotes mean backquote at next higher level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (def-edebug-spec , (&or ("quote" edebug-`) def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (def-edebug-spec ,@ (&define ;; so (,@ form) is never wrapped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 &or ("quote" edebug-`) def-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 ;; New byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (def-edebug-spec defsubst defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (def-edebug-spec dont-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (def-edebug-spec eval-when-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (def-edebug-spec eval-and-compile t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 ;; Anything else?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 ;;====================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 ;; Some miscellaneous specs for macros in public packages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 ;; Send me yours.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 ;; advice.el by Hans Chalupsky (hans@cs.buffalo.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (def-edebug-spec ad-dolist ((symbolp form &optional form) body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (def-edebug-spec defadvice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (&define name ;; thing being advised.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (name ;; class is [&or "before" "around" "after"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;; "activation" "deactivation"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 name ;; name of advice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 &rest sexp ;; optional position and flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 [&optional stringp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 [&optional ("interactive" interactive)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 ;;;; The debugger itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (defvar edebug-active nil) ;; Non-nil when edebug is active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 ;;; add minor-mode-alist entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (or (assq 'edebug-active minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (setq minor-mode-alist (cons (list 'edebug-active " *Debugging*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (defvar edebug-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 ;; Stack of active functions evaluated via edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 ;; Should be nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (defvar edebug-stack-depth -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 ;; Index of last edebug-stack item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (defvar edebug-offset-indices nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 ;; Stack of offset indices of visited edebug sexps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 ;; Should be nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 ;; Each function adds one cons. Top is modified with setcar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (defvar edebug-entered nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 ;; Non-nil if edebug has already been entered at this recursive edit level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 ;; This should stay nil at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 ;; Should these be options?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (defconst edebug-debugger 'edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 ;; Name of function to use for debugging when error or quit occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 ;; Set this to 'debug if you want to debug edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 ;; Dynamically bound variables, declared globally but left unbound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (defvar edebug-function) ; the function being executed. change name!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (defvar edebug-args) ; the arguments of the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (defvar edebug-data) ; the edebug data for the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (defvar edebug-value) ; the result of the expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 (defvar edebug-after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (defvar edebug-def-mark) ; the mark for the definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (defvar edebug-freq-count) ; the count of expression visits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (defvar edebug-coverage) ; the coverage results of each expression of function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (defvar edebug-buffer) ; which buffer the function is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (defvar edebug-result) ; the result of the function call returned by body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (defvar edebug-outside-executing-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (defvar edebug-outside-defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (defvar edebug-execution-mode 'step) ; Current edebug mode set by user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (defvar edebug-next-execution-mode nil) ; Use once instead of initial mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (defvar edebug-outside-debug-on-error) ; the value of debug-on-error outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (defvar edebug-outside-debug-on-quit) ; the value of debug-on-quit outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (defvar edebug-outside-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (defvar edebug-outside-post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (defvar edebug-outside-post-command-idle-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 ;; Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (defvar pre-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (defvar post-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (defvar post-command-idle-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (defvar cl-lexical-debug) ;; Defined in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 ;;; Handling signals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 ;;; =================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (if (not (fboundp 'edebug-original-signal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (defalias 'edebug-original-signal (symbol-function 'signal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 ;; We should use advise for this!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (defun edebug-signal (edebug-signal-name edebug-signal-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 "Signal an error. Args are SIGNAL-NAME, and associated DATA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 A signal name is a symbol with an `error-conditions' property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 that is a list of condition names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 A handler for any of those names will get to handle this signal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 The symbol `error' should always be one of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 DATA should be a list. Its elements are printed as part of the error message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 If the signal is handled, DATA is made available to the handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 See `condition-case'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 This is the Edebug replacement for the standard `signal'. It should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 only be active while Edebug is. It checks `debug-on-error' to see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 whether it should call the debugger. When execution is resumed, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 error is signaled again."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (if (and (listp debug-on-error) (memq edebug-signal-name debug-on-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (edebug 'error (cons edebug-signal-name edebug-signal-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 ;; If we reach here without another non-local exit, then send signal again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 ;; i.e. the signal is not continuable, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (edebug-original-signal edebug-signal-name edebug-signal-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 ;;; Entering Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 ;;; ==================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (defun edebug-enter (edebug-function edebug-args edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 ;; Entering FUNC. The arguments are ARGS, and the body is BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 ;; Setup edebug variables and evaluate BODY. This function is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 ;; when a function evaluated with edebug-eval-top-level-form is entered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 ;; Return the result of BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 ;; Is this the first time we are entering edebug since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 ;; lower-level recursive-edit command?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 ;; More precisely, this tests whether Edebug is currently active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 (if (not edebug-entered)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (let ((edebug-entered t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 ;; Binding max-lisp-eval-depth here is OK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 ;; but not inside an unwind-protect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 ;; Doing it here also keeps it from growing too large.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (max-lisp-eval-depth (+ 100 max-lisp-eval-depth)) ; too much??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (max-specpdl-size (+ 200 max-specpdl-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (debugger edebug-debugger) ; only while edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (edebug-outside-debug-on-error debug-on-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (edebug-outside-debug-on-quit debug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 ;; Binding these may not be the right thing to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 ;; We want to allow the global values to be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (debug-on-error (or debug-on-error edebug-on-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (debug-on-quit edebug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 ;; Lexical bindings must be uncompiled for this to work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 (cl-lexical-debug t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 ;; Save the outside value of executing macro. (here??)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (edebug-outside-executing-macro executing-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (edebug-outside-pre-command-hook pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 (edebug-outside-post-command-hook post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (edebug-outside-post-command-idle-hook post-command-idle-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (let (;; Don't keep reading from an executing kbd macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 ;; within edebug unless edebug-continue-kbd-macro is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 ;; non-nil. Again, local binding may not be best.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 (executing-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (if edebug-continue-kbd-macro executing-macro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 ;; Disable command hooks. This is essential when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 ;; a hook function is instrumented - to avoid infinite loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 ;; This may be more than we need, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (pre-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (post-command-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (post-command-idle-hook nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (setq edebug-execution-mode (or edebug-next-execution-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 edebug-execution-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 edebug-next-execution-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 ;; Bind signal to edebug-signal only while Edebug is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (fset 'signal 'edebug-signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (edebug-enter edebug-function edebug-args edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (fset 'signal (symbol-function 'edebug-original-signal))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 ;; Reset global variables in case outside value was changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (setq executing-macro edebug-outside-executing-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 pre-command-hook edebug-outside-pre-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 post-command-hook edebug-outside-post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 post-command-idle-hook edebug-outside-post-command-idle-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (let* ((edebug-data (get edebug-function 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 (edebug-def-mark (car edebug-data)) ; mark at def start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (edebug-freq-count (get edebug-function 'edebug-freq-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (edebug-coverage (get edebug-function 'edebug-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (edebug-buffer (marker-buffer edebug-def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 (edebug-stack (cons edebug-function edebug-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (edebug-offset-indices (cons 0 edebug-offset-indices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (if (get edebug-function 'edebug-on-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (setq edebug-execution-mode 'step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 (if (eq (get edebug-function 'edebug-on-entry) 'temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 (put edebug-function 'edebug-on-entry nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 (if edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (edebug-enter-trace edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (funcall edebug-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (defun edebug-enter-trace (edebug-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (let ((edebug-stack-depth (1+ edebug-stack-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (edebug-print-trace-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 (format "%s args: %s" edebug-function edebug-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (prog1 (setq edebug-result (funcall edebug-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (edebug-print-trace-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 (format "%s result: %s" edebug-function edebug-result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (def-edebug-spec edebug-tracing (form body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (defmacro edebug-tracing (msg &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 "Print MSG in *edebug-trace* before and after evaluating BODY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 The result of BODY is also printed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 (` (let ((edebug-stack-depth (1+ edebug-stack-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 edebug-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (edebug-print-trace-before (, msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 (prog1 (setq edebug-result (progn (,@ body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 (edebug-print-trace-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (format "%s result: %s" (, msg) edebug-result))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (defun edebug-print-trace-before (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 "Function called to print trace info before expression evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 MSG is printed after `::::{ '."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (edebug-trace-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 edebug-trace-buffer "%s{ %s" (make-string edebug-stack-depth ?\:) msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (defun edebug-print-trace-after (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 "Function called to print trace info after expression evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 MSG is printed after `::::} '."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (edebug-trace-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 edebug-trace-buffer "%s} %s" (make-string edebug-stack-depth ?\:) msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (defun edebug-slow-before (edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 ;; Debug current function given BEFORE position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 ;; Called from functions compiled with edebug-eval-top-level-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 ;; Return the before index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (setcar edebug-offset-indices edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 ;; Increment frequency count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (aset edebug-freq-count edebug-before-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (1+ (aref edebug-freq-count edebug-before-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (if (or (not (memq edebug-execution-mode '(Go-nonstop next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (edebug-input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (edebug-debugger edebug-before-index 'before nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (defun edebug-fast-before (edebug-before-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 ;; Do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (defun edebug-slow-after (edebug-before-index edebug-after-index edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 ;; Debug current function given AFTER position and VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 ;; Called from functions compiled with edebug-eval-top-level-form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 ;; Return VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (setcar edebug-offset-indices edebug-after-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 ;; Increment frequency count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (aset edebug-freq-count edebug-after-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (1+ (aref edebug-freq-count edebug-after-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (if edebug-test-coverage (edebug-update-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 (if (and (eq edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 (not (edebug-input-pending-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 ;; Just return result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 edebug-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (edebug-debugger edebug-after-index 'after edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (defun edebug-fast-after (edebug-before-index edebug-after-index edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 ;; Do nothing but return the value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (defun edebug-run-slow ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (defalias 'edebug-before 'edebug-slow-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (defalias 'edebug-after 'edebug-slow-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 ;; This is not used, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (defun edebug-run-fast ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (defalias 'edebug-before 'edebug-fast-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (defalias 'edebug-after 'edebug-fast-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (edebug-run-slow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 (defun edebug-update-coverage ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (let ((old-result (aref edebug-coverage edebug-after-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 ((eq 'ok-coverage old-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 ((eq 'unknown old-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 (aset edebug-coverage edebug-after-index edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 ;; Test if a different result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 ((not (eq edebug-value old-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (aset edebug-coverage edebug-after-index 'ok-coverage)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 ;; Dynamically declared unbound variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (defvar edebug-arg-mode) ; the mode, either before, after, or error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (defvar edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (defvar edebug-break-data) ; break data for current function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 (defvar edebug-break) ; whether a break occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (defvar edebug-global-break) ; whether a global break occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (defvar edebug-break-condition) ; whether the breakpoint is conditional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 (defvar edebug-break-result nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (defvar edebug-global-break-result nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (defun edebug-debugger (edebug-offset-index edebug-arg-mode edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 ;; Check breakpoints and pending input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 ;; If edebug display should be updated, call edebug-display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 ;; Return edebug-value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (let* (;; This needs to be here since breakpoints may be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (edebug-breakpoints (car (cdr edebug-data))) ; list of breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (edebug-break-data (assq edebug-offset-index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 (edebug-break-condition (car (cdr edebug-break-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 (edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (if edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (setq edebug-global-break-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 (eval edebug-global-break-condition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 (edebug-break))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 ;;; (edebug-trace "exp: %s" edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 ;; Test whether we should break.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (setq edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (or edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 (and edebug-break-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (or (not edebug-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (setq edebug-break-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 (eval edebug-break-condition))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (if (and edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 (nth 2 edebug-break-data)) ; is it temporary?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 ;; Delete the breakpoint.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 (setcdr edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 (cons (delq edebug-break-data edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (cdr (cdr edebug-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 ;; Display if mode is not go, continue, or Continue-fast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 ;; or break, or input is pending,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (if (or (not (memq edebug-execution-mode '(go continue Continue-fast)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 (edebug-input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (edebug-display)) ; <--------------- display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 edebug-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 ;; window-start now stored with each function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 ;;(defvar edebug-window-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 ;; Remember where each buffers' window starts between edebug calls.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 ;; This is to avoid spurious recentering.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 ;; Does this still need to be buffer-local??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 ;;(setq-default edebug-window-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 ;;(make-variable-buffer-local 'edebug-window-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 ;; Dynamically declared unbound vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (defvar edebug-point) ; the point in edebug buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 (defvar edebug-outside-buffer) ; the current-buffer outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (defvar edebug-outside-point) ; the point outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (defvar edebug-outside-mark) ; the mark outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (defvar edebug-window-data) ; window and window-start for current function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (defvar edebug-outside-windows) ; outside window configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (defvar edebug-eval-buffer) ; for the evaluation list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (defvar edebug-outside-o-a-p) ; outside overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (defvar edebug-outside-o-a-s) ; outside overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (defvar edebug-outside-c-i-e-a) ; outside cursor-in-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 (defvar edebug-eval-list nil) ;; List of expressions to evaluate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (defvar edebug-previous-result nil) ;; Last result returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 ;; Emacs 19 adds an arg to mark and mark-marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (defalias 'edebug-mark 'mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (defalias 'edebug-mark-marker 'mark-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (defun edebug-display ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 ;; Setup windows for edebug, determine mode, maybe enter recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 ;; Uses local variables of edebug-enter, edebug-before, edebug-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 ;; and edebug-debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (let ((edebug-active t) ; for minor mode alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 edebug-stop ; should we enter recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (edebug-point (+ edebug-def-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (aref (nth 2 edebug-data) edebug-offset-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 edebug-buffer-outside-point ; current point in edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 ;; window displaying edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (edebug-window-data (nth 3 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (edebug-outside-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (edebug-outside-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (edebug-outside-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 (edebug-outside-mark (edebug-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 edebug-outside-windows ; window or screen configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 edebug-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 edebug-eval-buffer ; declared here so we can kill it below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (edebug-eval-result-list (and edebug-eval-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (edebug-eval-result-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 edebug-trace-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (edebug-outside-o-a-p overlay-arrow-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 (edebug-outside-o-a-s overlay-arrow-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (edebug-outside-c-i-e-a cursor-in-echo-area))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (let ((overlay-arrow-position overlay-arrow-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (overlay-arrow-string overlay-arrow-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (cursor-in-echo-area nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 ;; any others??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 (if (not (buffer-name edebug-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (let ((debug-on-error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (error "Buffer defining %s not found" edebug-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (if (eq 'after edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 ;; Compute result string now before windows are modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (edebug-compute-previous-result edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 ;; Save windows now before we modify them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 (edebug-current-windows edebug-save-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (if edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (setq edebug-buffer-points (edebug-get-displayed-buffer-points)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 ;; First move the edebug buffer point to edebug-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 ;; so that window start doesnt get changed when we display it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 ;; I dont know if this is going to help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 ;;(set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 ;;(goto-char edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 ;; If edebug-buffer is not currently displayed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 ;; first find a window for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 (edebug-pop-to-buffer edebug-buffer (car edebug-window-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (setcar edebug-window-data (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 ;; Now display eval list, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 ;; This is done after the pop to edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;; so that buffer-window correspondence is correct after quitting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (edebug-eval-display edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 ;; The evaluation list better not have deleted edebug-window-data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (select-window (car edebug-window-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 (setq edebug-buffer-outside-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 (goto-char edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 (if (eq 'before edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 ;; Check whether positions are up-to-date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 ;; This assumes point is never before symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (if (not (memq (following-char) '(?\( ?\# ?\` )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (let ((debug-on-error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (error "Source has changed - reevaluate definition of %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 edebug-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (setcdr edebug-window-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (edebug-adjust-window (cdr edebug-window-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 ;; Test if there is input, not including keyboard macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 (if (edebug-input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (setq edebug-execution-mode 'step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 edebug-stop t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 (edebug-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 ;; (discard-input) ; is this unfriendly??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 ;; Now display arrow based on mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 (edebug-overlay-arrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 ((eq 'error edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 ;; Display error message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 (setq edebug-execution-mode 'step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (edebug-overlay-arrow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 (if (eq 'quit (car edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (message "Quit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (edebug-report-error edebug-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 (edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 (message "Global Break: %s => %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 edebug-global-break-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 (edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (message "Break: %s => %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 edebug-break-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 ((not (eq edebug-execution-mode 'Continue-fast))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 (message "Break"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (t (message "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (if (eq 'after edebug-arg-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 ;; Display result of previous evaluation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (if (and edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (not (eq edebug-execution-mode 'Continue-fast)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (sit-for 1)) ; Show break message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (edebug-previous-result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 ((eq edebug-execution-mode 'continue) (edebug-sit-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 ((eq edebug-execution-mode 'Continue-fast) (edebug-sit-for 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (t (setq edebug-stop t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 ;; not edebug-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 ((eq edebug-execution-mode 'trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (edebug-sit-for 1)) ; Force update and pause.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 ((eq edebug-execution-mode 'Trace-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (edebug-sit-for 0)) ; Force update and continue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (if (or edebug-stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (memq edebug-execution-mode '(step next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (eq edebug-arg-mode 'error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 ;; (setq edebug-execution-mode 'step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 ;; (edebug-overlay-arrow) ; this doesnt always show up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 (edebug-recursive-edit))) ; <---------- Recursive edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 ;; Reset the edebug-window-data to whatever it is now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (let ((window (if (eq (window-buffer) edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 (edebug-get-buffer-window edebug-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 ;; Remember window-start for edebug-buffer, if still displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (setcar edebug-window-data window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (setcdr edebug-window-data (window-start window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 ;; Save trace window point before restoring outside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 ;; Could generalize this for other buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (setq edebug-trace-window (get-buffer-window edebug-trace-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (if edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (setq edebug-trace-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (and edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (window-start edebug-trace-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 ;; Restore windows before continuing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 ;; Restore displayed buffer points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 ;; Needed even if restoring windows because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 ;; window-points are not restored. (should they be??)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 (if edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 (edebug-set-buffer-points edebug-buffer-points))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 ;; Unrestore trace window's window-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 (if edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 (set-window-start edebug-trace-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 edebug-trace-window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 ;; Unrestore edebug-buffer's window-start, if displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (let ((window (car edebug-window-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 (if (and window (edebug-window-live-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 (eq (window-buffer) edebug-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (set-window-start window (cdr edebug-window-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 'no-force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 ;; Unrestore edebug-buffer's window-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 ;; Needed in addition to setting the buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 ;; - otherwise quitting doesnt leave point as is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 ;; But this causes point to not be restored at times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 ;; Also, it may not be a visible window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 ;; (set-window-point window edebug-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 ;; Unrestore edebug-buffer's point. Rerestored below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 ;; (goto-char edebug-point) ;; in edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 ;; Since we may be in a save-excursion, in case of quit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 ;; reselect the outside window only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 ;; Only needed if we are not recovering windows??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (if (edebug-window-live-p edebug-outside-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (select-window edebug-outside-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 ) ; if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 ;; Restore current buffer always, in case application needs it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 (set-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 ;; Restore point, and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 ;; Needed even if restoring windows because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 ;; that doesnt restore point and mark in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 ;; But dont restore point if edebug-buffer is current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 (if (not (eq edebug-buffer edebug-outside-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (goto-char edebug-outside-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 ;; Does zmacs-regions need to be nil while doing set-marker?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 (set-marker (edebug-mark-marker) edebug-outside-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 ) ; unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 ;; None of the following is done if quit or signal occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 ;; Restore edebug-buffer's outside point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 ;; (edebug-trace "restore edebug-buffer point: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 ;; edebug-buffer-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 (let ((current-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (goto-char edebug-buffer-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 (set-buffer current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 ;; ... nothing more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 ;; Reset global variables to outside values in case they were changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 overlay-arrow-position edebug-outside-o-a-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 overlay-arrow-string edebug-outside-o-a-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 cursor-in-echo-area edebug-outside-c-i-e-a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 (defvar edebug-number-of-recursions 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 ;; Number of recursive edits started by edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 ;; Should be 0 at the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 (defvar edebug-recursion-depth 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 ;; Value of recursion-depth when edebug was called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 ;; Dynamically declared unbound vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 (defvar edebug-outside-match-data) ; match data outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 (defvar edebug-backtrace-buffer) ; each recursive edit gets its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 (defvar edebug-inside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 (defvar edebug-interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 (defvar edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 (defvar edebug-outside-standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (defvar edebug-outside-standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (defvar edebug-outside-last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (defvar edebug-outside-last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 (defvar edebug-outside-this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (defvar edebug-outside-last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 ;; Note: here we have defvars for variables that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 ;; built-in in certain versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 ;; Each defvar makes a difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 ;; in versions where the variable is *not* built-in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 ;; Emacs 18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (defvar edebug-outside-unread-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (defvar edebug-outside-unread-command-event) ;; like unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 (defvar unread-command-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 ;; Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 (defvar edebug-outside-last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 (defvar edebug-outside-unread-command-events)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 (defvar edebug-outside-last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 (defvar edebug-outside-last-event-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 (defvar edebug-outside-last-nonmenu-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (defvar edebug-outside-track-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 ;; Disable byte compiler warnings about unread-command-char and -event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 ;; (maybe works with byte-compile-version 2.22 at least)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 (defvar edebug-unread-command-char-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 (defvar edebug-unread-command-event-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 (setq edebug-unread-command-char-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 (get 'unread-command-char 'byte-obsolete-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 (put 'unread-command-char 'byte-obsolete-variable nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 (setq edebug-unread-command-event-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 (get 'unread-command-event 'byte-obsolete-variable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 (put 'unread-command-event 'byte-obsolete-variable nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 (defun edebug-recursive-edit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 ;; Start up a recursive edit inside of edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 ;; The current buffer is the edebug-buffer, which is put into edebug-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 ;; Assume that none of the variables below are buffer-local.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 (let ((edebug-buffer-read-only buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 ;; match-data must be done in the outside buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 (edebug-outside-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (save-excursion ; might be unnecessary now??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 (set-buffer edebug-outside-buffer) ; in case match buffer different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 (match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 ;;(edebug-number-of-recursions (1+ edebug-number-of-recursions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (edebug-recursion-depth (recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 edebug-entered ; bind locally to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (edebug-interactive-p nil) ; again non-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 edebug-backtrace-buffer ; each recursive edit gets its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 ;; The window configuration may be saved and restored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 ;; during a recursive-edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 (edebug-outside-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 (edebug-outside-standard-output standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 (edebug-outside-standard-input standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 (edebug-outside-defining-kbd-macro defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 (edebug-outside-last-command-char last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 (edebug-outside-last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 (edebug-outside-this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 (edebug-outside-last-input-char last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 ;; XEmacs: added the boundp checks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 (edebug-outside-unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 (and (boundp 'unread-command-char) unread-command-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 (edebug-outside-last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 (and (boundp 'last-input-event) last-input-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 (edebug-outside-last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 (and (boundp 'last-command-event) last-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 (edebug-outside-unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 (and (boundp 'unread-command-event) unread-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 (edebug-outside-unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 (and (boundp 'unread-command-events) unread-command-events))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 (edebug-outside-last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 (and (boundp 'last-event-frame) last-event-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 (edebug-outside-last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 (and (boundp 'last-nonmenu-event) last-nonmenu-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 (edebug-outside-track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (and (boundp 'track-mouse) track-mouse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 ;; Declare global values local but using the same global value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 ;; We could set these to the values for previous edebug call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 (last-command-char last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 (last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 (this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 (last-input-char last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 ;; Assume no edebug command sets unread-command-char.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 (unread-command-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 ;; More for Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 (last-input-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (last-command-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 (unread-command-event nil);; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (unread-command-events nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 (last-event-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 (last-nonmenu-event nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 (track-mouse nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 ;; Bind again to outside values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 (debug-on-error edebug-outside-debug-on-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 (debug-on-quit edebug-outside-debug-on-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 ;; Don't keep defining a kbd macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 (defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 (if edebug-continue-kbd-macro defining-kbd-macro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 ;; others??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (if (fboundp 'zmacs-deactivate-region);; for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (zmacs-deactivate-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 (if (and (eq edebug-execution-mode 'go)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 (not (memq edebug-arg-mode '(after error))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 (message "Break"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (fset 'signal (symbol-function 'edebug-original-signal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 (edebug-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 (recursive-edit) ; <<<<<<<<<< Recursive edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 ;; Do the following, even if quit occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (fset 'signal 'edebug-signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (if edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 (kill-buffer edebug-backtrace-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 ;; Could be an option to keep eval display up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 (if edebug-eval-buffer (kill-buffer edebug-eval-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 ;; Remember selected-window after recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 ;; (setq edebug-inside-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 (store-match-data edebug-outside-match-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 ;; Recursive edit may have changed buffers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 ;; so set it back before exiting let.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (if (buffer-name edebug-buffer) ; if it still exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (set-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (if (memq edebug-execution-mode '(go Go-nonstop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 (edebug-overlay-arrow))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 (setq buffer-read-only edebug-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (use-local-map edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 ;; gotta have a buffer to let its buffer local variables be set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 (get-buffer-create " bogus edebug buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 ));; inner let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 ;; Reset global vars to outside values, in case they have been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 last-command-char edebug-outside-last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 last-command-event edebug-outside-last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 last-command edebug-outside-last-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 this-command edebug-outside-this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 unread-command-char edebug-outside-unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 unread-command-event edebug-outside-unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 unread-command-events edebug-outside-unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 last-input-char edebug-outside-last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 last-input-event edebug-outside-last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 last-event-frame edebug-outside-last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 last-nonmenu-event edebug-outside-last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 track-mouse edebug-outside-track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 standard-output edebug-outside-standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 standard-input edebug-outside-standard-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 defining-kbd-macro edebug-outside-defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 ;;; Display related functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 (defun edebug-adjust-window (old-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 ;; If pos is not visible, adjust current window to fit following context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 ;;; (message "window: %s old-start: %s window-start: %s pos: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 ;;; (selected-window) old-start (window-start) (point)) (sit-for 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 (if (not (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 ;; First try old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 (if old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (set-window-start (selected-window) old-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 (if (not (pos-visible-in-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 ;; (message "resetting window start") (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 (set-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 (forward-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (if (< (point) (window-start)) -1 ; one line before if in back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 (- (/ (window-height) 2)) ; center the line moving forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 (defconst edebug-arrow-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 '((Continue-fast . "=")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 (Trace-fast . "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 (continue . ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 (trace . "->")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 (step . "=>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 (next . "=>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 (go . "<>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 (Go-nonstop . "..") ; not used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 "Association list of arrows for each edebug mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (defun edebug-overlay-arrow ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 ;; Set up the overlay arrow at beginning-of-line in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 ;; The arrow string is derived from edebug-arrow-alist and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 ;; edebug-execution-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 (let ((pos (save-excursion (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 (setq overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 (cdr (assq edebug-execution-mode edebug-arrow-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (setq overlay-arrow-position (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 (set-marker overlay-arrow-position pos (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 (defun edebug-toggle-save-all-windows ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 "Toggle the saving and restoring of all windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 Also, each time you toggle it on, the inside and outside window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 configurations become the same as the current configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 (setq edebug-save-windows (not edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (edebug-current-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 edebug-save-windows))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 (message "Window saving is %s for all windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 (if edebug-save-windows "on" "off")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 (defmacro edebug-changing-windows (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 (` (let ((window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 (setq edebug-inside-windows (edebug-current-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (,@ body) ;; Code to change edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 (setq edebug-outside-windows (edebug-current-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 ;; Problem: what about outside windows that are deleted inside?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 (edebug-set-windows edebug-inside-windows))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 (defun edebug-toggle-save-selected-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 "Toggle the saving and restoring of the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 Also, each time you toggle it on, the inside and outside window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 configurations become the same as the current configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 ((eq t edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 ;; Save all outside windows except the selected one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 ;; Remove (selected-window) from outside-windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 (edebug-changing-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 (setq edebug-save-windows (delq window (edebug-window-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 ((memq (selected-window) edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 (setq edebug-outside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 (delq (assq (selected-window) edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 edebug-outside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 (setq edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 (delq (selected-window) edebug-save-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 (t ; Save a new window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 (edebug-changing-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 (setq edebug-save-windows (cons window edebug-save-windows)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 (message "Window saving is %s for %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 (if (memq (selected-window) edebug-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 "on" "off")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 (defun edebug-toggle-save-windows (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 "Toggle the saving and restoring of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 With prefix, toggle for just the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 Otherwise, toggle for all windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 (edebug-toggle-save-selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 (edebug-toggle-save-all-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 (defun edebug-where ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 "Show the debug windows and where we stopped in the program."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 ;; Restore the window configuration to what it last was inside.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 ;; But it is not always set. - experiment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 ;;(if edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 ;; (edebug-set-windows edebug-inside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 (edebug-pop-to-buffer edebug-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (goto-char edebug-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 (defun edebug-view-outside ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 "Change to the outside window configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 (edebug-current-windows edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 (edebug-set-windows edebug-outside-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 (message "Window configuration outside of Edebug. Return with %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 (substitute-command-keys "\\<global-map>\\[edebug-where]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 (defun edebug-bounce-point (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 "Bounce the point in the outside current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 If prefix arg is supplied, sit for that many seconds before returning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 The default is one second."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 (if (not edebug-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 (error "Edebug is not active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 ;; If the buffer's currently displayed, avoid set-window-configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 (edebug-pop-to-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 (message "Current buffer: %s Point: %s Mark: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 (current-buffer) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 (marker-position (edebug-mark-marker)) "<not set>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 (edebug-sit-for arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (edebug-pop-to-buffer edebug-buffer (car edebug-window-data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 ;; Joe Wells, here is a start at your idea of adding a buffer to the internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 ;; display list. Still need to use this list in edebug-display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 '(defvar edebug-display-buffer-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 "List of buffers that edebug will display when it is active.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 '(defun edebug-display-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 "Toggle display of a buffer inside of edebug."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (interactive "bBuffer: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 (let ((already-displaying (memq buffer edebug-display-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (setq edebug-display-buffer-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 (if already-displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (delq buffer edebug-display-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 (cons buffer edebug-display-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 (message "Displaying %s %s" buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 (if already-displaying "off" "on"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 ;;; Breakpoint related functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 (defun edebug-find-stop-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 ;; Return (function . index) of the nearest edebug stop point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 (let* ((edebug-def-name (edebug-form-data-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 (edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 (let ((data (get edebug-def-name 'edebug)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 (if (or (null data) (markerp data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 (error "%s is not instrumented for Edebug" edebug-def-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 data)) ; we could do it automatically, if data is a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 ;; pull out parts of edebug-data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 ;; (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 (offset (- (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 (if (looking-at "[ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 ;; skip backwards until non-whitespace, or bol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 (skip-chars-backward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 edebug-def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 len i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 ;; the offsets are in order so we can do a linear search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 (setq len (length offset-vector))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 (setq i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 (while (and (< i len) (> offset (aref offset-vector i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (if (and (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 (<= offset (aref offset-vector i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 ;; return the relevant info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 (cons edebug-def-name i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 (message "Point is not on an expression in %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 (defun edebug-next-breakpoint ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 "Move point to the next breakpoint, or first if none past point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 ;; pull out parts of edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (if (not edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 (message "No breakpoints in this function.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 (let ((breaks edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 (while (and breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 (<= (car (car breaks)) index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 (setq breaks (cdr breaks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 (setq breakpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 (if breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 (car breaks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 ;; goto the first breakpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 (car edebug-breakpoints)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 (goto-char (+ edebug-def-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 (aref offset-vector (car breakpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 (message (concat (if (nth 2 breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 "Temporary " "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (if (car (cdr breakpoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 (format "Condition: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 (edebug-safe-prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 (car (cdr breakpoint))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 (defun edebug-modify-breakpoint (flag &optional condition temporary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 "Modify the breakpoint for the form at point or after it according
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 to FLAG: set if t, clear if nil. Then move to that point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 If CONDITION or TEMPORARY are non-nil, add those attributes to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 the breakpoint. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 ;; pull out parts of edebug-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 (edebug-def-mark (car edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 (offset-vector (nth 2 edebug-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 present)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 ;; delete it either way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 (setq present (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 (setq edebug-breakpoints (delq present edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 (if flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 ;; add it to the list and resort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 (setq edebug-breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 (edebug-sort-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 (list index condition temporary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 edebug-breakpoints) '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 (if condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 (message "Breakpoint set in %s with condition: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 edebug-def-name condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 (message "Breakpoint set in %s" edebug-def-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 (if present
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 (message "Breakpoint unset in %s" edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 (message "No breakpoint here")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 (setcar (cdr edebug-data) edebug-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 (goto-char (+ edebug-def-mark (aref offset-vector index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 (defun edebug-set-breakpoint (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 "Set the breakpoint of nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 (edebug-modify-breakpoint t nil arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 (defun edebug-unset-breakpoint ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 "Clear the breakpoint of nearest sexp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 (edebug-modify-breakpoint nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 ;; For emacs 18, no read-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 (defun edebug-set-conditional-breakpoint (arg condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 "Set a conditional breakpoint at nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 The condition is evaluated in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 ;; (interactive "P\nxCondition: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 ;; Edit previous condition as follows, but it is cumbersome:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 (edebug-break-data (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (edebug-break-condition (car (cdr edebug-break-data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (read-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 (format "Condition in %s: " edebug-def-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 (if edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 (format "%s" edebug-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (format ""))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (edebug-modify-breakpoint t condition arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 (defun edebug-set-global-break-condition (expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 (interactive (list (read-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 "Global Condition: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 (format "%s" edebug-global-break-condition))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 (setq edebug-global-break-condition expression))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 ;;; Mode switching functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 (defun edebug-set-mode (mode shortmsg msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 ;; Set the edebug mode to MODE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 ;; Display SHORTMSG, or MSG if not within edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 (if (eq (1+ edebug-recursion-depth) (recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 (setq edebug-execution-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 (message shortmsg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 ;; Continue execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 (exit-recursive-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 ;; This is not terribly useful!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 (setq edebug-next-execution-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 (message msg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 (defalias 'edebug-step-through-mode 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (defun edebug-step-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 "Proceed to next stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 (edebug-set-mode 'step "" "Edebug will stop at next stop point."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (defun edebug-next-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 "Proceed to next `after' stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 (edebug-set-mode 'next "" "Edebug will stop after next eval."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 (defun edebug-go-mode (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 "Go, evaluating until break.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 With prefix ARG, set temporary break at current point and go."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 (edebug-set-breakpoint t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 (edebug-set-mode 'go "Go..." "Edebug will go until break."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 (defun edebug-Go-nonstop-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 "Go, evaluating without debugging."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 (edebug-set-mode 'Go-nonstop "Go-Nonstop..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 "Edebug will not stop at breaks."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 (defun edebug-trace-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 "Begin trace mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (edebug-set-mode 'trace "Tracing..." "Edebug will trace with pause."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 (defun edebug-Trace-fast-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 "Trace with no wait at each step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 (edebug-set-mode 'Trace-fast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 "Trace fast..." "Edebug will trace without pause."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 (defun edebug-continue-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 "Begin continue mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 (edebug-set-mode 'continue "Continue..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 "Edebug will pause at breakpoints."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 (defun edebug-Continue-fast-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 "Trace with no wait at each step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 (edebug-set-mode 'Continue-fast "Continue fast..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 "Edebug will stop and go at breakpoints."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 ;; ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 ;; The following use the mode changing commands and breakpoints.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 (defun edebug-goto-here ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 "Proceed to this stop point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 (defun edebug-stop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 "Stop execution and do not continue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 Useful for exiting from trace or continue loop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 (message "Stop"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 '(defun edebug-forward ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 "Proceed to the exit of the next expression to be evaluated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323 (edebug-set-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 'forward "Forward"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 "Edebug will stop after exiting the next expression."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 (defun edebug-forward-sexp (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 "Proceed from the current point to the end of the ARGth sexp ahead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 If there are not ARG sexps ahead, then do edebug-step-out."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 (let ((parse-sexp-ignore-comments t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 ;; Call forward-sexp repeatedly until done or failure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 (forward-sexp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 (edebug-step-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341 (defun edebug-step-out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 "Proceed from the current point to the end of the containing sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 If there is no containing sexp that is not the top level defun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 go to the end of the last sexp, or if that is the same point, then step."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 (let ((parse-sexp-ignore-comments t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 (up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 ;; Is there still a containing expression?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 (up-list 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 (edebug-go-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 ;; At top level - 1, so first check if there are more sexps at this level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 (let ((start-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 ;; (up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 (down-list -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 (if (= (point) start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 (edebug-step-mode) ; No more at this level, so step.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 (edebug-go-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 (defun edebug-instrument-function (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 ;; Func should be a function symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 ;; Return the function symbol, or nil if not instrumented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 (let ((func-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 (setq func-marker (get func 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 ((markerp func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 ;; It is uninstrumented, so instrument it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 (set-buffer (marker-buffer func-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 (goto-char func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 (edebug-eval-top-level-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 func))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 ((consp func-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 (message "%s is already instrumented." func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 ;; We could try harder, e.g. do a tags search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 (error "Don't know where %s is defined" func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 (defun edebug-instrument-callee ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 "Instrument the definition of the function or macro about to be called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 Do this when stopped before the form or it will be too late.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 One side effect of using this command is that the next time the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 function or macro is called, Edebug will be called there as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 (if (not (looking-at "\("))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 (error "You must be before a list form")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 (let ((func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 (down-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395 (if (looking-at "\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 (edebug-form-data-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 (edebug-get-form-data-entry (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 (edebug-original-read (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 (edebug-instrument-function func))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 (defun edebug-step-in ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 "Step into the definition of the function or macro about to be called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 This first does `edebug-instrument-callee' to ensure that it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 instrumented. Then it does `edebug-on-entry' and switches to `go' mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 (let ((func (edebug-instrument-callee)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 (if func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 (edebug-on-entry func 'temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 (edebug-go-mode nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413 (defun edebug-on-entry (function &optional flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 "Cause Edebug to stop when FUNCTION is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415 With prefix argument, make this temporary so it is automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416 cancelled the first time the function is entered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 (interactive "aEdebug on entry to: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 ;; Could store this in the edebug data instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 (put function 'edebug-on-entry (if flag 'temp t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 (defun cancel-edebug-on-entry (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 (interactive "aEdebug on entry to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423 (put function 'edebug-on-entry nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 (if (not (fboundp 'edebug-original-debug-on-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3427 (fset 'edebug-original-debug-on-entry (symbol-function 'debug-on-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 '(fset 'debug-on-entry 'edebug-debug-on-entry) ;; Should we do this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429 ;; Also need edebug-cancel-debug-on-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 '(defun edebug-debug-on-entry (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 "Request FUNCTION to invoke debugger each time it is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 If the user continues, FUNCTION's execution proceeds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434 Works by modifying the definition of FUNCTION,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 which must be written in Lisp, not predefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436 Use `cancel-debug-on-entry' to cancel the effect of this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437 Redefining FUNCTION also does that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 This version is from Edebug. If the function is instrumented for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3440 Edebug, it calls `edebug-on-entry'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 (interactive "aDebug on entry (to function): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 (let ((func-data (get function 'edebug)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 (if (or (null func-data) (markerp func-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 (edebug-original-debug-on-entry function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445 (edebug-on-entry function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 (defun edebug-top-level-nonstop ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 "Set mode to Go-nonstop, and exit to top-level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 This is useful for exiting even if unwind-protect code may be executed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 (setq edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 (top-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 ;;(defun edebug-exit-out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 ;; "Go until the current function exits."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 ;; (edebug-set-mode 'exiting "Exit..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 ;;; -----------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 ;;; The following initial mode setting definitions are not used yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 '(defconst edebug-initial-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 '((edebug-Continue-fast . Continue-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 (edebug-Trace-fast . Trace-fast)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 (edebug-continue . continue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 (edebug-trace . trace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 (edebug-go . go)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 (edebug-step-through . step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 (edebug-Go-nonstop . Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 "Association list between commands and the modes they set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 '(defun edebug-set-initial-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 "Ask for the initial mode of the enclosing function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 The mode is requested via the key that would be used to set the mode in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 edebug-mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 (let* ((this-function (edebug-which-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 (keymap (if (eq edebug-mode-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 edebug-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 (old-mode (or (get this-function 'edebug-initial-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 edebug-initial-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 (key (read-key-sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 "Change initial edebug mode for %s from %s (%s) to (enter key): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 this-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 old-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 (where-is-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 (car (rassq old-mode edebug-initial-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 keymap 'firstonly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 (mode (cdr (assq (key-binding key) edebug-initial-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 (if (and mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499 (or (get this-function 'edebug-initial-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 (not (eq mode edebug-initial-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 (put this-function 'edebug-initial-mode mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 (message "Initial mode for %s is now: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 this-function mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 (error "Key must map to one of the mode changing commands")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 ;;; Evaluation of expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512 (def-edebug-spec edebug-outside-excursion t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514 (defmacro edebug-outside-excursion (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3515 "Evaluate an expression list in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3516 Return the result of the last expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517 (` (save-excursion ; of current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3518 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520 ;; After excursion, we will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 ;; restore to current window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 (setq edebug-inside-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 (edebug-current-windows edebug-save-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524 ;; Restore outside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525 (edebug-set-windows edebug-outside-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 (set-buffer edebug-buffer) ; why?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 ;; (use-local-map edebug-outside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 (store-match-data edebug-outside-match-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 ;; Restore outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 (let (;; (edebug-inside-map (current-local-map)) ;; restore map??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 (last-command-char edebug-outside-last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 (last-command-event edebug-outside-last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 (last-command edebug-outside-last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 (this-command edebug-outside-this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 (unread-command-char edebug-outside-unread-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537 (unread-command-event edebug-outside-unread-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 (unread-command-events edebug-outside-unread-command-events)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539 (last-input-char edebug-outside-last-input-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 (last-input-event edebug-outside-last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541 (last-event-frame edebug-outside-last-event-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542 (last-nonmenu-event edebug-outside-last-nonmenu-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3543 (track-mouse edebug-outside-track-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3544 (standard-output edebug-outside-standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 (standard-input edebug-outside-standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547 (executing-macro edebug-outside-executing-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548 (defining-kbd-macro edebug-outside-defining-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3549 (pre-command-hook edebug-outside-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550 (post-command-hook edebug-outside-post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 (post-command-idle-hook edebug-outside-post-command-idle-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 ;; See edebug-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 (overlay-arrow-position edebug-outside-o-a-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555 (overlay-arrow-string edebug-outside-o-a-s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 (cursor-in-echo-area edebug-outside-c-i-e-a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559 (save-excursion ; of edebug-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 (set-buffer edebug-outside-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 (goto-char edebug-outside-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 (if (marker-buffer (edebug-mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 (set-marker (edebug-mark-marker) edebug-outside-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566 ;; Back to edebug-buffer. Restore rest of inside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 ;; (use-local-map edebug-inside-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 (if edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 ;; Restore inside windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 (edebug-set-windows edebug-inside-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 ;; Save values that may have been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 edebug-outside-last-command-char last-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 edebug-outside-last-command-event last-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 edebug-outside-last-command last-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 edebug-outside-this-command this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 edebug-outside-unread-command-char unread-command-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 edebug-outside-unread-command-event unread-command-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 edebug-outside-unread-command-events unread-command-events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 edebug-outside-last-input-char last-input-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 edebug-outside-last-input-event last-input-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 edebug-outside-last-event-frame last-event-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584 edebug-outside-last-nonmenu-event last-nonmenu-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585 edebug-outside-track-mouse track-mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 edebug-outside-standard-output standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 edebug-outside-standard-input standard-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 edebug-outside-executing-macro executing-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590 edebug-outside-defining-kbd-macro defining-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3591 edebug-outside-pre-command-hook pre-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3592 edebug-outside-post-command-hook post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593 edebug-outside-post-command-idle-hook post-command-idle-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595 edebug-outside-o-a-p overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596 edebug-outside-o-a-s overlay-arrow-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597 edebug-outside-c-i-e-a cursor-in-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 ))) ; let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 (defvar cl-debug-env nil) ;; defined in cl; non-nil when lexical env used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 (defun edebug-eval (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 ;; Are there cl lexical variables active?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 (if cl-debug-env
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 (eval (cl-macroexpand-all edebug-expr cl-debug-env))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 (eval edebug-expr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 (defun edebug-safe-eval (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610 ;; Evaluate EXPR safely.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 ;; If there is an error, a string is returned describing the error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 (condition-case edebug-err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 (edebug-eval edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 (error (edebug-format "%s: %s" ;; could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 (get (car edebug-err) 'error-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 (car (cdr edebug-err))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618 ;;;; Printing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 ;;; =========
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620 ;; Replace printing functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 ;; obsolete names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 (defalias 'edebug-install-custom-print-funcs 'edebug-install-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 (defalias 'edebug-reset-print-funcs 'edebug-uninstall-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 (defalias 'edebug-uninstall-custom-print-funcs 'edebug-uninstall-custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627 (defun edebug-install-custom-print ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 "Replace print functions used by Edebug with custom versions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 ;; Modifying the custom print functions, or changing print-length,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3630 ;; print-level, print-circle, custom-print-list or custom-print-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3631 ;; have immediate effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3632 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3633 (require 'cust-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3634 (defalias 'edebug-prin1 'custom-prin1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3635 (defalias 'edebug-print 'custom-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3636 (defalias 'edebug-prin1-to-string 'custom-prin1-to-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3637 (defalias 'edebug-format 'custom-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3638 (defalias 'edebug-message 'custom-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3639 "Installed")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3641 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3642 (defun edebug-uninstall-custom-print ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3643 "Replace edebug custom print functions with internal versions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3644 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3645 (defalias 'edebug-prin1 'prin1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3646 (defalias 'edebug-print 'print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3647 (defalias 'edebug-prin1-to-string 'prin1-to-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3648 (defalias 'edebug-format 'format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3649 (defalias 'edebug-message 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3650 "Uninstalled")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3652 ;; Default print functions are the same as Emacs'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3653 (edebug-uninstall-custom-print))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3656 (defun edebug-report-error (edebug-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3657 ;; Print an error message like command level does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3658 ;; This also prints the error name if it has no error-message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3659 (message "%s: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3660 (or (get (car edebug-value) 'error-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3661 (format "peculiar error (%s)" (car edebug-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3662 (mapconcat (function (lambda (edebug-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3663 ;; continuing after an error may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3664 ;; complain about edebug-arg. why??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3665 (prin1-to-string edebug-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3666 (cdr edebug-value) ", ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3668 ;; Define here in case they are not already defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3669 (defvar print-level nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3670 (defvar print-circle nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3671 (defvar print-readably) ;; defined by XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3672 ;; Alternatively, we could change the definition of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3673 ;; edebug-safe-prin1-to-string to only use these if defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3675 (defun edebug-safe-prin1-to-string (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3676 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3677 (print-length (or edebug-print-length print-length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3678 (print-level (or edebug-print-level print-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3679 (print-circle (or edebug-print-circle print-circle))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 (print-readably nil)) ;; XEmacs uses this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681 (edebug-prin1-to-string value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683 (defun edebug-compute-previous-result (edebug-previous-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3684 (setq edebug-previous-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3685 (if (and (numberp edebug-previous-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3686 (< edebug-previous-value 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3687 (>= edebug-previous-value 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3688 (format "Result: %s = %s" edebug-previous-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689 (single-key-description edebug-previous-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3690 (if edebug-unwrap-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 (setq edebug-previous-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692 (edebug-unwrap* edebug-previous-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 (concat "Result: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3694 (edebug-safe-prin1-to-string edebug-previous-value)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 (defun edebug-previous-result ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697 "Print the previous result."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3698 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699 (message "%s" edebug-previous-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701 ;;;; Read, Eval and Print
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3702 ;;; =====================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 (defun edebug-eval-expression (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705 "Evaluate an expression in the outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 If interactive, prompt for the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707 Print result in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708 (interactive "xEval: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711 (setq values (cons (edebug-eval edebug-expr) values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 (edebug-safe-prin1-to-string (car values)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3714 (defun edebug-eval-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715 "Evaluate sexp before point in the outside environment;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3716 print value in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3718 (edebug-eval-expression (edebug-last-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720 (defun edebug-eval-print-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721 "Evaluate sexp before point in the outside environment;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3722 print value into current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3724 (let* ((edebug-form (edebug-last-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3725 (edebug-result-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3726 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3727 (edebug-safe-prin1-to-string (edebug-safe-eval edebug-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3728 (standard-output (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3729 (princ "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3730 ;; princ the string to get rid of quotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3731 (princ edebug-result-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3732 (princ "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3733 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3736 ;;;; Edebug Minor Mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3737 ;;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3739 ;; Global GUD bindings for all emacs-lisp-mode buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3740 (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3741 (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3742 (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3743 (define-key emacs-lisp-mode-map "\C-x\C-a\C-l" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3746 (defvar edebug-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3747 (if edebug-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3748 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3749 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3750 (setq edebug-mode-map (copy-keymap emacs-lisp-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751 ;; control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 (define-key edebug-mode-map " " 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753 (define-key edebug-mode-map "n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 (define-key edebug-mode-map "g" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755 (define-key edebug-mode-map "G" 'edebug-Go-nonstop-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 (define-key edebug-mode-map "t" 'edebug-trace-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 (define-key edebug-mode-map "T" 'edebug-Trace-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758 (define-key edebug-mode-map "c" 'edebug-continue-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 (define-key edebug-mode-map "C" 'edebug-Continue-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3761 ;;(define-key edebug-mode-map "f" 'edebug-forward) not implemented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3762 (define-key edebug-mode-map "f" 'edebug-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763 (define-key edebug-mode-map "h" 'edebug-goto-here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3765 (define-key edebug-mode-map "I" 'edebug-instrument-callee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3766 (define-key edebug-mode-map "i" 'edebug-step-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3767 (define-key edebug-mode-map "o" 'edebug-step-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3769 ;; quitting and stopping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3770 (define-key edebug-mode-map "q" 'top-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771 (define-key edebug-mode-map "Q" 'edebug-top-level-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772 (define-key edebug-mode-map "a" 'abort-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3773 (define-key edebug-mode-map "S" 'edebug-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3775 ;; breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3776 (define-key edebug-mode-map "b" 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3777 (define-key edebug-mode-map "u" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3778 (define-key edebug-mode-map "B" 'edebug-next-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3779 (define-key edebug-mode-map "x" 'edebug-set-conditional-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3780 (define-key edebug-mode-map "X" 'edebug-set-global-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3782 ;; evaluation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3783 (define-key edebug-mode-map "r" 'edebug-previous-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3784 (define-key edebug-mode-map "e" 'edebug-eval-expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3785 (define-key edebug-mode-map "\C-x\C-e" 'edebug-eval-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3786 (define-key edebug-mode-map "E" 'edebug-visit-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3788 ;; views
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3789 (define-key edebug-mode-map "w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3790 (define-key edebug-mode-map "v" 'edebug-view-outside) ;; maybe obsolete??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3791 (define-key edebug-mode-map "p" 'edebug-bounce-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3792 (define-key edebug-mode-map "P" 'edebug-view-outside) ;; same as v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3793 (define-key edebug-mode-map "W" 'edebug-toggle-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3795 ;; misc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3796 (define-key edebug-mode-map "?" 'edebug-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3797 (define-key edebug-mode-map "d" 'edebug-backtrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3799 (define-key edebug-mode-map "-" 'negative-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3801 ;; statistics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3802 (define-key edebug-mode-map "=" 'edebug-temp-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3804 ;; GUD bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3805 (define-key edebug-mode-map "\C-c\C-s" 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3806 (define-key edebug-mode-map "\C-c\C-n" 'edebug-next-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3807 (define-key edebug-mode-map "\C-c\C-c" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3809 (define-key edebug-mode-map "\C-x " 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3810 (define-key edebug-mode-map "\C-c\C-d" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3811 (define-key edebug-mode-map "\C-c\C-t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3812 (function (lambda () (edebug-set-breakpoint t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3813 (define-key edebug-mode-map "\C-c\C-l" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816 ;; Autoloading these global bindings doesn't make sense because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3817 ;; they cannot be used anyway unless Edebug is already loaded and active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3819 (defvar global-edebug-prefix "\^XX"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3820 "Prefix key for global edebug commands, available from any buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3822 (defvar global-edebug-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3823 "Global map of edebug commands, available from any buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3825 (if global-edebug-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3826 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3827 (setq global-edebug-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3829 (global-unset-key global-edebug-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3830 (global-set-key global-edebug-prefix global-edebug-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3832 (define-key global-edebug-map " " 'edebug-step-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3833 (define-key global-edebug-map "g" 'edebug-go-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3834 (define-key global-edebug-map "G" 'edebug-Go-nonstop-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3835 (define-key global-edebug-map "t" 'edebug-trace-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3836 (define-key global-edebug-map "T" 'edebug-Trace-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3837 (define-key global-edebug-map "c" 'edebug-continue-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3838 (define-key global-edebug-map "C" 'edebug-Continue-fast-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3840 ;; breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3841 (define-key global-edebug-map "b" 'edebug-set-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3842 (define-key global-edebug-map "u" 'edebug-unset-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3843 (define-key global-edebug-map "x" 'edebug-set-conditional-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3844 (define-key global-edebug-map "X" 'edebug-set-global-break-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846 ;; views
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 (define-key global-edebug-map "w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848 (define-key global-edebug-map "W" 'edebug-toggle-save-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 ;; quitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851 (define-key global-edebug-map "q" 'top-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852 (define-key global-edebug-map "Q" 'edebug-top-level-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853 (define-key global-edebug-map "a" 'abort-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3855 ;; statistics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3856 (define-key global-edebug-map "=" 'edebug-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3857 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3859 (defun edebug-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3860 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3861 (describe-function 'edebug-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3863 (defun edebug-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3864 "Mode for Emacs Lisp buffers while in Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3866 In addition to all Emacs Lisp commands (except those that modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3867 buffer) there are local and global key bindings to several Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3868 specific commands. E.g. `edebug-step-mode' is bound to \\[edebug-step-mode]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3869 in the Edebug buffer and \\<global-map>\\[edebug-step-mode] in any buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3871 Also see bindings for the eval list buffer, *edebug*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3873 The edebug buffer commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3874 \\{edebug-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3876 Global commands prefixed by `global-edebug-prefix':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3877 \\{global-edebug-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3879 Options:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3880 edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3881 edebug-all-defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3882 edebug-all-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3883 edebug-save-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3884 edebug-save-displayed-buffer-points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3885 edebug-initial-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3886 edebug-trace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3887 edebug-test-coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3888 edebug-continue-kbd-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3889 edebug-print-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3890 edebug-print-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3891 edebug-print-circle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3892 edebug-on-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3893 edebug-on-quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3894 edebug-on-signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3895 edebug-unwrap-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3896 edebug-global-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3897 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3898 (use-local-map edebug-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3901 ;;;; edebug eval list mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3902 ;;; ===============================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3903 ;; A list of expressions and their evaluations is displayed in *edebug*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3905 (defun edebug-eval-result-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3906 "Return a list of evaluations of edebug-eval-list"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3907 ;; Assumes in outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3908 ;; Don't do any edebug things now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3909 (let ((edebug-execution-mode 'Go-nonstop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3910 (edebug-trace nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3911 (mapcar 'edebug-safe-eval edebug-eval-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3913 (defun edebug-eval-display-list (edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3914 ;; Assumes edebug-eval-buffer exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3915 (let ((edebug-eval-list-temp edebug-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3916 (standard-output edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3917 (edebug-comment-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3918 (format ";%s\n" (make-string (- (window-width) 2) ?-))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3919 (set-buffer edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3920 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3921 (while edebug-eval-list-temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3922 (prin1 (car edebug-eval-list-temp)) (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3923 (prin1 (car edebug-eval-result-list)) (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3924 (princ edebug-comment-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3925 (setq edebug-eval-list-temp (cdr edebug-eval-list-temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3926 (setq edebug-eval-result-list (cdr edebug-eval-result-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3927 (edebug-pop-to-buffer edebug-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3928 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3930 (defun edebug-create-eval-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3931 (if (not (and edebug-eval-buffer (buffer-name edebug-eval-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3932 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3933 (set-buffer (setq edebug-eval-buffer (get-buffer-create "*edebug*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3934 (edebug-eval-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3936 ;; Should generalize this to be callable outside of edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3937 ;; with calls in user functions, e.g. (edebug-eval-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3939 (defun edebug-eval-display (edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3940 "Display expressions and evaluations in EVAL-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3941 It modifies the context by popping up the eval display."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3942 (if edebug-eval-result-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3943 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3944 (edebug-create-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3945 (edebug-eval-display-list edebug-eval-result-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3946 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3948 (defun edebug-eval-redisplay ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3949 "Redisplay eval list in outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3950 May only be called from within edebug-recursive-edit."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3951 (edebug-create-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3952 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3953 (edebug-eval-display-list (edebug-eval-result-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3954 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3956 (defun edebug-visit-eval-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3957 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3958 (edebug-eval-redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3959 (edebug-pop-to-buffer edebug-eval-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3962 (defun edebug-update-eval-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3963 "Replace the evaluation list with the sexps now in the eval buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3964 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3965 (let ((starting-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3966 new-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3967 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3968 ;; get the first expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3969 (edebug-skip-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3970 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3971 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3972 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3973 (setq new-list (cons (edebug-last-sexp) new-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3975 (while (re-search-forward "^;" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3976 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3977 (skip-chars-forward " \t\n\r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3978 (if (and (/= ?\; (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3979 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3980 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3981 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3982 (setq new-list (cons (edebug-last-sexp) new-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3984 (setq edebug-eval-list (nreverse new-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3985 (edebug-eval-redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3986 (goto-char starting-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3989 (defun edebug-delete-eval-item ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3990 "Delete the item under point and redisplay."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3991 ;; could add arg to do repeatedly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3992 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3993 (if (re-search-backward "^;" nil 'nofail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3994 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3995 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3996 (point) (progn (re-search-forward "^;" nil 'nofail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3997 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3998 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3999 (edebug-update-eval-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4002
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4003 (defvar edebug-eval-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4004 "Keymap for edebug-eval-mode. Superset of lisp-interaction-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4006 (if edebug-eval-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4007 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4008 (setq edebug-eval-mode-map (copy-keymap lisp-interaction-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4010 (define-key edebug-eval-mode-map "\C-c\C-w" 'edebug-where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4011 (define-key edebug-eval-mode-map "\C-c\C-d" 'edebug-delete-eval-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4012 (define-key edebug-eval-mode-map "\C-c\C-u" 'edebug-update-eval-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4013 (define-key edebug-eval-mode-map "\C-x\C-e" 'edebug-eval-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4014 (define-key edebug-eval-mode-map "\C-j" 'edebug-eval-print-last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4015 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4018 (defun edebug-eval-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4019 "Mode for evaluation list buffer while in Edebug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4021 In addition to all Interactive Emacs Lisp commands there are local and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4022 global key bindings to several Edebug specific commands. E.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4023 `edebug-step-mode' is bound to \\[edebug-step-mode] in the Edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4024 buffer and \\<global-map>\\[edebug-step-mode] in any buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4026 Eval list buffer commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4027 \\{edebug-eval-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4029 Global commands prefixed by global-edebug-prefix:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4030 \\{global-edebug-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4031 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4032 (lisp-interaction-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4033 (setq major-mode 'edebug-eval-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4034 (setq mode-name "Edebug-Eval")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4035 (use-local-map edebug-eval-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4038 ;;;; Interface with standard debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4039 ;;; ========================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4041 ;; (setq debugger 'edebug) ; to use the edebug debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4042 ;; (setq debugger 'debug) ; use the standard debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4044 ;; Note that debug and its utilities must be byte-compiled to work,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4045 ;; since they depend on the backtrace looking a certain way. But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4046 ;; edebug is not dependent on this, yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4048 (defun edebug (&optional edebug-arg-mode &rest debugger-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4049 "Replacement for debug.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4050 If we are running an edebugged function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4051 show where we last were. Otherwise call debug normally."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4052 ;; (message "entered: %s depth: %s edebug-recursion-depth: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4053 ;; edebug-entered (recursion-depth) edebug-recursion-depth) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4054 (if (and edebug-entered ; anything active?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4055 (eq (recursion-depth) edebug-recursion-depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4056 (let (;; Where were we before the error occurred?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4057 (edebug-offset-index (car edebug-offset-indices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4058 ;; Bind variables required by edebug-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4059 (edebug-value (car debugger-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4060 edebug-breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4061 edebug-break-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4062 edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4063 edebug-global-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4064 (edebug-break (null edebug-arg-mode)) ;; if called explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4065 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4066 (edebug-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4067 (if (eq edebug-arg-mode 'error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4068 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4069 edebug-value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4071 ;; Otherwise call debug normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4072 ;; Still need to remove extraneous edebug calls from stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4073 (apply 'debug edebug-arg-mode debugger-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4074 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4077 (defun edebug-backtrace ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4078 "Display a non-working backtrace. Better than nothing..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4079 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4080 (if (or (not edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4081 (null (buffer-name edebug-backtrace-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4082 (setq edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4083 (generate-new-buffer "*Backtrace*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4084 ;; else, could just display edebug-backtrace-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4085 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4086 (with-output-to-temp-buffer (buffer-name edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4087 (setq edebug-backtrace-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4088 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4089 (print-length 50)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4090 last-ok-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4091 (backtrace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4093 ;; Clean up the backtrace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4094 ;; Not quite right for current edebug scheme.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4095 (set-buffer edebug-backtrace-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4096 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4097 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4098 (setq last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4099 (if t (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4101 ;; Delete interspersed edebug internals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4102 (while (re-search-forward "^ \(?edebug" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4103 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4104 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4105 ((looking-at "^ \(edebug-after")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4106 ;; Previous lines may contain code, so just delete this line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4107 (setq last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4108 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4109 (delete-region last-ok-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4111 ((looking-at "^ edebug")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4112 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4113 (delete-region last-ok-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4114 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4115 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4118 ;;;; Trace display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4119 ;; ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4121 (defun edebug-trace-display (buf-name fmt &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4122 "In buffer BUF-NAME, display FMT and ARGS at the end and make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4123 The buffer is created if it does not exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4124 You must include newlines in FMT to break lines, but one newline is appended."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4125 ;; e.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4126 ;; (edebug-trace-display "*trace-point*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4127 ;; "saving: point = %s window-start = %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4128 ;; (point) (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4129 (let* ((selected-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4130 (buffer (get-buffer-create buf-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4131 buf-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4132 ;; (message "before pop-to-buffer") (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4133 (edebug-pop-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4134 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4135 (setq buf-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4136 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4137 (insert (apply 'edebug-format fmt args) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4138 ;; Make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4139 (vertical-motion (- 1 (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4140 (set-window-start buf-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4141 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4142 ;; (set-window-point buf-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4143 ;; (edebug-sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4144 (bury-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4145 (select-window selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4146 buf-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4149 (defun edebug-trace (fmt &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4150 "Convenience call to edebug-trace-display using edebug-trace-buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4151 (apply 'edebug-trace-display edebug-trace-buffer fmt args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4154 ;;;; Frequency count and coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4155 ;;; ==============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4157 (defun edebug-display-freq-count ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4158 "Display the frequency count data for each line of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4159 definition. The frequency counts are inserted as comment lines after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4160 each line, and you can undo all insertions with one `undo' command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4162 The counts are inserted starting under the `(' before an expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4163 or the `)' after an expression, or on the last char of a symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 The counts are only displayed when they differ from previous counts on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4165 the same line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4167 If coverage is being tested, whenever all known results of an expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4168 are `eq', the char `=' will be appended after the count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4169 for that expression. Note that this is always the case for an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4170 expression only evaluated once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4172 To clear the frequency count and coverage data for a definition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4173 reinstrument it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4174 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4175 (let* ((function (edebug-form-data-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4176 (counts (get function 'edebug-freq-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4177 (coverages (get function 'edebug-coverage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178 (data (get function 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4179 (def-mark (car data)) ; mark at def start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180 (edebug-points (nth 2 data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4181 (i (1- (length edebug-points)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4182 (last-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4183 (first-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184 (start-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4185 (start-of-count-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4186 (last-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4187 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4188 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4189 ;; Traverse in reverse order so offsets are correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4190 (while (<= 0 i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191 ;; Start at last expression in line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4192 (goto-char (+ def-mark (aref edebug-points i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4193 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4194 (setq start-of-line (- (point) def-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195 last-index i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4197 ;; Find all indexes on same line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198 (while (and (<= 0 (setq i (1- i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4199 (<= start-of-line (aref edebug-points i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200 ;; Insert all the indices for this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202 (setq start-of-count-line (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4203 first-index i ; really last index for line above this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4204 last-count -1) ; cause first count to always appear.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205 (insert ";#")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4206 ;; i == first-index still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4207 (while (<= (setq i (1+ i)) last-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4208 (let ((count (aref counts i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4209 (coverage (aref coverages i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4210 (col (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4211 (goto-char (+ (aref edebug-points i) def-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4212 (- (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4213 (if (= ?\( (following-char)) 0 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4214 (insert (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4215 (max 0 (- col (- (point) start-of-count-line))) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4216 (if (and (< 0 count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4217 (not (memq coverage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4218 '(unknown ok-coverage))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4219 "=" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4220 (if (= count last-count) "" (int-to-string count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4221 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4222 (setq last-count count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4223 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4224 (setq i first-index)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4226 (defun edebug-temp-display-freq-count ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4227 "Temporarily display the frequency count data for the current definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4228 It is removed when you hit any char."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4229 ;; This seems not to work with Emacs 18.59. It undoes too far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4230 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4231 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4232 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4233 (edebug-display-freq-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4234 (setq unread-command-char (read-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4235 (undo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4238 ;;;; Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4239 ;;;=========
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4241 (defun edebug-toggle (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4242 (set variable (not (eval variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4243 (message "%s: %s" variable (eval variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4245 ;; We have to require easymenu (even for Emacs 18) just so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4246 ;; the easy-menu-define macro call is compiled correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4247 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4249 (defconst edebug-mode-menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4250 '("Edebug"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4251 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4252 ["Stop" edebug-stop t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4253 ["Step" edebug-step-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 ["Next" edebug-next-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4255 ["Trace" edebug-trace-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4256 ["Trace Fast" edebug-Trace-fast-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4257 ["Continue" edebug-continue-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4258 ["Continue Fast" edebug-Continue-fast-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4259 ["Go" edebug-go-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4260 ["Go Nonstop" edebug-Go-nonstop-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4261 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4262 ["Help" edebug-help t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4263 ["Abort" abort-recursive-edit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4264 ["Quit to Top Level" top-level t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4265 ["Quit Nonstop" edebug-top-level-nonstop t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267 ("Jumps"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 ["Forward Sexp" edebug-forward-sexp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 ["Step In" edebug-step-in t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270 ["Step Out" edebug-step-out t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271 ["Goto Here" edebug-goto-here t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 ("Breaks"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274 ["Set Breakpoint" edebug-set-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 ["Unset Breakpoint" edebug-unset-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4276 ["Set Conditional Breakpoint" edebug-set-conditional-breakpoint t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4277 ["Set Global Break Condition" edebug-set-global-break-condition t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4278 ["Show Next Breakpoint" edebug-next-breakpoint t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4280 ("Views"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 ["Where am I?" edebug-where t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282 ["Bounce to Current Point" edebug-bounce-point t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4283 ["View Outside Windows" edebug-view-outside t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 ["Previous Result" edebug-previous-result t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 ["Show Backtrace" edebug-backtrace t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286 ["Display Freq Count" edebug-display-freq-count t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 ("Eval"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289 ["Expression" edebug-eval-expression t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4290 ["Last Sexp" edebug-eval-last-sexp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4291 ["Visit Eval List" edebug-visit-eval-list t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4293 ("Options"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4294 ["Edebug All Defs" edebug-all-defs t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4295 ["Edebug All Forms" edebug-all-forms t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4296 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4297 ["Toggle Tracing" (edebug-toggle 'edebug-trace) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4298 ["Toggle Coverage Testing" (edebug-toggle 'edebug-test-coverage) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4299 ["Toggle Window Saving" edebug-toggle-save-windows t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4300 ["Toggle Point Saving"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4301 (edebug-toggle 'edebug-save-displayed-buffer-points) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4302 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 "XEmacs style menus for Edebug.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4306 ;;;; Emacs version specific code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4307 ;;;=============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4308 ;;; The default for all above is Emacs 18, because it is easier to compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4309 ;;; Emacs 18 code in Emacs 19 than vice versa. This default will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4310 ;;; change once most people are using Emacs 19 or derivatives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4312 ;; Epoch specific code is in a separate file: edebug-epoch.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4314 ;; The byte-compiler will complain about changes in number of arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4315 ;; to functions like mark and read-from-minibuffer. These warnings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4316 ;; may be ignored because the right call should always be made.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4318 (defun edebug-emacs-19-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4320 (defalias 'edebug-window-live-p 'window-live-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4322 ;; Mark takes an argument in Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4323 (defun edebug-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4324 (mark t));; Does this work for XEmacs too?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4326 ;; Use minibuffer-history when reading expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4327 (defvar read-expression-history) ;; hush bytecomp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4328 (defvar read-expression-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4330 (defun edebug-set-conditional-breakpoint (arg condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4331 "Set a conditional breakpoint at nearest sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4332 The condition is evaluated in the outside context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4333 With prefix argument, make it a temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4334 ;; (interactive "P\nxCondition: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4335 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4336 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4337 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4338 ;; Read condition as follows; getting previous condition is cumbersome:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4339 (let ((edebug-stop-point (edebug-find-stop-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4340 (if edebug-stop-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4341 (let* ((edebug-def-name (car edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4342 (index (cdr edebug-stop-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4343 (edebug-data (get edebug-def-name 'edebug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4344 (edebug-breakpoints (car (cdr edebug-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4345 (edebug-break-data (assq index edebug-breakpoints))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4346 (edebug-break-condition (car (cdr edebug-break-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4347 (edebug-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4348 ;; Prepend the current condition, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4349 (if edebug-break-condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4350 (cons edebug-break-condition read-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351 read-expression-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4353 (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4354 "Condition: " nil read-expression-map t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4355 'edebug-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4356 (setq read-expression-history edebug-expression-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4357 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4358 (edebug-modify-breakpoint t condition arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4360 (defun edebug-eval-expression (edebug-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4361 "Evaluate an expression in the outside environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4362 If interactive, prompt for the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4363 Print result in minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4364 (interactive (list (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4365 "Eval: " nil read-expression-map t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4366 'read-expression-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4367 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4368 (edebug-outside-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4369 (setq values (cons (edebug-eval edebug-expr) values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4370 (edebug-safe-prin1-to-string (car values)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4372 (easy-menu-define edebug-menu edebug-mode-map "Edebug menus" edebug-mode-menus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4373 (if window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4374 (x-popup-menu nil (lookup-key edebug-mode-map [menu-bar Edebug])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4375 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4378 (defun edebug-xemacs-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4380 ;; We need to bind zmacs-regions to nil around all calls to `mark' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4381 ;; `mark-marker' but don't bind it to nil before entering a recursive edit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4382 ;; that is, don't interfere with the binding the user might see while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4383 ;; executing a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4385 (defvar zmacs-regions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4387 (defun edebug-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4388 (let ((zmacs-regions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4389 (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4391 (defun edebug-mark-marker ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4392 (let ((zmacs-regions nil));; for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4393 (mark-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4396 (defun edebug-mode-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4397 (interactive "@event")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4398 (popup-menu edebug-mode-menus))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4400 (define-key edebug-mode-map 'button3 'edebug-mode-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4401 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4403 (defun edebug-emacs-version-specific ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4404 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4405 ((string-match "XEmacs" emacs-version);; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4406 (edebug-xemacs-specific))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4408 ((and (boundp 'epoch::version) epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4409 (require 'edebug-epoch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4411 ((not (string-match "^18" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4412 (edebug-emacs-19-specific))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4414 (edebug-emacs-version-specific)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4417 ;;;; Byte-compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4418 ;;; ====================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4419 ;; Extension for bytecomp to resolve undefined function references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4420 ;; Requires new byte compiler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4422 ;; Reenable byte compiler warnings about unread-command-char and -event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4423 ;; Disabled before edebug-recursive-edit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4424 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4425 (if edebug-unread-command-char-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4426 (put 'unread-command-char 'byte-obsolete-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4427 edebug-unread-command-char-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4428 (if edebug-unread-command-event-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4429 (put 'unread-command-event 'byte-obsolete-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4430 edebug-unread-command-event-warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4432 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4433 ;; The body of eval-when-compile seems to get evaluated with eval-defun.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4434 ;; We only want to evaluate when actually byte compiling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4435 ;; But it is OK to evaluate as long as byte-compiler has been loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4436 (if (featurep 'byte-compile) (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4438 (defun byte-compile-resolve-functions (funcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4439 "Say it is OK for the named functions to be unresolved."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4440 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4441 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4442 (lambda (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4443 (setq byte-compile-unresolved-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4444 (delq (assq func byte-compile-unresolved-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4445 byte-compile-unresolved-functions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4446 funcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4447 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4449 '(defun byte-compile-resolve-free-references (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4450 "Say it is OK for the named variables to be referenced."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4451 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4452 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4453 (lambda (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4454 (setq byte-compile-free-references
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4455 (delq var byte-compile-free-references))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4456 vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4457 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4459 '(defun byte-compile-resolve-free-assignments (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4460 "Say it is OK for the named variables to be assigned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4461 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4462 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4463 (lambda (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4464 (setq byte-compile-free-assignments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4465 (delq var byte-compile-free-assignments))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4466 vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4467 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4469 (byte-compile-resolve-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4470 '(reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4471 edebug-gensym ;; also in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4472 ;; Interfaces to standard functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4473 edebug-original-eval-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4474 edebug-original-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4475 edebug-get-buffer-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4476 edebug-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4477 edebug-mark-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4478 edebug-input-pending-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4479 edebug-sit-for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4480 edebug-prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4481 edebug-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4482 edebug-original-signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4483 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4484 zmacs-deactivate-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4485 popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4486 ;; CL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4487 cl-macroexpand-all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4488 ;; And believe it or not, the byte compiler doesnt know about:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4489 byte-compile-resolve-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4490 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4492 '(byte-compile-resolve-free-references
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4493 '(read-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4494 read-expression-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4496 '(byte-compile-resolve-free-assignments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4497 '(read-expression-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4499 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4502 ;;;; Autoloading of Edebug accessories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4503 ;;;===================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4505 (if (featurep 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4506 (add-hook 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4507 (function (lambda () (require 'cl-specs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4508 ;; The following causes cl-specs to be loaded if you load cl.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4509 (add-hook 'cl-load-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4510 (function (lambda () (require 'cl-specs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4512 ;;; edebug-cl-read and cl-read are available from liberte@cs.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4513 (if (featurep 'cl-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4514 (add-hook 'edebug-setup-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4515 (function (lambda () (require 'edebug-cl-read))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4516 ;; The following causes edebug-cl-read to be loaded when you load cl-read.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4517 (add-hook 'cl-read-load-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4518 (function (lambda () (require 'edebug-cl-read)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4521 ;;;; Finalize Loading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4522 ;;;===================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4524 ;;; Finally, hook edebug into the rest of Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4525 ;;; There are probably some other things that could go here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4527 ;; Install edebug read and eval functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4528 (edebug-install-read-eval-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4530 (provide 'edebug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4532 ;;; edebug.el ends here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4534