]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / realgud.el
1 ;;; realgud.el --- A modular front-end for interacting with external debuggers
2
3 ;; Author: Rocky Bernstein
4 ;; Version: 1.1
5 ;; Package-Requires: ((load-relative "1.0") (list-utils "0.4.2") (loc-changes "1.1") (test-simple "1.0"))
6 ;; URL: http://github.com/rocky/emacs-dbgr
7 ;; Compatibility: GNU Emacs 24.x
8
9 ;; Copyright (C) 2013-2015 Rocky Bernstein <rocky@gnu.org>
10
11 ;; This program is free software: you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation, either version 3 of the
14 ;; License, or (at your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program. If not, see
23 ;; <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; Once upon a time in an Emacs far far away and a programming-style
28 ;; deservedly banished, there was a monolithic Cathederal-like
29 ;; debugger front-end called gub. This interfaced with a number of
30 ;; debuggers, many now dead. Is there anyone still alive that
31 ;; remembers sdb from UNIX/32V circa 1980?
32 ;;
33 ;; This isn't that. Here we make use of more modern programming
34 ;; practices, more numerous and smaller files, unit tests, and better
35 ;; use of emacs primitives, e.g. buffer marks, buffer-local variables,
36 ;; structures, rings, hash tables. Although there is still much to be
37 ;; desired, this code is more scalable and suitable as a common base for
38 ;; an Emacs front-end to modern debuggers.
39 ;;
40 ;; Oh, and because global variables are largely banned, we can support
41 ;; several simultaneous debug sessions.
42 ;;
43 ;; See URL `https://github.com/rocky/emacs-dbgr/wiki/Features' for a list
44 ;; features.
45
46 ;;
47 ;; The debuggers we currently support are:
48
49 ;; NAME INVOCATION** WHAT
50 ; -----------------------------------
51 ;; bashdb bashdb bash
52 ;; Devel::Trepan trepan.pl Perl5
53 ;; gdb realgud:gdb gdb
54 ;; gub gub Go SSA debugger
55 ;; jdb realgud:jdb Java jdb debugger
56 ;; kshdb kshdb Korn Shell 93u+
57 ;; nodejs nodejs node.js javascript debugger
58 ;; pdb realgud:pdb stock C Python debugger
59 ;; perldb realgud:perldb stock Perl5 debugger
60 ;; pydb pydb slighly enhanced pdb for Python 2.x
61 ;; pydbgr pydbgr obsolete trepanning debugger for Python 2.x
62 ;; rb8-trepanning trepan8 MRI Ruby 1.8 and an unpatched YARV 1.9
63 ;; rbx-trepanning trepanx trepanning debugger for Rubinius Ruby
64 ;; remake remake GNU Make
65 ;; ruby-debug rdebug Ruby
66 ;; trepanning trepan trepanning debugger for a patched Ruby 1.9
67 ;; trepan2 trepan2 trepanning debugger for Python 2.x
68 ;; trepan3k trepan3k trepanning debugger for Python 3.x
69 ;; zshdb zshdb Zsh
70 ;;
71 ;;
72 ;; **gdb, jdb, perldb, pdb invocations require the realgud: preface to
73 ;; disambiguate it from older, preexisting emacs commands in `gud'. The other
74 ;; invocations also accept realgud: prefaces, e.g. realgud:bashdb or
75 ;; realgud:rdebug. Alas there are older obsolete (i.e. often written by me)
76 ;; Emacs packages out there for bashdb, kshdb, nodejs, pydb, rdebug, zshdb.
77
78 ;; If you don't see your favorite debugger above, see URL
79 ;; `https://github.com/rocky/emacs-dbgr/wiki/How-to-add-a-new-debugger/'
80 ;; for how you can add your own.
81
82 ;; The debugger is run out of a comint process buffer, or you can use
83 ;; a `realgud-track-mode' inside an existing shell.
84
85 ;; To install you will need a couple of other Emacs packages
86 ;; installed. If you install via melpa (`package-install') or
87 ;; `el-get', these will be pulled in automatically. See the
88 ;; installation instructions URL
89 ;; `https://github.com/rocky/emacs-dbgr/wiki/How-to-Install' for all
90 ;; the ways to to install and more details on installation.
91
92 ;;; Code:
93
94 (require 'load-relative)
95
96 (defgroup realgud nil
97 "The Grand Cathedral Debugger rewrite"
98 :group 'processes
99 :group 'tools
100 :version "24.2")
101
102 ;; FIXME: extend require-relative for "autoload".
103 (defun realgud:load-features()
104 (require-relative-list
105 '(
106 "./realgud/common/track-mode"
107 "./realgud/common/utils"
108 "./realgud/debugger/bashdb/bashdb"
109 "./realgud/debugger/gdb/gdb"
110 "./realgud/debugger/gub/gub"
111 "./realgud/debugger/jdb/jdb"
112 "./realgud/debugger/kshdb/kshdb"
113 "./realgud/debugger/nodejs/nodejs"
114 "./realgud/debugger/pdb/pdb"
115 "./realgud/debugger/perldb/perldb"
116 "./realgud/debugger/pydb/pydb"
117 "./realgud/debugger/pydbgr/pydbgr"
118 "./realgud/debugger/rdebug/rdebug"
119 "./realgud/debugger/remake/remake"
120 "./realgud/debugger/trepan/trepan"
121 "./realgud/debugger/trepan.pl/trepanpl"
122 "./realgud/debugger/trepan2/trepan2"
123 "./realgud/debugger/trepan3k/trepan3k"
124 "./realgud/debugger/trepanx/trepanx"
125 "./realgud/debugger/trepan8/trepan8"
126 "./realgud/debugger/zshdb/zshdb"
127 ) "realgud-")
128 )
129
130 (load-relative "./realgud/common/custom")
131
132 (defun realgud-feature-starts-with(feature prefix)
133 "realgud-strings-starts-with on stringified FEATURE and PREFIX."
134 (declare (indent 1))
135 (string-prefix-p (symbol-name feature) prefix)
136 )
137
138 (defun realgud:loaded-features()
139 "Return a list of loaded debugger features. These are the
140 features that start with 'realgud-' and also include standalone debugger features
141 like 'pydbgr'."
142 (let ((result nil))
143 (dolist (feature features result)
144 (setq feature-str (symbol-name feature))
145 (cond ((eq 't
146 (string-prefix-p feature-str "realgud-"))
147 (setq result (cons feature-str result)))
148 ((eq 't
149 (string-prefix-p feature-str "nodejs"))
150 (setq result (cons feature-str result)))
151 ((eq 't
152 (string-prefix-p feature-str "pydbgr"))
153 (setq result (cons feature-str result)))
154 ((eq 't
155 ;; No trailing '-' to get a plain "trepan".
156 (string-prefix-p feature-str "trepan"))
157 (setq result (cons feature-str result)))
158 ((eq 't
159 ;; No trailing '-' to get a plain "trepanx".
160 (string-prefix-p feature-str "trepanx"))
161 (setq result (cons feature-str result)))
162 ('t nil))
163 )
164 )
165 )
166
167 (defun realgud:unload-features()
168 "Remove all features loaded from this package. Used in
169 `realgud:reload-features'. See that."
170 (interactive "")
171 (let ((result (realgud:loaded-features)))
172 (dolist (feature result result)
173 (unless (symbolp feature) (setq feature (make-symbol feature)))
174 (if (featurep feature)
175 (unload-feature feature) 't))
176 ))
177
178 (defun realgud:reload-features()
179 "Reload all features loaded from this package. Useful if have
180 changed some code or want to reload another version, say a newer
181 development version and you already have this package loaded."
182 (interactive "")
183 (realgud:unload-features)
184 (realgud:load-features)
185 )
186
187 ;; Load everything.
188 (realgud:load-features)
189
190 (provide-me)
191
192 ;;; realgud.el ends here