]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/jdb/init.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / jdb / init.el
1 ;;; Copyright (C) 2014 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
10 ;; (require-relative-list '("../../lang/java") "realgud-lang-")
11
12 (defvar realgud-pat-hash)
13 (declare-function make-realgud-loc-pat (realgud-loc))
14
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")
18
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")
23
24 (setf (gethash "loc-callback-fn" realgud:jdb-pat-hash) 'realgud:jdb-loc-fn-callback)
25
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
30
31 (setf (gethash "loc" realgud:jdb-pat-hash)
32 (make-realgud-loc-pat
33 :regexp "\\(?:Breakpoint hit\\|Step completed\\): \"thread=.+\", \\(.+\\)?[.]\\(.+\\)(), line=\\([0-9]+\\) bci=\\([0-9]+\\)\\(?:\n\\([0-9]+\\)\\(.*\\)\\)?"
34 :file-group 1
35 :line-group 3
36 :text-group 6))
37
38 ;; Regular expression that describes a jdb command prompt
39 ;; For example:
40 ;; main[1]
41 ;; main[2]
42 ;; >
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)
46 (make-realgud-loc-pat
47 :regexp "^\\(?:main\\[\\([0-9]+\\)\\]\\|>\\) "
48 :num 1
49 ))
50
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)
54
55 ;; Regular expression that describes a Java backtrace line.
56 ;; For example:
57 ;; [1] ca.snpEffect.commandLine.SnpEff.run (SnpEff.java:7)
58 (setf (gethash "lang-backtrace" realgud:jdb-pat-hash)
59 (make-realgud-loc-pat
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]+\\))"
62 :file-group 1
63 :line-group 2))
64
65 ;; Regular expression that describes a "breakpoint set" line.
66 ;; For example:
67 ;; Set breakpoint TestMe:7
68 (setf (gethash "brkpt-set" realgud:jdb-pat-hash)
69 (make-realgud-loc-pat
70 :regexp "^Set breakpoint \\(.+\\):\\([0-9]+\\)"
71 :num 1
72 :line-group 2))
73
74 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
75 ;; For example:
76 ;; Removed: breakpoint TestMe:7
77 (setf (gethash "brkpt-del" realgud:jdb-pat-hash)
78 (make-realgud-loc-pat
79 :regexp "^Removed breakpoint \\(.+\\):\\([0-9]+\\)\n"
80 :line-group 1))
81
82 (defconst realgud:jdb-selected-frame-indicator "-->"
83 "String that describes which frame is selected in a debugger
84 backtrace listing.")
85
86 (defconst realgud:jdb-frame-file-regexp
87 "[ \t\n]+in file \\([^ \n]+\\)")
88
89 (defconst realgud:jdb-debugger-name "jdb" "Name of debugger")
90
91 ;; Top frame number
92 (setf (gethash "top-frame-num" realgud:jdb-pat-hash) 0)
93
94 ;; Regular expression that describes a debugger "selected" frame in in
95 ;; a frame-motion command.
96 ;; For example:
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)
99 (make-realgud-loc-pat
100 :regexp
101 (format "^%s #\\([0-9]+\\) .*%s"
102 realgud:jdb-selected-frame-indicator
103 realgud:jdb-frame-file-regexp)
104 :num 1))
105
106 ;; Regular expression that describes a jdb backtrace line.
107 ;; For example:
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]+\\)"
117 :file-group 1
118 :line-group 2))
119
120 (setf (gethash "font-lock-keywords" realgud:jdb-pat-hash)
121 '(
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
130 ("<\\(.+\\)>"
131 (1 font-lock-variable-name-face))
132 ;; "::Type", which occurs in class name of function and in parameter list.
133 ;; Parameter sequence
134 ("(\\(.+\\))"
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))
139 ;; File name.
140 ("[ \t]+in file \\([^ ]+*\\)"
141 (1 realgud-file-name-face))
142 ;; Line number.
143 ("[ \t]+at line \\([0-9]+\\)$"
144 (1 realgud-line-number-face))
145 ;; Function name.
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))
151 ))
152
153 ;; (setf (gethash "font-lock-keywords" realgud:jdb-pat-hash)
154 ;; '(
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
164 ;; ("<\\(.+\\)>"
165 ;; (1 font-lock-variable-name-face))
166 ;; ;; "::Type", which occurs in class name of function and in
167 ;; ;; parameter list. Parameter sequence
168 ;; ("(\\(.+\\))"
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))
174 ;; ;; File name.
175 ;; (realgud:jdb-frame-file-regexp (1 realgud-file-name-face))
176 ;; ;; Line number.
177 ;; (realgud:jdb-frame-line-regexp (1 realgud-line-number-face))
178 ;; ;; Function name.
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))
184 ;; ))
185
186 (setf (gethash realgud:jdb-debugger-name realgud-pat-hash) realgud:jdb-pat-hash)
187
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!'")
191
192 (setf (gethash realgud:jdb-debugger-name
193 realgud-command-hash) realgud:jdb-command-hash)
194
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")
202
203
204 (provide-me "realgud:jdb-")