]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/gub/init.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / gub / init.el
1 ;;; Copyright (C) 2013-2014 Rocky Bernstein <rocky@gnu.org>
2 ;;; Regular expressions for Go SSA debugger: gub
3
4 (eval-when-compile (require 'cl))
5
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp"
8 "../../common/loc"
9 "../../common/init")
10 "realgud-")
11
12 (defvar realgud-pat-hash)
13 (declare-function make-realgud-loc-pat (realgud-loc))
14
15 (defvar realgud:gub-pat-hash (make-hash-table :test 'equal)
16 "Hash key is the what kind of pattern we want to match:
17 backtrace, prompt, etc. The values of a hash entry is a
18 realgud-loc-pat struct")
19
20 ;; Regular expression that describes a gub location generally shown
21 ;; before a command prompt.
22 ;; For example:
23 ;; interp/testdata/square.go:16:2-17
24 (setf (gethash "loc" realgud:gub-pat-hash)
25 (make-realgud-loc-pat
26 :regexp
27 "\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):\\([0-9]+\\)"
28 :file-group 1
29 :line-group 2))
30
31 ;; Regular expression that describes a Go backtrace line.
32 ;; For example:
33 ;; ssa-interp/interp/interp.go:202 (0x506c84)
34 ;; visitInstr: *fr.get(instr.Addr).(*Value) = copyVal(fr.get(instr.Val))
35 ;; sa-interp/interp/interp.go:604 (0x50b5b1)
36 ;; runFrame: switch visitInstr(fr, instr) {
37 (setf (gethash "lang-backtrace" realgud:gub-pat-hash)
38 (make-realgud-loc-pat
39 :regexp
40 "\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\]*\\.go\\):\\([0-9]+\\)"
41 :file-group 1
42 :line-group 2))
43
44
45 ;; Regular expression that describes a gub location generally shown
46 ;; before a command prompt.
47 ;; For example:
48 ;; gub[1]:
49 ;; gub[1@3]:
50 (setf (gethash "prompt" realgud:gub-pat-hash)
51 (make-realgud-loc-pat
52 :regexp "^gub\\[\\([0-9]+\\)\\(?:@\\([0-9]+\\)\\)?\\]: "
53 :num 1
54 ))
55
56 ;; Regular expression that describes a "breakpoint set" line
57 (setf (gethash "brkpt-set" realgud:gub-pat-hash)
58 (make-realgud-loc-pat
59 :regexp "^ Breakpoint \\([0-9]+\\) set\\(?:in function \\) at \\([a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):\\([0-9]+\\)"
60 :num 1
61 :file-group 2
62 :line-group 3))
63
64 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
65 ;; For example:
66 ;; Deleted breakpoint 1.
67 (setf (gethash "brkpt-del" realgud:gub-pat-hash)
68 (make-realgud-loc-pat
69 :regexp "^ Deleted breakpoint \\([0-9]+\\)\n"
70 :num 1))
71
72 ;; Regular expression describes general location. In contrast to loc
73 ;; which triggers automatically, we bind this to a key like C-c !s
74 ;; For example:
75 ;; interp/testdata/square.go:16:2-17
76 ; ^^^^^^ spaces
77 (setf (gethash "general-location" realgud:gub-pat-hash)
78 (make-realgud-loc-pat
79 :regexp
80 "\\(?:^\\|\n\\)[ \t]*\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):\\([0-9]+\\)"
81 :file-group 1
82 :line-group 2))
83
84 (defconst realgud:gub-selected-frame-arrow "=>"
85 "String that describes which frame is selected in a debugger
86 backtrace listing.")
87 (defconst realgud:gub-frame-arrow (format "\\(%s\\| \\)"
88 realgud:gub-selected-frame-arrow))
89 (defconst realgud:gub-frame-num-regexp " #\\([0-9]+\\) ")
90
91 (defconst realgud:gub-frame-file-regexp " at \\(.*\\):\\([0-9]+\\)")
92
93
94 ;; Regular expression that describes a debugger "backtrace" command line.
95 ;; For example:
96 ;; => #0 square(n)
97 ;; #1 main()
98 (setf (gethash "debugger-backtrace" realgud:gub-pat-hash)
99 (make-realgud-loc-pat
100 :regexp (concat "^"
101 realgud:gub-frame-arrow
102 realgud:gub-frame-num-regexp
103 "\\(.*\\)"
104 realgud:gub-frame-file-regexp
105 )
106 :num 2
107 :file-group 4
108 :line-group 5)
109 )
110
111 (setf (gethash "selected-frame-indicator" realgud:gub-pat-hash)
112 realgud:gub-selected-frame-arrow)
113
114 ;; Regular expression that describes a Go backtrace line
115 ;; For example:
116 ;; /usr/local/go/src/pkg/runtime/panic.c:482 (0x805c956)
117 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^^-----------
118 (setf (gethash "lang-backtrace" realgud:gub-pat-hash)
119 (make-realgud-loc-pat
120 :regexp "^\\(/.+\\):\\([0-9]+\\) \\((0x[0-9a-f]+)\\)?$"
121 :file-group 1
122 :line-group 2))
123
124 ;; Regular expression that describes a Go runtime panic
125 ;; For example:
126 ;; /tmp/github.com/rocky/ssa-interp/eval/selectorexpr.go:18 +0x9f
127 ;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^------
128 (setf (gethash "panic-backtrace" realgud:gub-pat-hash)
129 (make-realgud-loc-pat
130 :regexp "^[ \t]*\\(/.+\\):\\([0-9]+\\) \\(+0x[0-9a-f]+\\)?$"
131 :file-group 1
132 :line-group 2))
133
134 ;; Regular expression for a termination message.
135 (setf (gethash "termination" realgud:gub-pat-hash)
136 "^gub: That's all, folks...\n")
137
138 (setf (gethash "font-lock-keywords" realgud:gub-pat-hash)
139 '(
140 ;; File name and line number
141 ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
142 ;; ---^^^^^^^^^^^^^-^^^
143 (" at \\(.*\\):\\([0-9]+\\)"
144 (1 realgud-file-name-face)
145 (2 realgud-line-number-face))
146
147 ;; The frame number and first type name, if present.
148 ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
149 ;; ---^
150 ("#\\([0-9]+\\) "
151 (1 realgud-backtrace-number-face))
152 ))
153
154 (setf (gethash "gub" realgud-pat-hash) realgud:gub-pat-hash)
155
156 (defvar realgud:gub-command-hash (make-hash-table :test 'equal)
157 "Hash key is command name like 'quit' and the value is
158 the gub command to use, like 'q'")
159
160 (setf (gethash "backtrace" realgud:gub-command-hash) "backtrace")
161 (setf (gethash "break" realgud:gub-command-hash) "break %l")
162 (setf (gethash "continue" realgud:gub-command-hash) "continue")
163 ;;(setf (gethash "eval" realgud:gub-command-hash) "x %s")
164 (setf (gethash "quit" realgud:gub-command-hash) "quit")
165 (setf (gethash "restart" realgud:gub-command-hash) "R")
166 (setf (gethash "run" realgud:gub-command-hash) "R")
167 (setf (gethash "step" realgud:gub-command-hash) "step")
168 (setf (gethash "next" realgud:gub-command-hash) "next")
169 (setf (gethash "until" realgud:gub-command-hash) "until %l")
170 (setf (gethash "gub" realgud-command-hash) realgud:gub-command-hash)
171
172
173 (provide-me "realgud:gub-")