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.

147 lines
5.7 KiB

  1. ;; Copyright (C) 2010-2012, 2014-2017, 2019 Free Software Foundation, Inc
  2. ;; Author: Rocky Bernstein <rocky@gnu.org>
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU 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 <http://www.gnu.org/licenses/>.
  13. ;; trepan2: Python 2.5 - 2.7; for 3.0+ see trepan3k
  14. (eval-when-compile (require 'cl-lib)) ;For setf.
  15. (require 'load-relative)
  16. (require-relative-list '("../../common/regexp"
  17. "../../common/loc"
  18. "../../common/init")
  19. "realgud-")
  20. (require-relative-list '("../../lang/python") "realgud-lang-")
  21. (defvar realgud-pat-hash)
  22. (declare-function make-realgud-loc-pat 'realgud-regexp)
  23. (defvar realgud:trepan2-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. (declare-function make-realgud-loc 'realgud-loc)
  28. (setf (gethash "loc-callback-fn" realgud:trepan2-pat-hash) 'realgud:trepan2-loc-fn-callback)
  29. ;; realgud-loc-pat that describes a trepan2 location generally shown
  30. ;; before a command prompt.
  31. ;;
  32. ;; For example:
  33. ;; (/usr/bin/zonetab2pot.py:15 @3): <module>
  34. ;; (/usr/bin/zonetab2pot.py:15 remapped <string>): <module>
  35. ;; or MS Windows:
  36. ;; (c:\\mydirectory\\gcd.py:10): <module>
  37. (setf (gethash "loc" realgud:trepan2-pat-hash)
  38. realgud:python-trepan-loc-pat)
  39. ;; An initial list of regexps that don't generally have files
  40. ;; associated with them and therefore we should not try to find file
  41. ;; associations for them. This list is used to seed a field of the
  42. ;; same name in the cmd-info structure inside a command buffer. A user
  43. ;; may add additional files to the command-buffer's re-ignore-list.
  44. (setf (gethash "ignore-re-file-list" realgud:trepan2-pat-hash)
  45. (list realgud-python-ignore-file-re))
  46. ;; realgud-loc-pat that describes a trepan2 prompt.
  47. ;; Note: the prompt in nested debugging
  48. ;; For example:
  49. ;; (trepan2)
  50. ;; ((trepan2))
  51. (setf (gethash "prompt" realgud:trepan2-pat-hash)
  52. (make-realgud-loc-pat
  53. :regexp "^(+trepan2)+ "
  54. ))
  55. ;; realgud-loc-pat that describes a trepan2 backtrace line.
  56. ;; For example:
  57. ;; ->0 get_distribution(dist='trepan==0.3.9')
  58. ;; called from file '/python2.7/dist-packages/pkg_res.py' at line 341
  59. ;; ##1 load_entry_point(dist='tr=0.3.9', group='console_scripts', name='tr')
  60. ;; called from file '/python2.7/dist-packages/pkg_res.py' at line 351
  61. ;; ##2 <module> exec()
  62. (setf (gethash "debugger-backtrace" realgud:trepan2-pat-hash)
  63. realgud:python-trepan-backtrace-pat)
  64. ;; realgud-loc-pat that describes a line a Python "info break" line.
  65. ;; For example:
  66. ;; 1 breakpoint keep y at /usr/local/bin/trepan2k:7
  67. (setf (gethash "debugger-breakpoint" realgud:trepan2-pat-hash)
  68. realgud-python-breakpoint-pat)
  69. ;; realgud-loc-pat that describes a Python backtrace line.
  70. (setf (gethash "lang-backtrace" realgud:trepan2-pat-hash)
  71. realgud-python-backtrace-loc-pat)
  72. ;; realgud-loc-pat expression that describes location in a pytest error
  73. (setf (gethash "pytest-error" realgud:trepan2-pat-hash)
  74. realgud-pytest-error-loc-pat)
  75. ;; realgud-loc-pat that describes location in a flake8 message
  76. (setf (gethash "flake8-msg" realgud:trepan2-pat-hash)
  77. realgud-flake8-msg-loc-pat)
  78. ;; realgud-loc-pat that describes a "breakpoint set" line
  79. (setf (gethash "brkpt-set" realgud:trepan2-pat-hash)
  80. realgud:python-trepan-brkpt-set-pat)
  81. ;; realgud-loc-pat that describes a "delete breakpoint" line
  82. (setf (gethash "brkpt-del" realgud:trepan2-pat-hash)
  83. realgud:python-trepan-brkpt-del-pat)
  84. ;; realgud-loc-pat that describes a debugger "disable" (breakpoint) response.
  85. ;; For example:
  86. ;; Breakpoint 4 disabled.
  87. (setf (gethash "brkpt-disable" realgud:trepan2-pat-hash)
  88. realgud:python-trepan-brkpt-disable-pat)
  89. ;; realgud-loc-pat that describes a debugger "enable" (breakpoint) response.
  90. ;; For example:
  91. ;; Breakpoint 4 enabled.
  92. (setf (gethash "brkpt-enable" realgud:trepan2-pat-hash)
  93. realgud:python-trepan-brkpt-disable-pat)
  94. ;; realgud-loc-pat for a termination message.
  95. (setf (gethash "termination" realgud:trepan2-pat-hash)
  96. "^trepan2: That's all, folks...\n")
  97. (setf (gethash "font-lock-keywords" realgud:trepan2-pat-hash)
  98. realgud:python-debugger-font-lock-keywords)
  99. (setf (gethash "font-lock-breakpoint-keywords" realgud:trepan2-pat-hash)
  100. realgud:python-debugger-font-lock-breakpoint-keywords)
  101. (setf (gethash "trepan2" realgud-pat-hash) realgud:trepan2-pat-hash)
  102. (defvar realgud:trepan2-command-hash (make-hash-table :test 'equal)
  103. "Hash key is command name like 'shell' and the value is
  104. the trepan2 command to use, like 'python'")
  105. (setf (gethash "eval" realgud:trepan2-command-hash) "eval %s")
  106. (setf (gethash "pprint" realgud:trepan2-command-hash) "pp %s")
  107. (setf (gethash "info-breakpoints" realgud:trepan2-command-hash) "info break")
  108. (setf (gethash "shell" realgud:trepan2-command-hash) "python")
  109. (setf (gethash "until" realgud:trepan2-command-hash) "continue %l")
  110. ;; If your version of trepan2 doesn't support "quit!",
  111. ;; get a more recent version of trepan2
  112. (setf (gethash "quit" realgud:trepan2-command-hash) "quit!")
  113. (setf (gethash "trepan2" realgud-command-hash) realgud:trepan2-command-hash)
  114. (provide-me "realgud:trepan2-")