Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
7.1 KiB

  1. ;; Copyright (C) 2015-2016, 2019 Free Software Foundation, Inc
  2. ;; Author: Rocky Bernstein <rocky@gnu.org>
  3. ;; This program is free software: you can redistribute it and/or
  4. ;; modify it under the terms of the GNU General Public License as
  5. ;; published by the Free Software Foundation, either version 3 of the
  6. ;; License, or (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful, but
  8. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. ;; General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see
  13. ;; <http://www.gnu.org/licenses/>.
  14. ;; Regular expressions for Go SSA debugger: gub
  15. (eval-when-compile (require 'cl-lib)) ;For setf.
  16. (require 'load-relative)
  17. (require-relative-list '("../../common/regexp"
  18. "../../common/loc"
  19. "../../common/init")
  20. "realgud-")
  21. (defvar realgud-pat-hash)
  22. (declare-function make-realgud-loc-pat 'realgud-regexp)
  23. (defvar realgud:gub-pat-hash (make-hash-table :test 'equal)
  24. "Hash key is the what kind of pattern we want to match:
  25. backtrace, prompt, etc. The values of a hash entry is a
  26. realgud-loc-pat struct")
  27. ;; Regular expression that describes a gub location generally shown
  28. ;; before a command prompt.
  29. ;; For example:
  30. ;; interp/testdata/square.go:16:2-17
  31. (setf (gethash "loc" realgud:gub-pat-hash)
  32. (make-realgud-loc-pat
  33. :regexp
  34. "\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):\\([0-9]+\\)"
  35. :file-group 1
  36. :line-group 2))
  37. ;; Regular expression that describes a Go backtrace line.
  38. ;; For example:
  39. ;; ssa-interp/interp/interp.go:202 (0x506c84)
  40. ;; visitInstr: *fr.get(instr.Addr).(*Value) = copyVal(fr.get(instr.Val))
  41. ;; sa-interp/interp/interp.go:604 (0x50b5b1)
  42. ;; runFrame: switch visitInstr(fr, instr) {
  43. (setf (gethash "lang-backtrace" realgud:gub-pat-hash)
  44. (make-realgud-loc-pat
  45. :regexp
  46. "\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\]*\\.go\\):\\([0-9]+\\)"
  47. :file-group 1
  48. :line-group 2))
  49. ;; Regular expression that describes a gub location generally shown
  50. ;; before a command prompt.
  51. ;; For example:
  52. ;; gub[1]:
  53. ;; gub[1@3]:
  54. (setf (gethash "prompt" realgud:gub-pat-hash)
  55. (make-realgud-loc-pat
  56. :regexp (format "^gub\\[%s\\(?:@%s\\)?\\]: "
  57. realgud:regexp-captured-num
  58. realgud:regexp-captured-num)
  59. :num 1
  60. ))
  61. ;; Regular expression that describes a "breakpoint set" line
  62. (setf (gethash "brkpt-set" realgud:gub-pat-hash)
  63. (make-realgud-loc-pat
  64. :regexp (format
  65. "^Breakpoint %s set\\(?:in function \\) in file \\([a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\) line %s, column %s"
  66. realgud:regexp-captured-num realgud:regexp-captured-num
  67. realgud:regexp-captured-num)
  68. :num 1
  69. :file-group 2
  70. :line-group 3
  71. :char-offset-group 4))
  72. ;; Regular expression that describes a debugger "delete" (breakpoint) response.
  73. ;; For example:
  74. ;; Deleted breakpoint 1.
  75. (setf (gethash "brkpt-del" realgud:gub-pat-hash)
  76. (make-realgud-loc-pat
  77. :regexp (format
  78. "^Deleted breakpoint %s\n"
  79. realgud:regexp-captured-num)
  80. :num 1))
  81. ;; Regular expression describes general location. In contrast to loc
  82. ;; which triggers automatically, we bind this to a key like C-c !s
  83. ;; For example:
  84. ;; interp/testdata/square.go:16:2-17
  85. ; ^^^^^^ spaces
  86. (setf (gethash "general-location" realgud:gub-pat-hash)
  87. (make-realgud-loc-pat
  88. :regexp
  89. (format
  90. "\\(?:^\\|\n\\)[ \t]*\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):%s" realgud:regexp-captured-num)
  91. :file-group 1
  92. :line-group 2))
  93. (defconst realgud:gub-selected-frame-arrow "=>"
  94. "String that describes which frame is selected in a debugger
  95. backtrace listing.")
  96. (defconst realgud:gub-frame-arrow (format "\\(%s\\| \\)"
  97. realgud:gub-selected-frame-arrow))
  98. (defconst realgud:gub-frame-num-regexp
  99. (format " #%s " realgud:regexp-captured-num))
  100. (defconst realgud:gub-frame-file-regexp
  101. (format " at \\(.*\\):%s" realgud:regexp-captured-num))
  102. ;; Regular expression that describes a debugger "backtrace" command line.
  103. ;; For example:
  104. ;; => #0 square(n)
  105. ;; #1 main()
  106. (setf (gethash "debugger-backtrace" realgud:gub-pat-hash)
  107. (make-realgud-loc-pat
  108. :regexp (concat "^"
  109. realgud:gub-frame-arrow
  110. realgud:gub-frame-num-regexp
  111. "\\(.*\\)"
  112. realgud:gub-frame-file-regexp
  113. )
  114. :num 2
  115. :file-group 4
  116. :line-group 5)
  117. )
  118. (setf (gethash "selected-frame-indicator" realgud:gub-pat-hash)
  119. realgud:gub-selected-frame-arrow)
  120. ;; Regular expression that describes a Go backtrace line
  121. ;; For example:
  122. ;; /usr/local/go/src/pkg/runtime/panic.c:482 (0x805c956)
  123. ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^^-----------
  124. (setf (gethash "lang-backtrace" realgud:gub-pat-hash)
  125. (make-realgud-loc-pat
  126. :regexp "^\\(/.+\\):\\([0-9]+\\) \\((0x[0-9a-f]+)\\)?$"
  127. :file-group 1
  128. :line-group 2))
  129. ;; Regular expression that describes a Go runtime panic
  130. ;; For example:
  131. ;; /tmp/github.com/rocky/ssa-interp/eval/selectorexpr.go:18 +0x9f
  132. ;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^------
  133. (setf (gethash "panic-backtrace" realgud:gub-pat-hash)
  134. (make-realgud-loc-pat
  135. :regexp (format "^[ \t]*\\(/.+\\):%s \\(+0x[0-9a-f]+\\)?$"
  136. realgud:regexp-captured-num)
  137. :file-group 1
  138. :line-group 2))
  139. ;; Regular expression for a termination message.
  140. (setf (gethash "termination" realgud:gub-pat-hash)
  141. "^gub: That's all, folks...\n")
  142. (setf (gethash "font-lock-keywords" realgud:gub-pat-hash)
  143. '(
  144. ;; File name and line number
  145. ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
  146. ;; ---^^^^^^^^^^^^^-^^^
  147. (" at \\(.*\\):\\([0-9]+\\)"
  148. (1 realgud-file-name-face)
  149. (2 realgud-line-number-face))
  150. ;; The frame number and first type name, if present.
  151. ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
  152. ;; ---^
  153. ("#\\([0-9]+\\) "
  154. (1 realgud-backtrace-number-face))
  155. ))
  156. (setf (gethash "gub" realgud-pat-hash) realgud:gub-pat-hash)
  157. ;; Prefix used in variable names (e.g. short-key-mode-map) for
  158. ;; this debugger
  159. (setf (gethash "tortoise" realgud:variable-basename-hash) "realgud:gub")
  160. (defvar realgud:gub-command-hash (make-hash-table :test 'equal)
  161. "Hash key is command name like 'quit' and the value is
  162. the gub command to use, like 'q'")
  163. (setf (gethash "backtrace" realgud:gub-command-hash) "backtrace")
  164. (setf (gethash "break" realgud:gub-command-hash) "break %l")
  165. (setf (gethash "continue" realgud:gub-command-hash) "continue")
  166. ;;(setf (gethash "eval" realgud:gub-command-hash) "x %s")
  167. (setf (gethash "quit" realgud:gub-command-hash) "quit")
  168. (setf (gethash "restart" realgud:gub-command-hash) "R")
  169. (setf (gethash "run" realgud:gub-command-hash) "R")
  170. (setf (gethash "step" realgud:gub-command-hash) "step")
  171. (setf (gethash "next" realgud:gub-command-hash) "next")
  172. (setf (gethash "until" realgud:gub-command-hash) "until %l")
  173. (setf (gethash "gub" realgud-command-hash) realgud:gub-command-hash)
  174. (provide-me "realgud:gub-")