]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/trepan/init.el
2da793ef8d21361bc0bf108cde51b10695cc9299
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / trepan / init.el
1 ;;; Copyright (C) 2010, 2014-2015 Rocky Bernstein <rocky@gnu.org>
2 (eval-when-compile (require 'cl))
3
4 (require 'load-relative)
5 (require-relative-list '("../../common/regexp"
6 "../../common/loc"
7 "../../common/init")
8 "realgud-")
9 (require-relative-list '("../../lang/ruby") "realgud-lang-")
10
11 (defvar realgud-pat-hash)
12 (declare-function make-realgud-loc-pat (realgud-loc))
13
14 (defvar realgud:trepan-pat-hash (make-hash-table :test 'equal)
15 "Hash key is the what kind of pattern we want to match:
16 backtrace, prompt, etc. The values of a hash entry is a
17 realgud-loc-pat struct")
18
19 (setf (gethash "loc-callback-fn" realgud:trepan-pat-hash) 'realgud:trepan-loc-fn-callback)
20
21 ;; Regular expression that describes a trepan location generally shown
22 ;; before a command prompt.
23 ;; For example:
24 ;; -- (/tmp/linecache.rb:64)
25 ;; C> (/tmp/eval.rb:2)
26 (setf (gethash "loc" realgud:trepan-pat-hash)
27 (make-realgud-loc-pat
28 :regexp ".. (\\(?:.+ \\(?:via\\|remapped\\) \\)?\\(.+\\):\\([0-9]+\\)\\(?: @[0-9]+\\)?)\\(?:\n\\(.*?\\)\n\\)?"
29 :file-group 1
30 :line-group 2
31 :text-group 3
32 :ignore-file-re "(eval: .*)"
33 ))
34
35 ;; Regular expression that describes a trepan command prompt
36 ;; For example:
37 ;; (trepan):
38 ;; ((trepan)):
39 ;; (trepan@main):
40 ;; (trepan@55):
41 (setf (gethash "prompt" realgud:trepan-pat-hash)
42 (make-realgud-loc-pat
43 :regexp "^(+trepan\\(@[0-9]+\\|@main\\)?)+: "
44 ))
45
46 ;; Regular expression that describes a Ruby YARV 1.9 syntax error line.
47 (setf (gethash "syntax-error" realgud:trepan-pat-hash)
48 realgud-ruby-YARV-syntax-error-pat)
49
50 ;; Regular expression that describes a Ruby YARV 1.9 backtrace line.
51 ;; For example:
52 ;; <internal:lib/rubygems/custom_require>:29:in `require'
53 ;; <internal:lib/rubygems/custom_require>:29:in `require'
54 ;; /tmp/Rakefile:50:in `<top /src/external-vcs/laser/Rakefile>'
55 ;; from /usr/lib/ruby/gems/rspec/compatibility.rb:6:in `const_missing'
56 (setf (gethash "lang-backtrace" realgud:trepan-pat-hash)
57 (make-realgud-loc-pat
58 :regexp "^\\(?:[\t]from \\)?\\([^:]+\\):\\([0-9]+\\)\\(?:in `.*'\\)?"
59 :file-group 1
60 :line-group 2))
61
62 ;; Regular expression that describes a ruby $! backtrace
63 (setf (gethash "dollar-bang-backtrace" realgud:trepan-pat-hash)
64 realgud-ruby-dollar-bang-loc-pat)
65
66 ;; Regular expression that describes a "breakpoint set" line.
67 ;; For example:
68 ;; Breakpoint 1 set at VM offset 2 of instruction sequence "require",
69 ;; line 29 in file <internal:lib/rubygems/custom_require>.
70 ;; Breakpoint 2 set at VM offset 29 of instruction sequence "<top /xx.rb>",
71 ;; line 64 in file /src/external-vcs/linecache/trunk/lib/linecache.rb.
72 (setf (gethash "brkpt-set" realgud:trepan-pat-hash)
73 (make-realgud-loc-pat
74 :regexp "^Breakpoint \\([0-9]+\\) set at .*[\n\t ]+line \\([0-9]+\\)[ \t\n]+in file \\(.+\\)."
75 :num 1
76 :file-group 3
77 :line-group 2))
78
79 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
80 ;; For example:
81 ;; Deleted breakpoint 1.
82 (setf (gethash "brkpt-del" realgud:trepan-pat-hash)
83 (make-realgud-loc-pat
84 :regexp "^Deleted breakpoint \\([0-9]+\\).\n"
85 :num 1))
86
87 (defconst realgud:trepan-selected-frame-indicator "-->"
88 "String that describes which frame is selected in a debugger
89 backtrace listing.")
90
91 (defconst realgud:trepan-frame-file-regexp
92 "[ \t\n]+in file \\([^ \n]+\\)")
93
94 (defconst realgud:trepan-debugger-name "trepan" "Name of debugger")
95
96 ;; Top frame number
97 (setf (gethash "top-frame-num" realgud:trepan-pat-hash) 0)
98
99 ;; Regular expression that describes a debugger "selected" frame in in
100 ;; a frame-motion command.
101 ;; For example:
102 ;; --> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/irb at line 9
103 (setf (gethash "selected-frame" realgud:trepan-pat-hash)
104 (make-realgud-loc-pat
105 :regexp
106 (format "^%s #\\([0-9]+\\) .*%s"
107 realgud:trepan-selected-frame-indicator
108 realgud:trepan-frame-file-regexp)
109 :num 1))
110
111 (setf (gethash "control-frame" realgud:trepan-pat-hash)
112 (make-realgud-loc-pat
113 :regexp "^c:\\([0-9]+\\) p:\\([0-9]+\\) s:\\([0-9]+\\) b:\\([0-9]+\\) l:\\([0-9a-f]+\\) d:\\([0-9a-f]+\\) \\([A-Z]+\\) \\(.+\\):\\([0-9]+\\)"
114 :file-group 8
115 :line-group 9))
116
117 ;; Regular expression that describes a Ruby $! string
118 (setf (gethash "dollar-bang" realgud:trepan-pat-hash)
119 realgud-ruby-dollar-bang-loc-pat)
120
121 ;; Regular expression that describes debugger "backtrace" command line.
122 ;; e.g.
123 ;; --> #0 METHOD Object#require(path) in file <internal:lib/require> at line 28
124 ;; #1 TOP Object#<top /tmp/linecache.rb> in file /tmp/linecache.rb
125 (setf (gethash "debugger-backtrace" realgud:trepan-pat-hash)
126 (make-realgud-loc-pat
127 :regexp (concat realgud:trepan-frame-start-regexp " "
128 realgud:trepan-frame-num-regexp " "
129 "\\([A-Z]+\\) *\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\(.*\\)"
130 realgud:trepan-frame-file-regexp
131 "\\(?:" realgud:trepan-frame-line-regexp "\\)?"
132 )
133 :num 2
134 :file-group 6
135 :line-group 7)
136 )
137
138 ;; Regular expression that for a termination message.
139 (setf (gethash "termination" realgud:trepan-pat-hash)
140 "^trepan: That's all, folks...\n")
141
142 (setf (gethash "font-lock-keywords" realgud:trepan-pat-hash)
143 '(
144 ;; The frame number and first type name, if present.
145 ("^\\(-->\\| \\)? #\\([0-9]+\\) \\([A-Z]+\\) *\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?"
146 (2 realgud-backtrace-number-face)
147 (3 font-lock-keyword-face) ; e.g. METHOD, TOP
148 (4 font-lock-constant-face) ; e.g. Object
149 (5 font-lock-function-name-face nil t)) ; t means optional
150 ;; Instruction sequence
151 ("<\\(.+\\)>"
152 (1 font-lock-variable-name-face))
153 ;; "::Type", which occurs in class name of function and in parameter list.
154 ;; Parameter sequence
155 ("(\\(.+\\))"
156 (1 font-lock-variable-name-face))
157 ;; "::Type", which occurs in class name of function and in parameter list.
158 ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
159 (1 font-lock-type-face))
160 ;; File name.
161 ("[ \t]+in file \\([^ ]+*\\)"
162 (1 realgud-file-name-face))
163 ;; Line number.
164 ("[ \t]+at line \\([0-9]+\\)$"
165 (1 realgud-line-number-face))
166 ;; Function name.
167 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
168 (1 font-lock-type-face)
169 (2 font-lock-function-name-face))
170 ;; (trepan-frames-match-current-line
171 ;; (0 trepan-frames-current-frame-face append))
172 ))
173
174 ;; (setf (gethash "font-lock-keywords" realgud:trepan-pat-hash)
175 ;; '(
176 ;; ;; The frame number and first type name, if present.
177 ;; ((concat realgud:trepan-frame-start-regexp " "
178 ;; realgud:trepan-frame-num-regexp " "
179 ;; "\\([A-Z]+\\) *\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?")
180 ;; (2 realgud-backtrace-number-face)
181 ;; (3 font-lock-keyword-face) ; e.g. METHOD, TOP
182 ;; (4 font-lock-constant-face) ; e.g. Object
183 ;; (5 font-lock-function-name-face nil t)) ; t means optional
184 ;; ;; Instruction sequence
185 ;; ("<\\(.+\\)>"
186 ;; (1 font-lock-variable-name-face))
187 ;; ;; "::Type", which occurs in class name of function and in
188 ;; ;; parameter list. Parameter sequence
189 ;; ("(\\(.+\\))"
190 ;; (1 font-lock-variable-name-face))
191 ;; ;; "::Type", which occurs in class name of function and in
192 ;; ;; parameter list.
193 ;; ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
194 ;; (1 font-lock-type-face))
195 ;; ;; File name.
196 ;; (realgud:trepan-frame-file-regexp (1 realgud-file-name-face))
197 ;; ;; Line number.
198 ;; (realgud:trepan-frame-line-regexp (1 realgud-line-number-face))
199 ;; ;; Function name.
200 ;; ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
201 ;; (1 font-lock-type-face)
202 ;; (2 font-lock-function-name-face))
203 ;; ;; (trepan-frames-match-current-line
204 ;; ;; (0 trepan-frames-current-frame-face append))
205 ;; ))
206
207 (setf (gethash realgud:trepan-debugger-name realgud-pat-hash) realgud:trepan-pat-hash)
208
209 (defvar realgud:trepan-command-hash (make-hash-table :test 'equal)
210 "Hash key is command name like 'quit' and the value is
211 the trepan command to use, like 'quit!'")
212
213 (setf (gethash "quit" realgud:trepan-command-hash) "quit!")
214 (setf (gethash "shell" realgud:trepan-command-hash) "irb")
215 (setf (gethash realgud:trepan-debugger-name
216 realgud-command-hash) realgud:trepan-command-hash)
217
218 (provide-me "realgud:trepan-")