annotate lisp/cedet/semantic/debug.el @ 107747:94a453a3e40a

(vc-hg-push, vc-hg-pull): Use `apply' when calling `vc-hg-command' with a list of flags.
author Sam Steingold <sds@gnu.org>
date Fri, 02 Apr 2010 10:21:57 -0400
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
1 ;;; semantic/debug.el --- Language Debugger framework
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105842
diff changeset
3 ;; Copyright (C) 2003, 2004, 2005, 2008, 2009, 2010 Free Software Foundation, Inc.
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; (at your option) any later version.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; To provide better support for debugging parsers, this framework
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; provides the interface for debugging. The work of parsing and
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; controlling and stepping through the parsing work must be implemented
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; by the parser.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;
105336
bd4a08d4865a Fix comment typo.
Glenn Morris <rgm@gnu.org>
parents: 105285
diff changeset
29 ;; Fortunately, the nature of language support files means that the parser
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; may not need to be instrumented first.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; The debugger uses EIEIO objects. One object controls the user
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;; interface, including stepping, data-view, queries. A second
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; object implemented here represents the parser itself. A third represents
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;; a parser independent frame which knows how to highlight the parser buffer.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; Each parser must implement the interface and override any methods as needed.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
39 (eval-when-compile (require 'cl))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (require 'semantic)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (require 'eieio)
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
42 (eval-when-compile (require 'semantic/find))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;;; Code:
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
45
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
46 ;;;###autoload
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (defvar semantic-debug-parser-source nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 "For any buffer, the file name (no path) of the parser.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 This would be a parser for a specific language, not the source
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 to one of the parser generators.")
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
51 ;;;###autoload
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (make-variable-buffer-local 'semantic-debug-parser-source)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
54 ;;;###autoload
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (defvar semantic-debug-parser-class nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 "Class to create when building a debug parser object.")
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
57 ;;;###autoload
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (make-variable-buffer-local 'semantic-debug-parser-class)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (defvar semantic-debug-enabled nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 "Non-nil when debugging a parser.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;;; Variables used during a debug session.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 (defvar semantic-debug-current-interface nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 "The debugger interface currently active for this buffer.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 (defvar semantic-debug-current-parser nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 "The parser current active for this buffer.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;;; User Interface Portion
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 (defclass semantic-debug-interface ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 ((parser-buffer :initarg :parser-buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 :type buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 "The buffer containing the parser we are debugging.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 (parser-local-map :initarg :parser-local-map
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 :type keymap
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 "The local keymap originally in the PARSER buffer.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (parser-location :type marker
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 "A marker representing where we are in the parser buffer.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (source-buffer :initarg :source-buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 :type buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 "The buffer containing the source we are parsing.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 The :parser-buffer defines a parser that can parse the text in the
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 :source-buffer.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (source-local-map :initarg :source-local-map
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 :type keymap
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 "The local keymap originally in the SOURCE buffer.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (source-location :type marker
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 "A marker representing where we are in the parser buffer.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 (data-buffer :initarg :data-buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 :type buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 "Buffer being used to display some useful data.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 These buffers are brought into view when layout occurs.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (current-frame :type semantic-debug-frame
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 "The currently displayed frame.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (overlays :type list
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 :initarg nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 "Any active overlays being used to show the debug position.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 "Controls action when in `semantic-debug-mode'")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 ;; Methods
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 (defmethod semantic-debug-set-frame ((iface semantic-debug-interface) frame)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 "Set the current frame on IFACE to FRAME."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (if frame
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 (oset iface current-frame frame)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 (slot-makeunbound iface 'current-frame)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (defmethod semantic-debug-set-parser-location ((iface semantic-debug-interface) point)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 "Set the parser location in IFACE to POINT."
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
121 (with-current-buffer (oref iface parser-buffer)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (if (not (slot-boundp iface 'parser-location))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 (oset iface parser-location (make-marker)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (move-marker (oref iface parser-location) point))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (defmethod semantic-debug-set-source-location ((iface semantic-debug-interface) point)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 "Set the source location in IFACE to POINT."
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
129 (with-current-buffer (oref iface source-buffer)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (if (not (slot-boundp iface 'source-location))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 (oset iface source-location (make-marker)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (move-marker (oref iface source-location) point))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (defmethod semantic-debug-interface-layout ((iface semantic-debug-interface))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 "Layout windows in the current frame to facilitate debugging."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (delete-other-windows)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 ;; Deal with the data buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (when (slot-boundp iface 'data-buffer)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (let ((lines (/ (frame-height (selected-frame)) 3))
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
141 (cnt (with-current-buffer (oref iface data-buffer)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 (count-lines (point-min) (point-max))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 ;; Set the number of lines to 1/3, or the size of the data buffer.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (if (< cnt lines) (setq cnt lines))
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
146
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 (split-window-vertically cnt)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (switch-to-buffer (oref iface data-buffer))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (other-window 1))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 ;; Parser
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 (switch-to-buffer (oref iface parser-buffer))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (when (slot-boundp iface 'parser-location)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (goto-char (oref iface parser-location)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (split-window-vertically)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (other-window 1)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 ;; Source
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (switch-to-buffer (oref iface source-buffer))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (when (slot-boundp iface 'source-location)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (goto-char (oref iface source-location)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (defmethod semantic-debug-highlight-lexical-token ((iface semantic-debug-interface) token)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 "For IFACE, highlight TOKEN in the source buffer .
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 TOKEN is a lexical token."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (set-buffer (oref iface :source-buffer))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (object-add-to-list iface 'overlays
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (semantic-lex-highlight-token token))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (semantic-debug-set-source-location iface (semantic-lex-token-start token))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 (defmethod semantic-debug-highlight-rule ((iface semantic-debug-interface) nonterm &optional rule match)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 "For IFACE, highlight NONTERM in the parser buffer.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 NONTERM is the name of the rule currently being processed that shows up
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 as a nonterminal (or tag) in the source buffer.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 If RULE and MATCH indicies are specified, highlight those also."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (set-buffer (oref iface :parser-buffer))
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
180
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (let* ((rules (semantic-find-tags-by-class 'nonterminal (current-buffer)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (nt (semantic-find-first-tag-by-name nonterm rules))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (o nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (when nt
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 ;; I know it is the first symbol appearing in the body of this token.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 (goto-char (semantic-tag-start nt))
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
188
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (setq o (semantic-make-overlay (point) (progn (forward-sexp 1) (point))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (semantic-overlay-put o 'face 'highlight)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (object-add-to-list iface 'overlays o)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (semantic-debug-set-parser-location iface (semantic-overlay-start o))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 (when (and rule match)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 ;; Rule, an int, is the rule inside the nonterminal we are following.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (re-search-forward ":\\s-*")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (while (/= 0 rule)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (re-search-forward "^\\s-*|\\s-*")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (setq rule (1- rule)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 ;; Now find the match inside the rule
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (while (/= 0 match)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 (forward-sexp 1)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (skip-chars-forward " \t")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 (setq match (1- match)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 ;; Now highlight the thingy we find there.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 (setq o (semantic-make-overlay (point) (progn (forward-sexp 1) (point))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (semantic-overlay-put o 'face 'highlight)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (object-add-to-list iface 'overlays o)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 ;; If we have a match for a sub-rule, have the parser position
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 ;; move so we can see it in the output window for very long rules.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (semantic-debug-set-parser-location iface (semantic-overlay-start o))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 ))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (defmethod semantic-debug-unhighlight ((iface semantic-debug-interface))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 "Remove all debugging overlays."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (mapc 'semantic-overlay-delete (oref iface overlays))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (oset iface overlays nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 ;; Call from the parser at a breakpoint
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (defvar semantic-debug-user-command nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 "The command the user is requesting.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (defun semantic-debug-break (frame)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 "Stop parsing now at FRAME.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 FRAME is an object that represents the parser's view of the
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 current state of the world.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 This function enters a recursive edit. It returns
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 on an `exit-recursive-edit', or if someone uses one
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 of the `semantic-debug-mode' commands.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 It returns the command specified. Parsers need to take action
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 on different types of return values."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (save-window-excursion
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 ;; Set up displaying information
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (semantic-debug-mode t)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 (unwind-protect
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (progn
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (semantic-debug-frame-highlight frame)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (semantic-debug-interface-layout semantic-debug-current-interface)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (condition-case nil
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 ;; Enter recursive edit... wait for user command.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (recursive-edit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 (error nil)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (semantic-debug-unhighlight semantic-debug-current-interface)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (semantic-debug-mode nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 ;; Find the requested user state. Do something.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (let ((returnstate semantic-debug-user-command))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (setq semantic-debug-user-command nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 returnstate)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 ;;; Frame
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 ;; A frame can represent the state at a break point.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (defclass semantic-debug-frame ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 "One frame representation.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 (defmethod semantic-debug-frame-highlight ((frame semantic-debug-frame))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 "Highlight one parser frame."
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
269
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (defmethod semantic-debug-frame-info ((frame semantic-debug-frame))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 "Display info about this one parser frame."
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
274
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 ;;; Major Mode
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (defvar semantic-debug-mode-map
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (let ((km (make-sparse-keymap)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 (define-key km "n" 'semantic-debug-next)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (define-key km " " 'semantic-debug-next)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (define-key km "s" 'semantic-debug-step)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (define-key km "u" 'semantic-debug-up)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (define-key km "d" 'semantic-debug-down)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (define-key km "f" 'semantic-debug-fail-match)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (define-key km "h" 'semantic-debug-print-state)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (define-key km "s" 'semantic-debug-jump-to-source)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (define-key km "p" 'semantic-debug-jump-to-parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (define-key km "q" 'semantic-debug-quit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (define-key km "a" 'semantic-debug-abort)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (define-key km "g" 'semantic-debug-go)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (define-key km "b" 'semantic-debug-set-breakpoint)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 ;; Some boring bindings.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (define-key km "e" 'eval-expression)
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
296
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 km)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 "Keymap used when in semantic-debug-node.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (defun semantic-debug-mode (onoff)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 "Turn `semantic-debug-mode' on and off.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 Argument ONOFF is non-nil when we are entering debug mode.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 \\{semantic-debug-mode-map}"
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (let ((iface semantic-debug-current-interface))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (if onoff
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 ;; Turn it on
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
307 (with-current-buffer (oref iface parser-buffer)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 ;; Install our map onto this buffer
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (use-local-map semantic-debug-mode-map)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 ;; Make the buffer read only
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (toggle-read-only 1)
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
312
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (set-buffer (oref iface source-buffer))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 ;; Use our map in the source buffer also
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (use-local-map semantic-debug-mode-map)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 ;; Make the buffer read only
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (toggle-read-only 1)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 ;; Hooks
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104470
diff changeset
319 (run-hooks 'semantic-debug-mode-hook)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 ;; Restore old mode information
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
322 (with-current-buffer
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
323 (oref semantic-debug-current-interface parser-buffer)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (use-local-map
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (oref semantic-debug-current-interface parser-local-map))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 )
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
327 (with-current-buffer
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
328 (oref semantic-debug-current-interface source-buffer)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (use-local-map
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (oref semantic-debug-current-interface source-local-map))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 )
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104470
diff changeset
332 (run-hooks 'semantic-debug-exit-hook)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 )))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (defun semantic-debug ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 "Parse the current buffer and run in debug mode."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (if semantic-debug-current-interface
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 (error "You are already in a debug session"))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (if (not semantic-debug-parser-class)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 (error "This major mode does not support parser debugging"))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 ;; Clear the cache to force a full reparse.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (semantic-clear-toplevel-cache)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 ;; Do the parse
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (let ((semantic-debug-enabled t)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 ;; Create an interface
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (semantic-debug-current-interface
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (let ((parserb (semantic-debug-find-parser-source)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (semantic-debug-interface
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 "Debug Interface"
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 :parser-buffer parserb
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
352 :parser-local-map (with-current-buffer parserb
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (current-local-map))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 :source-buffer (current-buffer)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 :source-local-map (current-local-map)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 )))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 ;; Create a parser debug interface
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 (semantic-debug-current-parser
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (funcall semantic-debug-parser-class "parser"))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 ;; We could recurse into a parser while debugging.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 ;; Is that a problem?
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (semantic-fetch-tags)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 ;; We should turn the auto-parser back on, but don't do it for
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 ;; now until the debugger is working well.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 (defun semantic-debug-find-parser-source ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 "Return a buffer containing the parser source file for the current buffer.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 The parser needs to be on the load path, or this routine returns nil."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 (if (not semantic-debug-parser-source)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (error "No parser is associated with this buffer"))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (let ((parser (locate-library semantic-debug-parser-source t)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (if parser
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 (find-file-noselect parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (error "Cannot find parser source. It should be on the load-path"))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 ;;; Debugger commands
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (defun semantic-debug-next ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 "Perform one parser operation.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 In the recursive parser, this steps past one match rule.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 In other parsers, this may be just like `semantic-debug-step'."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (let ((parser semantic-debug-current-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (semantic-debug-parser-next parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (exit-recursive-edit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (defun semantic-debug-step ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 "Perform one parser operation."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (let ((parser semantic-debug-current-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (semantic-debug-parser-step parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (exit-recursive-edit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (defun semantic-debug-up ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 "Move highlighting representation up one level."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (message "Not implemented yet.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (defun semantic-debug-down ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 "Move highlighting representation down one level."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (message "Not implemented yet.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (defun semantic-debug-fail-match ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 "Artificially fail the current match."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (let ((parser semantic-debug-current-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 (semantic-debug-parser-fail parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 (exit-recursive-edit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (defun semantic-debug-print-state ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 "Show interesting parser state."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 (let ((parser semantic-debug-current-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (semantic-debug-parser-print-state parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (defun semantic-debug-jump-to-source ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 "Move cursor to the source code being parsed at the current lexical token."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (let* ((interface semantic-debug-current-interface)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (buf (oref interface source-buffer)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (if (get-buffer-window buf)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (progn
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 (select-frame (window-frame (get-buffer-window buf)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 (select-window (get-buffer-window buf)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 ;; Technically, this should do a window layout operation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (switch-to-buffer buf))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (defun semantic-debug-jump-to-parser ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 "Move cursor to the parser being debugged."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (let* ((interface semantic-debug-current-interface)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (buf (oref interface parser-buffer)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (if (get-buffer-window buf)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (progn
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (select-frame (window-frame (get-buffer-window buf)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 (select-window (get-buffer-window buf)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 ;; Technically, this should do a window layout operation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 (switch-to-buffer buf))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (defun semantic-debug-quit ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 "Exit debug mode, blowing all stack, and leaving the parse incomplete.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 Do not update any tokens already parsed."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (let ((parser semantic-debug-current-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (semantic-debug-parser-quit parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 (exit-recursive-edit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 (defun semantic-debug-abort ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 "Abort one level of debug mode, blowing all stack."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (let ((parser semantic-debug-current-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (semantic-debug-parser-abort parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (exit-recursive-edit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (defun semantic-debug-go ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 "Continue parsing till finish or breakpoint."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (let ((parser semantic-debug-current-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 (semantic-debug-parser-go parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 (exit-recursive-edit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 (defun semantic-debug-set-breakpoint ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 "Set a breakpoint at the current rule location."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 (let ((parser semantic-debug-current-parser)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 ;; Get the location as semantic tokens.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 (location (semantic-current-tag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 (if location
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 (semantic-debug-parser-break parser location)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 (error "Not on a rule"))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 ;;; Debugger superclass
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 (defclass semantic-debug-parser ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 (
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 "Represents a parser and its state.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 When implementing the debug parser you can add extra functionality
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 by overriding one of the command methods. Be sure to use
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 `call-next-method' so that the debug command is saved, and passed
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 down to your parser later."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 :abstract t)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 (defmethod semantic-debug-parser-next ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 "Execute next for this PARSER."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 (setq semantic-debug-user-command 'next)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 (defmethod semantic-debug-parser-step ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 "Execute a step for this PARSER."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 (setq semantic-debug-user-command 'step)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 (defmethod semantic-debug-parser-go ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 "Continue executiong in this PARSER until the next breakpoint."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 (setq semantic-debug-user-command 'go)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 (defmethod semantic-debug-parser-fail ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 "Continue executiong in this PARSER until the next breakpoint."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 (setq semantic-debug-user-command 'fail)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 (defmethod semantic-debug-parser-quit ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 "Continue executiong in this PARSER until the next breakpoint."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 (setq semantic-debug-user-command 'quit)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 (defmethod semantic-debug-parser-abort ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 "Continue executiong in this PARSER until the next breakpoint."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 (setq semantic-debug-user-command 'abort)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 (defmethod semantic-debug-parser-print-state ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 "Print state for this PARSER at the current breakpoint."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 (with-slots (current-frame) semantic-debug-current-interface
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 (when current-frame
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 (semantic-debug-frame-info current-frame)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 )))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 (defmethod semantic-debug-parser-break ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 "Set a breakpoint for this PARSER."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 ;; Stack stuff
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 (defmethod semantic-debug-parser-frames ((parser semantic-debug-parser))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 "Return a list of frames for the current parser.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 A frame is of the form:
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 ( .. .what ? .. )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 "
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 (error "Parser has not implemented frame values")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 (provide 'semantic/debug)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
564 ;; Local variables:
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
565 ;; generated-autoload-file: "loaddefs.el"
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
566 ;; generated-autoload-load-name: "semantic/debug"
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
567 ;; End:
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104468
diff changeset
568
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105336
diff changeset
569 ;; arch-tag: 6f189d2d-8a65-45a5-a7f0-9894625eb860
104468
3e6235dcb480 lisp/cedet/semantic/java.el: File moved here from bovine/ subdirectory.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
570 ;;; semantic/debug.el ends here