1 ;;; Copyright (C) 2014 Rocky Bernstein <rocky@gnu.org>
2 (eval-when-compile (require 'cl))
4 (require 'load-relative)
5 (require-relative-list '("../../common/regexp"
10 ;; (require-relative-list '("../../lang/java") "realgud-lang-")
12 (defvar realgud-pat-hash)
13 (declare-function make-realgud-loc-pat (realgud-loc))
15 (defconst realgud:jdb-identifier "[A-Za-z_][A-Za-z0-9_.]+"
16 "Regexp string that matches a Java identifier possily with class
17 name. For example java.lang.Class.getDeclaredMethods")
19 (defvar realgud:jdb-pat-hash (make-hash-table :test 'equal)
20 "Hash key is the what kind of pattern we want to match:
21 backtrace, prompt, etc. The values of a hash entry is a
22 realgud-loc-pat struct")
24 (setf (gethash "loc-callback-fn" realgud:jdb-pat-hash) 'realgud:jdb-loc-fn-callback)
26 ;; Regular expression that describes a jdb location generally shown
27 ;; before a command prompt. For example:
28 ;; Breakpoint hit: "thread=main", TestMe.main(), line=7 bci=0
29 ;; Step completed: "thread=main", TestMe.<init>(), line=15 bci=0
31 (setf (gethash "loc" realgud:jdb-pat-hash)
33 :regexp "\\(?:Breakpoint hit\\|Step completed\\): \"thread=.+\", \\(.+\\)?[.]\\(.+\\)(), line=\\([0-9]+\\) bci=\\([0-9]+\\)\\(?:\n\\([0-9]+\\)\\(.*\\)\\)?"
38 ;; Regular expression that describes a jdb command prompt
43 ;; FIXME: I think the pattern is thread-name[stack-level]
44 ;; Here, we only deal with main.
45 (setf (gethash "prompt" realgud:jdb-pat-hash)
47 :regexp "^\\(?:main\\[\\([0-9]+\\)\\]\\|>\\) "
51 ;; Regular expression that describes a Java syntax error line.
52 ;; (setf (gethash "syntax-error" realgud:jdb-pat-hash)
53 ;; realgud-java-syntax-error-pat)
55 ;; Regular expression that describes a Java backtrace line.
57 ;; [1] ca.snpEffect.commandLine.SnpEff.run (SnpEff.java:7)
58 (setf (gethash "lang-backtrace" realgud:jdb-pat-hash)
60 ;; FIXME: use realgud:jdb-identifier
61 :regexp "^\\(?:[ ]*[\\[0-9\\]+]\\) \\([A-Za-z_.][A-Za-z0-9.]+\\) (\\([A-Za-z_.][A-Za-z0-9.]+\\):\\([0-9]+\\))"
65 ;; Regular expression that describes a "breakpoint set" line.
67 ;; Set breakpoint TestMe:7
68 (setf (gethash "brkpt-set" realgud:jdb-pat-hash)
70 :regexp "^Set breakpoint \\(.+\\):\\([0-9]+\\)"
74 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
76 ;; Removed: breakpoint TestMe:7
77 (setf (gethash "brkpt-del" realgud:jdb-pat-hash)
79 :regexp "^Removed breakpoint \\(.+\\):\\([0-9]+\\)\n"
82 (defconst realgud:jdb-selected-frame-indicator "-->"
83 "String that describes which frame is selected in a debugger
86 (defconst realgud:jdb-frame-file-regexp
87 "[ \t\n]+in file \\([^ \n]+\\)")
89 (defconst realgud:jdb-debugger-name "jdb" "Name of debugger")
92 (setf (gethash "top-frame-num" realgud:jdb-pat-hash) 0)
94 ;; Regular expression that describes a debugger "selected" frame in in
95 ;; a frame-motion command.
97 ;; --> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/irb at line 9
98 (setf (gethash "selected-frame" realgud:jdb-pat-hash)
101 (format "^%s #\\([0-9]+\\) .*%s"
102 realgud:jdb-selected-frame-indicator
103 realgud:jdb-frame-file-regexp)
106 ;; Regular expression that describes a jdb backtrace line.
108 ;; [1] TestMe.main (TestMe.java:7)
109 ;; [2] java.lang.Class.privateGetDeclaredMethods (Class.java:2,570)
110 ;; [3] java.lang.Class.getMethod0 (Class.java:2,813)
111 ;; [4] java.lang.Class.getMethod (Class.java:1,663)
112 ;; [5] sun.launcher.LauncherHelper.getMainMethod (LauncherHelper.java:494)
113 ;; [6] sun.launcher.LauncherHelper.checkAndLoadMain (LauncherHelper.java:486)
114 (setf (gethash "debugger-backtrace" realgud:jdb-pat-hash)
115 (make-realgud-loc-pat
116 :regexp "^\\(?:[\t ]*[\\[[0-9]+\\] \\)\\([A-Za-z_.][A-Za-z0-9.]+\\):\\([0-9]+\\)"
120 (setf (gethash "font-lock-keywords" realgud:jdb-pat-hash)
122 ;; The frame number and first type name, if present.
123 ;; FIXME: use realgud:jdb-identifier
124 ("^\\(-->\\| \\)? #\\([0-9]+\\) \\([A-Z]+\\) *\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?"
125 (2 realgud-backtrace-number-face)
126 (3 font-lock-keyword-face) ; e.g. METHOD, TOP
127 (4 font-lock-constant-face) ; e.g. Object
128 (5 font-lock-function-name-face nil t)) ; t means optional
129 ;; Instruction sequence
131 (1 font-lock-variable-name-face))
132 ;; "::Type", which occurs in class name of function and in parameter list.
133 ;; Parameter sequence
135 (1 font-lock-variable-name-face))
136 ;; "::Type", which occurs in class name of function and in parameter list.
137 ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
138 (1 font-lock-type-face))
140 ("[ \t]+in file \\([^ ]+*\\)"
141 (1 realgud-file-name-face))
143 ("[ \t]+at line \\([0-9]+\\)$"
144 (1 realgud-line-number-face))
146 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
147 (1 font-lock-type-face)
148 (2 font-lock-function-name-face))
149 ;; (jdb-frames-match-current-line
150 ;; (0 jdb-frames-current-frame-face append))
153 ;; (setf (gethash "font-lock-keywords" realgud:jdb-pat-hash)
155 ;; ;; The frame number and first type name, if present.
156 ;; ((concat realgud:jdb-frame-start-regexp " "
157 ;; realgud:jdb-frame-num-regexp " "
158 ;; "\\([A-Z]+\\) *\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?")
159 ;; (2 realgud-backtrace-number-face)
160 ;; (3 font-lock-keyword-face) ; e.g. METHOD, TOP
161 ;; (4 font-lock-constant-face) ; e.g. Object
162 ;; (5 font-lock-function-name-face nil t)) ; t means optional
163 ;; ;; Instruction sequence
165 ;; (1 font-lock-variable-name-face))
166 ;; ;; "::Type", which occurs in class name of function and in
167 ;; ;; parameter list. Parameter sequence
169 ;; (1 font-lock-variable-name-face))
170 ;; ;; "::Type", which occurs in class name of function and in
171 ;; ;; parameter list.
172 ;; ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
173 ;; (1 font-lock-type-face))
175 ;; (realgud:jdb-frame-file-regexp (1 realgud-file-name-face))
177 ;; (realgud:jdb-frame-line-regexp (1 realgud-line-number-face))
179 ;; ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
180 ;; (1 font-lock-type-face)
181 ;; (2 font-lock-function-name-face))
182 ;; ;; (jdb-frames-match-current-line
183 ;; ;; (0 jdb-frames-current-frame-face append))
186 (setf (gethash realgud:jdb-debugger-name realgud-pat-hash) realgud:jdb-pat-hash)
188 (defvar realgud:jdb-command-hash (make-hash-table :test 'equal)
189 "Hash key is command name like 'quit' and the value is
190 the jdb command to use, like 'quit!'")
192 (setf (gethash realgud:jdb-debugger-name
193 realgud-command-hash) realgud:jdb-command-hash)
195 (setf (gethash "backtrace" realgud:jdb-command-hash) "where")
196 (setf (gethash "break" realgud:jdb-command-hash) "stop at %c:%l")
197 (setf (gethash "clear" realgud:jdb-command-hash) "clear %c:%l")
198 (setf (gethash "continue" realgud:jdb-command-hash) "cont")
199 (setf (gethash "finish" realgud:jdb-command-hash) "step up")
200 (setf (gethash "up" realgud:jdb-command-hash) "up\C-Mwhere")
201 (setf (gethash "down" realgud:jdb-command-hash) "down\C-Mwhere")
204 (provide-me "realgud:jdb-")