1 ;;; Copyright (C) 2013-2014 Rocky Bernstein <rocky@gnu.org>
2 ;;; Regular expressions for Go SSA debugger: gub
4 (eval-when-compile (require 'cl))
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp"
12 (defvar realgud-pat-hash)
13 (declare-function make-realgud-loc-pat (realgud-loc))
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")
20 ;; Regular expression that describes a gub location generally shown
21 ;; before a command prompt.
23 ;; interp/testdata/square.go:16:2-17
24 (setf (gethash "loc" realgud:gub-pat-hash)
27 "\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):\\([0-9]+\\)"
31 ;; Regular expression that describes a Go backtrace line.
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)
40 "\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\]*\\.go\\):\\([0-9]+\\)"
45 ;; Regular expression that describes a gub location generally shown
46 ;; before a command prompt.
50 (setf (gethash "prompt" realgud:gub-pat-hash)
52 :regexp "^gub\\[\\([0-9]+\\)\\(?:@\\([0-9]+\\)\\)?\\]: "
56 ;; Regular expression that describes a "breakpoint set" line
57 (setf (gethash "brkpt-set" realgud:gub-pat-hash)
59 :regexp "^ Breakpoint \\([0-9]+\\) set\\(?:in function \\) at \\([a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):\\([0-9]+\\)"
64 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
66 ;; Deleted breakpoint 1.
67 (setf (gethash "brkpt-del" realgud:gub-pat-hash)
69 :regexp "^ Deleted breakpoint \\([0-9]+\\)\n"
72 ;; Regular expression describes general location. In contrast to loc
73 ;; which triggers automatically, we bind this to a key like C-c !s
75 ;; interp/testdata/square.go:16:2-17
77 (setf (gethash "general-location" realgud:gub-pat-hash)
80 "\\(?:^\\|\n\\)[ \t]*\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):\\([0-9]+\\)"
84 (defconst realgud:gub-selected-frame-arrow "=>"
85 "String that describes which frame is selected in a debugger
87 (defconst realgud:gub-frame-arrow (format "\\(%s\\| \\)"
88 realgud:gub-selected-frame-arrow))
89 (defconst realgud:gub-frame-num-regexp " #\\([0-9]+\\) ")
91 (defconst realgud:gub-frame-file-regexp " at \\(.*\\):\\([0-9]+\\)")
94 ;; Regular expression that describes a debugger "backtrace" command line.
98 (setf (gethash "debugger-backtrace" realgud:gub-pat-hash)
101 realgud:gub-frame-arrow
102 realgud:gub-frame-num-regexp
104 realgud:gub-frame-file-regexp
111 (setf (gethash "selected-frame-indicator" realgud:gub-pat-hash)
112 realgud:gub-selected-frame-arrow)
114 ;; Regular expression that describes a Go backtrace line
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]+)\\)?$"
124 ;; Regular expression that describes a Go runtime panic
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]+\\)?$"
134 ;; Regular expression for a termination message.
135 (setf (gethash "termination" realgud:gub-pat-hash)
136 "^gub: That's all, folks...\n")
138 (setf (gethash "font-lock-keywords" realgud:gub-pat-hash)
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))
147 ;; The frame number and first type name, if present.
148 ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
151 (1 realgud-backtrace-number-face))
154 (setf (gethash "gub" realgud-pat-hash) realgud:gub-pat-hash)
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'")
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)
173 (provide-me "realgud:gub-")