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.

209 lines
7.8 KiB

  1. ;;; realgud.el --- A modular front-end for interacting with external debuggers -*- lexical-binding: t -*-
  2. ;; Author: Rocky Bernstein <rocky@gnu.org>
  3. ;; Version: 1.5.1
  4. ;; Package-Type: multi
  5. ;; Package-Requires: ((load-relative "1.3.1") (loc-changes "1.2") (test-simple "1.3.0") (emacs "25"))
  6. ;; URL: http://github.com/realgud/realgud/
  7. ;; Keywords: debugger, gdb, python, perl, go, bash, zsh, bashdb, zshdb, remake, trepan, perldb, pdb
  8. ;; Copyright (C) 2015-2019 Free Software Foundation, Inc
  9. ;; This program is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation, either version 3 of the License, or
  12. ;; (at your option) any later version.
  13. ;; This program is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. ;;; Commentary:
  20. ;; A modular, extensible GNU Emacs front-end for interacting with
  21. ;; external debuggers.
  22. ;;
  23. ;; Quick start: https://github.com/realgud/realgud/
  24. ;;
  25. ;; See URL `https://github.com/realgud/realgud/wiki/Features' for features, and
  26. ;; URL `https://github.com/realgud/realgud/wiki/Debuggers-Supported' for
  27. ;; debuggers we can handle.
  28. ;;
  29. ;; Once upon a time in an Emacs far far away and a programming-style
  30. ;; deservedly banished, there was a monolithic Cathederal-like
  31. ;; debugger front-end called gud. This interfaced with a number of
  32. ;; debuggers, many now dead.[1] Is there anyone still alive that
  33. ;; remembers sdb from UNIX/32V circa 1980?
  34. ;;
  35. ;; This isn't that. Here we make use of more modern programming
  36. ;; practices, more numerous and smaller files, unit tests, and better
  37. ;; use of Emacs primitives, e.g. buffer marks, buffer-local variables,
  38. ;; structures, rings, hash tables. Although there is still much to be
  39. ;; desired, this code is more scalable and suitable as a common base for
  40. ;; an Emacs front-end to modern debuggers.
  41. ;;
  42. ;; Oh, and because global variables are largely banned, we can support
  43. ;; several simultaneous debug sessions.
  44. ;; RealGUD supports many external debuggers. See URL
  45. ;; `https://github.com/realgud/realgud/wiki/Debuggers-Supported' for a
  46. ;; list. However, if you don't see your favorite debugger, see URL
  47. ;; `https://github.com/realgud/realgud/wiki/How-to-add-a-new-debugger/'
  48. ;; for how you can add your own.
  49. ;; The debugger is run out of a comint process buffer, or you can use
  50. ;; a `realgud-track-mode' inside an existing comint shell, or eshell
  51. ;; buffer.
  52. ;; To install you will need a couple of other Emacs packages
  53. ;; installed. If you install via melpa (`package-install') or
  54. ;; `el-get', these will be pulled in automatically. See the
  55. ;; installation instructions URL
  56. ;; `https://github.com/realgud/realgud/wiki/How-to-Install' for all
  57. ;; the ways to to install and more details on installation.
  58. ;; [1] Four or more years in, as of 2018 realgud sports a number of
  59. ;; old debuggers too. However we *mark* them as such, and move them
  60. ;; out of the main code base. See for example:
  61. ;; https://github.com/realgud/realgud-old-debuggers. So that's
  62. ;; another difference: this code better *maintained*.
  63. ;;; Code:
  64. ;; Press C-x C-e at the end of the next line configure the program in
  65. ;; for building via "make" to get set up.
  66. ;; (compile (format "EMACSLOADPATH=:%s:%s:%s ./autogen.sh" (file-name-directory (locate-library "test-simple.elc")) (file-name-directory (locate-library "load-relative.elc")) (file-name-directory (locate-library "loc-changes.elc"))))
  67. (require 'load-relative)
  68. (defgroup realgud nil
  69. "The Grand Cathedral Debugger rewrite"
  70. :group 'processes
  71. :group 'tools
  72. :version "25.1")
  73. ;; FIXME: extend require-relative for "autoload".
  74. (defun realgud:load-features()
  75. (progn
  76. (require-relative-list
  77. '(
  78. "./realgud/common/attach"
  79. "./realgud/common/track-mode"
  80. "./realgud/common/backtrack-mode"
  81. "./realgud/common/breakpoint-mode"
  82. "./realgud/common/utils"
  83. "./realgud/debugger/bashdb/bashdb"
  84. "./realgud/debugger/gdb/gdb"
  85. "./realgud/debugger/gub/gub"
  86. "./realgud/debugger/kshdb/kshdb"
  87. "./realgud/debugger/pdb/pdb"
  88. "./realgud/debugger/perldb/perldb"
  89. "./realgud/debugger/rdebug/rdebug"
  90. "./realgud/debugger/remake/remake"
  91. "./realgud/debugger/trepan/trepan"
  92. "./realgud/debugger/trepanjs/trepanjs"
  93. "./realgud/debugger/trepan.pl/trepanpl"
  94. "./realgud/debugger/trepan2/trepan2"
  95. "./realgud/debugger/trepan3k/trepan3k"
  96. "./realgud/debugger/zshdb/zshdb"
  97. ) "realgud-")
  98. (require-relative-list
  99. '(
  100. "./realgud/lang/java"
  101. "./realgud/lang/js"
  102. "./realgud/lang/perl"
  103. "./realgud/lang/posix-shell"
  104. "./realgud/lang/python"
  105. "./realgud/lang/ruby"
  106. ) "realgud-lang-")
  107. (realgud:loaded-features)
  108. )
  109. )
  110. (load-relative "./realgud/common/custom")
  111. (load-relative "./realgud/lang/java")
  112. (defun realgud-feature-starts-with(feature prefix)
  113. "realgud-strings-starts-with on stringified FEATURE and PREFIX."
  114. (declare (indent 1))
  115. (string-prefix-p (symbol-name feature) prefix)
  116. )
  117. (defun realgud:loaded-features()
  118. "Return a list of loaded debugger features. These are the features
  119. that start with 'realgud-' and 'realgud:'"
  120. (delq nil
  121. (mapcar (lambda (x) (and (string-match-p "^\\(realgud:\\|realgud-\\)" (symbol-name x)) x))
  122. features)))
  123. (defun realgud:unload-features()
  124. "Remove all features loaded from this package. Used in
  125. `realgud:reload-features'. See that."
  126. (let ((removal-set (realgud:loaded-features)))
  127. (dolist (feature removal-set)
  128. (unload-feature feature t))
  129. removal-set)) ; return removed set
  130. (defun realgud:reload-features()
  131. "Reload all features loaded from this package. Useful if have
  132. changed some code or want to reload another version, say a newer
  133. development version and you already have this package loaded."
  134. (interactive "")
  135. (realgud:unload-features)
  136. (realgud:load-features)
  137. )
  138. ;; Load everything.
  139. (realgud:load-features)
  140. ;;; Autoloads-related code
  141. ;; This section is needed because package.el doesn't recurse into subdirectories
  142. ;; when looking for autoload-able forms. As a workaround, we statically
  143. ;; generate our own autoloads, and force Emacs to read them by adding an extra
  144. ;; autoloded form.
  145. ;;;###autoload
  146. (defconst realgud--recursive-autoloads-file-name "realgud-recursive-autoloads.el"
  147. "Where to store autoloads for subdirectory contents.")
  148. ;;;###autoload
  149. (defconst realgud--recursive-autoloads-base-directory
  150. (file-name-directory
  151. (if load-in-progress load-file-name
  152. buffer-file-name)))
  153. ;;;###autoload
  154. (with-demoted-errors "Error in RealGUD's autoloads: %s"
  155. (load (expand-file-name realgud--recursive-autoloads-file-name
  156. realgud--recursive-autoloads-base-directory)
  157. t t))
  158. (defun realgud--rebuild-recursive-autoloads ()
  159. "Update RealGUD's recursive autoloads.
  160. This is needed because the package.el infrastructure doesn't
  161. process autoloads in subdirectories; instead we create an
  162. additional autoloads file of our own, and we load it from an
  163. autoloaded form. Maintainers should run this after adding
  164. autoloaded functions, and commit the resulting changes."
  165. (interactive)
  166. (let ((generated-autoload-file
  167. (expand-file-name realgud--recursive-autoloads-file-name
  168. realgud--recursive-autoloads-base-directory)))
  169. (when (file-exists-p generated-autoload-file)
  170. (delete-file generated-autoload-file))
  171. (dolist (name (with-no-warnings
  172. (directory-files-recursively
  173. realgud--recursive-autoloads-base-directory "" t)))
  174. (when (file-directory-p name)
  175. (update-directory-autoloads name)))))
  176. (provide-me)
  177. ;;; realgud.el ends here