1 ;;; Copyright (C) 2010, 2014-2015 Rocky Bernstein <rocky@gnu.org>
2 (eval-when-compile (require 'cl))
4 (require 'load-relative)
5 (require-relative-list '("../../common/regexp"
9 (require-relative-list '("../../lang/ruby") "realgud-lang-")
11 (defvar realgud-pat-hash)
12 (declare-function make-realgud-loc-pat (realgud-loc))
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")
19 (setf (gethash "loc-callback-fn" realgud:trepan-pat-hash) 'realgud:trepan-loc-fn-callback)
21 ;; Regular expression that describes a trepan location generally shown
22 ;; before a command prompt.
24 ;; -- (/tmp/linecache.rb:64)
25 ;; C> (/tmp/eval.rb:2)
26 (setf (gethash "loc" realgud:trepan-pat-hash)
28 :regexp ".. (\\(?:.+ \\(?:via\\|remapped\\) \\)?\\(.+\\):\\([0-9]+\\)\\(?: @[0-9]+\\)?)\\(?:\n\\(.*?\\)\n\\)?"
32 :ignore-file-re "(eval: .*)"
35 ;; Regular expression that describes a trepan command prompt
41 (setf (gethash "prompt" realgud:trepan-pat-hash)
43 :regexp "^(+trepan\\(@[0-9]+\\|@main\\)?)+: "
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)
50 ;; Regular expression that describes a Ruby YARV 1.9 backtrace line.
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)
58 :regexp "^\\(?:[\t]from \\)?\\([^:]+\\):\\([0-9]+\\)\\(?:in `.*'\\)?"
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)
66 ;; Regular expression that describes a "breakpoint set" line.
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)
74 :regexp "^Breakpoint \\([0-9]+\\) set at .*[\n\t ]+line \\([0-9]+\\)[ \t\n]+in file \\(.+\\)."
79 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
81 ;; Deleted breakpoint 1.
82 (setf (gethash "brkpt-del" realgud:trepan-pat-hash)
84 :regexp "^Deleted breakpoint \\([0-9]+\\).\n"
87 (defconst realgud:trepan-selected-frame-indicator "-->"
88 "String that describes which frame is selected in a debugger
91 (defconst realgud:trepan-frame-file-regexp
92 "[ \t\n]+in file \\([^ \n]+\\)")
94 (defconst realgud:trepan-debugger-name "trepan" "Name of debugger")
97 (setf (gethash "top-frame-num" realgud:trepan-pat-hash) 0)
99 ;; Regular expression that describes a debugger "selected" frame in in
100 ;; a frame-motion command.
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
106 (format "^%s #\\([0-9]+\\) .*%s"
107 realgud:trepan-selected-frame-indicator
108 realgud:trepan-frame-file-regexp)
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]+\\)"
117 ;; Regular expression that describes a Ruby $! string
118 (setf (gethash "dollar-bang" realgud:trepan-pat-hash)
119 realgud-ruby-dollar-bang-loc-pat)
121 ;; Regular expression that describes debugger "backtrace" command line.
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 "\\)?"
138 ;; Regular expression that for a termination message.
139 (setf (gethash "termination" realgud:trepan-pat-hash)
140 "^trepan: That's all, folks...\n")
142 (setf (gethash "font-lock-keywords" realgud:trepan-pat-hash)
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
152 (1 font-lock-variable-name-face))
153 ;; "::Type", which occurs in class name of function and in parameter list.
154 ;; Parameter sequence
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))
161 ("[ \t]+in file \\([^ ]+*\\)"
162 (1 realgud-file-name-face))
164 ("[ \t]+at line \\([0-9]+\\)$"
165 (1 realgud-line-number-face))
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))
174 ;; (setf (gethash "font-lock-keywords" realgud:trepan-pat-hash)
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
186 ;; (1 font-lock-variable-name-face))
187 ;; ;; "::Type", which occurs in class name of function and in
188 ;; ;; parameter list. Parameter sequence
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))
196 ;; (realgud:trepan-frame-file-regexp (1 realgud-file-name-face))
198 ;; (realgud:trepan-frame-line-regexp (1 realgud-line-number-face))
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))
207 (setf (gethash realgud:trepan-debugger-name realgud-pat-hash) realgud:trepan-pat-hash)
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!'")
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)
218 (provide-me "realgud:trepan-")