[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] realgud 59b0b26: Try realgud
From: |
Rocky Bernstein |
Subject: |
[elpa] realgud 59b0b26: Try realgud |
Date: |
Sun, 06 Mar 2016 11:05:00 +0000 |
branch: realgud
commit 59b0b269cbffdf3f01367b5c3aa00496453548a7
Author: rocky <address@hidden>
Commit: rocky <address@hidden>
Try realgud
realgud is a more modern and modular gud replacement
---
packages/realgud/.gitignore | 24 +
packages/realgud/AUTHORS | 1 +
packages/realgud/COPYING | 674 ++++++++++++++++++
packages/realgud/Cask | 4 +
packages/realgud/INSTALL | 250 +++++++
packages/realgud/Makefile.am | 47 ++
packages/realgud/README.md | 23 +
packages/realgud/THANKS | 11 +
packages/realgud/autogen.sh | 7 +
packages/realgud/common.mk | 10 +
packages/realgud/compute-lispdir.sh | 46 ++
packages/realgud/configure.ac | 87 +++
packages/realgud/el-get-install.el | 104 +++
packages/realgud/elisp-comp | 93 +++
packages/realgud/realgud.el | 204 ++++++
packages/realgud/realgud/Makefile.am | 1 +
packages/realgud/realgud/common/Makefile.am | 4 +
packages/realgud/realgud/common/attach.el | 69 ++
packages/realgud/realgud/common/backtrace-mode.el | 118 ++++
packages/realgud/realgud/common/backtrack-mode.el | 116 ++++
packages/realgud/realgud/common/bp-image-data.el | 357 ++++++++++
packages/realgud/realgud/common/bp.el | 180 +++++
packages/realgud/realgud/common/buffer/Makefile.am | 3 +
.../realgud/realgud/common/buffer/backtrace.el | 480 +++++++++++++
packages/realgud/realgud/common/buffer/command.el | 391 +++++++++++
packages/realgud/realgud/common/buffer/helper.el | 168 +++++
packages/realgud/realgud/common/buffer/info.el | 50 ++
packages/realgud/realgud/common/buffer/source.el | 175 +++++
packages/realgud/realgud/common/cmds.el | 282 ++++++++
packages/realgud/realgud/common/core.el | 309 +++++++++
packages/realgud/realgud/common/custom.el | 15 +
packages/realgud/realgud/common/eval.el | 101 +++
packages/realgud/realgud/common/file.el | 129 ++++
packages/realgud/realgud/common/follow.el | 37 +
packages/realgud/realgud/common/fringe.el | 223 ++++++
packages/realgud/realgud/common/helper.el | 89 +++
packages/realgud/realgud/common/init.el | 32 +
packages/realgud/realgud/common/key.el | 143 ++++
packages/realgud/realgud/common/lang.el | 98 +++
packages/realgud/realgud/common/loc.el | 185 +++++
packages/realgud/realgud/common/lochist.el | 132 ++++
packages/realgud/realgud/common/menu.el | 170 +++++
packages/realgud/realgud/common/regexp.el | 63 ++
packages/realgud/realgud/common/reset.el | 45 ++
packages/realgud/realgud/common/run.el | 190 +++++
packages/realgud/realgud/common/send.el | 257 +++++++
packages/realgud/realgud/common/shortkey.el | 221 ++++++
packages/realgud/realgud/common/track-mode.el | 240 +++++++
packages/realgud/realgud/common/track.el | 729 ++++++++++++++++++++
packages/realgud/realgud/common/utils.el | 33 +
packages/realgud/realgud/common/window.el | 167 +++++
packages/realgud/realgud/debugger/Makefile.am | 8 +
.../realgud/realgud/debugger/bashdb/Makefile.am | 1 +
packages/realgud/realgud/debugger/bashdb/bashdb.el | 82 +++
packages/realgud/realgud/debugger/bashdb/core.el | 198 ++++++
packages/realgud/realgud/debugger/bashdb/init.el | 92 +++
.../realgud/realgud/debugger/bashdb/track-mode.el | 76 ++
packages/realgud/realgud/debugger/common.mk | 3 +
packages/realgud/realgud/debugger/gdb/Makefile.am | 1 +
packages/realgud/realgud/debugger/gdb/core.el | 219 ++++++
packages/realgud/realgud/debugger/gdb/gdb.el | 142 ++++
packages/realgud/realgud/debugger/gdb/init.el | 155 +++++
.../realgud/realgud/debugger/gdb/track-mode.el | 75 ++
packages/realgud/realgud/debugger/gub/Makefile.am | 1 +
packages/realgud/realgud/debugger/gub/core.el | 175 +++++
packages/realgud/realgud/debugger/gub/gub.el | 86 +++
packages/realgud/realgud/debugger/gub/init.el | 206 ++++++
.../realgud/realgud/debugger/gub/track-mode.el | 78 +++
packages/realgud/realgud/debugger/ipdb/Makefile.am | 1 +
packages/realgud/realgud/debugger/ipdb/core.el | 269 +++++++
packages/realgud/realgud/debugger/ipdb/init.el | 120 ++++
packages/realgud/realgud/debugger/ipdb/ipdb.el | 118 ++++
.../realgud/realgud/debugger/ipdb/track-mode.el | 78 +++
packages/realgud/realgud/debugger/jdb/Makefile.am | 1 +
packages/realgud/realgud/debugger/jdb/README | 2 +
.../realgud/realgud/debugger/jdb/backtrack-mode.el | 79 +++
packages/realgud/realgud/debugger/jdb/core.el | 186 +++++
packages/realgud/realgud/debugger/jdb/file.el | 228 ++++++
packages/realgud/realgud/debugger/jdb/init.el | 217 ++++++
packages/realgud/realgud/debugger/jdb/jdb.el | 97 +++
.../realgud/realgud/debugger/jdb/track-mode.el | 82 +++
.../realgud/realgud/debugger/kshdb/Makefile.am | 1 +
packages/realgud/realgud/debugger/kshdb/core.el | 169 +++++
packages/realgud/realgud/debugger/kshdb/init.el | 114 +++
packages/realgud/realgud/debugger/kshdb/kshdb.el | 62 ++
.../realgud/realgud/debugger/kshdb/track-mode.el | 73 ++
.../realgud/realgud/debugger/nodejs/Makefile.am | 1 +
packages/realgud/realgud/debugger/nodejs/core.el | 168 +++++
packages/realgud/realgud/debugger/nodejs/init.el | 164 +++++
packages/realgud/realgud/debugger/nodejs/nodejs.el | 92 +++
.../realgud/realgud/debugger/nodejs/track-mode.el | 98 +++
packages/realgud/realgud/debugger/pdb/Makefile.am | 1 +
packages/realgud/realgud/debugger/pdb/core.el | 203 ++++++
packages/realgud/realgud/debugger/pdb/init.el | 119 ++++
packages/realgud/realgud/debugger/pdb/pdb.el | 108 +++
.../realgud/realgud/debugger/pdb/track-mode.el | 74 ++
.../realgud/realgud/debugger/perldb/Makefile.am | 1 +
packages/realgud/realgud/debugger/perldb/core.el | 145 ++++
packages/realgud/realgud/debugger/perldb/init.el | 122 ++++
packages/realgud/realgud/debugger/perldb/perldb.el | 63 ++
.../realgud/realgud/debugger/perldb/track-mode.el | 87 +++
.../realgud/realgud/debugger/rdebug/Makefile.am | 1 +
packages/realgud/realgud/debugger/rdebug/core.el | 165 +++++
packages/realgud/realgud/debugger/rdebug/init.el | 135 ++++
packages/realgud/realgud/debugger/rdebug/rdebug.el | 115 +++
.../realgud/realgud/debugger/rdebug/track-mode.el | 63 ++
.../realgud/realgud/debugger/remake/Makefile.am | 1 +
packages/realgud/realgud/debugger/remake/core.el | 253 +++++++
packages/realgud/realgud/debugger/remake/init.el | 135 ++++
packages/realgud/realgud/debugger/remake/remake.el | 89 +++
.../realgud/realgud/debugger/remake/track-mode.el | 63 ++
.../realgud/realgud/debugger/trepan.pl/Makefile.am | 1 +
.../realgud/debugger/trepan.pl/backtrack-mode.el | 67 ++
.../realgud/realgud/debugger/trepan.pl/core.el | 176 +++++
.../realgud/realgud/debugger/trepan.pl/init.el | 259 +++++++
.../realgud/debugger/trepan.pl/track-mode.el | 74 ++
.../realgud/realgud/debugger/trepan.pl/trepanpl.el | 65 ++
.../realgud/realgud/debugger/trepan/Makefile.am | 1 +
.../realgud/debugger/trepan/backtrack-mode.el | 81 +++
packages/realgud/realgud/debugger/trepan/core.el | 236 +++++++
packages/realgud/realgud/debugger/trepan/init.el | 213 ++++++
.../realgud/realgud/debugger/trepan/track-mode.el | 82 +++
packages/realgud/realgud/debugger/trepan/trepan.el | 58 ++
.../realgud/realgud/debugger/trepan2/Makefile.am | 1 +
packages/realgud/realgud/debugger/trepan2/core.el | 227 ++++++
packages/realgud/realgud/debugger/trepan2/init.el | 90 +++
.../realgud/realgud/debugger/trepan2/track-mode.el | 63 ++
.../realgud/realgud/debugger/trepan2/trepan2.el | 66 ++
.../realgud/realgud/debugger/trepan3k/Makefile.am | 1 +
packages/realgud/realgud/debugger/trepan3k/core.el | 173 +++++
packages/realgud/realgud/debugger/trepan3k/init.el | 88 +++
.../realgud/debugger/trepan3k/track-mode.el | 78 +++
.../realgud/realgud/debugger/trepan3k/trepan3k.el | 66 ++
.../realgud/realgud/debugger/trepanjs/Makefile.am | 1 +
.../realgud/debugger/trepanjs/backtrack-mode.el | 81 +++
packages/realgud/realgud/debugger/trepanjs/core.el | 169 +++++
packages/realgud/realgud/debugger/trepanjs/init.el | 146 ++++
.../realgud/debugger/trepanjs/track-mode.el | 88 +++
.../realgud/realgud/debugger/trepanjs/trepanjs.el | 84 +++
.../realgud/realgud/debugger/zshdb/Makefile.am | 1 +
packages/realgud/realgud/debugger/zshdb/core.el | 176 +++++
packages/realgud/realgud/debugger/zshdb/init.el | 90 +++
.../realgud/realgud/debugger/zshdb/track-mode.el | 63 ++
packages/realgud/realgud/debugger/zshdb/zshdb.el | 72 ++
packages/realgud/realgud/lang/Makefile.am | 5 +
packages/realgud/realgud/lang/js.el | 54 ++
packages/realgud/realgud/lang/perl.el | 54 ++
packages/realgud/realgud/lang/posix-shell.el | 134 ++++
packages/realgud/realgud/lang/python.el | 144 ++++
packages/realgud/realgud/lang/ruby.el | 125 ++++
packages/realgud/test/.gitignore | 5 +
packages/realgud/test/HelloWorld.java | 6 +
packages/realgud/test/Makefile.am | 69 ++
packages/realgud/test/bt-helper.el | 48 ++
packages/realgud/test/gcd.js | 45 ++
packages/realgud/test/gcd.pl | 21 +
packages/realgud/test/gcd.py | 41 ++
packages/realgud/test/gcd.rb | 19 +
packages/realgud/test/gcd.sh | 25 +
packages/realgud/test/gdb/bar.sh | 2 +
packages/realgud/test/gdb/test2/bar.sh | 2 +
packages/realgud/test/make-check-filter.rb | 24 +
packages/realgud/test/node_modules/gcd.js/gcd.js | 47 ++
.../realgud/test/node_modules/gcd.js/package.json | 12 +
packages/realgud/test/regexp-helper.el | 50 ++
packages/realgud/test/test-bashdb.el | 60 ++
packages/realgud/test/test-bp.el | 59 ++
packages/realgud/test/test-bt-pdb.el | 45 ++
packages/realgud/test/test-bt-rdebug.el | 47 ++
packages/realgud/test/test-bt-trepan.el | 49 ++
packages/realgud/test/test-bt-trepan2.el | 43 ++
packages/realgud/test/test-bt-trepan3k.el | 43 ++
packages/realgud/test/test-bt-zshdb.el | 38 +
packages/realgud/test/test-buf-bt.el | 27 +
packages/realgud/test/test-buf-cmd.el | 56 ++
packages/realgud/test/test-common-helper.el | 29 +
packages/realgud/test/test-core.el | 96 +++
packages/realgud/test/test-file.el | 128 ++++
packages/realgud/test/test-gdb-core.el | 36 +
packages/realgud/test/test-gdb.el | 68 ++
packages/realgud/test/test-gub-core.el | 22 +
packages/realgud/test/test-ipdb.el | 39 +
packages/realgud/test/test-jdb.el | 18 +
packages/realgud/test/test-lang.el | 65 ++
packages/realgud/test/test-loc-regexp-gub.el | 63 ++
packages/realgud/test/test-loc-regexp-nodejs.el | 115 +++
packages/realgud/test/test-loc-regexp-trepan.el | 83 +++
packages/realgud/test/test-loc-regexp-trepanpl.el | 128 ++++
packages/realgud/test/test-loc.el | 63 ++
packages/realgud/test/test-lochist.el | 114 +++
packages/realgud/test/test-nodejs.el | 37 +
packages/realgud/test/test-pdb.el | 39 +
packages/realgud/test/test-perldb.el | 26 +
packages/realgud/test/test-rdebug.el | 45 ++
packages/realgud/test/test-realgud.el | 31 +
packages/realgud/test/test-regexp-bashdb.el | 111 +++
packages/realgud/test/test-regexp-gdb.el | 111 +++
packages/realgud/test/test-regexp-gub.el | 65 ++
packages/realgud/test/test-regexp-ipdb.el | 108 +++
packages/realgud/test/test-regexp-jdb.el | 78 +++
packages/realgud/test/test-regexp-nodejs.el | 74 ++
packages/realgud/test/test-regexp-pdb.el | 107 +++
packages/realgud/test/test-regexp-perldb.el | 207 ++++++
packages/realgud/test/test-regexp-rdebug.el | 44 ++
packages/realgud/test/test-regexp-remake.el | 62 ++
packages/realgud/test/test-regexp-ruby.el | 41 ++
packages/realgud/test/test-regexp-trepan.el | 124 ++++
packages/realgud/test/test-regexp-trepan2.el | 167 +++++
packages/realgud/test/test-regexp-trepan3k.el | 167 +++++
packages/realgud/test/test-regexp-trepanjs.el | 94 +++
packages/realgud/test/test-regexp-trepanpl.el | 89 +++
packages/realgud/test/test-regexp-zshdb.el | 70 ++
packages/realgud/test/test-regexp.el | 77 ++
packages/realgud/test/test-remake-core.el | 38 +
packages/realgud/test/test-remake.el | 37 +
packages/realgud/test/test-send.el | 61 ++
packages/realgud/test/test-shortkey.el | 40 ++
packages/realgud/test/test-srcbuf.el | 72 ++
packages/realgud/test/test-track-mode.el | 66 ++
packages/realgud/test/test-track.el | 119 ++++
packages/realgud/test/test-trepan2.el | 45 ++
packages/realgud/test/test-trepan3k.el | 37 +
packages/realgud/test/test-trepanpl.el | 50 ++
packages/realgud/test/test-utils.el | 49 ++
packages/realgud/test/test-zshdb.el | 58 ++
225 files changed, 21797 insertions(+), 0 deletions(-)
diff --git a/packages/realgud/.gitignore b/packages/realgud/.gitignore
new file mode 100644
index 0000000..c3d7bcd
--- /dev/null
+++ b/packages/realgud/.gitignore
@@ -0,0 +1,24 @@
+*.elc
+*~
+/*-pkg.el
+/*.tar.gz
+/.cask/
+/.python-version
+/README
+/aclocal.m4
+/autom4te.cache
+/config.log
+/config.status
+/configure
+/configure.lineno
+/elpa
+/install-sh
+/missing
+/node_modules
+/test/npm-debug.log
+/tmp
+Makefile
+Makefile.in
+elc-stamp
+elc-temp
+script
diff --git a/packages/realgud/AUTHORS b/packages/realgud/AUTHORS
new file mode 100644
index 0000000..60fc84e
--- /dev/null
+++ b/packages/realgud/AUTHORS
@@ -0,0 +1 @@
address@hidden
diff --git a/packages/realgud/COPYING b/packages/realgud/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/packages/realgud/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/packages/realgud/Cask b/packages/realgud/Cask
new file mode 100644
index 0000000..dcfdc80
--- /dev/null
+++ b/packages/realgud/Cask
@@ -0,0 +1,4 @@
+(source gnu)
+(source melpa)
+
+(package-file "realgud.el")
diff --git a/packages/realgud/INSTALL b/packages/realgud/INSTALL
new file mode 100644
index 0000000..8101860
--- /dev/null
+++ b/packages/realgud/INSTALL
@@ -0,0 +1,250 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure && make' should configure,
+and build this package. If that succeeds `make install' will install
+the package. However on some systems you may need root privileges, you
+may have to use `sudo make install' or perhaps `su root' beforehand.
+
+
+ See http://wiki.github.com/rocky/emacs-dbgr/how-to-install for more
+detail as to how to install this package.
+
+Generic Information
+===================
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It also creates a shell script `config.status' that you can run in
+the future to recreate the current configuration, and a file
+`config.log' containing compiler output (useful mainly for debugging
+`configure').
+
+ The configure script can also use an optional file (typically
+called `config.cache' and enabled with `--cache-file=config.cache' or
+simply `-C') that saves the results of its tests to speed up
+reconfiguring. Caching is disabled by default to prevent problems
+with accidental use of stale cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' is used to create `configure' by a program
+called `autoconf'. You need `configure.ac' if you want to change it
+or regenerate `configure' using a newer version of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. You can remove the compiled Emacs Lisp files and other derived
+ files from the source code directory by typing `make clean'. To
+ also remove the files that `configure' created (so you can
+ compile the package for a different kind of computer), type `make
+ distclean'. There is also a `make maintainer-clean' target, but
+ that is intended mainly for the package's developers. If you use
+ it, you may have to get all sorts of other programs in order to
+ regenerate files that came with the distribution.
+
+ 6. You can also type `make uninstall' to remove the installed files
+ again.
+
+ 7. We don't provide `make distcheck' right now, but perhaps someday
+ we will. This is by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Options
+=====================
+
+ Run `./configure --help' for details on the pertinent
+environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 EMACS=/usr/bin/emacs23-x
+
+ *Note Defining Variables::, for more details.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's emacs files under
+`/usr/local/share/emacs/site-lisp', You can specify an installation
+prefix other than `/usr/local/emacs/site-lisp' by giving `configure'
+the option `--with-site-lisp=PREFIX', where PREFIX must be an absolute
+file name.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure EMACS=/usr/bin/emacs23-x
+
+causes the specified `/usr/bin/emacs23-x' to be used as the Emacs program
+to use.
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/packages/realgud/Makefile.am b/packages/realgud/Makefile.am
new file mode 100644
index 0000000..9866e0f
--- /dev/null
+++ b/packages/realgud/Makefile.am
@@ -0,0 +1,47 @@
+# Note: This makefile include remake-style target comments.
+# These comments before the targets start with #:
+# remake --tasks to shows the targets and the comments
+
+SUBDIRS = realgud test
+
+GIT2CL ?= git2cl
+RUBY ?= ruby
+
+lispdir = @lispdir@
+
+include common.mk
+
+PHONY=check clean dist distclean test check-short check-terse install-short
+
+EXTRA_DIST+=common.mk README.md THANKS
+
+if MAINTAINER_MODE
+
+#: Remove change log: ChangeLog
+rmChangeLog:
+ rm ChangeLog || true
+
+#: Create a ChangeLog file from git logs
+ChangeLog: rmChangeLog
+ git log --pretty --numstat --summary | $(GIT2CL) > $@
+
+ACLOCAL_AMFLAGS=-I .
+
+endif
+
+#: Run all tests
+test: check
+
+#: Run all tests without bloated output
+check-short:
+ $(MAKE) check 2>&1 | $(RUBY) test/make-check-filter.rb
+
+#: Run all tests without and show just the failure lines
+check-terse:
+ $(MAKE) check 2>&1 | $(RUBY) tes/make-check-filter.rb | grep failure
+
+#: Run "make install"
+install-short:
+ $(MAKE) install 2>&1 | $(RUBY) test/make-check-filter.rb
+
+.PHONY: test check check-short rmChangeLog
diff --git a/packages/realgud/NEWS b/packages/realgud/NEWS
new file mode 100644
index 0000000..e69de29
diff --git a/packages/realgud/README.md b/packages/realgud/README.md
new file mode 100644
index 0000000..5155738
--- /dev/null
+++ b/packages/realgud/README.md
@@ -0,0 +1,23 @@
+[![Build Status][travis-image]][travis-url]
+[![MELPA Stable][melpa-image]][melpa-stable]
+
+A modular GNU Emacs front-end for interacting with external debuggers.
+
+See https://github.com/rocky/emacs-dbgr/wiki/Debuggers-Supported for a list of
debuggers supported.
+
+A debugger can be run out of a *comint* process buffer, or you can use a
+`M-x realgud-track-mode` inside an existing
[shell](http://www.gnu.org/software/emacs/manual/html_node/emacs/Shell.html),
or [eshell](https://www.gnu.org/software/emacs/manual/html_mono/eshell.html)
buffer.
+
+To install, you'll need a couple of other Emacs packages installed. See
+[the installation
instructions](http://wiki.github.com/rocky/emacs-dbgr/how-to-install)
+for details.
+
+To get started using, see the
+[notes on using realgud](http://wiki.github.com/rocky/emacs-dbgr/how-to-use).
+
+*Author:* Rocky Bernstein <address@hidden>
+
+[travis-image]:
https://img.shields.io/travis/rocky/emacs-dbgr.svg?style=flat-square
+[travis-url]: https://travis-ci.org/rocky/emacs-dbgr
+[melpa-image]: http://stable.melpa.org/packages/realgud-badge.svg
+[melpa-stable]: http://stable.melpa.org/#/realgud
diff --git a/packages/realgud/THANKS b/packages/realgud/THANKS
new file mode 100644
index 0000000..bacb71c
--- /dev/null
+++ b/packages/realgud/THANKS
@@ -0,0 +1,11 @@
+Lars Andersen (expez) - Getting this packaged and put on to Melpa. Also the
new name, realgud, is basically his idea.
+
+Anders Lindgren - The inspiration behind in an earlier incarnation of this
code, ruby-debug. Ideas like short-key-mode are his.
+
+Nick Roberts - We used some of the code for the fringe icons from gdb-mi.
+
+NYC Emacs Meetup and Nicolas Dudebout - straightening me out on
set-keymap-parent
+
+Kilian Kilger - gdb fixes
+
+Sean Farley - ipdb support
diff --git a/packages/realgud/autogen.sh b/packages/realgud/autogen.sh
new file mode 100755
index 0000000..8948b34
--- /dev/null
+++ b/packages/realgud/autogen.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+ln -fs README.md README
+autoreconf -vi && \
+autoconf && {
+ echo "Running configure with --enable-maintainer-mode $@"
+ ./configure --enable-maintainer-mode $@
+}
diff --git a/packages/realgud/common.mk b/packages/realgud/common.mk
new file mode 100644
index 0000000..c8fc92a
--- /dev/null
+++ b/packages/realgud/common.mk
@@ -0,0 +1,10 @@
+lisp_files := $(wildcard *.el)
+lisp_LISP = $(lisp_files)
+EXTRA_DIST = $(lisp_files)
+MOSTLYCLEANFILES = *.elc
+
+short:
+ $(MAKE) 2>&1 >/dev/null | ruby $(top_srcdir)/make-check-filter.rb
+
+%.short:
+ $(MAKE) $(@:.short=) 2>&1 >/dev/null
diff --git a/packages/realgud/compute-lispdir.sh
b/packages/realgud/compute-lispdir.sh
new file mode 100755
index 0000000..220befd
--- /dev/null
+++ b/packages/realgud/compute-lispdir.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Figures out a reasonable --prefix
+typeset -i rc=0
+typeset -i DEBUG=${DEBUG:-0}
+EMACS_PROG=${EMACS_PROG:-emacs}
+list=$($EMACS_PROG --batch --no-splash --no-site-file --eval '(message
(substring (format "%s" load-path) 1 -1))' 2>&1)
+rc=$?
+if (( rc != 0 )) ; then
+ echo >&2 "Something went wrong running $EMACS_PROG"
+ exit $rc
+$cmd
+fi
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/site-lisp)
+ ((DEBUG)) && echo "site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/2[34]\.[0-9]/site-lisp)
+ ((DEBUG)) && echo "versioned site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/2[34]\.[0-9]/site-lisp)
+ ((DEBUG)) && echo "versioned site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+exit 0
diff --git a/packages/realgud/configure.ac b/packages/realgud/configure.ac
new file mode 100644
index 0000000..e616ad6
--- /dev/null
+++ b/packages/realgud/configure.ac
@@ -0,0 +1,87 @@
+dnl FIXME: pick up from realgud.el
+AC_INIT(emacs-realgud, 1.1,)
+AC_CONFIG_SRCDIR(realgud.el)
+AM_INIT_AUTOMAKE([foreign])
+AM_MAINTAINER_MODE
+
+AC_PATH_PROG([EMACS], [emacs], [emacs])
+AC_ARG_WITH(emacs, AC_HELP_STRING([--with-emacs],
+ [location of emacs program]), EMACS=$withval)
+
+AC_MSG_NOTICE("Checking emacs version")
+$EMACS -batch -q --no-site-file -eval \
+ '(if (<= emacs-major-version 23)
+ (progn
+ (error "You need GNU Emacs 24 or better.")
+ (kill-emacs 1)
+ )
+ )'
+if test $? -ne 0 ; then
+ AC_MSG_ERROR([Can't continue until above error is corrected.])
+fi
+
+if test "$NO_CHECK_EMACS_PACKAGES" = "" ; then
+AC_MSG_NOTICE("Checking prerequiste packages")
+$EMACS -batch -q --no-site-file -eval \
+ '(dolist (package
+ (quote (cl-lib list-utils loc-changes load-relative test-simple)))
+ (require package))
+ )'
+fi
+if test $? -ne 0 ; then
+ AC_MSG_ERROR([Can't continue until above error is corrected.])
+fi
+
+##################################################################
+# See if --with-lispdir was set. If not, set it to a reasonable default
+# based on where bash thinks bashdb is supposed to be installed.
+##################################################################
+
+AM_MISSING_PROG(GIT2CL, git2cl, $missing_dir)
+
+# Check whether --with-lispdir was given.
+if test "${with_lispdir+set}" = set; then :
+else
+ my_lispdir=$(EMACS_PROG=$EMACS $SH_PROG $(dirname $0)/compute-lispdir.sh)
+ if test "${my_lispdir+set}" = set; then :
+ with_lispdir=$my_lispdir
+ echo "'compute-lispdir.sh' lispdir install directory override:
'$with_lispdir'"
+ fi
+fi
+
+##
+## Find out where to install the debugger emacs lisp files
+##
+AM_PATH_LISPDIR
+lispdir_realgud=$lispdir/realgud
+AC_SUBST([lispdir])
+AC_SUBST([lispdir_realgud])
+
+AM_CONDITIONAL(INSTALL_EMACS_LISP, test "x$lispdir_realgud" != "x")
+
+AC_CONFIG_FILES([Makefile \
+ realgud/Makefile \
+ realgud/common/Makefile \
+ realgud/common/buffer/Makefile \
+ realgud/debugger/Makefile \
+ realgud/debugger/bashdb/Makefile \
+ realgud/debugger/gdb/Makefile \
+ realgud/debugger/gub/Makefile \
+ realgud/debugger/ipdb/Makefile \
+ realgud/debugger/jdb/Makefile \
+ realgud/debugger/kshdb/Makefile \
+ realgud/debugger/nodejs/Makefile \
+ realgud/debugger/perldb/Makefile \
+ realgud/debugger/pdb/Makefile \
+ realgud/debugger/rdebug/Makefile \
+ realgud/debugger/remake/Makefile \
+ realgud/debugger/trepan/Makefile \
+ realgud/debugger/trepan2/Makefile \
+ realgud/debugger/trepan3k/Makefile \
+ realgud/debugger/trepan.pl/Makefile \
+ realgud/debugger/trepanjs/Makefile \
+ realgud/debugger/zshdb/Makefile \
+ realgud/lang/Makefile \
+ test/Makefile \
+ ])
+AC_OUTPUT
diff --git a/packages/realgud/copyright_exceptions
b/packages/realgud/copyright_exceptions
new file mode 100644
index 0000000..e69de29
diff --git a/packages/realgud/el-get-install.el
b/packages/realgud/el-get-install.el
new file mode 100644
index 0000000..86c55ec
--- /dev/null
+++ b/packages/realgud/el-get-install.el
@@ -0,0 +1,104 @@
+(eval-when-compile
+ (defvar el-get-sources)
+)
+
+(declare-function el-get-post-install 'el-get)
+
+(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
+
+;;; el-get-install.el --- installer for the lazy
+;;
+;; Copyright (C) 2010 Dimitri Fontaine
+;;
+;; Author: Dimitri Fontaine <address@hidden>
+;; URL: http://www.emacswiki.org/emacs/el-get.el
+;; Created: 2010-06-17
+;; Keywords: emacs package elisp install elpa git git-svn bzr cvs apt-get fink
http http-tar
+;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
+;;
+;; This file is NOT part of GNU Emacs.
+;;
+;; bootstrap your el-get installation, the goal is then to use el-get to
+;; update el-get.
+;;
+;; So the idea is that you copy/paste this code into your *scratch* buffer,
+;; hit C-j, and you have a working el-get.
+
+(let ((el-get-root
+ (file-name-as-directory
+ (or (bound-and-true-p el-get-dir)
+ (concat (file-name-as-directory user-emacs-directory) "el-get")))))
+
+ (when (file-directory-p el-get-root)
+ (add-to-list 'load-path el-get-root))
+
+ ;; try to require el-get, failure means we have to install it
+ (unless (require 'el-get nil t)
+ (unless (file-directory-p el-get-root)
+ (make-directory el-get-root t))
+
+ (let* ((package "el-get")
+ (buf (switch-to-buffer "*el-get bootstrap*"))
+ (pdir (file-name-as-directory (concat el-get-root package)))
+ (git (or (executable-find "git")
+ (error "Unable to find `git'")))
+ (url (or (bound-and-true-p el-get-git-install-url)
+ "http://github.com/dimitri/el-get.git"))
+ (default-directory el-get-root)
+ (process-connection-type nil) ; pipe, no pty (--no-progress)
+
+ ;; First clone el-get
+ (status
+ (call-process
+ git nil `(,buf t) t "--no-pager" "clone" "-v" url package)))
+
+ (unless (zerop status)
+ (error "Couldn't clone el-get from the Git repository: %s" url))
+
+ ;; switch branch if we have to
+ (let* ((branch (cond
+ ;; Check if a specific branch is requested
+ ((bound-and-true-p el-get-install-branch))
+ ;; Check if master branch is requested
+ ((boundp 'el-get-master-branch) "master")
+ ;; Read the default branch from the el-get recipe
+ ((plist-get (with-temp-buffer
+ (insert-file-contents-literally
+ (expand-file-name "recipes/el-get.rcp"
pdir))
+ (read (current-buffer)))
+ :branch))
+ ;; As a last resort, use the master branch
+ ("master")))
+ (remote-branch (format "origin/%s" branch))
+ (default-directory pdir)
+ (bstatus
+ (if (string-equal branch "master")
+ 0
+ (call-process git nil (list buf t) t "checkout" "-t"
remote-branch))))
+ (unless (zerop bstatus)
+ (error "Couldn't `git checkout -t %s`" branch)))
+
+ (add-to-list 'load-path pdir)
+ (load package)
+ (let ((el-get-default-process-sync t) ; force sync operations for
installer
+ (el-get-verbose t)) ; let's see it all
+ (el-get-post-install "el-get"))
+ (with-current-buffer buf
+ (goto-char (point-max))
+ (insert "\nCongrats, el-get is installed and ready to serve!")))))
+
+
+(declare-function el-get 'el-get)
+
+;; now either el-get is `require'd already, or have been `load'ed by the
+;; el-get installer.
+(setq
+ el-get-sources
+ '(el-get ; el-get is self-hosting
+ loc-changes ; loc marks in buffers
+ load-relative ; load emacs lisp relative to emacs source
+ test-simple ; simple test framework
+ ))
+
+;; install new packages and init already installed packages
+(el-get 'sync '(loc-changes list-utils load-relative test-simple))
diff --git a/packages/realgud/elisp-comp b/packages/realgud/elisp-comp
new file mode 100755
index 0000000..8277552
--- /dev/null
+++ b/packages/realgud/elisp-comp
@@ -0,0 +1,93 @@
+#!/bin/sh
+# Copyright (C) 1995-2012 Free Software Foundation, Inc.
+
+scriptversion=2014-02-09.22; # UTC
+
+# Franc,ois Pinard <address@hidden>, 1995.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <address@hidden> or send patches to
+# <address@hidden>.
+
+case $1 in
+ '')
+ echo "$0: No files. Try '$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: elisp-comp [--help] [--version] FILES...
+
+This script byte-compiles all '.el' files listed as FILES using GNU
+Emacs, and put the resulting '.elc' files into the current directory,
+so disregarding the original directories used in '.el' arguments.
+
+This script manages in such a way that all Emacs LISP files to
+be compiled are made visible between themselves, in the event
+they require or load-library one another.
+
+Report bugs to <address@hidden>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "elisp-comp $scriptversion"
+ exit $?
+ ;;
+esac
+
+if test -z "$EMACS" || test "$EMACS" = "t"; then
+ # Value of "t" means we are running in a shell under Emacs.
+ # Just assume Emacs is called "emacs".
+ EMACS=emacs
+fi
+
+tempdir=elc.$$
+
+# Cleanup the temporary directory on exit.
+trap 'ret=$?; rm -rf "$tempdir" && exit $ret' 0
+do_exit='(exit $ret); exit $ret'
+trap "ret=129; $do_exit" 1
+trap "ret=130; $do_exit" 2
+trap "ret=141; $do_exit" 13
+trap "ret=143; $do_exit" 15
+
+# mkdir $tempdir
+# cp "$@" $tempdir
+
+(
+ # cd $tempdir
+ echo "(setq load-path (cons nil (cons \"$abs_srcdir\" load-path)))" > script
+ $EMACS -batch -q -l script -f batch-byte-compile-if-not-done *.el || exit $?
+ # mv *.elc ..
+) || exit $?
+
+(exit 0); exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/packages/realgud/realgud.el b/packages/realgud/realgud.el
new file mode 100644
index 0000000..62c1032
--- /dev/null
+++ b/packages/realgud/realgud.el
@@ -0,0 +1,204 @@
+;;; realgud.el --- A modular front-end for interacting with external debuggers
+
+;; Author: Rocky Bernstein
+;; Version: 1.3
+;; Package-Requires: ((load-relative "1.0") (list-utils "0.4.2") (loc-changes
"1.1") (test-simple "1.0"))
+;; URL: http://github.com/rocky/emacs-dbgr
+;; Compatibility: GNU Emacs 24.x
+
+;; Copyright (C) 2015, 2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Once upon a time in an Emacs far far away and a programming-style
+;; deservedly banished, there was a monolithic Cathederal-like
+;; debugger front-end called gub. This interfaced with a number of
+;; debuggers, many now dead. Is there anyone still alive that
+;; remembers sdb from UNIX/32V circa 1980?
+;;
+;; This isn't that. Here we make use of more modern programming
+;; practices, more numerous and smaller files, unit tests, and better
+;; use of Emacs primitives, e.g. buffer marks, buffer-local variables,
+;; structures, rings, hash tables. Although there is still much to be
+;; desired, this code is more scalable and suitable as a common base for
+;; an Emacs front-end to modern debuggers.
+;;
+;; Oh, and because global variables are largely banned, we can support
+;; several simultaneous debug sessions.
+;;
+;; See URL `https://github.com/rocky/emacs-dbgr/wiki/Features' for a list
+;; features.
+
+;;
+;; The debuggers we currently support are:
+
+;; NAME INVOCATION** WHAT
+; -----------------------------------
+;; bashdb bashdb bash
+;; Devel::Trepan trepan.pl Perl5
+;; gdb realgud:gdb gdb
+;; gub gub Go SSA debugger
+;; jdb realgud:jdb Java jdb debugger
+;; kshdb kshdb Korn Shell 93u+
+;; nodejs nodejs node.js javascript debugger
+;; pdb realgud:pdb stock C Python debugger
+;; ipdb realgud:ipdb iPython debugger
+;; perldb realgud:perldb stock Perl5 debugger
+;; remake remake GNU Make
+;; ruby-debug rdebug Ruby
+;; trepanning trepan trepanning debugger for a patched Ruby 1.9
+;; trepanjs trepanjs trepanning debugger for nodejs and V8
+;; trepan2 trepan2 trepanning debugger for Python 2.x
+;; trepan3k trepan3k trepanning debugger for Python 3.x
+;; zshdb zshdb Zsh
+;;
+;; The following older packages can be found in the realgud-older-debuggers
+;; package:
+
+;; pydb pydb slighly enhanced pdb for Python 2.x
+;; pydbgr pydbgr obsolete trepanning debugger for Python 2.x
+;; rb8-trepanning trepan8 MRI Ruby 1.8 and an unpatched YARV 1.9
+;; rbx-trepanning trepanx trepanning debugger for Rubinius Ruby
+
+;; The following debuggers are found in separate individual packages:
+
+;; byebug realgud:byebug Ruby debugger byebug
+;; pry realgud:pry Ruby debugger pry
+;;
+;;
+;;
+
+;; **gdb, jdb, perldb, pdb invocations require the realgud: preface to
+;; disambiguate it from older, preexisting Emacs commands in `gud'.
+;; The other invocations also accept realgud: prefaces,
+;; e.g. realgud:bashdb or realgud:rdebug. Alas there are older
+;; obsolete (i.e. often written by me) Emacs packages out there for
+;; bashdb, kshdb, nodejs, pydb, rdebug, zshdb.
+
+;; If you don't see your favorite debugger above, see URL
+;; `https://github.com/rocky/emacs-dbgr/wiki/How-to-add-a-new-debugger/'
+;; for how you can add your own.
+
+;; The debugger is run out of a comint process buffer, or you can use
+;; a `realgud-track-mode' inside an existing shell.
+
+;; To install you will need a couple of other Emacs packages
+;; installed. If you install via melpa (`package-install') or
+;; `el-get', these will be pulled in automatically. See the
+;; installation instructions URL
+;; `https://github.com/rocky/emacs-dbgr/wiki/How-to-Install' for all
+;; the ways to to install and more details on installation.
+
+;;; Code:
+
+(require 'load-relative)
+
+(defgroup realgud nil
+ "The Grand Cathedral Debugger rewrite"
+ :group 'processes
+ :group 'tools
+ :version "24.3")
+
+;; FIXME: extend require-relative for "autoload".
+(defun realgud:load-features()
+ (require-relative-list
+ '(
+ "./realgud/common/track-mode"
+ "./realgud/common/utils"
+ "./realgud/debugger/bashdb/bashdb"
+ "./realgud/debugger/gdb/gdb"
+ "./realgud/debugger/gub/gub"
+ ;; Temporarily remove ipdb until the Melpa recipie is in place
+ ;; "./realgud/debugger/ipdb/ipdb"
+ "./realgud/debugger/jdb/jdb"
+ "./realgud/debugger/kshdb/kshdb"
+ "./realgud/debugger/nodejs/nodejs"
+ "./realgud/debugger/pdb/pdb"
+ "./realgud/debugger/perldb/perldb"
+ "./realgud/debugger/rdebug/rdebug"
+ "./realgud/debugger/remake/remake"
+ "./realgud/debugger/trepan/trepan"
+ "./realgud/debugger/trepanjs/trepanjs"
+ "./realgud/debugger/trepan.pl/trepanpl"
+ "./realgud/debugger/trepan2/trepan2"
+ "./realgud/debugger/trepan3k/trepan3k"
+ "./realgud/debugger/zshdb/zshdb"
+ ) "realgud-")
+ )
+
+(load-relative "./realgud/common/custom")
+
+(defun realgud-feature-starts-with(feature prefix)
+ "realgud-strings-starts-with on stringified FEATURE and PREFIX."
+ (declare (indent 1))
+ (string-prefix-p (symbol-name feature) prefix)
+ )
+
+(defun realgud:loaded-features()
+ "Return a list of loaded debugger features. These are the
+features that start with 'realgud-' and also include standalone debugger
features
+like 'pydbgr'."
+ (let ((result nil)
+ (feature-str))
+ (dolist (feature features result)
+ (setq feature-str (symbol-name feature))
+ (cond ((eq 't
+ (string-prefix-p feature-str "realgud-"))
+ (setq result (cons feature-str result)))
+ ((eq 't
+ (string-prefix-p feature-str "nodejs"))
+ (setq result (cons feature-str result)))
+ ((eq 't
+ ;; No trailing '-' to get a plain "trepan".
+ (string-prefix-p feature-str "trepan"))
+ (setq result (cons feature-str result)))
+ ((eq 't
+ ;; No trailing '-' to get a plain "trepanx".
+ (string-prefix-p feature-str "trepanx"))
+ (setq result (cons feature-str result)))
+ ('t nil))
+ )
+ )
+)
+
+(defun realgud:unload-features()
+ "Remove all features loaded from this package. Used in
+`realgud:reload-features'. See that."
+ (interactive "")
+ (let ((result (realgud:loaded-features)))
+ (dolist (feature result result)
+ (unless (symbolp feature) (setq feature (make-symbol feature)))
+ (if (featurep feature)
+ (unload-feature feature) 't))
+ ))
+
+(defun realgud:reload-features()
+ "Reload all features loaded from this package. Useful if have
+changed some code or want to reload another version, say a newer
+development version and you already have this package loaded."
+ (interactive "")
+ (realgud:unload-features)
+ (realgud:load-features)
+ )
+
+;; Load everything.
+(realgud:load-features)
+
+(provide-me)
+
+;;; realgud.el ends here
diff --git a/packages/realgud/realgud/Makefile.am
b/packages/realgud/realgud/Makefile.am
new file mode 100644
index 0000000..75a2af8
--- /dev/null
+++ b/packages/realgud/realgud/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = common debugger lang
diff --git a/packages/realgud/realgud/common/Makefile.am
b/packages/realgud/realgud/common/Makefile.am
new file mode 100644
index 0000000..44d7530
--- /dev/null
+++ b/packages/realgud/realgud/common/Makefile.am
@@ -0,0 +1,4 @@
+SUBDIRS = buffer
+
+include $(top_srcdir)/common.mk
+lispdir = @lispdir_realgud@/$(notdir $(subdir))
diff --git a/packages/realgud/realgud/common/attach.el
b/packages/realgud/realgud/common/attach.el
new file mode 100644
index 0000000..f0efbff
--- /dev/null
+++ b/packages/realgud/realgud/common/attach.el
@@ -0,0 +1,69 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Emacs Commands to associate or attach a source buffer to a command
+;;; buffer and vice versa.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '("buffer/command" "buffer/source")
+ "realgud-buffer-")
+(require-relative-list '("shortkey") "realgud-")
+
+(declare-function realgud-cmdbuf-add-srcbuf 'realgud-buffer-command)
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud-srcbuf-init-or-update 'realgud-source)
+(declare-function realgud-short-key-mode-setup 'realgud-shortkey)
+
+(defun realgud:attach-source-buffer(srcbuf)
+ "Associate a source buffer with the current command buffer"
+ (interactive "bsource buffer: ")
+ (unless (realgud-cmdbuf?)
+ (error "The command only works inside a command buffer"))
+ (unless (get-buffer-process (current-buffer))
+ (warn "Can't find a process for command buffer %s" (current-buffer)))
+
+ (let* ((cmdbuf (current-buffer))
+ (shortkey-mode? (realgud-sget 'cmdbuf-info 'src-shortkey?)))
+ (if (stringp srcbuf) (setq srcbuf (get-buffer srcbuf)))
+ (realgud-cmdbuf-add-srcbuf srcbuf)
+ (realgud-srcbuf-init-or-update srcbuf cmdbuf)
+ (if shortkey-mode?
+ (with-current-buffer srcbuf
+ (realgud-short-key-mode-setup 't))
+ )
+ )
+ )
+
+(defun realgud:attach-command-buffer(cmdbuf)
+ "Associate a command buffer with the current source buffer"
+
+ (interactive "bcommand buffer: ")
+ (if (stringp cmdbuf) (setq cmdbuf (get-buffer cmdbuf)))
+ (let* ((srcbuf (current-buffer))
+ (shortkey-mode?))
+ (with-current-buffer cmdbuf
+ (unless (realgud-cmdbuf?)
+ (error "The buffer is not a command buffer"))
+ (unless (get-buffer-process (current-buffer))
+ (warn "Can't find a process for command buffer %s" (current-buffer)))
+ (setq shortkey-mode? (realgud-sget 'cmdbuf-info 'src-shortkey?)))
+ (realgud-cmdbuf-add-srcbuf srcbuf)
+ (realgud-srcbuf-init-or-update srcbuf cmdbuf)
+ (if shortkey-mode? (realgud-short-key-mode-setup 't)))
+ )
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/backtrace-mode.el
b/packages/realgud/realgud/common/backtrace-mode.el
new file mode 100644
index 0000000..96fec26
--- /dev/null
+++ b/packages/realgud/realgud/common/backtrace-mode.el
@@ -0,0 +1,118 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Debugger Backtrace buffer mode settings
+(require 'load-relative)
+(require-relative-list '("menu" "key") "realgud-")
+(require-relative-list '("buffer/command") "realgud-buffer-")
+
+(declare-function realgud-populate-debugger-menu 'realgud-menu)
+(declare-function realgud-populate-common-keys 'realgud-menu)
+(declare-function realgud-cmdbuf-pat 'realgud-menu)
+
+(defvar realgud:frames-menu nil
+ "Frames menu in Backtrace menu.")
+
+;; (setq realgud:frames-menu
+;; (let ((map (make-sparse-keymap "Goto Specific Frames")))
+;; (define-key map [frames-menu]
+;; (list 'menu-item "Specific Frames" 'realgud:frames-menu))
+;; (realgud-menu-item map "Frame 1" 'realgud-goto-frame-1)
+;; (realgud-menu-item map "Frame 2" 'realgud-goto-frame-2)
+;; (realgud-menu-item map "Frame 3" 'realgud-goto-frame-3)
+;; )
+;; map)
+
+(defvar realgud-backtrace-mode-map
+ (let ((map (realgud-populate-debugger-menu (make-sparse-keymap))))
+ (suppress-keymap map)
+ (realgud-populate-common-keys map)
+ (define-key map "." 'realgud-backtrace-moveto-frame-selected)
+ (define-key map "r" 'realgud:backtrace-init)
+ (define-key map [double-mouse-1] 'realgud:follow-event)
+ (define-key map [mouse-2] 'realgud:follow-event)
+ (define-key map [enter] 'realgud:follow-event)
+ (define-key map [mouse-3] 'realgud:follow-event)
+ (define-key map [enter] 'realgud:follow-event)
+ (define-key map [return] 'realgud:follow-point)
+ (define-key map [up] 'realgud-backtrace-moveto-frame-prev)
+ (define-key map [down] 'realgud-backtrace-moveto-frame-next)
+ (define-key map "l" 'realgud-recenter-arrow)
+
+ (define-key map [frames-menu]
+ (list 'menu-item "Specific Frames" 'realgud:frames-menu))
+
+ ;; FIXME: these can go to a common routine. See also shortkey.el and
+ ;; key.el
+ (define-key map "<" 'realgud:cmd-newer-frame)
+ (define-key map ">" 'realgud:cmd-older-frame)
+ (define-key map "d" 'realgud:cmd-newer-frame)
+ (define-key map "u" 'realgud:cmd-older-frame)
+ (define-key map "q" 'realgud:cmd-quit)
+ (define-key map "C" 'realgud-window-cmd-undisturb-src)
+ (define-key map "F" 'realgud:window-bt)
+ (define-key map "I" 'realgud:cmdbuf-info-describe)
+ (define-key map "S" 'realgud-window-src-undisturb-cmd)
+
+ (define-key map "n" 'realgud-backtrace-moveto-frame-next)
+ (define-key map "p" 'realgud-backtrace-moveto-frame-prev)
+ (define-key map "0" 'realgud-goto-frame-n)
+ (define-key map "1" 'realgud-goto-frame-n)
+ (define-key map "2" 'realgud-goto-frame-n)
+ (define-key map "3" 'realgud-goto-frame-n)
+ (define-key map "4" 'realgud-goto-frame-n)
+ (define-key map "5" 'realgud-goto-frame-n)
+ (define-key map "6" 'realgud-goto-frame-n)
+ (define-key map "7" 'realgud-goto-frame-n)
+ (define-key map "8" 'realgud-goto-frame-n)
+ (define-key map "9" 'realgud-goto-frame-n)
+
+ ;; --------------------
+ ;; The "Stack window" submenu.
+ ;; (let ((submenu realgud:frames-menu))
+ ;; (define-key-after map [menu-bar debugger stack]
+ ;; (cons "Stack window" submenu)
+ ;; 'placeholder))
+ map)
+ "Keymap to navigate realgud stack frames.
+
+\\{realgud-backtrace-mode-map}")
+
+(defun realgud-backtrace-mode (&optional cmdbuf)
+ "Major mode for displaying the stack frames.
+\\{realgud-frames-mode-map}"
+ (interactive)
+ (kill-all-local-variables)
+ (setq buffer-read-only 't)
+ (setq major-mode 'realgud-backtrace-mode)
+ (setq mode-name "Realgud Stack Frames")
+ ;; (set (make-local-variable 'realgud-secondary-buffer) t)
+ (setq mode-line-process 'realgud-mode-line-process)
+ (use-local-map realgud-backtrace-mode-map)
+
+ ;; FIXME: make buffer specific
+ (if cmdbuf
+ (let* ((font-lock-keywords
+ (with-current-buffer cmdbuf
+ (realgud-cmdbuf-pat "font-lock-keywords"))))
+ (if font-lock-keywords
+ (set (make-local-variable 'font-lock-defaults)
+ (list font-lock-keywords)))
+ ))
+ ;; (run-mode-hooks 'realgud-backtrace-mode-hook)
+ )
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/backtrack-mode.el
b/packages/realgud/realgud/common/backtrack-mode.el
new file mode 100644
index 0000000..aaf89c9
--- /dev/null
+++ b/packages/realgud/realgud/common/backtrack-mode.el
@@ -0,0 +1,116 @@
+;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; Used to parse programming-language backtrace-like tracks
+;; output. In contrast to track-mode, there doesn't have to be a
+;; process shell arround Compare with backtrace-mode.el which
+;; handles backtraces inside the debugger
+
+(eval-when-compile (require 'cl))
+(require 'shell)
+
+(require 'load-relative)
+(require-relative-list
+ '("core" "helper" "track" "loc" "lochist" "file"
+ "fringe" "window" "regexp" "menu"
+ "send" "shortkey") "realgud-")
+
+(require-relative-list '("buffer/command") "realgud-buffer-")
+
+(declare-function realgud:debugger-name-transform 'realgud-helper)
+(declare-function realgud-populate-debugger-menu 'realgud-menu)
+(declare-function realgud:track-set-debugger 'realgud-track)
+
+(defvar realgud-backtrack-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [frames-menu]
+ (list 'menu-item "Specific Frames" 'realgud:frames-menu))
+ (define-key map [M-right] 'realgud-track-hist-newest)
+ (define-key map [M-down] 'realgud-track-hist-newer)
+ (define-key map [M-up] 'realgud-track-hist-older)
+ (define-key map [M-print] 'realgud-track-hist-older)
+ (define-key map [M-S-down] 'realgud-track-hist-newest)
+ (define-key map [M-S-up] 'realgud-track-hist-oldest)
+ (realgud-populate-debugger-menu map)
+ map)
+ "Keymap used in `realgud-backtrack-minor-mode'.")
+
+;; FIXME figure out if I can put this in something like a header file.
+;; FIXME: combine with realgud:track-set-debugger's completing read
+(defun realgud-backtrack-set-debugger (debugger-name)
+ "Set debugger name This info is returned or nil if we can't find a
+debugger with that information"
+ (interactive
+ (list (completing-read "Debugger name: " realgud-pat-hash)))
+ (let ((regexp-hash (gethash debugger-name realgud-pat-hash)))
+ (if regexp-hash
+ (let* ((base-variable-name
+ (or (gethash debugger-name realgud:variable-basename-hash)
+ debugger-name))
+ (specific-track-mode (intern (concat base-variable-name
"-backtrack-mode")))
+ )
+ (if (and (not (eval specific-track-mode))
+ (functionp specific-track-mode))
+ (funcall specific-track-mode 't))
+ )
+ (progn
+ (message "I Don't have %s listed as a debugger." debugger-name)
+ nil)
+ )))
+
+(define-minor-mode realgud-backtrack-mode
+ "Minor mode for backtracking parsing."
+ :init-value nil
+ :global nil
+ :group 'realgud
+
+ :lighter
+ (:eval (progn
+ (concat " "
+ (if (realgud-cmdbuf-info-set?)
+ (realgud-sget 'cmdbuf-info 'debugger-name)
+ "dbgr??"))))
+
+ :keymap realgud-backtrack-mode-map
+ ;; Setup/teardown
+ )
+
+(defmacro realgud-backtrack-mode-vars (name)
+ `(progn
+ (defvar ,(intern (concat name "-backtrack-mode")) nil
+ ,(format "Non-nil if using %s-backtrack-mode as a minor mode of some
other mode.
+Use the command `%s-track-mode' to toggle or set this variable." name name))
+ (defvar ,(intern (concat name "-backtrack-mode-map")) (make-sparse-keymap)
+ ,(format "Keymap used in `%s-backtrack-mode'." name))
+ ))
+
+;; FIXME: The below could be a macro? I have a hard time getting
+;; macros right.
+(defun realgud-backtrack-mode-body(name)
+ "Used in by custom debuggers: pydbgr, trepan, gdb, etc. NAME is
+the name of the debugger which is used to preface variables."
+ (realgud:track-set-debugger name)
+ (funcall (intern (concat "realgud-define-" name "-commands")))
+ (if (intern (concat name "-backtrack-mode"))
+ (progn
+ (realgud-backtrack-mode 't)
+ (run-mode-hooks (intern (concat name "-backtrack-mode-hook"))))
+ (progn
+ (realgud-backtrack-mode nil)
+ )))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/bp-image-data.el
b/packages/realgud/realgud/common/bp-image-data.el
new file mode 100644
index 0000000..01abaf3
--- /dev/null
+++ b/packages/realgud/realgud/common/bp-image-data.el
@@ -0,0 +1,357 @@
+(require 'load-relative)
+(defconst realgud-bp-xpm-data
+ "/* XPM */
+static char *magick[] = {
+/* columns rows colors chars-per-pixel */
+\"10 10 2 1\",
+\" c red\",
+\"+ c None\",
+/* pixels */
+\"+++ +++\",
+\"++ ++\",
+\"+ +\",
+\" \",
+\" \",
+\" \",
+\" \",
+\"+ +\",
+\"++ ++\",
+\"+++ +++\",
+};"
+ "XPM data used for breakpoint enable and disable icon.")
+
+;; For seeing what above icon looks like:
+(if nil
+ (progn
+ (let ((image
+ (find-image `((:type xpm :data
+ ,realgud-bp-xpm-data
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ (let ((image
+ (find-image `((:type xpm :data
+ ,realgud-bp-xpm-data
+ :conversion disabled
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ )
+ )
+
+(defconst realgud-bp-enabled-pbm-data
+ "P1
+10 10\",
+0 0 0 0 1 1 1 1 0 0 0 0
+0 0 0 1 1 1 1 1 1 0 0 0
+0 0 1 1 1 1 1 1 1 1 0 0
+0 1 1 1 1 1 1 1 1 1 1 0
+0 1 1 1 1 1 1 1 1 1 1 0
+0 1 1 1 1 1 1 1 1 1 1 0
+0 1 1 1 1 1 1 1 1 1 1 0
+0 0 1 1 1 1 1 1 1 1 0 0
+0 0 0 1 1 1 1 1 1 0 0 0
+0 0 0 0 1 1 1 1 0 0 0 0"
+ "PBM data used for enabled breakpoint icon.")
+
+;; For seeing what above icon looks like:
+(if nil
+ (let ((image
+ (find-image `((:type pbm :data
+ ,realgud-bp-enabled-pbm-data
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ )
+
+(defconst realgud-bp-disabled-pbm-data
+ "P1
+10 10\",
+1 1 1 1 0 0 0 0 1 1 1 1
+1 1 1 0 0 0 0 0 0 1 1 1
+1 1 0 0 0 0 0 0 0 0 1 1
+1 0 0 0 0 0 0 0 0 0 0 1
+1 0 0 0 0 0 0 0 0 0 0 1
+1 0 0 0 0 0 0 0 0 0 0 1
+1 0 0 0 0 0 0 0 0 0 0 1
+1 1 0 0 0 0 0 0 0 0 1 1
+1 1 1 0 0 0 0 0 0 1 1 1
+1 1 1 1 0 0 0 0 1 1 1 1"
+ "PBM data used for disabled breakpoint icon.")
+
+;; For seeing what above icon looks like:
+(if nil
+ (let ((image
+ (find-image `((:type pbm :data
+ ,realgud-bp-disabled-pbm-data
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ )
+
+
+
+(defconst realgud-bp-enabled-svg-data
+"<?xml version='1.0' standalone='no'?>
+<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN'
+ 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
+<svg width='10' height='10'>
+ <circle cx='0' cy='0' r='1' fill='none'/>
+ <circle cx='1' cy='0' r='1' fill='none'/>
+ <circle cx='2' cy='0' r='1' fill='none'/>
+ <circle cx='3' cy='0' r='1' fill='red'/>
+ <circle cx='4' cy='0' r='1' fill='red'/>
+ <circle cx='5' cy='0' r='1' fill='red'/>
+ <circle cx='6' cy='0' r='1' fill='red'/>
+ <circle cx='7' cy='0' r='1' fill='none'/>
+ <circle cx='8' cy='0' r='1' fill='none'/>
+ <circle cx='9' cy='0' r='1' fill='none'/>
+ <circle cx='0' cy='1' r='1' fill='none'/>
+ <circle cx='1' cy='1' r='1' fill='none'/>
+ <circle cx='2' cy='1' r='1' fill='red'/>
+ <circle cx='3' cy='1' r='1' fill='red'/>
+ <circle cx='4' cy='1' r='1' fill='red'/>
+ <circle cx='5' cy='1' r='1' fill='red'/>
+ <circle cx='6' cy='1' r='1' fill='red'/>
+ <circle cx='7' cy='1' r='1' fill='red'/>
+ <circle cx='8' cy='1' r='1' fill='none'/>
+ <circle cx='9' cy='1' r='1' fill='none'/>
+ <circle cx='0' cy='2' r='1' fill='none'/>
+ <circle cx='1' cy='2' r='1' fill='red'/>
+ <circle cx='2' cy='2' r='1' fill='red'/>
+ <circle cx='3' cy='2' r='1' fill='red'/>
+ <circle cx='4' cy='2' r='1' fill='red'/>
+ <circle cx='5' cy='2' r='1' fill='red'/>
+ <circle cx='6' cy='2' r='1' fill='red'/>
+ <circle cx='7' cy='2' r='1' fill='red'/>
+ <circle cx='8' cy='2' r='1' fill='red'/>
+ <circle cx='9' cy='2' r='1' fill='none'/>
+ <circle cx='0' cy='3' r='1' fill='red'/>
+ <circle cx='1' cy='3' r='1' fill='red'/>
+ <circle cx='2' cy='3' r='1' fill='red'/>
+ <circle cx='3' cy='3' r='1' fill='red'/>
+ <circle cx='4' cy='3' r='1' fill='red'/>
+ <circle cx='5' cy='3' r='1' fill='red'/>
+ <circle cx='6' cy='3' r='1' fill='red'/>
+ <circle cx='7' cy='3' r='1' fill='red'/>
+ <circle cx='8' cy='3' r='1' fill='red'/>
+ <circle cx='9' cy='3' r='1' fill='red'/>
+ <circle cx='0' cy='4' r='1' fill='red'/>
+ <circle cx='1' cy='4' r='1' fill='red'/>
+ <circle cx='2' cy='4' r='1' fill='red'/>
+ <circle cx='3' cy='4' r='1' fill='red'/>
+ <circle cx='4' cy='4' r='1' fill='red'/>
+ <circle cx='5' cy='4' r='1' fill='red'/>
+ <circle cx='6' cy='4' r='1' fill='red'/>
+ <circle cx='7' cy='4' r='1' fill='red'/>
+ <circle cx='8' cy='4' r='1' fill='red'/>
+ <circle cx='9' cy='4' r='1' fill='red'/>
+ <circle cx='0' cy='5' r='1' fill='red'/>
+ <circle cx='1' cy='5' r='1' fill='red'/>
+ <circle cx='2' cy='5' r='1' fill='red'/>
+ <circle cx='3' cy='5' r='1' fill='red'/>
+ <circle cx='4' cy='5' r='1' fill='red'/>
+ <circle cx='5' cy='5' r='1' fill='red'/>
+ <circle cx='6' cy='5' r='1' fill='red'/>
+ <circle cx='7' cy='5' r='1' fill='red'/>
+ <circle cx='8' cy='5' r='1' fill='red'/>
+ <circle cx='9' cy='5' r='1' fill='red'/>
+ <circle cx='0' cy='6' r='1' fill='red'/>
+ <circle cx='1' cy='6' r='1' fill='red'/>
+ <circle cx='2' cy='6' r='1' fill='red'/>
+ <circle cx='3' cy='6' r='1' fill='red'/>
+ <circle cx='4' cy='6' r='1' fill='red'/>
+ <circle cx='5' cy='6' r='1' fill='red'/>
+ <circle cx='6' cy='6' r='1' fill='red'/>
+ <circle cx='7' cy='6' r='1' fill='red'/>
+ <circle cx='8' cy='6' r='1' fill='red'/>
+ <circle cx='9' cy='6' r='1' fill='red'/>
+ <circle cx='0' cy='7' r='1' fill='none'/>
+ <circle cx='1' cy='7' r='1' fill='red'/>
+ <circle cx='2' cy='7' r='1' fill='red'/>
+ <circle cx='3' cy='7' r='1' fill='red'/>
+ <circle cx='4' cy='7' r='1' fill='red'/>
+ <circle cx='5' cy='7' r='1' fill='red'/>
+ <circle cx='6' cy='7' r='1' fill='red'/>
+ <circle cx='7' cy='7' r='1' fill='red'/>
+ <circle cx='8' cy='7' r='1' fill='red'/>
+ <circle cx='9' cy='7' r='1' fill='none'/>
+ <circle cx='0' cy='8' r='1' fill='none'/>
+ <circle cx='1' cy='8' r='1' fill='none'/>
+ <circle cx='2' cy='8' r='1' fill='red'/>
+ <circle cx='3' cy='8' r='1' fill='red'/>
+ <circle cx='4' cy='8' r='1' fill='red'/>
+ <circle cx='5' cy='8' r='1' fill='red'/>
+ <circle cx='6' cy='8' r='1' fill='red'/>
+ <circle cx='7' cy='8' r='1' fill='red'/>
+ <circle cx='8' cy='8' r='1' fill='none'/>
+ <circle cx='9' cy='8' r='1' fill='none'/>
+ <circle cx='0' cy='9' r='1' fill='none'/>
+ <circle cx='1' cy='9' r='1' fill='none'/>
+ <circle cx='2' cy='9' r='1' fill='none'/>
+ <circle cx='3' cy='9' r='1' fill='red'/>
+ <circle cx='4' cy='9' r='1' fill='red'/>
+ <circle cx='5' cy='9' r='1' fill='red'/>
+ <circle cx='6' cy='9' r='1' fill='red'/>
+ <circle cx='7' cy='9' r='1' fill='none'/>
+ <circle cx='8' cy='9' r='1' fill='none'/>
+ <circle cx='9' cy='9' r='1' fill='none'/>
+</svg>")
+
+;; For seeing what above icon looks like:
+(if nil
+ (let ((image
+ (find-image `((:type svg :data
+ ,realgud-bp-enabled-svg-data
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ )
+
+(defconst realgud-bp-disabled-svg-data
+"<?xml version='1.0' standalone='no'?>
+<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN'
+ 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
+<svg width='10' height='10'>
+ <circle cx='0' cy='0' r='1' fill='none'/>
+ <circle cx='1' cy='0' r='1' fill='none'/>
+ <circle cx='2' cy='0' r='1' fill='none'/>
+ <circle cx='3' cy='0' r='1' fill='gray'/>
+ <circle cx='4' cy='0' r='1' fill='gray'/>
+ <circle cx='5' cy='0' r='1' fill='gray'/>
+ <circle cx='6' cy='0' r='1' fill='gray'/>
+ <circle cx='7' cy='0' r='1' fill='none'/>
+ <circle cx='8' cy='0' r='1' fill='none'/>
+ <circle cx='9' cy='0' r='1' fill='none'/>
+ <circle cx='0' cy='1' r='1' fill='none'/>
+ <circle cx='1' cy='1' r='1' fill='none'/>
+ <circle cx='2' cy='1' r='1' fill='gray'/>
+ <circle cx='3' cy='1' r='1' fill='gray'/>
+ <circle cx='4' cy='1' r='1' fill='gray'/>
+ <circle cx='5' cy='1' r='1' fill='gray'/>
+ <circle cx='6' cy='1' r='1' fill='gray'/>
+ <circle cx='7' cy='1' r='1' fill='gray'/>
+ <circle cx='8' cy='1' r='1' fill='none'/>
+ <circle cx='9' cy='1' r='1' fill='none'/>
+ <circle cx='0' cy='2' r='1' fill='none'/>
+ <circle cx='1' cy='2' r='1' fill='gray'/>
+ <circle cx='2' cy='2' r='1' fill='gray'/>
+ <circle cx='3' cy='2' r='1' fill='gray'/>
+ <circle cx='4' cy='2' r='1' fill='gray'/>
+ <circle cx='5' cy='2' r='1' fill='gray'/>
+ <circle cx='6' cy='2' r='1' fill='gray'/>
+ <circle cx='7' cy='2' r='1' fill='gray'/>
+ <circle cx='8' cy='2' r='1' fill='gray'/>
+ <circle cx='9' cy='2' r='1' fill='none'/>
+ <circle cx='0' cy='3' r='1' fill='gray'/>
+ <circle cx='1' cy='3' r='1' fill='gray'/>
+ <circle cx='2' cy='3' r='1' fill='gray'/>
+ <circle cx='3' cy='3' r='1' fill='gray'/>
+ <circle cx='4' cy='3' r='1' fill='gray'/>
+ <circle cx='5' cy='3' r='1' fill='gray'/>
+ <circle cx='6' cy='3' r='1' fill='gray'/>
+ <circle cx='7' cy='3' r='1' fill='gray'/>
+ <circle cx='8' cy='3' r='1' fill='gray'/>
+ <circle cx='9' cy='3' r='1' fill='gray'/>
+ <circle cx='0' cy='4' r='1' fill='gray'/>
+ <circle cx='1' cy='4' r='1' fill='gray'/>
+ <circle cx='2' cy='4' r='1' fill='gray'/>
+ <circle cx='3' cy='4' r='1' fill='gray'/>
+ <circle cx='4' cy='4' r='1' fill='gray'/>
+ <circle cx='5' cy='4' r='1' fill='gray'/>
+ <circle cx='6' cy='4' r='1' fill='gray'/>
+ <circle cx='7' cy='4' r='1' fill='gray'/>
+ <circle cx='8' cy='4' r='1' fill='gray'/>
+ <circle cx='9' cy='4' r='1' fill='gray'/>
+ <circle cx='0' cy='5' r='1' fill='gray'/>
+ <circle cx='1' cy='5' r='1' fill='gray'/>
+ <circle cx='2' cy='5' r='1' fill='gray'/>
+ <circle cx='3' cy='5' r='1' fill='gray'/>
+ <circle cx='4' cy='5' r='1' fill='gray'/>
+ <circle cx='5' cy='5' r='1' fill='gray'/>
+ <circle cx='6' cy='5' r='1' fill='gray'/>
+ <circle cx='7' cy='5' r='1' fill='gray'/>
+ <circle cx='8' cy='5' r='1' fill='gray'/>
+ <circle cx='9' cy='5' r='1' fill='gray'/>
+ <circle cx='0' cy='6' r='1' fill='gray'/>
+ <circle cx='1' cy='6' r='1' fill='gray'/>
+ <circle cx='2' cy='6' r='1' fill='gray'/>
+ <circle cx='3' cy='6' r='1' fill='gray'/>
+ <circle cx='4' cy='6' r='1' fill='gray'/>
+ <circle cx='5' cy='6' r='1' fill='gray'/>
+ <circle cx='6' cy='6' r='1' fill='gray'/>
+ <circle cx='7' cy='6' r='1' fill='gray'/>
+ <circle cx='8' cy='6' r='1' fill='gray'/>
+ <circle cx='9' cy='6' r='1' fill='gray'/>
+ <circle cx='0' cy='7' r='1' fill='none'/>
+ <circle cx='1' cy='7' r='1' fill='gray'/>
+ <circle cx='2' cy='7' r='1' fill='gray'/>
+ <circle cx='3' cy='7' r='1' fill='gray'/>
+ <circle cx='4' cy='7' r='1' fill='gray'/>
+ <circle cx='5' cy='7' r='1' fill='gray'/>
+ <circle cx='6' cy='7' r='1' fill='gray'/>
+ <circle cx='7' cy='7' r='1' fill='gray'/>
+ <circle cx='8' cy='7' r='1' fill='gray'/>
+ <circle cx='9' cy='7' r='1' fill='none'/>
+ <circle cx='0' cy='8' r='1' fill='none'/>
+ <circle cx='1' cy='8' r='1' fill='none'/>
+ <circle cx='2' cy='8' r='1' fill='gray'/>
+ <circle cx='3' cy='8' r='1' fill='gray'/>
+ <circle cx='4' cy='8' r='1' fill='gray'/>
+ <circle cx='5' cy='8' r='1' fill='gray'/>
+ <circle cx='6' cy='8' r='1' fill='gray'/>
+ <circle cx='7' cy='8' r='1' fill='gray'/>
+ <circle cx='8' cy='8' r='1' fill='none'/>
+ <circle cx='9' cy='8' r='1' fill='none'/>
+ <circle cx='0' cy='9' r='1' fill='none'/>
+ <circle cx='1' cy='9' r='1' fill='none'/>
+ <circle cx='2' cy='9' r='1' fill='none'/>
+ <circle cx='3' cy='9' r='1' fill='gray'/>
+ <circle cx='4' cy='9' r='1' fill='gray'/>
+ <circle cx='5' cy='9' r='1' fill='gray'/>
+ <circle cx='6' cy='9' r='1' fill='gray'/>
+ <circle cx='7' cy='9' r='1' fill='none'/>
+ <circle cx='8' cy='9' r='1' fill='none'/>
+ <circle cx='9' cy='9' r='1' fill='none'/>
+</svg>")
+
+;; For seeing what above icon looks like:
+(if nil
+ (let ((image
+ (find-image `((:type svg :data
+ ,realgud-bp-disabled-svg-data
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ )
+
+(defconst realgud-bp-enabled-tiff-data
+"II* ( ����������@@@@������������������������BBBB��������������������@@@@��������������������������������BBBB������������������������������������������������BBBB����������������������������������������������������������������������������������������������������������������������������
[...]
+
+
+
& f
4 < ( ) > D ? T R /tmp/address@hidden@���(address@hidden@@address@hidden&address@hidden
@<
+� @"
+ "TIFF data used for breakpoint enabled icon.")
+
+;; For seeing what above icon looks like:
+(if nil
+ (let ((image
+ (find-image `((:type tiff :data
+ ,realgud-bp-enabled-tiff-data
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ )
+
+(defconst realgud-bp-disabled-tiff-data
+"II* � ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
+
+
+
� � � � � ( ) > � ? � R /tmp/address@hidden@���(address@hidden@@address@hidden&address@hidden
@<
+� @"
+ "TIFF data used for breakpoint disabled icon.")
+
+;; For seeing what above icon looks like:
+(if nil
+ (let ((image
+ (find-image `((:type tiff :data
+ ,realgud-bp-disabled-tiff-data
+ :ascent 100 :pointer hand)))))
+ (insert-image image)) ;; eval-last-sexp after previous ))
+ )
+
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/bp.el
b/packages/realgud/realgud/common/bp.el
new file mode 100644
index 0000000..7b9365f
--- /dev/null
+++ b/packages/realgud/realgud/common/bp.el
@@ -0,0 +1,180 @@
+;; Copyright (C) 2010, 2012-2015 Rocky Bernstein <address@hidden>
+;; Code associated with breakpoints
+
+(require 'image)
+(require 'load-relative)
+(require-relative-list '("loc" "bp-image-data") "realgud-")
+
+(defvar realgud-bp-enabled-icon nil
+ "Icon for an enabled breakpoint in display margin.")
+
+(defvar realgud-bp-disabled-icon nil
+ "Icon for a disabled breakpoint in display margin.")
+
+(defun realgud-bp-remove-icons (&optional opt-begin-pos opt-end-pos)
+ "Remove dbgr breakpoint icons (overlays) in the region
+OPT-BEGIN-POS to OPT-END-POS. The default value for OPT-BEGIN-POS
+is `point'. The default value for OPT-END-POS is OPT-BEGIN-POS.
+
+The way we determine if an overlay is ours is by inspecting the
+overlay for a before-string property containing one we normally set.
+"
+ (interactive "r")
+ (let* ((begin-pos (or opt-begin-pos (point)))
+ (end-pos (or opt-end-pos begin-pos))
+ )
+ (dolist (overlay (overlays-in begin-pos end-pos))
+ ;; We determine if this overlay is one we set by seeing if the
+ ;; string in its 'before-string property has a 'realgud-bptno property
+ (let ((before-string (overlay-get overlay 'before-string)))
+ (when (and before-string (get-text-property 0 'realgud-bptno
before-string))
+ (delete-overlay overlay)
+ )
+ )
+ )
+ )
+ )
+
+(defun realgud-set-bp-icons()
+ (if (display-images-p)
+ ;; NOTE: if you don't see the icon, check the that the window margin
+ ;; is not nil.
+ (progn
+ (setq realgud-bp-enabled-icon
+ (find-image `((:type xpm :data
+ ,realgud-bp-xpm-data
+ :ascent 100 :pointer hand)
+ (:type svg :data
+ ,realgud-bp-enabled-svg-data
+ :ascent 100 :pointer hand)
+ (:type tiff :data
+ ,realgud-bp-enabled-tiff-data
+ :ascent 100 :pointer hand)
+ (:type pbm :data
+ ,realgud-bp-enabled-pbm-data
+ :ascent 100 :pointer hand)
+ )))
+
+ ;; For seeing what realgud-bp-enabled-icon looks like:
+ ;; (insert-image realgud-bp-enabled-icon)
+
+ (setq realgud-bp-disabled-icon
+ (find-image `((:type xpm :data
+ ,realgud-bp-xpm-data
+ :conversion disabled ;; different than
'enabled'
+ :ascent 100 :pointer hand)
+ (:type svg :data
+ ,realgud-bp-disabled-svg-data
+ :ascent 100 :pointer hand)
+ (:type tiff :data
+ ,realgud-bp-disabled-tiff-data
+ :ascent 100 :pointer hand)
+ (:type pbm :data
+ ,realgud-bp-disabled-pbm-data
+ :ascent 100 :pointer hand)
+ (:type svg :data
+ ,realgud-bp-disabled-svg-data
+ :ascent 100 :pointer hand)
+ )))
+ ;; For seeing what realgud-bp-enabled-icon looks like:
+ ;; (insert-image realgud-bp-disabled-icon)
+ )
+ (message "Display doesn't support breakpoint images in fringe")
+ )
+ )
+
+
+(defun realgud-bp-put-icon (pos enabled bp-num &optional opt-buf)
+ "Add a breakpoint icon in the left margin at POS via a `put-image' overlay.
+The alternate string name for the image is created from the value
+of ENABLED and BP-NUM. In particular, if ENABLED is 't and
+BP-NUM is 5 the overlay string is be 'B5:' If ENABLED is false
+then the overlay string is 'b5:'. Breakpoint text properties are
+also attached to the icon via its display string."
+ (let ((enabled-str)
+ (buf (or opt-buf (current-buffer)))
+ (bp-num-str
+ (cond
+ ((or (not bp-num) (not (numberp bp-num))) ":")
+ ('t (format "%d:" bp-num))))
+ (brkpt-icon)
+ (bp-str)
+ (help-string "mouse-1: enable/disable bkpt")
+ )
+ (with-current-buffer buf
+ (unless realgud-bp-enabled-icon (realgud-set-bp-icons))
+ (if enabled
+ (progn
+ (setq enabled-str "B")
+ (setq brkpt-icon realgud-bp-enabled-icon)
+ )
+ (progn
+ (setq enabled-str "b")
+ (setq brkpt-icon realgud-bp-disabled-icon)
+ ))
+ ;; Create alternate display string and attach
+ ;; properties it.
+ (setq bp-str (concat enabled-str bp-num-str))
+ (add-text-properties
+ 0 1 `(realgud-bptno ,bp-num enabled ,enabled) bp-str)
+ (add-text-properties
+ 0 1 (list 'help-echo (format "%s %s" bp-str help-string))
+ bp-str)
+
+ ;; Display breakpoint icon or display string. If the window is
+ ;; nil, the image doesn't get displayed, so make sure it is large
+ ;; enough.
+ (let ((window (get-buffer-window (current-buffer) 0)))
+ (if window
+ (set-window-margins window 2)
+ ;; FIXME: This is all crap, but I don't know how to fix.
+ (let ((buffer-save (window-buffer (selected-window))))
+ (set-window-buffer (selected-window) (current-buffer))
+ (set-window-margins (selected-window) 2)
+ (set-window-buffer (selected-window) buffer-save))
+ ))
+ (realgud-bp-remove-icons pos)
+ (if brkpt-icon
+ (put-image brkpt-icon pos bp-str 'left-margin))
+ )
+ )
+ )
+
+(defun realgud-bp-del-icon (pos &optional opt-buf)
+ "Delete breakpoint icon in the left margin at POS via a `put-image' overlay.
+The alternate string name for the image is created from the value
+of ENABLED and BP-NUM. In particular, if ENABLED is 't and
+BP-NUM is 5 the overlay string is be 'B5:' If ENABLED is false
+then the overlay string is 'b5:'. Breakpoint text properties are
+also attached to the icon via its display string."
+ (let ((buf (or opt-buf (current-buffer))))
+ (with-current-buffer buf
+ (realgud-bp-remove-icons pos)
+ )
+ )
+)
+
+(defun realgud-bp-add-info (loc)
+ "Record bp information for location LOC."
+ (if (realgud-loc? loc)
+ (let* ((marker (realgud-loc-marker loc))
+ (bp-num (realgud-loc-num loc))
+ )
+ (realgud-bp-put-icon marker 't bp-num)
+ )
+ )
+)
+
+(defun realgud-bp-del-info (loc)
+ "Remove bp information for location LOC."
+ (if (realgud-loc? loc)
+ (let* ((marker (realgud-loc-marker loc))
+ (bp-num (realgud-loc-num loc))
+ )
+ (realgud-bp-del-icon marker)
+ )
+ )
+)
+
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/buffer/Makefile.am
b/packages/realgud/realgud/common/buffer/Makefile.am
new file mode 100644
index 0000000..b881b44
--- /dev/null
+++ b/packages/realgud/realgud/common/buffer/Makefile.am
@@ -0,0 +1,3 @@
+include $(top_srcdir)/common.mk
+
+lispdir = @lispdir_realgud@/common/buffer
diff --git a/packages/realgud/realgud/common/buffer/backtrace.el
b/packages/realgud/realgud/common/buffer/backtrace.el
new file mode 100644
index 0000000..a46c65e
--- /dev/null
+++ b/packages/realgud/realgud/common/buffer/backtrace.el
@@ -0,0 +1,480 @@
+;;; Backtrace buffer
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see
+;; <http://www.gnu.org/licenses/>.
+
+(require 'ansi-color)
+(require 'ring)
+(require 'load-relative)
+(eval-when-compile (require 'cl-lib))
+(require-relative-list
+ '("../key" "helper" "../follow" "../loc") "realgud-")
+
+(require-relative-list
+ '("command") "realgud-buffer-")
+
+(declare-function realgud-cmdbuf-debugger-name 'realgud-buffer-command)
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud-backtrace-mode (cmdbuf))
+(declare-function realgud:cmd-backtrace (arg))
+(declare-function realgud-cmdbuf-pat(key))
+(declare-function realgud-cmdbuf-info-in-srcbuf?= (arg))
+(declare-function realgud-get-cmdbuf 'realgud-buffer-helper)
+(declare-function realgud:file-loc-from-line 'realgud-file)
+(declare-function realgud:loc-describe 'realgud-loc)
+
+(defstruct realgud-backtrace-info
+ "debugger object/structure specific to a (top-level) program to be debugged."
+ (cmdbuf nil) ;; buffer of the associated debugger process
+ (cur-pos 0) ;; Frame we are at
+ frame-ring ;; ring of marks in buffer of frame numbers. The
+ ;; text at that marker has additional properties about the
+ ;; frame
+)
+
+(declare-function realgud:cmd-frame 'realgud-buffer-command)
+(declare-function realgud-get-cmdbuf(&optional opt-buffer))
+(declare-function realgud-command 'realgud-send)
+
+(make-variable-buffer-local (defvar realgud-backtrace-info))
+
+;: FIXME: not picked up from track. Why?
+(defvar realgud-track-divert-string nil)
+
+(defvar realgud-goto-entry-acc "")
+
+(defun realgud-get-buffer-base-name(string)
+ "Leading and ending * in string. For example:
+ *shell<2>* -> shell<2>
+ *foo shell* -> foo
+ buffer.c -> buffer.c"
+ (if (string-match "^[*]?\\([^*]+\\)[*]?$" string)
+ (let ((string-sans-stars (match-string 1 string)))
+ (if (string-match "\\(.+\\) shell" string-sans-stars)
+ (match-string 1 string-sans-stars)
+ string-sans-stars)
+ )
+ string
+ )
+)
+
+(defun realgud:backtrace-describe (&optional buffer)
+ (interactive "")
+ (unless buffer (setq buffer (current-buffer)))
+ (with-current-buffer buffer
+ (let ((frames (realgud-backtrace-info-frame-ring realgud-backtrace-info))
+ (frame)
+ (loc)
+ (i 0))
+ (switch-to-buffer (get-buffer-create "*Describe*"))
+ (while (and (< i (ring-length frames)) (setq frame (ring-ref frames i)))
+ (insert (format "*** %d\n" i))
+ (insert (format "%s\n" frame))
+ (when (markerp frame)
+ (with-current-buffer (marker-buffer frame)
+ (goto-char frame)
+ (setq loc (get-text-property (point) 'loc))
+ )
+ (when loc (realgud:loc-describe loc)))
+ (setq i (1+ i))
+ )
+ )
+ ))
+
+;; FIXME: create this in a new frame.
+(defun realgud:backtrace-init ()
+ (interactive)
+ (let ((buffer (current-buffer))
+ (cmdbuf (realgud-get-cmdbuf))
+ (process)
+ )
+ (with-current-buffer-safe cmdbuf
+ (let ((frame-pat (realgud-cmdbuf-pat "debugger-backtrace"))
+ (indicator-re (or (realgud-cmdbuf-pat "selected-frame-indicator")
+ "->"))
+ (selected-frame-num)
+ (frame-pos-ring)
+ (sleep-count 0)
+ )
+ (unless frame-pat
+ (error "No 'debugger-backtrace' regular expression recorded for
debugger %s"
+ (realgud-cmdbuf-debugger-name)))
+ (setq process (get-buffer-process (current-buffer)))
+ (realgud-cmdbuf-info-in-srcbuf?= (not (realgud-cmdbuf? buffer)))
+ (realgud-cmdbuf-info-divert-output?= 't)
+ (setq realgud-track-divert-string nil)
+ (realgud:cmd-backtrace 0)
+ (while (and (eq 'run (process-status process))
+ (null realgud-track-divert-string)
+ (> 1000 (setq sleep-count (1+ sleep-count))))
+ (sleep-for 0.001)
+ )
+ (if (>= sleep-count 1000)
+ (message "Timeout on running debugger command")
+ ;; else
+ ;; (message "+++4 %s" realgud-track-divert-string)
+ (let ((bt-buffer (get-buffer-create
+ (format "*Backtrace %s*"
+ (realgud-get-buffer-base-name
+ (buffer-name)))))
+ (divert-string realgud-track-divert-string)
+ )
+ (realgud-cmdbuf-info-bt-buf= bt-buffer)
+ (with-current-buffer bt-buffer
+ (setq buffer-read-only nil)
+ (delete-region (point-min) (point-max))
+ (if divert-string
+ (let* ((triple
+ (realgud:backtrace-add-text-properties
+ frame-pat cmdbuf divert-string indicator-re))
+ (string-with-props
+ (ansi-color-filter-apply (car triple)))
+ (frame-num-pos-list (caddr triple))
+ )
+ (setq selected-frame-num (cadr triple))
+ (insert string-with-props)
+ ;; add marks for each position
+ (realgud-backtrace-mode cmdbuf)
+ (setq frame-pos-ring
+ (make-ring (length frame-num-pos-list)))
+ (dolist (pos frame-num-pos-list)
+ (goto-char (1+ pos))
+ (ring-insert-at-beginning frame-pos-ring (point-marker))
+ )
+ )
+ )
+ ;; realgud-backtrace-mode kills all local variables so
+ ;; we set this after. Alternatively change realgud-backtrace-mode.
+ (set (make-local-variable 'realgud-backtrace-info)
+ (make-realgud-backtrace-info
+ :cmdbuf cmdbuf
+ :frame-ring frame-pos-ring
+ ))
+ (if selected-frame-num
+ (realgud-backtrace-moveto-frame selected-frame-num))
+ )
+ )
+ )
+ )
+ )
+ (unless cmdbuf
+ (message "Unable to find debugger command buffer for %s" buffer))
+ )
+ )
+
+(defun realgud-backtrace? ( &optional buffer)
+ "Return true if BUFFER is a debugger command buffer."
+ (with-current-buffer-safe
+ (or buffer (current-buffer))
+ (realgud-backtrace-info-set?)))
+
+
+(defalias 'realgud-backtrace-info? 'realgud-backtrace-info-p)
+
+(defun realgud-backtrace-info-set? ()
+ "Return true if realgud-backtrace-info is set."
+ (and (boundp 'realgud-backtrace-info)
+ realgud-backtrace-info
+ (realgud-backtrace-info? realgud-backtrace-info)))
+
+
+(defun realgud-backtrace-moveto-frame-selected ()
+ "Set point to the selected frame."
+ (interactive)
+ (if (realgud-backtrace?)
+ (let* ((cur-pos (realgud-sget 'backtrace-info 'cur-pos))
+ (ring-size (ring-size (realgud-sget 'backtrace-info 'frame-ring)))
+ )
+ (if (and cur-pos (> ring-size 0))
+ (realgud-backtrace-moveto-frame cur-pos)
+ ;else
+ (message "No frame information recorded")
+ )
+ )
+ )
+ )
+
+(defun realgud-backtrace-moveto-frame (num &optional opt-buffer)
+ (if (integerp num)
+ (if (realgud-backtrace?)
+ (let* ((ring (realgud-sget 'backtrace-info 'frame-ring))
+ (marker (ring-ref ring num)))
+ (setf (realgud-backtrace-info-cur-pos realgud-backtrace-info) num)
+ (goto-char marker)
+ )
+ )
+ ; else
+ (message "frame number %s is not an integer" num)
+ )
+ )
+
+(defun realgud-backtrace-moveto-frame-next ()
+ "Set point to the next frame. If we are at the end, wrap to the
+beginning. Note that we are just moving in the backtrace buffer,
+not updating the frame stack."
+ (interactive)
+ (if (realgud-backtrace?)
+ (let* ((cur-pos (realgud-sget 'backtrace-info 'cur-pos))
+ (ring-size (ring-size (realgud-sget 'backtrace-info 'frame-ring)))
+ )
+ (if (and cur-pos (> ring-size 0))
+ (realgud-backtrace-moveto-frame (ring-plus1 cur-pos ring-size))
+ ;else
+ (message "No frame information recorded")
+ )
+ )
+ )
+ )
+
+(defun realgud-backtrace-moveto-frame-prev ()
+ "Set point to the next frame. If we are at the beginning, wrap to the
+end. Note that we are just moving in the backtrace buffer,
+not updating the frame stack."
+ (interactive)
+ (if (realgud-backtrace?)
+ (let* ((cur-pos (realgud-sget 'backtrace-info 'cur-pos))
+ (ring-size (ring-size (realgud-sget 'backtrace-info 'frame-ring)))
+ )
+ (if (and cur-pos (> ring-size 0))
+ (realgud-backtrace-moveto-frame (ring-minus1 cur-pos ring-size))
+ ;else
+ (message "No frame information recorded")
+ )
+ )
+ )
+ )
+
+(defun realgud-goto-frame-n-internal (keys)
+ (if (and (stringp keys)
+ (= (length keys) 1))
+ (progn
+ (setq realgud-goto-entry-acc (concat realgud-goto-entry-acc keys))
+ ;; Try to find the longest suffix.
+ (let ((acc realgud-goto-entry-acc))
+ (while (not (string= acc ""))
+ (if (not (realgud-goto-entry-try acc))
+ (setq acc (substring acc 1))
+ (realgud:cmd-frame (string-to-number acc))
+ ;; Break loop.
+ (setq acc "")))))
+ (message "`realgud-goto-frame-n' must be bound to a number key")))
+
+;; FIXME: replace with ring.
+(defun realgud-goto-entry-try (str)
+ "See if there is an entry with number STR. If not return nil."
+ (goto-char (point-min))
+ (if (re-search-forward (concat "^[^0-9]*\\(" str "\\)[^0-9]") nil t)
+ (progn
+ (goto-char (match-end 1))
+ t)
+ nil))
+
+
+;; The following is split in two to facilitate debugging.
+(defun realgud-goto-entry-n-internal (keys)
+ (if (and (stringp keys)
+ (= (length keys) 1))
+ (progn
+ (setq realgud-goto-entry-acc (concat realgud-goto-entry-acc keys))
+ ;; Try to find the longest suffix.
+ (let ((acc realgud-goto-entry-acc)
+ (p (point)))
+ (while (not (string= acc ""))
+ (if (not (realgud-goto-entry-try acc))
+ (setq acc (substring acc 1))
+ (setq p (point))
+ ;; Break loop.
+ (setq acc "")))
+ (goto-char p)))
+ (message "`realgud-goto-entry-n' must be bound to a number key")))
+
+
+(defun realgud-goto-entry-n ()
+ "Go to an entry number.
+
+Breakpoints, Display expressions and Stack Frames all have
+numbers associated with them which are distinct from line
+numbers. In a secondary buffer, this function is usually bound to
+a numeric key which will position you at that entry number. To
+go to an entry above 9, just keep entering the number. For
+example, if you press 1 and then 9, you should jump to entry
+1 (if it exists) and then 19 (if that exists). Entering any
+non-digit will start entry number from the beginning again."
+ (interactive)
+ (if (not (eq last-command 'realgud-goto-entry-n))
+ (setq realgud-goto-entry-acc ""))
+ (realgud-goto-entry-n-internal (this-command-keys)))
+
+(defun realgud-goto-frame ()
+ "Go to the frame number. We get the frame number from the
+'frame-num property"
+ (interactive)
+ (if (realgud-backtrace?)
+ (let ((frame-num (get-text-property (point) 'frame-num)))
+ (if frame-num
+ (realgud:cmd-frame frame-num)
+ (message "No frame property found at this point")
+ )
+ )
+ )
+ )
+
+(defun realgud-goto-frame-1 ()
+ "Go to the frame 1"
+ (interactive)
+ (if (realgud-backtrace?)
+ (realgud:cmd-frame 1)
+ )
+ )
+
+(defun realgud-goto-frame-2 ()
+ "Go to the frame 2"
+ (interactive)
+ (if (realgud-backtrace?)
+ (realgud:cmd-frame 2)
+ )
+ )
+
+(defun realgud-goto-frame-3 ()
+ "Go to the frame 3"
+ (interactive)
+ (if (realgud-backtrace?)
+ (realgud:cmd-frame 3)
+ )
+ )
+
+(defun realgud-goto-frame-mouse (event)
+ (interactive "e")
+ (let* ((pos (posn-point (event-end event)))
+ (frame-num (get-text-property pos 'frame-num)))
+ (if (realgud-backtrace?)
+ (if frame-num
+ (realgud:cmd-frame frame-num)
+ (message "No frame property found at this point")
+ )
+ )
+ )
+)
+
+(defun realgud-goto-frame-n ()
+ "Go to the frame number indicated by the accumulated numeric keys just
entered.
+
+This function is usually bound to a numeric key in a 'frame'
+secondary buffer. To go to an entry above 9, just keep entering
+the number. For example, if you press 1 and then 9, frame 1 is selected
+\(if it exists) and then frame 19 (if that exists). Entering any
+non-digit will start entry number from the beginning again."
+ (interactive)
+ (if (not (eq last-command 'realgud-goto-frame-n))
+ (setq realgud-goto-entry-acc ""))
+ (realgud-goto-frame-n-internal (this-command-keys)))
+
+(defun realgud:backtrace-add-text-properties(frame-pat cmdbuf &optional
opt-string
+ frame-indicator-re)
+ "Parse OPT-STRING or the current buffer and add frame properties: frame
number,
+filename, line number, whether the frame is selected as text properties."
+
+ (let* ((string (or opt-string
+ (buffer-substring (point-min) (point-max))
+ ))
+ (stripped-string (ansi-color-filter-apply string))
+ (frame-regexp (realgud-loc-pat-regexp frame-pat))
+ (frame-group-pat (realgud-loc-pat-num frame-pat))
+ (file-group-pat (realgud-loc-pat-file-group frame-pat))
+ (line-group-pat (realgud-loc-pat-line-group frame-pat))
+ (alt-frame-num -1)
+ (last-pos 0)
+ (selected-frame-num nil)
+ (frame-num-pos-list '())
+ )
+ (while (string-match frame-regexp stripped-string last-pos)
+ (let ((frame-num-str) (frame-num) (line-num) (filename)
+ ;; FIXME: Remove hack that group 1 is always the frame indicator.
+ (frame-indicator
+ (substring stripped-string (match-beginning 1) (match-end 1)))
+ (frame-num-pos)
+
+ )
+ (if frame-group-pat
+ (progn
+ (setq frame-num-str
+ (substring stripped-string
+ (match-beginning frame-group-pat)
+ (match-end frame-group-pat)))
+ (setq frame-num (string-to-number frame-num-str))
+ (setq frame-num-pos (match-beginning frame-group-pat))
+ (add-to-list 'frame-num-pos-list frame-num-pos 't)
+ (add-text-properties (match-beginning frame-group-pat)
+ (match-end frame-group-pat)
+ (list 'mouse-face 'highlight
+ 'help-echo "mouse-2: goto this frame"
+ 'frame frame-num)
+ string)
+ )
+ ; else
+ (progn
+ (setq frame-num-str
+ (substring stripped-string (match-beginning 0)
+ (match-end 0)))
+ (setq frame-num (incf alt-frame-num))
+ (setq frame-num-pos (match-beginning 0))
+ (add-to-list 'frame-num-pos-list frame-num-pos 't)
+ (add-text-properties (match-beginning 0) (match-end 0)
+ (list 'mouse-face 'highlight
+ 'help-echo "mouse-2: goto this frame"
+ 'frame frame-num)
+ string)
+ )
+ )
+ (when file-group-pat
+ (setq filename (substring stripped-string
+ (match-beginning file-group-pat)
+ (match-end file-group-pat)))
+ (add-text-properties (match-beginning file-group-pat)
+ (match-end file-group-pat)
+ (list 'mouse-face 'highlight
+ 'help-echo "mouse-2: goto this file"
+ 'action 'realgud:follow-event
+ 'file filename)
+ string)
+ )
+ (when line-group-pat
+ (let ((line-num-str (substring stripped-string
+ (match-beginning line-group-pat)
+ (match-end line-group-pat))))
+ (setq line-num (string-to-number (or line-num-str "1")))
+ ))
+
+ (when (and (stringp filename) (numberp line-num))
+ (let ((loc (realgud:file-loc-from-line filename line-num cmdbuf)))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'loc loc string)
+ ))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'frame-num frame-num string)
+ (setq last-pos (match-end 0))
+
+ (if (string-match frame-indicator-re frame-indicator)
+ (setq selected-frame-num frame-num))
+ ))
+
+ (list string selected-frame-num frame-num-pos-list)
+ )
+ )
+
+(provide-me "realgud-buffer-")
diff --git a/packages/realgud/realgud/common/buffer/command.el
b/packages/realgud/realgud/common/buffer/command.el
new file mode 100644
index 0000000..913c68e
--- /dev/null
+++ b/packages/realgud/realgud/common/buffer/command.el
@@ -0,0 +1,391 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; process-command buffer things
+
+(require 'load-relative)
+(require 'json)
+(require-relative-list
+ '("../fringe" "../loc" "../lochist" "../regexp") "realgud-")
+(require-relative-list '("info") "realgud-buffer-")
+
+(declare-function realgud-get-cmdbuf 'realgud-buffer-helper)
+
+(eval-when-compile
+ (byte-compile-disable-warning 'cl-functions)
+ ;; Somehow disabling cl-functions causes the erroneous message:
+ ;; Warning: the function `reduce' might not be defined at runtime.
+ ;; FIXME: isolate, fix and/or report back to Emacs developers a bug
+ (byte-compile-disable-warning 'unresolved)
+ (defvar realgud-cmdbuf-info)
+ )
+(require 'cl-lib)
+
+(defface debugger-running
+ '((((class color) (min-colors 16) (background light))
+ (:foreground "Green4" :weight bold))
+ (((class color) (min-colors 88) (background dark))
+ (:foreground "Green1" :weight bold))
+ (((class color) (min-colors 16) (background dark))
+ (:foreground "Green" :weight bold))
+ (((class color)) (:foreground "green" :weight bold))
+ (t (:weight bold)))
+ "Face used to highlight debugger run information."
+ :group 'realgud
+ :version "24.3")
+
+(defface debugger-not-running
+ '((t :inherit font-lock-warning-face))
+ "Face used when debugger or process is not running."
+ :group 'realgud
+ :version "24.3")
+
+
+(defstruct realgud-cmdbuf-info
+ "The debugger object/structure specific to a process buffer."
+ debugger-name ;; Name of debugger
+ base-variable-name ;; prefix used in variables pertinent to this
+ ;; debugger sometimes it is the same as the debugger
+ ;; and sometimes it is different
+ cmd-args ;; Command-line invocation arguments
+ frame-switch? ;; Should the selected window be the source buffer or
+ ;; command buffer?
+ in-srcbuf? ;; If true, selected window should be the source buffer.
+ ;; Otherwise, the command buffer?
+ last-input-end ;; point where input last ended. Set from
+ ;; comint-last-input-end
+ prior-prompt-regexp ;; regular expression prompt (e.g.
+ ;; comint-prompt-regexp) *before* setting
+ ;; loc-regexp
+ no-record? ;; Should we update the location history?
+ in-debugger? ;; True if we think we are in a debugger
+ src-shortkey? ;; Are source buffers in realgud-short-key mode?
+ regexp-hash ;; hash table of regular expressions appropriate for
+ ;; this debugger. Eventually loc-regexp, file-group
+ ;; and line-group below will removed and stored here.
+ srcbuf-list ;; list of source buffers we have stopped at
+ bt-buf ;; backtrace buffer if it exists
+ bp-list ;; list of breakpoints
+ divert-output? ;; Output is part of a conversation between front-end
+ ;; debugger.
+ cmd-hash ;; Allows us to remap command names like
+ ;; quit => quit!
+ callback-loc-fn ;; If we need, as in the case of Java, to do
+ ;; special handling to map output to a file
+ ;; location, this is set to that special
+ ;; function
+ callback-eval-filter ;; If set, this function strip extraneous output
+ ;; when evaluating an expression. For example,
+ ;; some trepan debuggers expression values prefaced
with:
+ ;; $DB::D[0] =
+
+ ;; FIXME: REMOVE THIS and use regexp-hash
+ loc-regexp ;; Location regular expression string
+ file-group
+ line-group
+ alt-file-group
+ alt-line-group
+ text-group
+ ignore-file-re
+
+ loc-hist ;; ring of locations seen in the course of execution
+ ;; see realgud-lochist
+)
+(make-variable-buffer-local 'realgud-cmdbuf-info)
+(make-variable-buffer-local 'realgud-last-output-start)
+
+(defalias 'realgud-cmdbuf-info? 'realgud-cmdbuf-info-p)
+
+;; FIXME: figure out how to put in a loop.
+(realgud-struct-field-setter "realgud-cmdbuf-info" "bp-list")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "bt-buf")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "cmd-args")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "last-input-end")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "divert-output?")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "frame-switch?")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "in-srcbuf?")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "no-record?")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "prior-prompt-regexp")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "src-shortkey?")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "in-debugger?")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "callback-loc-fn")
+(realgud-struct-field-setter "realgud-cmdbuf-info" "callback-eval-filter")
+
+(defun realgud:cmdbuf-follow-buffer(event)
+ (interactive "e")
+ (let* ((pos (posn-point (event-end event)))
+ (buffer (get-text-property pos 'buffer)))
+ (find-file-other-window (buffer-file-name buffer))))
+
+(defun realgud:cmdbuf-buffers-describe (buffer-list)
+ (insert "** Source Buffers Seen\n")
+ (dolist (buffer buffer-list)
+ (insert " - ")
+ (put-text-property
+ (insert-text-button
+ (buffer-name buffer)
+ 'action 'realgud:cmdbuf-follow-buffer
+ 'help-echo "mouse-2: visit this file")
+ (point)
+ 'buffer buffer)
+ (insert "\n")
+ ))
+
+(defun realgud:cmdbuf-info-describe (&optional buffer)
+ "Display realgud-cmdcbuf-info fields of BUFFER.
+BUFFER is either a debugger command or source buffer. If BUFFER is not given
+the current buffer is used as a starting point.
+Information is put in an internal buffer called *Describe*."
+ (interactive "")
+ (setq buffer (realgud-get-cmdbuf buffer))
+ (if buffer
+ (with-current-buffer buffer
+ (let ((info realgud-cmdbuf-info)
+ (cmdbuf-name (buffer-name)))
+ (switch-to-buffer (get-buffer-create "*Describe*"))
+ (setq buffer-read-only 'nil)
+ (delete-region (point-min) (point-max))
+ (insert "#+STARTUP: showall\n")
+ ;;(insert "#+OPTIONS: H:2 num:nil toc:t \\n:nil ::t |:t ^:nil -:t
f:t *:t tex:t d:(HIDE) tags:not-in-toc\n")
+ (insert (format "#+TITLE: Debugger info for %s\n" cmdbuf-name))
+ (insert "** General Information\n")
+ (mapc 'insert
+ (list
+ (format " - Debugger name ::\t%s\n"
+ (json-encode (realgud-cmdbuf-info-debugger-name info)))
+ (format " - Command-line args ::\t%s\n"
+ (json-encode (realgud-cmdbuf-info-cmd-args info)))
+ (format " - Selected window should contain source? :: %s\n"
+ (realgud-cmdbuf-info-in-srcbuf? info))
+ (format " - Last input end ::\t%s\n"
+ (realgud-cmdbuf-info-last-input-end info))
+ (format " - Source should go into short-key mode? :: %s\n"
+ (realgud-cmdbuf-info-src-shortkey? info))
+ (format " - Breakpoint list ::\t %s\n"
+ (realgud-cmdbuf-info-bp-list info))
+ (format " - Remap table for debugger commands ::\n\t%s\n"
+ (json-encode (realgud-cmdbuf-info-cmd-hash info)))
+ (format " - Backtrace buffer ::\t%s\n"
+ (realgud-cmdbuf-info-bt-buf info))
+ (format " - In debugger? ::\t%s\n"
+ (realgud-cmdbuf-info-in-debugger? info))
+ ))
+ (insert "\n")
+ (realgud:cmdbuf-buffers-describe (realgud-cmdbuf-info-srcbuf-list
info))
+ (insert "\n")
+ (realgud:loc-hist-describe (realgud-cmdbuf-info-loc-hist info))
+ (goto-char (point-min))
+ (realgud:info-mode)
+ )
+ )
+ (message "Buffer %s is not a debugger source or command buffer; nothing
done."
+ (or buffer (current-buffer)))
+ )
+ )
+
+(defun realgud-cmdbuf? (&optional buffer)
+ "Return true if BUFFER is a debugger command buffer."
+ (with-current-buffer-safe
+ (or buffer (current-buffer))
+ (realgud-cmdbuf-info-set?)))
+
+(defun realgud-cmdbuf-info-set? ()
+ "Return true if realgud-cmdbuf-info is set."
+ (and (boundp 'realgud-cmdbuf-info)
+ realgud-cmdbuf-info
+ (realgud-cmdbuf-info? realgud-cmdbuf-info)))
+
+(defun realgud-cmdbuf-toggle-in-debugger? (&optional buffer)
+ "Toggle state of whether we think we are in the debugger or not"
+ (interactive "")
+ (setq buffer (realgud-get-cmdbuf buffer))
+ (if buffer
+ (with-current-buffer buffer
+ (realgud-cmdbuf-info-in-debugger?=
+ (not (realgud-sget 'cmdbuf-info 'in-debugger?)))
+ (message "Command buffer is in debugger?: %s\n"
+ (realgud-cmdbuf-info-in-debugger? realgud-cmdbuf-info))
+ (realgud-cmdbuf-mode-line-update)
+ )
+ (message "Buffer %s is not a debugger buffer; nothing done."
+ (or buffer (current-buffer)))
+ )
+ )
+
+(defun realgud-cmdbuf-stay-in-source-toggle (&optional buffer)
+ "Toggle state of whether we should stay in source code or not"
+ (interactive "")
+ (setq buffer (realgud-get-cmdbuf buffer))
+ (if buffer
+ (with-current-buffer buffer
+ (realgud-cmdbuf-info-in-srcbuf?=
+ (not (realgud-sget 'cmdbuf-info 'in-srcbuf?)))
+ (message "Selected window should contain source?: %s\n"
+ (realgud-cmdbuf-info-in-srcbuf? realgud-cmdbuf-info))
+ )
+ (message "Buffer %s is not a debugger buffer; nothing done."
+ (or buffer (current-buffer)))
+ )
+ )
+
+(defun realgud-cmdbuf-add-srcbuf(srcbuf &optional cmdbuf)
+ "Add SRCBUF to srcbuf-list field of INFO unless it is already included."
+ (setq cmdbuf (or cmdbuf (current-buffer)))
+ (if (realgud-cmdbuf? cmdbuf)
+ (with-current-buffer-safe cmdbuf
+ (unless (memq srcbuf (realgud-cmdbuf-info-srcbuf-list
realgud-cmdbuf-info))
+ (setf (realgud-cmdbuf-info-srcbuf-list realgud-cmdbuf-info)
+ (cons srcbuf (realgud-cmdbuf-info-srcbuf-list
realgud-cmdbuf-info))))
+ )
+ )
+ )
+
+(defun realgud-cmdbuf-set-shortkey(&optional cmdbuf unset)
+ (interactive "")
+ (setq cmdbuf (or cmdbuf (current-buffer)))
+ (if (realgud-cmdbuf? cmdbuf)
+ (with-current-buffer-safe cmdbuf
+ (setf (realgud-cmdbuf-info-src-shortkey? realgud-cmdbuf-info) (not
unset))
+ (message "Set source to shortkey is now %s" (not unset))
+ ))
+ )
+
+(defun realgud-cmdbuf-command-string(cmd-buffer)
+ "Get the command string invocation for this command buffer"
+ (cond
+ ((realgud-cmdbuf? cmd-buffer)
+ (with-current-buffer cmd-buffer
+ (let*
+ ((cmd-args (realgud-sget 'cmdbuf-info 'cmd-args))
+ (result (car cmd-args)))
+ (and cmd-args
+ (reduce (lambda(result x)
+ (setq result (concat result " " x)))
+ cmd-args)))))
+ (t nil)))
+
+;; FIXME cmd-hash should not be optional. And while I am at it, remove
+;; parameters loc-regexp, file-group, and line-group which can be found
+;; inside pat-hash
+;;
+;; To do this however we need to fix up the caller
+;; realgud:track-set-debugger by changing realgud-pat-hash to store a hash
+;; rather than the loc, file, and line fields; those fields then get
+;; removed.
+
+(defun realgud-cmdbuf-init
+ (cmd-buf debugger-name regexp-hash &optional cmd-hash base-variable-name)
+ "Initialize CMD-BUF for a working with a debugger.
+DEBUGGER-NAME is the name of the debugger; REGEXP-HASH are debugger-specific
+values set in the debugger's init.el."
+ (with-current-buffer-safe cmd-buf
+ (let ((realgud-loc-pat (gethash "loc" regexp-hash))
+ (font-lock-keywords)
+ )
+ (setq realgud-cmdbuf-info
+ (make-realgud-cmdbuf-info
+ :in-srcbuf? nil
+ :debugger-name debugger-name
+ :base-variable-name (or base-variable-name debugger-name)
+ :loc-regexp (realgud-sget 'loc-pat 'regexp)
+ :file-group (realgud-sget 'loc-pat 'file-group)
+ :line-group (realgud-sget 'loc-pat 'line-group)
+ :alt-file-group (realgud-sget 'loc-pat 'alt-file-group)
+ :alt-line-group (realgud-sget 'loc-pat 'alt-line-group)
+ :text-group (realgud-sget 'loc-pat 'text-group)
+ :ignore-file-re (realgud-sget 'loc-pat 'ignore-file-re)
+ :loc-hist (make-realgud-loc-hist)
+ :regexp-hash regexp-hash
+ :bt-buf nil
+ :last-input-end (point-max)
+ :cmd-hash cmd-hash
+ :src-shortkey? 't
+ :in-debugger? nil
+ :callback-loc-fn (gethash "loc-callback-fn" regexp-hash)
+ :callback-eval-filter (gethash "callback-eval-filter"
+ regexp-hash)
+ ))
+ (setq font-lock-keywords (realgud-cmdbuf-pat "font-lock-keywords"))
+ (if font-lock-keywords
+ (set (make-local-variable 'font-lock-defaults)
+ (list font-lock-keywords)))
+ )
+
+ (put 'realgud-cmdbuf-info 'variable-documentation
+ "Debugger object for a process buffer."))
+ )
+
+(defun realgud-cmdbuf-debugger-name (&optional cmd-buf)
+ "Return the debugger name recorded in the debugger command-process buffer."
+ (with-current-buffer-safe (or cmd-buf (current-buffer))
+ (if (realgud-cmdbuf?)
+ (realgud-sget 'cmdbuf-info 'debugger-name)
+ nil))
+ )
+
+(defun realgud-cmdbuf-pat(key)
+ "Extract regexp stored under KEY in a realgud-cmdbuf via realgud-cmdbuf-info"
+ (if (realgud-cmdbuf?)
+ (let*
+ ((debugger-name (realgud-cmdbuf-debugger-name))
+ (regexp-hash (gethash debugger-name realgud-pat-hash))
+ (loc-pat (gethash key regexp-hash)))
+ loc-pat)
+ nil))
+
+(defun realgud-cmdbuf-loc-hist(cmd-buf)
+ "Return the history ring of locations that a debugger
+command-process buffer has stored."
+ (with-current-buffer-safe cmd-buf
+ (realgud-sget 'cmdbuf-info 'loc-hist))
+)
+
+(defun realgud-cmdbuf-src-marker(cmd-buf)
+ "Return a marker to current source location stored in the history ring."
+ (with-current-buffer cmd-buf
+ (lexical-let* ((loc (realgud-loc-hist-item (realgud-cmdbuf-loc-hist
cmd-buf))))
+ (and loc (realgud-loc-marker loc)))))
+
+(defun realgud-cmdbuf-mode-line-update (&optional opt-cmdbuf)
+ "Force update of command buffer to include process status"
+ (let ((cmdbuf (realgud-get-cmdbuf opt-cmdbuf))
+ (debug-status)
+ (status)
+ (cmd-process)
+ )
+ (if (and cmdbuf (buffer-name cmdbuf))
+ (with-current-buffer cmdbuf
+ (setq cmd-process (get-buffer-process cmdbuf))
+ (setq debug-status
+ (if (realgud-sget 'cmdbuf-info 'in-debugger?)
+ " debugger"
+ ""))
+ (setq status
+ (if cmd-process
+ (list (propertize
+ (format ":%s%s"
+ (process-status cmd-process) debug-status)
+ 'face 'debugger-running))
+ (list (propertize ":not running" 'face
+ 'debugger-not-running))
+ ))
+ (setq mode-line-process status)
+ ;; Force mode line redisplay soon.
+ (force-mode-line-update))
+ ))
+ )
+
+
+(provide-me "realgud-buffer-")
diff --git a/packages/realgud/realgud/common/buffer/helper.el
b/packages/realgud/realgud/common/buffer/helper.el
new file mode 100644
index 0000000..1c47035
--- /dev/null
+++ b/packages/realgud/realgud/common/buffer/helper.el
@@ -0,0 +1,168 @@
+;; Copyright (C) 2010, 2014 Rocky Bernstein <address@hidden>
+(require 'load-relative)
+(require-relative-list '("../fringe" "../helper" "../lochist")
+ "realgud-")
+(require-relative-list '("command" "source" "backtrace") "realgud-buffer-")
+
+(declare-function realgud-backtrace? 'realgud-buffer-backtace)
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud:loc-hist-describe 'realgud-lochist)
+(declare-function realgud-loc-hist-item 'realgud-lochist)
+(declare-function realgud-srcbuf? 'realgud-buffer-command)
+(declare-function buffer-killed? 'realgud-helper)
+
+(defvar realgud-cmdbuf-info)
+
+(defun realgud-get-cmdbuf-from-backtrace ( &optional opt-buffer)
+ "Return the command buffer associated with source
+OPT-BUFFER or if that is ommited `current-buffer' which is
+assumed to be a source-code buffer."
+ (let ((buffer (or opt-buffer (current-buffer))))
+ (if (realgud-backtrace? buffer)
+ (with-current-buffer-safe buffer
+ (realgud-sget 'backtrace-info 'cmdbuf))
+ nil)))
+
+(defun realgud-get-cmdbuf-from-srcbuf ( &optional opt-buffer)
+ "Return the command buffer associated with source
+OPT-BUFFER or if that is ommited `current-buffer' which is
+assumed to be a source-code buffer."
+ (let ((buffer (or opt-buffer (current-buffer))))
+ (if (realgud-srcbuf? buffer)
+ (with-current-buffer-safe buffer
+ (realgud-sget 'srcbuf-info 'cmdproc))
+ nil)))
+
+(defun realgud-get-srcbuf-from-cmdbuf ( &optional opt-buffer opt-loc)
+ "Return the source-code buffer associated with command
+OPT-BUFFER or if that is ommited `current-buffer' which is
+assumed to be a process-command buffer."
+ (let ((buffer (or opt-buffer (current-buffer))))
+ (if (realgud-cmdbuf? buffer)
+ (with-current-buffer-safe buffer
+ (let ((loc
+ (or opt-loc
+ (realgud-loc-hist-item
+ (realgud-cmdbuf-info-loc-hist realgud-cmdbuf-info)))))
+ (if loc
+ (marker-buffer (realgud-loc-marker loc))
+ nil)
+ ))
+ nil)))
+
+(defun realgud-get-srcbuf( &optional opt-buffer opt-loc)
+ "Return source-code buffer associated with OPT-BUFFER or
+`current-buffer' if that is omitted. nil is returned if we don't
+find anything. If we started out with a buffer that is set up to
+be a source-code buffer we will use that even though it might not
+be the source code buffer for the frame that the debugger is
+using. See also `realgud-get-current-srcbuf'."
+
+ (let ((buffer (or opt-buffer (current-buffer))))
+ (with-current-buffer-safe buffer
+ (cond
+ ;; Perhaps buffer is a source source-code buffer?
+ ((realgud-srcbuf? buffer) buffer)
+ ;; Perhaps buffer is a process-command buffer.
+ ((realgud-cmdbuf? buffer)
+ (realgud-get-srcbuf-from-cmdbuf buffer opt-loc))
+ (t nil)))))
+
+(defun realgud-get-current-srcbuf( &optional opt-buffer)
+ "Return the source-code buffer associated with OPT-BUFFER
+or `current-buffer' if that is omitted. nil is returned
+if we don't find anything."
+
+ (let ((buffer (or opt-buffer (current-buffer))))
+ (with-current-buffer-safe buffer
+ (let ((cmdbuf
+ (cond
+ ((realgud-srcbuf? buffer)
+ (realgud-get-cmdbuf-from-srcbuf buffer))
+ ((realgud-cmdbuf? buffer)
+ buffer)
+ (t nil))))
+ (if cmdbuf
+ (realgud-get-srcbuf-from-cmdbuf cmdbuf)
+ nil)))))
+
+(defun realgud-get-cmdbuf( &optional opt-buffer)
+ "Return the command buffer associated with OPT-BUFFER
+or `current-buffer' if that is omitted. nil is returned
+if we don't find anything."
+
+ (let ((buffer (or opt-buffer (current-buffer))))
+ (with-current-buffer-safe buffer
+ (cond
+ ;; Perhaps buffer is a process-command buffer?
+ ((realgud-cmdbuf? buffer) buffer)
+ ;; Perhaps buffer is a source-code buffer?
+ ((realgud-srcbuf? buffer)
+ (realgud-get-cmdbuf-from-srcbuf buffer))
+ ;; Perhaps buffer is a backtrace buffer?
+ ((realgud-backtrace? buffer)
+ (realgud-get-cmdbuf-from-backtrace buffer))
+ (t nil)))))
+
+(defun realgud-get-backtrace-buf( &optional opt-buffer)
+ "Return the backtrace buffer associated with
+OPT-BUFFER or if that is ommited `current-buffer'."
+ (let* ((buffer (or opt-buffer (current-buffer)))
+ (cmdbuf (realgud-get-cmdbuf buffer)))
+ (with-current-buffer-safe cmdbuf
+ (realgud-sget 'cmdbuf-info 'bt-buf)
+ ))
+ )
+
+(defun realgud-get-process (&optional opt-buffer)
+ "Return the process buffer associated with OPT-BUFFER or
+ `current-buffer' if that is omitted. nil is returned if
+we don't find anything."
+ (let* ((buffer (or opt-buffer (current-buffer)))
+ (cmdbuf (realgud-get-cmdbuf buffer)))
+ (if cmdbuf
+ (get-buffer-process cmdbuf)
+ nil)
+ )
+)
+
+(defun realgud:srcbuf-info-describe (&optional buffer)
+ "Provide descriptive information of the buffer-local variable
+`realgud-srcbuf-info', a defstruct. BUFFER if given is the buffer to
+use to get the information from.
+"
+ (interactive "")
+ (setq buffer (realgud-get-srcbuf buffer))
+ (if buffer
+ (with-current-buffer buffer
+ (let ((info realgud-srcbuf-info)
+ (srcbuf-name (buffer-name))
+ (a1 realgud-overlay-arrow1)
+ (a2 realgud-overlay-arrow2)
+ (a3 realgud-overlay-arrow3)
+ )
+ (switch-to-buffer (get-buffer-create "*Describe*"))
+ (delete-region (point-min) (point-max))
+ (mapc 'insert
+ (list
+ (format "srcbuf-info for %s\n" srcbuf-name)
+ (format "Was previously read only?: %s\n"
+ (realgud-srcbuf-info-was-read-only? info))
+ (format "Command Process buffer: %s\n"
+ (realgud-srcbuf-info-cmdproc info))
+
+ ;; FIXME This info isn't part of the src info structure.
+ (format "Overlay arrow 1: %s\n" a1)
+ (format "Overlay arrow 2: %s\n" a2)
+ (format "Overlay arrow 3: %s\n" a3)
+ (format "Location history:\n")
+ ))
+ (realgud:loc-hist-describe (realgud-srcbuf-info-loc-hist info))
+ )
+ )
+ (message "Buffer %s is not a debugger source buffer; nothing done."
+ (or buffer (current-buffer)))
+ )
+ )
+
+(provide-me "realgud-buffer-")
diff --git a/packages/realgud/realgud/common/buffer/info.el
b/packages/realgud/realgud/common/buffer/info.el
new file mode 100644
index 0000000..328a478
--- /dev/null
+++ b/packages/realgud/realgud/common/buffer/info.el
@@ -0,0 +1,50 @@
+;;; Copyright (C) 2015 Rocky Bernstein <address@hidden>
+;;;
+;;; A mode based off of org mode to show debugger information
+
+(eval-when-compile (require 'cl))
+(require 'org)
+
+(require 'load-relative)
+
+(defstruct realgud-backtrace-info
+ "debugger object/structure specific to debugger info."
+ (cmdbuf nil) ;; buffer of the associated debugger process
+)
+
+;; Can't load because this causes a cyclic dependency on
+;; buffer/commands via cmd and buffer/commands uses us.
+;; (require-relative-list '("menu") "realgud-")
+
+;; FIXME: full definition is in menu.
+(defvar realgud:info-mode-map)
+
+(defcustom realgud:info-mode-hook '()
+ "Hook for customizing realgud info mode."
+ :type 'hook
+ :group 'realgud)
+
+
+(define-derived-mode realgud:info-mode org-mode "Debugger Info"
+ "Major mode for interacting realgud debugger information."
+ (use-local-map realgud:info-mode-map)
+ (setq buffer-read-only 't)
+ )
+
+;; FIXME:
+;; (defvar realgud:info-mode-map
+;; (realgud-populate-debugger-menu
+;; (make-sparse-keymap "Debugger")))
+
+;; (define-key realgud:info-mode-map [menu-bar debugger]
+;; (cons "Debugger" (realgud-populate-debugger-menu
+;; (make-sparse-keymap "Debugger"))))
+
+;; (define-key realgud:info-mode-map [menu-bar debugger backtrace]
+;; '("Backtrace" . realgud:window-bt))
+;;(define-key realgud:info-mode-map [menu-bar debugger command]
+;; '("Go to Command Buffer" . realgud-window-cmd-undisturb-src))
+;;(define-key realgud:info-mode-map [menu-bar debugger source]
+;; '("Go to Source Buffer" . realgud-window-src-undisturb-cmd))
+
+(provide-me "realgud-buffer-")
diff --git a/packages/realgud/realgud/common/buffer/source.el
b/packages/realgud/realgud/common/buffer/source.el
new file mode 100644
index 0000000..e99a026
--- /dev/null
+++ b/packages/realgud/realgud/common/buffer/source.el
@@ -0,0 +1,175 @@
+;;; Copyright (C) 2010, 2012-2015 Rocky Bernstein <address@hidden>
+;;; source-code buffer code
+(eval-when-compile
+ (require 'cl-lib)
+ (defvar realgud-srcbuf-info) ;; is buffer local
+ (defvar realgud-cmdbuf-info) ;; in the cmdbuf, this is buffer local
+ )
+
+(require 'load-relative)
+(require-relative-list '("../helper" "../key") "realgud-")
+
+(declare-function realgud-populate-common-keys 'realgud-menu)
+(declare-function buffer-killed? 'realgud-helper)
+(declare-function buffer-loc-line-number? 'realgud-loc)
+(declare-function realgud-cmdbuf-add-srcbuf 'realgud-cmdbuf)
+(declare-function realgud-cmdbuf-info-bp-list 'realgud-cmdbuf)
+(declare-function realgud-cmdbuf? 'realgud-cmdbuf)
+(declare-function realgud-loc-marker 'realgud-loc)
+(declare-function realgud-loc-line-number 'realgud-loc)
+(declare-function realgud-loc-num 'realgud-loc)
+(declare-function make-realgud-loc-hist 'realgud-lochist)
+(declare-function realgud-get-srcbuf 'helper)
+(declare-function realgud-short-key-mode-setup 'realgud-shortkey)
+
+(defstruct realgud-srcbuf-info
+ "debugger object/structure specific to a (top-level) source program
+to be debugged."
+ cmdproc ;; buffer of the associated debugger process
+ cur-pos ;; If not nil, the debugger thinks we are currently
+ ;; positioned at a corresponding place in the
+ ;; program.
+ short-key? ;; Was the source buffer previously in short-key
+ ;; mode? Used to deterimine when short-key mode
+ ;; changes state in a source buffer, so we need to
+ ;; perform on/off actions.
+ was-read-only? ;; Was buffer initially read only? (i.e. the original
+ ;; value of the buffer's buffer-read-only
+ ;; variable. Short-key-mode may change the read-only
+ ;; state, so we need restore this value when leaving
+ ;; short-key mode
+
+ loc-hist ;; ring of locations seen
+
+ ;; FILL IN THE FUTURE
+ ;;(brkpt-alist '()) ;; alist of breakpoints the debugger has referring
+ ;; to this buffer. Each item is (brkpt-name . marker)
+ ;;
+)
+
+
+(defalias 'realgud-srcbuf-info? 'realgud-srcbuf-p)
+
+;; FIXME: figure out how to put in a loop.
+(realgud-struct-field-setter "realgud-srcbuf-info" "cmdproc")
+(realgud-struct-field-setter "realgud-srcbuf-info" "short-key?")
+(realgud-struct-field-setter "realgud-srcbuf-info" "was-read-only?")
+
+(defun realgud-srcbuf-info-set? ()
+ "Return true if `realgud-srcbuf-info' is set."
+ (and (boundp 'realgud-srcbuf-info)
+ realgud-srcbuf-info
+ (realgud-srcbuf-info? realgud-srcbuf-info)))
+
+(defun realgud-srcbuf? (&optional buffer)
+ "Return true if BUFFER is a debugger source buffer."
+ (with-current-buffer-safe (or buffer (current-buffer))
+ (and (realgud-srcbuf-info-set?)
+ (not (buffer-killed? (realgud-sget 'srcbuf-info 'cmdproc)))
+ )))
+
+(defun realgud-srcbuf-debugger-name (&optional src-buf)
+ "Return the debugger name recorded in the debugger command-process buffer."
+ (with-current-buffer-safe (or src-buf (current-buffer))
+ (realgud-sget 'srcbuf-info 'debugger-name))
+)
+
+(defun realgud-srcbuf-loc-hist(src-buf)
+ "Return the history ring of locations that a debugger process has stored."
+ (with-current-buffer-safe src-buf
+ (realgud-sget 'srcbuf-info 'loc-hist))
+)
+
+(declare-function fn-p-to-fn?-alias(sym))
+(fn-p-to-fn?-alias 'realgud-srcbuf-info-p)
+(declare-function realgud-srcbuf-info?(var))
+(declare-function realgud-cmdbuf-info-name(cmdbuf-info))
+
+;; FIXME: support a list of cmdprocs's since we want to allow
+;; a source buffer to potentially participate in several debuggers
+;; which might be active.
+(make-variable-buffer-local 'realgud-srcbuf-info)
+
+(defun realgud-srcbuf-init
+ (src-buffer cmdproc-buffer)
+ "Initialize SRC-BUFFER as a source-code buffer for a debugger.
+CMDPROC-BUFFER is the process-command buffer containing the
+debugger. DEBUGGER-NAME is the name of the debugger as a main
+program name."
+ (with-current-buffer cmdproc-buffer
+ (set-buffer src-buffer)
+ (set (make-local-variable 'realgud-srcbuf-info)
+ (make-realgud-srcbuf-info
+ :cmdproc cmdproc-buffer
+ :loc-hist (make-realgud-loc-hist)))
+ (put 'realgud-srcbuf-info 'variable-documentation
+ "Debugger information for a buffer containing source code.")))
+
+(defun realgud-srcbuf-init-or-update (src-buffer cmdproc-buffer)
+ "Call `realgud-srcbuf-init' for SRC-BUFFER update `realgud-srcbuf-info'
variables
+in it with those from CMDPROC-BUFFER"
+ (realgud-cmdbuf-add-srcbuf src-buffer cmdproc-buffer)
+ (with-current-buffer-safe src-buffer
+ (realgud-populate-common-keys
+ ;; use-local-map returns nil so e have to call (current-local-map)
+ ;; again in this case.
+ (or (current-local-map) (use-local-map (make-sparse-keymap))
+ (current-local-map)))
+ (if (realgud-srcbuf-info? realgud-srcbuf-info)
+ (realgud-srcbuf-info-cmdproc= cmdproc-buffer)
+ (realgud-srcbuf-init src-buffer cmdproc-buffer))))
+
+;; FIXME: rewrite to add prompt function that only suggests
+;; command buffers;
+(defun realgud:cmdbuf-associate(cmdbuf-name)
+ "Associate a command buffer with for the current buffer which is
+assumed to be a source-code buffer"
+ (interactive "brealgud command buffer: ")
+ (let ((cmdbuf (get-buffer cmdbuf-name)))
+ (unless (realgud-cmdbuf? cmdbuf)
+ (error "%s doesn't smell like a command buffer" cmdbuf-name))
+ (realgud-srcbuf-init-or-update (current-buffer) cmdbuf )
+ (realgud-short-key-mode-setup 't)
+ ))
+
+(defun realgud-srcbuf-bp-list(&optional buffer)
+ "Return a list of breakpoint loc structures that reside in
+BUFFER which should be an initialized source buffer."
+ (let ((src-buffer (realgud-get-srcbuf buffer)))
+ (if src-buffer
+ (with-current-buffer src-buffer
+ (let* ((info realgud-srcbuf-info)
+ (cmdbuf (realgud-srcbuf-info-cmdproc info)))
+ (with-current-buffer cmdbuf
+ (let ((bp-list
+ (realgud-cmdbuf-info-bp-list realgud-cmdbuf-info)))
+ (delq nil
+ (mapcar (lambda (loc)
+ (cond ((eq src-buffer
+ (marker-buffer (realgud-loc-marker
loc)))
+ loc)
+ (nil)))
+ bp-list))
+ )))))))
+
+(defun realgud-get-bpnum-from-line-num(line-num &optional buffer)
+ "Find a breakpoint number associated with LINE-NUM in source code BUFFER.
+If none exists return nil"
+ (let ((src-buffer (realgud-get-srcbuf buffer))
+ (bp-num nil)
+ (bp)
+ (bp-list)
+ )
+ (if src-buffer
+ (progn
+ (setq bp-list (realgud-srcbuf-bp-list src-buffer))
+ (while (and (not bp-num) bp-list)
+ (setq bp (car bp-list))
+ (setq bp-list (cdr bp-list))
+ (if (eq line-num (realgud-loc-line-number bp))
+ (setq bp-num (realgud-loc-num bp)))
+ ))
+ )
+ bp-num))
+
+(provide-me "realgud-buffer-")
diff --git a/packages/realgud/realgud/common/cmds.el
b/packages/realgud/realgud/common/cmds.el
new file mode 100644
index 0000000..9ab344f
--- /dev/null
+++ b/packages/realgud/realgud/common/cmds.el
@@ -0,0 +1,282 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(require 'load-relative)
+(require-relative-list '("send" "core") "realgud-")
+(require-relative-list '("buffer/command") "realgud-buffer-")
+(require-relative-list '("buffer/source") "realgud-buffer-")
+
+(declare-function buffer-killed? 'helper)
+(declare-function realgud-cmdbuf-info-in-srcbuf?= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud-command 'realgud-send)
+(declare-function realgud-get-cmdbuf 'realgud-buffer-helper)
+(declare-function realgud-get-command 'realgud-buffer-command)
+(declare-function realgud-get-bpnum-from-line-num 'realgud-buffer-source)
+
+(declare-function realgud:terminate 'realgud-core)
+(declare-function realgud:terminate-srcbuf 'realdgud-core)
+
+(defun realgud:cmd-remap(arg cmd-name default-cmd-template key
+ &optional no-record? frame-switch?
+ realgud-prompts?)
+ "Run debugger command CMD-NAME using DEFAULT-CMD-TEMPLATE
+if none has been set in the command hash. If key is given we'll set
+a shortcut for that key."
+ (let ((buffer (current-buffer))
+ (cmdbuf (realgud-get-cmdbuf))
+ (cmd-hash)
+ (cmd)
+ )
+ (with-current-buffer-safe cmdbuf
+ (realgud-cmdbuf-info-in-srcbuf?= (not (realgud-cmdbuf? buffer)))
+ (setq cmd-hash (realgud-cmdbuf-info-cmd-hash realgud-cmdbuf-info))
+ (unless (and cmd-hash (setq cmd (gethash cmd-name cmd-hash)))
+ (setq cmd default-cmd-template))
+ )
+ (if (equal cmd "*not-implemented*")
+ (message "Command %s is not implemented for this debugger" cmd-name)
+ ;; else
+ (progn
+ (realgud-command cmd arg no-record? frame-switch? realgud-prompts?)
+ ;; FIXME: Figure out how to update the position if the source
+ ;; buffer is displayed.
+ ;; (if frame-switch?
+ ;; (let* ((src-buffer (realgud-get-srcbuf-from-cmdbuf cmdbuf))
+ ;; (src-window (get-buffer-window src-buffer))
+ ;; ))
+ ;; (with-selected-window src-window
+ ;; (message "recentering...")
+ ;; (realgud-recenter-arrow)
+ ;; ))
+ )
+ ;; FIXME: this is a one-time thing. Put in caller.
+ (if key
+ (local-set-key (format "\C-c%s" key)
+ (intern (format "realgud:cmd-%s" cmd-name))))
+ )
+ ))
+
+(defun realgud:cmd-backtrace(arg)
+ "Show the current call stack"
+ (interactive "p")
+ (realgud:cmd-remap arg "backtrace" "backtrace" "T")
+ )
+
+(defun realgud:cmd-break(arg)
+ "Set a breakpoint at the current line"
+ (interactive "p")
+ (realgud:cmd-remap arg "break" "break %X:%l" "b"))
+
+(defun realgud:cmd-clear(line-num)
+ "Delete breakpoint at the current line"
+ (interactive "p")
+ (realgud:cmd-remap line-num "clear" "clear %l" "X"))
+
+(defun realgud:cmd-continue(&optional arg)
+ "Continue execution."
+ (interactive "MContinue args: ")
+ (realgud:cmd-remap arg "continue" "continue" "c")
+)
+
+(defun realgud:cmd-delete(&optional arg)
+ "Delete breakpoint by number."
+ (interactive "pBreakpoint number: ")
+ (let* ((line-num (line-number-at-pos))
+ (arg (realgud-get-bpnum-from-line-num line-num)))
+ (if arg
+ (realgud:cmd-remap arg "delete" "delete %p" "D")
+ (message "Can't find breakpoint at line %d" line-num))
+ )
+ )
+
+(defun realgud:cmd-disable(&optional arg)
+ "Disable breakpoint."
+ (interactive "NBreakpoint number: ")
+ (realgud:cmd-remap arg "disable" "disable %p" "-")
+ )
+
+(defun realgud:cmd-enable(&optional arg)
+ "Enable breakpoint."
+ (interactive "NBreakpoint number: ")
+ (realgud:cmd-remap arg "enable" "enable %p" "+")
+ )
+
+(defun realgud:cmd-eval(arg)
+ "Exaluate an expression."
+ (interactive "MEval expesssion: ")
+ (realgud:cmd-remap arg "eval" "eval %s" "e")
+)
+
+(defun realgud:cmd-eval-region(start end)
+ (interactive "r")
+ (let ((text (buffer-substring-no-properties start end)))
+ (realgud:cmd-remap text "eval" "eval %s" "e")
+ )
+ )
+
+(defun realgud:cmd-finish(&optional arg)
+ "Run until the completion of the current stack frame.
+
+This command is often referred to as 'step out' as opposed to
+'step over' or 'step into'.
+"
+ (interactive "p")
+ (realgud:cmd-remap arg "finish" "finish" ".")
+)
+
+(defun realgud:cmd-frame(arg)
+ "Change the current frame number to the value of the numeric argument.
+If no argument specified use 0 or the most recent frame."
+ (interactive "p")
+ (realgud:cmd-remap arg "frame" "frame %p" "f" t t)
+)
+
+(defun realgud:cmd-kill(arg)
+ "kill debugger process"
+ (interactive "p")
+ (realgud:cmd-remap arg "kill" "kill" "k" nil nil 't)
+ )
+
+(defun realgud:cmd-newer-frame(&optional arg)
+ "Move the current frame to a newer (more recent) frame.
+With a numeric argument move that many levels forward."
+ (interactive "p")
+ (realgud:cmd-remap arg "down" "down %p" "<" t t)
+)
+
+(defun realgud:cmd-next(&optional arg)
+ "Step one source line at current call level.
+
+With a numeric argument, step that many times. This command is
+often referred to as 'step through' as opposed to 'step into' or
+'step out'.
+
+The definition of 'next' is debugger specific so, see the
+debugger documentation for a more complete definition of what is
+getting stepped."
+ (interactive "p")
+ (realgud:cmd-remap arg "next" "next %p" "n")
+)
+
+(defun realgud:cmd-next-no-arg(&optional arg)
+ "Step one source line at current call level.
+
+The definition of 'next' is debugger specific so, see the
+debugger documentation for a more complete definition of what is
+getting stepped."
+ (interactive)
+ (realgud:cmd-remap nil "next" "next" "n")
+)
+
+(defun realgud:cmd-older-frame(&optional arg)
+ "Move the current frame to an older (less recent) frame.
+With a numeric argument move that many levels back."
+ (interactive "p")
+ (realgud:cmd-remap arg "up" "up %p" ">" t t)
+)
+
+(defun realgud:cmd-repeat-last(&optional arg)
+ "Repeat the last command (or generally what <enter> does."
+ (interactive "")
+ (realgud:cmd-remap arg "repeat-last" "\n" "." 't nil 't)
+)
+
+(defun realgud:cmd-restart(&optional arg)
+ "Restart execution."
+ (interactive "")
+ (realgud:cmd-remap arg "restart" "run" "R" 't nil 't)
+)
+
+(defun realgud:cmd-shell(&optional arg)
+ "Restart execution."
+ (interactive "")
+ (realgud:cmd-remap arg "shell" "shell" "S")
+)
+
+(defun realgud:cmd-step(&optional arg)
+ "Step one source line.
+
+With a numeric argument, step that many times.
+This command is often referred to as 'step into' as opposed to
+'step over' or 'step out'.
+
+The definition of 'step' is debugger specific so, see the
+debugger documentation for a more complete definition of what is
+getting stepped."
+ (interactive "p")
+ (realgud:cmd-remap arg "step" "step %p" "s")
+)
+
+(defun realgud:cmd-step-no-arg()
+ "Step one source line.
+
+The definition of 'step' is debugger specific so, see the
+debugger documentation for a more complete definition of what is
+getting stepped."
+ (interactive)
+ (realgud:cmd-remap nil "step" "step" "s")
+)
+
+(defun realgud:cmd-terminate (&optional arg)
+ "Gently terminate source and command buffers without possibly
+issuing a command to the underlying debuger. Use this if the
+underlying debugger has died or you want to get out of all
+shortkey modes in the source window and possibly restart
+debugging after editing source."
+ (interactive "p")
+ (realgud:terminate (current-buffer))
+)
+
+(defun realgud:cmd-until(&optional arg)
+ "Run until the completion of the current stack frame.
+
+Continue until the current line. In some cases this is really
+two commands - setting a temporary breakpoint on the line and
+continuing execution."
+ (interactive "p")
+ (realgud:cmd-remap arg "until" "until" "u")
+)
+
+(defun realgud:cmd-quit (&optional arg)
+ "Gently terminate execution of the debugged program."
+ (interactive "p")
+ (let ((buffer (current-buffer))
+ (cmdbuf (realgud-get-cmdbuf))
+ (cmd-hash)
+ (cmd)
+ )
+ (if cmdbuf
+ (progn
+ (with-current-buffer cmdbuf
+ (realgud-cmdbuf-info-in-srcbuf?= (not (realgud-cmdbuf? buffer)))
+ (setq cmd-hash (realgud-cmdbuf-info-cmd-hash realgud-cmdbuf-info))
+ (unless (and cmd-hash (setq cmd (gethash "quit" cmd-hash)))
+ (setq cmd "quit"))
+ )
+ (realgud-command cmd arg 't)
+ (if cmdbuf (realgud:terminate cmdbuf))
+ )
+ ; else
+ (realgud:terminate-srcbuf buffer)
+ )
+ )
+ )
+
+(local-set-key "\C-cq" 'realgud:cmd-quit)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/core.el
b/packages/realgud/realgud/common/core.el
new file mode 100644
index 0000000..cecd5ee
--- /dev/null
+++ b/packages/realgud/realgud/common/core.el
@@ -0,0 +1,309 @@
+;;; Copyright (C) 2010-2015 Rocky Bernstein <address@hidden>
+; (require 'term)
+(if (< emacs-major-version 24)
+ (error
+ "You need at least Emacs 24 or greater to run this - you have version %d"
+ emacs-major-version))
+
+(require 'comint)
+(require 'load-relative)
+(require 'loc-changes)
+(require-relative-list '("fringe" "helper" "lang" "reset")
+ "realgud-")
+(require-relative-list '("buffer/command" "buffer/source") "realgud-buffer-")
+
+(declare-function comint-exec 'comint)
+(declare-function comint-mode 'comint)
+(declare-function realgud-bp-remove-icons 'realgud-bp)
+(declare-function realgud:suggest-file-from-buffer 'realgud-lang)
+(declare-function realgud-cmdbuf-args= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-command-string 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-debugger-name 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-bp-list= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-in-debugger?= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-mode-line-update 'realgud-buffer-command)
+(declare-function realgud-cmdbuf? 'realgud-helper)
+(declare-function realgud-command-string 'realgud-buffer-command)
+(declare-function realgud-fringe-erase-history-arrows 'realgud-buffer-command)
+(declare-function realgud-get-cmdbuf 'realgud-helper)
+(declare-function realgud:reset 'realgud-reset)
+(declare-function realgud-short-key-mode-setup 'realgud-shortkey)
+(declare-function realgud-srcbuf-command-string 'realgud-buffer-source)
+(declare-function realgud-srcbuf-debugger-name 'realgud-buffer-source)
+(declare-function realgud-srcbuf-init 'realgud-buffer-source)
+(declare-function realgud-srcbuf? 'realgud-buffer-source)
+(declare-function realgud-suggest-lang-file 'realgud-lang)
+
+(defvar realgud-srcbuf-info)
+
+(defun realgud:expand-file-name-if-exists (filename)
+ "Return FILENAME expanded using `expand-file-name' if that name exists.
+Otherwise, just return FILENAME."
+ (let* ((expanded-filename (expand-file-name filename))
+ (result (cond ((file-exists-p expanded-filename)
+ expanded-filename)
+ ('t filename))))
+ result)
+)
+
+(defun realgud-suggest-invocation
+ (debugger-name minibuffer-history lang-str lang-ext-regexp
+ &optional last-resort)
+ "Suggest a debugger command invocation. If the current buffer
+is a source file or process buffer previously set, then use the
+value of that the command invocations found by buffer-local
+variables. Next, try to use the first value of MINIBUFFER-HISTORY
+if that exists. Finally we try to find a suitable program file
+using LANG-STR and LANG-EXT-REGEXP."
+ (let* ((buf (current-buffer))
+ (filename)
+ (cmd-str-cmdbuf (realgud-cmdbuf-command-string buf))
+ )
+ (cond
+ ((and cmd-str-cmdbuf (equal debugger-name (realgud-cmdbuf-debugger-name
buf)))
+ cmd-str-cmdbuf)
+ ((and minibuffer-history (listp minibuffer-history))
+ (car minibuffer-history))
+ ((setq filename (realgud:suggest-file-from-buffer lang-str))
+ (concat debugger-name " " filename))
+ (t (concat debugger-name " "
+ (realgud-suggest-lang-file lang-str lang-ext-regexp
last-resort)))
+ )))
+
+(defun realgud-query-cmdline
+ (suggest-invocation-fn
+ minibuffer-local-map
+ minibuffer-history
+ &optional opt-debugger)
+ "Prompt for a debugger command invocation to run.
+Analogous to `gud-query-cmdline'.
+
+If you happen to be in a debugger process buffer, the last command invocation
+for that first one suggested. Failing that, some amount of guessing is done
+to find a suitable file via SUGGEST-INVOCATION-FN.
+
+We also set filename completion and use a history of the prior
+dbgr invocations "
+ (let ((debugger (or opt-debugger
+ (realgud-sget 'srcbuf-info 'debugger-name))))
+ (read-from-minibuffer
+ (format "Run %s (like this): " debugger) ;; prompt string
+ (funcall suggest-invocation-fn debugger) ;; initial value
+ minibuffer-local-map ;; keymap
+ nil ;; read - use default value
+ minibuffer-history ;; history variable
+ )))
+
+(defun realgud-parse-command-arg (args two-args opt-two-args)
+ "Return a cons node where the car is a list containing the
+entire first option and the cdr is the remaining arguments from ARGS.
+
+We determine if an option has length one or two using the lists
+TWO-ARGS and OPT-TWO-ARGS. Both of these are list of 'options',
+that is strings without the leading dash. TWO-ARGS takes a
+mandatory additional argument. OPT-TWO-ARGS might take two
+arguments. The rule for an optional argument that we use is if
+the next parameter starts with a dash ('-'), it is not part of
+the preceeding parameter when that parameter is optional.
+
+NOTE: we don't check whether the first arguments of ARGS is an
+option by testing to see if it starts say with a dash. So on
+return the first argument is always removed.
+"
+ (let ((arg (car args))
+ (d-two-args (mapcar (lambda(x) (concat "-" x)) two-args))
+ (d-opt-two-args (mapcar (lambda(x) (concat "-" x)) opt-two-args))
+ (remaining (cdr args)))
+ (cond
+ ((member arg d-two-args)
+ (if (not remaining)
+ (progn
+ (message "Expecting an argument after %s. Continuing anyway."
+ arg)
+ (cons (list arg) (list remaining)))
+ (cons (list arg (car remaining)) (list (cdr remaining)))))
+ ((member arg d-opt-two-args)
+ (if (and remaining (not (string-match "^-" (car remaining))))
+ (cons (list arg (car remaining)) (list (cdr remaining)))
+ (cons (list arg) (list remaining))))
+ (t (cons (list arg) (list remaining))))))
+
+(defun realgud:terminate-srcbuf (&optional srcbuf)
+ "Resets source buffer."
+ (interactive "bsource buffer: ")
+ (if (stringp srcbuf) (setq srcbuf (get-buffer srcbuf)))
+ (with-current-buffer srcbuf
+ (realgud-fringe-erase-history-arrows)
+ (realgud-bp-remove-icons (point-min) (point-max))
+ (when (realgud-srcbuf?)
+ (realgud-short-key-mode-setup nil)
+ (redisplay)
+ )
+ (loc-changes-clear-buffer)
+ ))
+
+(defun realgud:terminate (&optional buf)
+ "Resets state in all buffers associated with source or command
+buffer BUF) This does things like remove fringe arrows breakpoint
+icons and resets short-key mode."
+ (interactive "bbuffer: ")
+ (if (stringp buf) (setq buf (get-buffer buf)))
+ (let ((cmdbuf (realgud-get-cmdbuf buf)))
+ (if cmdbuf
+ (with-current-buffer cmdbuf
+ (realgud-cmdbuf-info-in-debugger?= nil)
+ (realgud-cmdbuf-info-bp-list= '())
+ (realgud-cmdbuf-mode-line-update)
+ (realgud-fringe-erase-history-arrows)
+ (if realgud-cmdbuf-info
+ (dolist (srcbuf (realgud-cmdbuf-info-srcbuf-list
realgud-cmdbuf-info))
+ (if (realgud-srcbuf? srcbuf)
+ (with-current-buffer srcbuf
+ (realgud:terminate-srcbuf srcbuf)
+ ))
+ )
+ )
+ )
+ (error "Buffer %s does not seem to be attached to a debugger"
+ (buffer-name))
+ )
+ )
+ )
+
+(defun realgud:kill-buffer-hook ()
+ "When a realgud command buffer is killed, call `realgud:terminate' to
+clean up.
+Note that `realgud-term-sentinel' is not helpful here because
+the buffer and data associated with it are already gone."
+ (when (realgud-cmdbuf?) (realgud:terminate (current-buffer)))
+)
+(add-hook 'kill-buffer-hook 'realgud:kill-buffer-hook)
+
+(defun realgud-term-sentinel (process string)
+ "Called when PROCESS dies. We call `realgud:terminate' to clean up."
+ (let ((cmdbuf (realgud-get-cmdbuf)))
+ (if cmdbuf (realgud:terminate cmdbuf)))
+ (message "That's all folks.... %s" string))
+
+(defun realgud:binary (file-name)
+"Return a priority for whether file-name is likely we can run gdb on"
+ (let ((output (shell-command-to-string (format "file %s" file-name))))
+ (cond
+ ((string-match "ELF" output) t)
+ ('t nil))))
+
+
+(defun realgud-exec-shell (debugger-name script-filename program
+ &optional no-reset &rest args)
+ "Run the specified SCRIPT-FILENAME in under debugger DEBUGGER-NAME a
+comint process buffer. ARGS are the arguments passed to the
+PROGRAM. At the moment, no piping of input is allowed.
+
+SCRIPT-FILENAME will have local variable `realgud-script-info' set
+which contains the debugger name and debugger process-command
+buffer.
+
+Normally command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset."
+
+ (let* ((starting-directory
+ (or (file-name-directory script-filename)
+ default-directory "./"))
+ (cmdproc-buffer-name
+ (replace-regexp-in-string "\s+" "\s"
+ (format "*%s %s shell*"
+ (file-name-nondirectory debugger-name)
+ (file-name-nondirectory script-filename))))
+ (cmdproc-buffer (get-buffer-create cmdproc-buffer-name))
+ (realgud-buf (current-buffer))
+ (cmd-args (cons program args))
+ (process (get-buffer-process cmdproc-buffer)))
+
+
+ (with-current-buffer cmdproc-buffer
+ ;; If the found command buffer isn't for the same debugger
+ ;; invocation command, rename that and start a new one.
+ ;;
+ ;; For example: "bashdb /tmp/foo" does not match "bashdb
+ ;; /etc/foo" even though they both canonicalize to the buffer
+ ;; "*bashdb foo shell*"
+ (when (and (realgud-cmdbuf?)
+ (not
+ (equal cmd-args
+ (realgud-cmdbuf-info-cmd-args realgud-cmdbuf-info))
+ ))
+ (rename-uniquely)
+ (setq cmdproc-buffer (get-buffer-create cmdproc-buffer-name))
+ (setq process nil)
+ ))
+
+ (if (and process (eq 'run (process-status process)))
+ cmdproc-buffer
+ (with-current-buffer cmdproc-buffer
+ (and (realgud-cmdbuf?) (not no-reset) (realgud:reset))
+ (setq default-directory default-directory)
+ (insert "Current directory: " default-directory "\n")
+ (insert "Command: " (mapconcat 'identity cmd-args " ") "\n")
+
+ ;; For term.el
+ ;; (term-mode)
+ ;; (set (make-local-variable 'term-term-name) realgud-term-name)
+ ;; (make-local-variable 'realgud-parent-buffer)
+ ;; (setq realgud-parent-buffer realgud-buf)
+
+ ;; For comint.el.
+ (comint-mode)
+
+ ;; Making overlay-arrow-variable-list buffer local has to be
+ ;; done after running commint mode. FIXME: find out why and if
+ ;; this reason is justifyable. Also consider moving this somewhere
+ ;; else.
+ (make-local-variable 'overlay-arrow-variable-list)
+ (make-local-variable 'realgud-overlay-arrow1)
+ (make-local-variable 'realgud-overlay-arrow2)
+ (make-local-variable 'realgud-overlay-arrow3)
+
+ (condition-case failure
+ (comint-exec cmdproc-buffer debugger-name program nil args)
+ (error
+ (let ((text (format "%S\n" failure)))
+ (insert text)
+ (message text)(sit-for 1)
+ text)))
+
+ (setq process (get-buffer-process cmdproc-buffer))
+
+ (if (and process (eq 'run (process-status process)))
+ (let ((src-buffer)
+ (cmdline-list (cons program args)))
+ ;; is this right?
+ (when (and (file-exists-p script-filename)
+ (not (realgud:binary script-filename)))
+ (setq src-buffer (find-file-noselect script-filename))
+ (point-max)
+ (realgud-srcbuf-init src-buffer cmdproc-buffer))
+ (process-put process 'buffer cmdproc-buffer))
+ ;; else
+ (let ((text
+ (format
+ "Failed to invoke debugger %s on program %s with args %s\n"
+ debugger-name program (mapconcat 'identity args " "))))
+ (with-current-buffer cmdproc-buffer (insert text))
+ (message text)
+ ))
+ cmdproc-buffer))))
+
+;; Start of a term-output-filter for term.el
+(defun realgud-term-output-filter (process string)
+ (let ((process-buffer (process-get process 'buffer)))
+ (if process-buffer
+ (save-current-buffer
+ (set-buffer process-buffer)
+ ;; (insert-before-markers (format "+++1 %s" string))
+ (insert-before-markers string)))))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/custom.el
b/packages/realgud/realgud/common/custom.el
new file mode 100644
index 0000000..c476142
--- /dev/null
+++ b/packages/realgud/realgud/common/custom.el
@@ -0,0 +1,15 @@
+;;; Copyright (C) 2010 Rocky Bernstein <address@hidden>
+(require 'load-relative)
+
+(defcustom realgud-key-prefix "\C-x\C-a"
+ "Prefix of all realgud commands valid in source buffers."
+ :type 'string
+ :group 'realgud)
+
+(defcustom realgud-srcbuf-lock t
+ "Set source buffers read-only when the debugger is active.
+A setting of `nil` allows editing, but Short-Key-mode use may inhibit this."
+ :type 'boolean
+ :group 'realgud)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/eval.el
b/packages/realgud/realgud/common/eval.el
new file mode 100644
index 0000000..1ba52a4
--- /dev/null
+++ b/packages/realgud/realgud/common/eval.el
@@ -0,0 +1,101 @@
+;; show expressions using tooltip
+
+;; Author: Rocky Bernstein <address@hidden>
+;; Version: 1.1
+;; Keywords: internal
+;; URL: http://github.com/rocky/emacs-load-relative
+;; Compatibility: GNU Emacs 24.x
+
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see
+;; <http://www.gnu.org/licenses/>.
+
+(require 'tooltip)
+(require 'ansi-color)
+(require 'load-relative)
+
+(require-relative-list '("cmds" "helper" "utils") "realgud-")
+(require-relative-list '("buffer/command") "realgud-buffer-")
+
+(declare-function realgud:cmd-eval 'realgud-cmd)
+(declare-function realgud-get-cmdbuf 'realgud-helper)
+(declare-function realgud-cmdbuf-pat 'realgud-send)
+(declare-function realgud:strip 'realgud-utils)
+
+(make-variable-buffer-local
+ (defvar realgud:process-filter-save nil
+ "realgud saves/restores the previous process filter here"))
+
+(defun realgud:tooltip-eval (event)
+ "Show tip for identifier or selection under the mouse.
+The mouse must either point at an identifier or inside a selected
+region for the tip window to be shown.
+
+This function must return nil if it doesn't handle EVENT."
+ (interactive "e")
+ (let ((process)
+ (cmdbuf (realgud-get-cmdbuf))
+ (process))
+ (when (and (eventp event)
+ cmdbuf
+ (setq process (get-buffer-process cmdbuf))
+ (posn-point (event-end event))
+ )
+ (let ((expr (tooltip-expr-to-print event)))
+ (when expr
+ (with-current-buffer cmdbuf
+ (setq realgud:process-filter-save (process-filter process))
+ (set-process-filter process 'realgud:eval-process-output))
+ (realgud:cmd-eval expr)
+ ))
+ )))
+
+(defun realgud:eval-process-output (process output-str)
+ "Process debugger output and show it in a tooltip window."
+ (set-process-filter process
+ (or realgud:process-filter-save 'comint-output-filter))
+ (with-current-buffer (realgud-get-cmdbuf)
+ (goto-char (process-mark process))
+ (setq comint-last-input-end (process-mark process))
+ (insert output-str)
+ (set-marker (process-mark process) (point)))
+ (setq comint-last-output-start
+ (setq realgud-last-output-start (process-mark process)))
+
+ (tooltip-show (realgud:eval-strip process output-str))
+ )
+
+(defun realgud:eval-strip-default(prompt-regexp output-str)
+ (realgud:strip
+ (ansi-color-filter-apply
+ (if (string-match prompt-regexp output-str)
+ (substring output-str 0 (match-beginning 0))
+ output-str))))
+
+
+(defun realgud:eval-strip(process output-str)
+ "Return OUTPUT-STR with any prompt of PROCESS stripped from its end."
+ (save-match-data
+ (with-current-buffer (process-buffer process)
+ (let* ((prompt-pat (realgud-cmdbuf-pat "prompt"))
+ (prompt-regexp (realgud-loc-pat-regexp prompt-pat))
+ (eval-filter (realgud-sget 'cmdbuf-info 'callback-eval-filter))
+ )
+ (if eval-filter
+ (funcall eval-filter output-str)
+ (realgud:eval-strip-default prompt-regexp output-str))
+ ))))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/file.el
b/packages/realgud/realgud/common/file.el
new file mode 100644
index 0000000..b4c378c
--- /dev/null
+++ b/packages/realgud/realgud/common/file.el
@@ -0,0 +1,129 @@
+;;; Copyright (C) 2010-2011, 2013-2014 Rocky Bernstein <address@hidden>
+; Should realgud:file-loc-from-line be here or elsewhere?
+(require 'load-relative)
+(require 'compile) ;; for compilation-find-file
+(require-relative-list '("helper" "loc") "realgud-")
+
+(defvar realgud-file-remap (make-hash-table :test 'equal)
+ "How to remap files we otherwise can't find in the
+ filesystem. The hash key is the file string we saw, and the
+ value is associated filesystem string presumably in the
+ filesystem")
+
+(declare-function realgud:strip 'realgud)
+(declare-function realgud-loc-goto 'realgud-loc)
+(declare-function buffer-killed? 'helper)
+(declare-function compilation-find-file 'compile)
+
+(defun realgud:file-line-count(filename)
+ "Return the number of lines in file FILENAME, or nil FILENAME can't be
+found"
+ (if (file-exists-p filename)
+ (let ((file-buffer (find-file-noselect filename)))
+ (with-current-buffer-safe file-buffer
+ (line-number-at-pos (point-max))))
+ nil))
+
+(defun realgud:file-column-from-string(filename line-number source-text
+ &optional no-strip-blanks)
+ "Return the column of the first column position of SOURCE-TEXT
+at LINE-NUMBER or nil if it is not there"
+ (condition-case nil
+ (if (file-exists-p filename)
+ (let ((file-buffer (find-file-noselect filename)))
+ (with-current-buffer-safe file-buffer
+ (save-excursion
+ (goto-char (point-min))
+ (forward-line (1- line-number))
+ (unless no-strip-blanks
+ (setq source-text (realgud:strip source-text)))
+ (if (search-forward source-text (point-at-eol))
+ (- (current-column)
+ (length source-text))))))
+ ;; else
+ nil)
+ (error nil))
+)
+
+
+;; FIXME: should allow column number to be passed in.
+(defun realgud:file-loc-from-line(filename line-number
+ &optional cmd-marker source-text
bp-num
+ ;; FIXME: remove ignore-file-re and
cover with
+ ;; find-file-fn.
+ ignore-file-re find-file-fn)
+ "Return a realgud-loc for FILENAME and LINE-NUMBER and the
+other optional position information.
+
+CMD-MARKER and BP-NUM get stored in the realgud-loc
+object. FIND-FILE-FN is a function which do special things to
+transform filename so it can be found. This could include
+searching classpaths (in Java), stripping leading and trailing
+blanks, or deliberately ignoring 'pseudo-file patterns like (eval
+1) of Perl and <string> of Python.
+
+If we're unable find the source code we return a string describing the
+problem as best as we can determine."
+
+ (unless (and filename (file-readable-p filename))
+ (if find-file-fn
+ (setq filename (funcall find-file-fn filename))
+ ;; FIXME: Remove the below by refactoring to use the above find-file-fn
+ ;; else
+ (if (and ignore-file-re (string-match ignore-file-re filename))
+ (message "tracking ignored for psuedo-file %s" filename)
+ ;; else
+ (let ((remapped-filename))
+ (if (gethash filename realgud-file-remap)
+ (progn
+ (setq remapped-filename (gethash filename realgud-file-remap))
+ (if (file-exists-p remapped-filename)
+ (setq filename remapped-filename)
+ (remhash filename realgud-file-remap)))
+ ;; else
+ (progn
+ (setq remapped-filename
+ (buffer-file-name
+ (compilation-find-file (point-marker) filename nil)))
+ (when (and remapped-filename (file-exists-p remapped-filename))
+ (puthash filename remapped-filename realgud-file-remap)
+ (setq filename remapped-filename)
+ )
+ )))
+ )
+ ;; FIXME: remove above -----------------------------------.
+ ))
+ (if filename
+ (if (file-readable-p filename)
+ (if (integerp line-number)
+ (if (> line-number 0)
+ (lexical-let ((line-count))
+ (if (setq line-count (realgud:file-line-count filename))
+ (if (> line-count line-number)
+ (let* ((column-number
+ (realgud:file-column-from-string filename
+ line-number
+
source-text))
+ ;; And you thought we'd never get around to
+ ;; doing something other than validation?
+ (loc (make-realgud-loc
+ :num bp-num
+ :cmd-marker cmd-marker
+ :filename filename
+ :line-number line-number
+ :column-number column-number
+ :source-text source-text
+ :marker (make-marker)
+ )))
+ loc)
+ ;; else
+ (format "File %s has only %d lines. (Line %d
requested.)"
+ filename line-count line-number))
+ (format "Problem getting line count for file `%s'"
filename)))
+ (format "line number %s should be greater than 0" line-number))
+ (format "%s is not an integer" line-number))
+ ;; else
+ (format "File named `%s' not readable" filename)))
+ )
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/follow.el
b/packages/realgud/realgud/common/follow.el
new file mode 100644
index 0000000..a360522
--- /dev/null
+++ b/packages/realgud/realgud/common/follow.el
@@ -0,0 +1,37 @@
+;;; Copyright (C) 2015 Rocky Bernstein <address@hidden>
+;;; Follows or goto's something
+(require 'load-relative)
+
+(declare-function realgud:cmd-frame 'realgud-cmds)
+
+(defun realgud:follow-mark(mark)
+ (when (markerp mark)
+ (let ((buffer (marker-buffer mark)))
+ (set-buffer buffer)
+ (set-window-point (display-buffer buffer) mark)
+ (goto-char mark)
+ )))
+
+
+(defun realgud:follow(pos)
+ (interactive "%d")
+ (let* ((mark (get-text-property pos 'mark))
+ (filename (get-text-property pos 'file))
+ (frame-num (get-text-property pos 'frame-num))
+ )
+ (cond ((markerp mark) (realgud:follow-mark mark) 't)
+ ((stringp filename)
+ (find-file-other-window filename))
+ ((numberp frame-num) (realgud:cmd-frame frame-num))
+ ('t (message "No location property found here")))
+ ))
+
+(defun realgud:follow-point()
+ (interactive "")
+ (realgud:follow (point)))
+
+(defun realgud:follow-event(event)
+ (interactive "e")
+ (realgud:follow (posn-point (event-end event))))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/fringe.el
b/packages/realgud/realgud/common/fringe.el
new file mode 100644
index 0000000..da6ade0
--- /dev/null
+++ b/packages/realgud/realgud/common/fringe.el
@@ -0,0 +1,223 @@
+;;; Copyright (C) 2010, 2012, 2014-2015 Rocky Bernstein <address@hidden>
+;; Fringe marks for history of stopping points
+(require 'load-relative)
+(require-relative-list '("helper") "realgud-")
+
+(declare-function realgud-loc-hist-item-at 'realgud-lochist)
+(declare-function buffer-killed? 'helper)
+(declare-function realgud-loc-cmd-marker 'realgud-loc)
+(declare-function realgud:loc-follow 'realgud-loc)
+(declare-function realgud-loc-marker 'realgud-loc)
+
+;; Bitmap for hollow overlay-arrow in fringe
+(if (display-images-p)
+ (define-fringe-bitmap 'hollow-right-triangle
+ "\xe0\x90\x88\x84\x84\x88\x90\xe0"))
+
+;; FIXME: Figure out how to do this as a macro.
+
+(if (equal 'dark (frame-parameter nil 'background-mode))
+ (progn
+ (defface realgud-overlay-arrow1
+ '((t
+ :foreground "green"
+ :weight bold))
+ "Fringe face for current position."
+ :group 'realgud)
+
+ (defface realgud-overlay-arrow2
+ '((t
+ :foreground "white"
+ :weight bold))
+ "Fringe face for position one back in fringe."
+ :group 'realgud)
+
+ (defface realgud-overlay-arrow3
+ '((t
+ :foreground "gray"
+ :weight bold))
+ "Fringe face for position two back in fringe."
+ :group 'realgud)
+ )
+ ;; else
+ (progn
+ (defface realgud-overlay-arrow1
+ '((t
+ :foreground "black"
+ :weight bold))
+ "Fringe face for current position."
+ :group 'realgud)
+
+ (defface realgud-overlay-arrow2
+ '((t
+ :foreground "gray"
+ :weight bold))
+ "Fringe face for position one back in fringe."
+ :group 'realgud)
+
+ (defface realgud-overlay-arrow3
+ '((t
+ :foreground "gainsboro"
+ :weight bold))
+ "Fringe face for position two back in fringe."
+ :group 'realgud)))
+
+
+(defvar realgud-overlay-arrow1 nil
+ "Overlay arrow variable which contains the most recent debugger
+position.")
+(defvar realgud-overlay-arrow2 nil
+ "Overlay arrow variable which contains the 2nd most recent debugger
+position.")
+(defvar realgud-overlay-arrow3 nil
+ "Overlay arrow variable which contains the 3rd most recent debugger
+position.")
+
+(eval-when-compile (require 'cl))
+
+
+;; FIXME: since overlay overlay-arrow-list can be global, and perhaps
+;; has to stay that way since some Emacs code may expect that, we
+;; should use different global overlay arrow variables for the
+;; different debuggers. E.g. trepan-overlay-arrow1,
+;; pyrealgud-overlay-arrow1 and so on. That way, if those debuggers are
+;; running concurrently, the fringe for one doesn't interfere with the
+;; fringe for another.
+
+;; Loop to set up fringe position markers.
+
+;; Here is an example of what each iteration does:
+;;
+;; (make-local-variable 'realgud-overlay-arrow1) ;; or 2, or 3
+;; (put 'realgud-overlay-arrow1 'overlay-arrow-string "=>" ;; or "2>", or
">3"
+;; (define-fringe-bitmap 'realgud-overlay-arrow1 "\xc0...")
+;; (add-to-list 'overlay-arrow-variable-list 'realgud-overlay-arrow1)
+
+(dolist (pair
+ '( ("3" . "3>") ("2" . "2>") ("1" . "=>")))
+ (let ((arrow-symbol (intern (concat "realgud-overlay-arrow" (car pair))))
+ (arrow-bitmap (intern (concat "realgud-right-triangle" (car pair))))
+ (arrow-face (intern (concat "realgud-overlay-arrow" (car pair)))))
+ (make-local-variable arrow-symbol)
+ (put arrow-symbol 'overlay-arrow-string (cdr pair))
+ (if (display-images-p)
+ (progn
+ (define-fringe-bitmap arrow-bitmap "\xc0\xf0\xf8\xfc\xfc\xf8\xf0\xc0")
+ (put arrow-symbol 'overlay-arrow-bitmap arrow-bitmap)
+ (set-fringe-bitmap-face arrow-bitmap arrow-face)))
+ (add-to-list 'overlay-arrow-variable-list arrow-symbol)))
+
+(defun realgud-fringe-set-arrow (overlay-arrow marker)
+ "Set the fringe indicator or overlay arrow to MARKER. This is done
+for example to indicate a debugger position."
+ (let ((position (marker-position marker)))
+ (if position
+ (with-current-buffer (marker-buffer marker)
+ (save-excursion
+ (save-restriction
+ (widen)
+ (progn
+ (goto-char position)
+ ;; We need to ignore field boundaries, so we use
+ ;; forward-line rather than beginning-of-line.
+ (forward-line 0)
+ (set overlay-arrow (point-marker)))))))))
+
+(defun realgud-fringe-history-set (loc-hist &optional do-cmdbuf?)
+ "Set arrows on the last positions we have stopped on."
+ ;; FIXME DRY somehow
+ (let* (
+ (loc1 (realgud-loc-hist-item-at loc-hist 2))
+ (loc2 (realgud-loc-hist-item-at loc-hist 1))
+ (loc3 (realgud-loc-hist-item-at loc-hist 0))
+ (mark1 (and loc3 (realgud-loc-marker loc3)))
+ (mark2 (and loc2 (realgud-loc-marker loc2)))
+ (mark3 (and loc1 (realgud-loc-marker loc1)))
+ (cmd-mark1 (and loc3 (realgud-loc-cmd-marker loc3)))
+ (cmd-mark2 (and loc2 (realgud-loc-cmd-marker loc2)))
+ (cmd-mark3 (and loc1 (realgud-loc-cmd-marker loc1)))
+ )
+ (when (and loc3 (not (equal mark3 mark2)))
+ (realgud-fringe-set-arrow 'realgud-overlay-arrow3 mark3)
+ (if do-cmdbuf?
+ (realgud-fringe-set-arrow 'realgud-overlay-arrow3 cmd-mark3)))
+ (when (and loc2 (not (equal mark2 mark1)))
+ (realgud-fringe-set-arrow 'realgud-overlay-arrow2 mark2)
+ (if do-cmdbuf?
+ (realgud-fringe-set-arrow 'realgud-overlay-arrow2 cmd-mark2)))
+ (when loc1
+ (realgud-fringe-set-arrow 'realgud-overlay-arrow1 mark1)
+ (when (and do-cmdbuf? cmd-mark1)
+ (realgud-fringe-set-arrow 'realgud-overlay-arrow1 cmd-mark1)
+ (goto-char (marker-position cmd-mark1)))
+ )
+ ))
+
+(defun realgud-fringe-erase-history-arrows ()
+ "Erase the history arrows from the fringe. You might want call
+this command interactively if you have conceptually stopped
+debugging and now find the fringe arrows distracting. But you
+don't want to kill the debugger process or quit a debugger
+session which should also erase those fringe arrows."
+ (interactive)
+ (setq realgud-overlay-arrow1 nil)
+ (setq realgud-overlay-arrow2 nil)
+ (setq realgud-overlay-arrow3 nil))
+
+(defun realgud-goto-arrow1()
+ "Goto the position stored in realgud-overlay-arrow1"
+ (interactive "")
+ (if realgud-overlay-arrow1
+ (realgud:loc-follow realgud-overlay-arrow1))
+ )
+
+(defun realgud-goto-arrow2()
+ "Goto the position stored in realgud-overlay-arrow2"
+ (interactive "")
+ (if realgud-overlay-arrow2
+ (realgud:loc-follow realgud-overlay-arrow2))
+ )
+
+
+(defun realgud-goto-arrow3()
+ "Goto the position stored in realgud-overlay-arrow3"
+ (interactive "")
+ (if realgud-overlay-arrow3
+ (realgud:loc-follow realgud-overlay-arrow3))
+ )
+
+(defun realgud-recenter-arrow1()
+ "If the current buffer contains realgud-overlay-arrow1 go to that position"
+ (interactive "")
+ (if (and realgud-overlay-arrow1
+ (eq (marker-buffer realgud-overlay-arrow1) (current-buffer)))
+ (goto-char realgud-overlay-arrow1))
+ )
+
+(defun realgud-recenter-arrow(&optional opt-buffer)
+ "If the current buffer contains realgud-overlay-arrows 1, 2 or 3
+ recenter window to show that"
+ (interactive "")
+ (let ((buffer (or opt-buffer (current-buffer))))
+ ;; We need to update in the order 3..1 so that if there are more than on
+ ;; arrows in the same buffer the smaller number (e.g. arrow 1) is the
+ ;; position we are at rather than the earlier one (e.g. arrow 3).
+ (with-current-buffer-safe buffer
+ (if (and realgud-overlay-arrow3
+ (eq (marker-buffer realgud-overlay-arrow3) buffer))
+ (realgud:loc-follow realgud-overlay-arrow3)
+ )
+ (if (and realgud-overlay-arrow2
+ (eq (marker-buffer realgud-overlay-arrow2) buffer))
+ (realgud:loc-follow realgud-overlay-arrow2)
+ )
+ (if (and realgud-overlay-arrow1
+ (eq (marker-buffer realgud-overlay-arrow1) buffer))
+ (realgud:loc-follow realgud-overlay-arrow1)
+ )
+ (redisplay)
+ )
+ ))
+
+
+(provide 'realgud-fringe)
diff --git a/packages/realgud/realgud/common/helper.el
b/packages/realgud/realgud/common/helper.el
new file mode 100644
index 0000000..9de9616
--- /dev/null
+++ b/packages/realgud/realgud/common/helper.el
@@ -0,0 +1,89 @@
+;;; Copyright (C) 2010, 2014, 2016 Rocky Bernstein <address@hidden>
+;;; Miscellaneous utility functions
+(require 'load-relative)
+
+(defun fn-p-to-fn?-alias (fn-sym)
+ "FN-SYM is assumed to be a symbol which is a function. If it
+ends in a 'p' or '-p', that suffix is stripped; in either case, a
+suffix with '?' is added this name is a new alias for that
+function FN-SYM."
+ (if (and (symbolp fn-sym) (functionp fn-sym))
+ (let*
+ ((fn-str (symbol-name fn-sym))
+ (new-fn-str
+ (cond
+ ((and (> (length fn-str) 2) (equal "-p" (substring fn-str -2)))
+ (substring fn-str 0 -2))
+ ((and (> (length fn-str) 1) (equal "p" (substring fn-str -1)))
+ (substring fn-str 0 -1))
+ (t fn-str)))
+ (new-fn-sym (intern (concat new-fn-str "?"))))
+ (defalias new-fn-sym fn-sym))))
+
+;; FIXME push the special casing into the debuggers themselves.
+(defun realgud:debugger-name-transform (debugger-name)
+ "In some cases we need to prefix a short debugger name, like
+'gdb' with 'realgud:'. This does that."
+ (let ((debugger-name-short
+ (file-name-sans-extension (file-name-nondirectory debugger-name))))
+ (cond
+ ;; ((equal debugger-name-short "gdb") "realgud:gdb")
+ ;; ((equal debugger-name-short "jdb") "realgud:jdb")
+ ((equal debugger-name-short "tortoise") "gub")
+ ((or (equal debugger-name "trepan.pl")
+ (equal debugger-name-short "trepanpl"))
+ "realgud:trepanpl")
+ ('t debugger-name-short))))
+
+(defun buffer-killed? (buffer)
+ "Return t if BUFFER is killed."
+ (not (buffer-name buffer)))
+
+(defmacro with-current-buffer-safe (buffer &rest body)
+ "Check that BUFFER has not been deleted before calling
+`with-current-buffer'. If it has been deleted return nil."
+ (declare (indent 1) (debug t))
+ `(if (or (not ,buffer) (buffer-killed? ,buffer))
+ nil
+ (with-current-buffer ,buffer
+ ,@body)))
+
+
+;; FIXME: prepend realgud- onto the beginning of struct-symbol
+(defmacro realgud-sget (struct-symbol struct-field)
+ "Simplified access to a field of a `defstruct'
+variable. STRUCT-SYMBOL is a defstruct symbol name. STRUCT-FIELD
+is a field in that. Access (STRUCT-SYMBOL-STRUCT-FIELD STRUCT-SYMBOL)"
+ (declare (indent 1) (debug t))
+ `(let* ((realgud-symbol-str
+ (concat "realgud-" (symbol-name ,struct-symbol)))
+ (realgud-field-access
+ (intern (concat realgud-symbol-str "-" (symbol-name,
struct-field)))))
+ (funcall realgud-field-access (eval (intern realgud-symbol-str)))))
+
+
+(defmacro realgud-struct-field-setter (variable-name field)
+ "Creates an defstruct setter method for field FIELD with
+of defstruct variable VARIABLE-NAME. For example:
+
+ (realgud-struct-field-setter \"realgud-srcbuf-info\" \"short-key?\")
+gives:
+ (defun realgud-srcbuf-info-short-key?=(value)
+ (setf (realgud-srcbuf-info-short-key? realgud-srcbuf-info) value))
+"
+ (declare (indent 1) (debug t))
+ `(defun ,(intern (concat variable-name "-" field "=")) (value)
+ ;; FIXME: figure out how to add docstring
+ ;; ,(concat "Sets field" ,field " of " ,variable-name " to VALUE")
+ (if ,(intern variable-name)
+ (setf (,(intern (concat variable-name "-" field))
+ ,(intern variable-name)) value))
+ ))
+
+;; (defun realgud-struct-field (var-sym field-sym)
+;; (setq var-str (symbol-name var-sym))
+;; (setq field-str (symbol-name field-sym))
+;; (funcall (symbol-function (intern (concat var-str "-" field-str)))
+;; (eval (intern var-str))))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/init.el
b/packages/realgud/realgud/common/init.el
new file mode 100644
index 0000000..38ee39c
--- /dev/null
+++ b/packages/realgud/realgud/common/init.el
@@ -0,0 +1,32 @@
+;;; Copyright (C) 2010, 2015 Rocky Bernstein <address@hidden>
+(require 'load-relative)
+
+(defface realgud-line-number
+ '((t :inherit font-lock-variable-name-face))
+ "Face for displaying line numbers in."
+ :group 'realgud
+ :version "23.4")
+
+(defvar realgud-line-number-face 'realgud-line-number
+ "Face name to use for line numbers.")
+
+(defface realgud-file-name
+ '((t :inherit font-lock-preprocessor-face))
+ "Face for displaying file names."
+ :group 'realgud
+ :version "23.4")
+
+(defface realgud-backtrace-number
+ '((t
+ :foreground "black"
+ :weight bold))
+ "Fringe face for current position."
+ :group 'realgud)
+
+(defvar realgud-backtrace-number-face 'realgud-backtrace-number
+ "Face name to use for backtrace numbers.")
+
+(defvar realgud-file-name-face 'realgud-file-name
+ "Face name to use for file names.")
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/key.el
b/packages/realgud/realgud/common/key.el
new file mode 100644
index 0000000..a7bd912
--- /dev/null
+++ b/packages/realgud/realgud/common/key.el
@@ -0,0 +1,143 @@
+;; Author: Rocky Bernstein <address@hidden>
+;; Version: 1.1
+;; Keywords: internal
+;; URL: http://github.com/rocky/emacs-load-relative
+;; Compatibility: GNU Emacs 24.x
+
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(provide 'key)
+;;; key.el ends here
+
+(require 'load-relative)
+(require-relative "custom" nil "realgud-")
+
+(defcustom realgud-populate-common-fn-keys-function
+ 'realgud-populate-common-fn-keys-standard
+ "The function to call to populate key bindings common to all dbgr windows.
+This includes the secondary windows, the debugger shell, and all
+Ruby source buffers when the debugger is active.
+
+This variable can be bound to the following:
+
+* nil -- Don't bind any keys.
+
+* `realgud-populate-common-fn-keys-standard' -- Bind the function
+ keys according to a widely used debugger convention:
+
+\\{realgud-example-map-standard}
+
+* `realgud-populate-common-fn-keys-eclipse' -- Bind according to Eclipse.
+
+\\{realgud-example-map-eclipse}
+
+* `realgud-populate-common-fn-keys-netbeans' -- Bind according to NetBeans.
+
+\\{realgud-example-map-netbeans}
+
+* Any other value is expected to be a callable function that takes one
+ argument, the keymap, and populates it with suitable keys."
+ :type 'function
+ :group 'realgud)
+
+;; -------------------------------------------------------------------
+;; Key bindings
+;;
+
+(defun realgud-populate-common-fn-keys-standard (&optional map)
+ "Bind the debugger function key layout used by many debuggers.
+
+\\{realgud-example-map-standard}"
+ (define-key map [f5] 'realgud:cmd-continue)
+ (define-key map [S-f5] 'realgud:cmd-quit)
+ ;; (define-key map [f9] 'realgud-toggle-source-breakpoint)
+ (define-key map [f9] 'realgud:cmd-break)
+ ;; (define-key map [C-f9] 'realgud-toggle-source-breakpoint-enabled)
+ (define-key map [f10] 'realgud:cmd-next)
+ (define-key map [f11] 'realgud:cmd-step)
+ (define-key map [S-f11] 'realgud:cmd-finish)
+ (define-key map [M-down] 'realgud-track-hist-newer)
+ (define-key map [A-down] 'realgud-track-hist-newer)
+ (define-key map [M-kp-2] 'realgud-track-hist-newer)
+ (define-key map [M-up] 'realgud-track-hist-older)
+ (define-key map [A-up] 'realgud-track-hist-older)
+ (define-key map [M-kp-8] 'realgud-track-hist-older)
+ (define-key map [M-kp-up] 'realgud-track-hist-older)
+ (define-key map [M-kp-down] 'realgud-track-hist-newer)
+ (define-key map [M-print] 'realgud-track-hist-older)
+ (define-key map [M-S-down] 'realgud-track-hist-newest)
+ (define-key map [M-S-up] 'realgud-track-hist-oldest)
+ (define-key map "\C-c " 'realgud:cmd-break)
+ )
+
+;; TODO: add eclipse, and netbeans
+
+(defun realgud-populate-common-keys (map)
+ "Define the keys that are used by all debugger buffers, including
+source-code buffers
+
+The variable `realgud-populate-common-fn-keys-function' controls the layout."
+ (define-key map "\C-x\C-a\C-q" 'realgud-short-key-mode)
+ (if realgud-populate-common-fn-keys-function
+ (funcall realgud-populate-common-fn-keys-function map))
+ (realgud-populate-common-fn-keys-standard map)
+)
+
+(defun realgud-populate-src-buffer-map-plain (map)
+ "Bind ordinary text characters used in debugger source-code buffers.
+
+This does not touch change menus; for that see
`realgud-populate-debugger-menu'.
+Nor does it touch prefix keys; for that see `realgud-populate-keys-standard'"
+ ;; Common Debugger functions
+ (let ((prefix-map (make-sparse-keymap)))
+ (define-key map "b" 'realgud:cmd-break)
+ (define-key map "D" 'realgud:cmd-delete)
+ (define-key map [delete] 'realgud:cmd-delete)
+ (define-key map [enter] 'realgud:cmd-repeat-last)
+ (define-key map (kbd "RET") 'realgud:cmd-repeat-last)
+ (define-key map " " 'realgud:cmd-step)
+ (define-key map "f" 'realgud:cmd-finish)
+ (define-key map "n" 'realgud:cmd-next)
+ (define-key map "q" 'realgud:cmd-quit)
+ (define-key map "r" 'realgud:cmd-restart)
+ (define-key map "R" 'realgud:cmd-restart)
+ (define-key map "s" 'realgud:cmd-step)
+ (define-key map "!" 'realgud:cmd-shell)
+
+ ;; FIXME: these can go to a common routine. See also shortkey.el
+ ;; and backtrace-mode.el
+ (define-key map "<" 'realgud:cmd-newer-frame)
+ (define-key map ">" 'realgud:cmd-older-frame)
+ (define-key map "d" 'realgud:cmd-newer-frame)
+ (define-key map "u" 'realgud:cmd-older-frame)
+ (define-key map "C" 'realgud-window-cmd-undisturb-src)
+ (define-key map "F" 'realgud:window-bt)
+ (define-key map "Q" 'realgud:cmd-terminate)
+ (define-key map "S" 'realgud-window-src-undisturb-cmd)
+ (define-key map "U" 'realgud:cmd-until)
+
+ (define-key map [M-down] 'realgud-track-hist-newer)
+ (define-key map [M-kp-2] 'realgud-track-hist-newer)
+ (define-key map [M-up] 'realgud-track-hist-older)
+ (define-key map [M-kp-8] 'realgud-track-hist-older)
+ (define-key map [M-kp-up] 'realgud-track-hist-older)
+ (define-key map [M-kp-down] 'realgud-track-hist-newer)
+ (define-key map [M-print] 'realgud-track-hist-older)
+ (define-key map [M-S-down] 'realgud-track-hist-newest)
+ (define-key map [M-S-up] 'realgud-track-hist-oldest)
+ ))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/lang.el
b/packages/realgud/realgud/common/lang.el
new file mode 100644
index 0000000..3d32891
--- /dev/null
+++ b/packages/realgud/realgud/common/lang.el
@@ -0,0 +1,98 @@
+;;; Copyright (C) 2010, 2012, 2014-2015 Rocky Bernstein <address@hidden>
+;;; Programming language specific stuff.
+(require 'load-relative)
+
+(defun realgud-lang-mode? (filename lang-str)
+ "Return true if FILENAME is a buffer we are visiting a buffer
+that is in LANG-STR mode. The test is just that the major mode
+starts LANG-STR."
+ (let ((buffer (and filename (find-buffer-visiting filename)))
+ (match-pos))
+ (cond (buffer
+ (save-current-buffer
+ (set-buffer buffer)
+ (setq match-pos
+ (string-match (format "^%s-" lang-str)
+ (format "%s" major-mode))))
+ (and match-pos (= 0 match-pos)))
+ ('t nil)
+ ))
+ )
+
+(defun realgud:suggest-file-from-buffer (lang-str &optional opt-buff-list)
+ "Suggest the first in the buffer list for which test-func is
+ 't. Typically this is used. To search for a buffer in one of
+ the programming modes like Ruby or Python."
+ (let ((file)
+ (buff)
+ (not-found 't)
+ (buff-list (or opt-buff-list (buffer-list)))
+ )
+ (while (and not-found (setq buff (car-safe buff-list)))
+ (setq buff-list (cdr buff-list))
+ (setq file (buffer-file-name buff))
+ (if (realgud-lang-mode? file lang-str)
+ (setq not-found nil)
+ ))
+ (if not-found nil file)
+ )
+ )
+
+(defun realgud-suggest-lang-file (lang-str lang-ext-regexp &optional
last-resort)
+ "Suggest a file to debug. We search for the the major mode for
+that programming language using we check filenames using
+LANG-EXT-REGEXP. For example, for ruby LANG-STR would be 'ruby'
+and LANG-EXT-REGEXP would be '\\.rb$'.
+
+Buffers and files are ranked with a priority. Higher is more
+priority and selected will be selected over lower-priorities.
+
+The first priority is given to the current buffer. If the major
+mode matches LANG-STR, then we are done. If not, we'll set
+priority 2 and we keep going. Then we will try files in the
+default-directory. Of those buffers we are visiting, we check the
+major mode. The first one we find we will return. Failing this,
+we see if the file is executable and has a LANG-EXT suffix. These
+have priority 8. Failing that, we'll go for just having a
+LANG-EXT suffix. These have priority 7. And other executable
+files that are not directories have priority 6 if they have the
+right LANG-EXT, otherwise they are priority 5.
+
+Within a given priority, we use the first one we find."
+ (let* ((file)
+ (file-list (directory-files default-directory))
+ (priority 2)
+ (is-not-directory)
+ (result (buffer-file-name)))
+ (unless (realgud-lang-mode? result lang-str)
+ (while (and (setq file (car-safe file-list)) (< priority 8))
+ (setq file-list (cdr file-list))
+ (when (realgud-lang-mode? file lang-str)
+ (setq result file)
+ (setq priority
+ (if (file-executable-p file)
+ (setq priority 8)
+ (setq priority 7))))
+ ;; The file isn't in a language-mode buffer,
+ ;; Check for an executable file with a language extension.
+ (if (and file (file-executable-p file)
+ (setq is-not-directory (not (file-directory-p file))))
+ (if (and (string-match lang-ext-regexp file))
+ (if (< priority 6)
+ (progn
+ (setq result file)
+ (setq priority 6))))
+ (when (and is-not-directory (< priority 5))
+ ;; Found some sort of regular file.
+ (setq result file)
+ (setq priority 5))
+ ))
+ )
+ (if (< priority 6)
+ (if (setq file (realgud:suggest-file-from-buffer lang-str))
+ (setq result file)
+ (if last-resort (setq result last-resort))))
+ result)
+ )
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/loc.el
b/packages/realgud/realgud/common/loc.el
new file mode 100644
index 0000000..00c75a0
--- /dev/null
+++ b/packages/realgud/realgud/common/loc.el
@@ -0,0 +1,185 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; This describes a debugger location structure and has code for
+;; working with them.
+
+(require 'load-relative)
+(require 'loc-changes)
+(require-relative-list '("fringe" "follow") "realgud-")
+(require-relative-list '("buffer/source") "realgud-buffer-")
+
+;; FIXME: removed because of recursive loads
+;; (require-relative-list '("buffer/helper") "realgud-buffer-")
+
+(declare-function realgud:strip 'realgud)
+(declare-function realgud-get-cmdbuf-from-srcbuf 'realgud-buffer-helper)
+(declare-function realgud-srcbuf? 'realgud-buffer-source)
+
+(defstruct realgud-loc
+"Our own location type. Even though a mark contains a
+file-name (via a buffer) and a line number (via an offset), we
+want to save the values that were seen/requested originally."
+ num ;; If there is a number such as a breakpoint or frame
+ ;; number associated with this location, this is set.
+ ;; nil otherwise.
+ filename
+ line-number
+ column-number ;; Column offset within line
+ source-text ;; Source text if available
+ marker ;; Position in source code
+ cmd-marker ;; Position in command process buffer
+)
+
+(defalias 'realgud-loc? 'realgud-loc-p)
+
+;; The below function is generic and might be found in standard
+;; library. Or it might be moved someplace more generic.
+(defun realgud:buffer-line-no-props()
+ "Returns a string containing the line that `point' is at,
+without buffer properties."
+ (buffer-substring-no-properties (point-at-bol)
+ (point-at-eol)))
+
+(defun realgud:loc-describe (loc)
+ "Display realgud-cmdcbuf-info.
+Information is put in an internal buffer called *Describe*."
+ (interactive "")
+ (switch-to-buffer (get-buffer-create "*Describe*"))
+ (let ((link-start) (link-end) (map) (filename))
+ (insert " - filename :: ")
+ (setq filename (realgud-loc-filename loc))
+ (put-text-property
+ (insert-text-button filename
+ 'action 'realgud:follow-event
+ 'help-echo "mouse-2: go to this file")
+ (point)
+ 'file filename)
+ (insert "\n")
+ (mapc 'insert
+ (list
+ (format " - line number :: %s\n" (realgud-loc-line-number loc))
+ (format " - brkpt num :: %s\n" (realgud-loc-num loc))
+ (format " - column number :: %s\n"
+ (realgud-loc-column-number loc))
+ (format " - source text :: %s\n" (realgud-loc-source-text loc))
+ ))
+ ;; Make locations clickable
+ (insert " - source marker :: ")
+ (put-text-property
+ (insert-text-button (format "%s" (realgud-loc-marker loc))
+ 'action 'realgud:follow-event
+ 'help-echo "mouse-2: go to this source location")
+ (point)
+ 'mark (realgud-loc-marker loc))
+
+ (insert "\n - cmdbuf marker :: ")
+ (put-text-property
+ (insert-text-button (format "%s" (realgud-loc-cmd-marker loc))
+ 'action 'realgud:follow-event
+ 'help-echo "mouse-2: go to this command-buffer
location")
+ (point)
+ 'mark (realgud-loc-cmd-marker loc))
+ (insert "\n")
+ )
+ )
+
+
+(defun realgud-loc-current(&optional source-buffer cmd-marker)
+ "Create a location object for the point in the current buffer.
+ If SOURCE-BUFFER is not given, take the current buffer as the
+ source buffer."
+ (interactive "")
+ (unless source-buffer
+ (setq source-buffer (current-buffer)))
+ (unless (realgud-srcbuf? source-buffer)
+ (error "%s is not a realgud source buffer" source-buffer))
+ (unless cmd-marker
+ (setq cmd-marker
+ (realgud-get-cmdbuf-from-srcbuf source-buffer))
+ )
+ (with-current-buffer source-buffer
+ (let ((mark (point-marker))
+ (text (realgud:buffer-line-no-props)))
+ (make-realgud-loc
+ :filename (buffer-file-name source-buffer)
+ :column-number (current-column)
+ :line-number (line-number-at-pos)
+ :source-text text
+ :marker mark
+ :cmd-marker cmd-marker
+ )
+ )))
+
+(defun realgud-loc-marker=(loc marker)
+ (setf (realgud-loc-marker loc) marker))
+
+(defun realgud-loc-goto(loc)
+ "Position point in the buffer referred to by LOC. This may
+involve reading in a file. In the process, the marker inside LOC
+may be updated.
+
+If LOC is found, The buffer containing the location referred to,
+the source-code buffer, is returned. Otherwise, nil is returned."
+ (if (realgud-loc? loc)
+ (let* ((filename (realgud-loc-filename loc))
+ (line-number (realgud-loc-line-number loc))
+ (column-number (realgud-loc-column-number loc))
+ (marker (realgud-loc-marker loc))
+ (cmd-marker (realgud-loc-cmd-marker loc))
+ (use-marker nil)
+ (src-buffer (marker-buffer (or marker (make-marker)))))
+ (if (and (not src-buffer) filename)
+ (setq src-buffer (find-file-noselect filename)))
+ (if cmd-marker
+ (with-current-buffer (marker-buffer cmd-marker)
+ (goto-char cmd-marker)))
+ (if src-buffer
+ (with-current-buffer src-buffer
+ (when (and marker (marker-position marker))
+ ;; A marker has been set in loc, so use that.
+ (goto-char (marker-position marker))
+ (setq use-marker 't)
+ (let ((current-text (realgud:buffer-line-no-props))
+ (loc-text (realgud-loc-source-text loc)))
+ (unless (and loc-text
+ (equal (realgud:strip current-text)
(realgud:strip loc-text)))
+ (loc-changes-goto line-number)
+ (setq current-text (realgud:buffer-line-no-props))
+ (when (equal current-text loc-text)
+ (message "Marked location needed updating")
+ (setq use-marker nil))
+ )))
+ (if use-marker
+ (goto-char (marker-position marker))
+ ;; else
+ ;; We don't have a position set in the source buffer
+ ;; so find it and go there. We use `loc-changes-goto'
+ ;; to find that spot. `loc-changes-goto' keeps a
+ ;; record of the first time we went to that spot, so
+ ;; in the face of buffer modifications, it may be more
+ ;; reliable.
+ (let ((src-marker))
+ (loc-changes-goto line-number)
+ (when column-number
+ (move-to-column column-number))
+ (setq src-marker (point-marker))
+ (realgud-loc-marker= loc src-marker)
+ ))))
+ src-buffer )))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/lochist.el
b/packages/realgud/realgud/common/lochist.el
new file mode 100644
index 0000000..ed61001
--- /dev/null
+++ b/packages/realgud/realgud/common/lochist.el
@@ -0,0 +1,132 @@
+;;; Copyright (C) 2010, 2012, 2014-2015 Rocky Bernstein <address@hidden>
+;;; Debugger location ring
+;;; Commentary:
+
+;; This file manages a ring of (recently stopped) positions to allow
+;; the programmer to move between them.
+
+;;; Code:
+
+(require 'ring)
+(require 'org)
+(require 'load-relative)
+(require-relative-list '("loc") "realgud-")
+
+(declare-function realgud:loc-describe 'realgud-loc)
+
+(defcustom realgud-loc-hist-size 20 ; For testing. Should really be larger.
+ "Size of realgud's position history ring"
+ :type 'integer
+ :group 'realgud)
+
+(defstruct realgud-loc-hist
+ "A list of source-code positions recently encountered"
+ (position -1)
+ (ring (make-ring realgud-loc-hist-size)))
+
+(defun realgud:loc-hist-describe(loc-hist)
+ "Format LOC-HIST values inside buffer *Describe*"
+ (switch-to-buffer (get-buffer-create "*Describe*"))
+ (org-mode)
+ (insert "** Source Positions Stopped At\n")
+ (mapc 'insert
+ (list
+ (format " - buffer size :: %d\n" realgud-loc-hist-size)
+ (format " - position :: %d\n"
+ (realgud-loc-hist-position loc-hist))))
+ (let ((locs (cddr (realgud-loc-hist-ring loc-hist)))
+ (loc)
+ (i 0))
+ (while (and (< i (length locs)) (setq loc (elt locs i)) (realgud-loc? loc)
)
+ (insert (format "*** %d\n" i))
+ (realgud:loc-describe loc)
+ (setq i (1+ i))
+ )
+ )
+)
+
+(defun realgud-loc-hist-item-at(loc-hist position)
+ "Get the current item stored at POSITION of the ring
+component in LOC-HIST"
+ (lexical-let ((ring (realgud-loc-hist-ring loc-hist)))
+ (if (ring-empty-p ring)
+ nil
+ (ring-ref ring position))))
+
+(defun realgud-loc-hist-item(loc-hist)
+ "Get the current item of LOC-HIST at the position previously set"
+ (realgud-loc-hist-item-at
+ loc-hist
+ (realgud-loc-hist-position loc-hist)))
+
+(defun realgud-loc-hist-add(loc-hist loc)
+ "Add FRAME to LOC-HIST"
+ ;; Switching frames shouldn't save a new ring
+ ;; position. Also make sure no position is different.
+ ;; Perhaps duplicates should be controlled by an option.
+ (let* ((ring (realgud-loc-hist-ring loc-hist))
+ (old-loc (realgud-loc-hist-item loc-hist)))
+ (unless (and
+ old-loc
+ (equal (realgud-loc-filename old-loc)
+ (realgud-loc-filename loc))
+ (equal (realgud-loc-line-number old-loc)
+ (realgud-loc-line-number loc))
+ (equal (realgud-loc-column-number old-loc)
+ (realgud-loc-column-number old-loc)))
+ (setf (realgud-loc-hist-position loc-hist) 0)
+ (ring-insert ring loc)
+ )
+ ))
+
+(defun realgud-loc-hist-clear(loc-hist)
+ "Clear out all source locations in LOC-HIST"
+ (lexical-let* ((ring (ring-ref (realgud-loc-hist-ring loc-hist)
+ (realgud-loc-hist-position loc-hist)))
+ (head (car ring)))
+ (setf (realgud-loc-hist-position loc-hist) (- head 1))
+ (while (not (ring-empty-p ring))
+ (ring-remove ring))))
+
+(defun realgud-loc-hist-index(loc-hist)
+ "Return the ring-index value of LOC-HIST"
+ (lexical-let* (
+ (ring (realgud-loc-hist-ring loc-hist))
+ (head (car ring))
+ (ringlen (cadr ring))
+ (index (mod (+ ringlen head
+ (- (realgud-loc-hist-position loc-hist)))
+ ringlen)))
+ (if (zerop index) ringlen index)
+ ))
+
+(defun realgud-loc-hist-set (loc-hist position)
+ "Set LOC-HIST to POSITION in the stopping history"
+ (setf (realgud-loc-hist-position loc-hist) position))
+
+;; FIXME: add numeric arg?
+(defun realgud-loc-hist-newer (loc-hist)
+ "Set LOC-HIST position to an newer position."
+
+ (setf (realgud-loc-hist-position loc-hist)
+ (ring-minus1 (realgud-loc-hist-position loc-hist)
+ (ring-length (realgud-loc-hist-ring loc-hist)))))
+
+(defun realgud-loc-hist-newest (loc-hist)
+ "Set LOC-HIST position to the newest position."
+ (setf (realgud-loc-hist-position loc-hist) -1))
+
+;; FIXME: add numeric arg?
+(defun realgud-loc-hist-older (loc-hist)
+ "Set LOC-HIST position to an older position."
+ (setf (realgud-loc-hist-position loc-hist)
+ (ring-plus1 (realgud-loc-hist-position loc-hist)
+ (ring-length (realgud-loc-hist-ring loc-hist)))))
+
+(defun realgud-loc-hist-oldest (loc-hist)
+ "Set LOC-HIST to the oldest stopping point."
+ (lexical-let* ((ring (realgud-loc-hist-ring loc-hist))
+ (head (car ring)))
+ (setf (realgud-loc-hist-position loc-hist) head)))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/menu.el
b/packages/realgud/realgud/common/menu.el
new file mode 100644
index 0000000..94d1385
--- /dev/null
+++ b/packages/realgud/realgud/common/menu.el
@@ -0,0 +1,170 @@
+;; Copyright (C) 2010-2011, 2015 Rocky Bernstein <address@hidden>
+;; -------------------------------------------------------------------
+;; Menu support.
+;;
+
+(require 'load-relative)
+
+;; We want the doc strings from gdb-like commands for our help
+;; menus.
+(require-relative-list '("cmds") "realgud-")
+
+;; Note: We want the key binding to show in the menu. However, our
+;; situation is a little bit complex:
+;;
+;; 1) We want the binding of the `common' man (i.e. the function key
+;; the user has selected.)
+;;
+;; 2) We want this even when the menu is disabled and the key isn't
+;; bound, typically when the debugger isn't running.
+;;
+;; This has been solved by setting up an explicit ":keys" properly.
+(defun realgud-menu-item (common-map name cmd &rest args)
+ "Return a menu item entry with the correct key bindings.
+
+A command can be bound to a number of different key sequences. If
+the realgud common map contains a binding it is displayed in the
+menu. (The common map typically contains function key bindings.)"
+ (let ((key-binding (where-is-internal cmd (list common-map) t))
+ (hint '()))
+ (if key-binding
+ (setq hint (list :keys (key-description key-binding))))
+ (append (list 'menu-item name cmd)
+ hint
+ args)))
+
+
+;; I had a *lot* of trouble with emacs keymaps and duplicate menus.
+;; Don't use set-parent-mode on any minor mode.
+;; It is possible that realgud-track-mode could be a derived major mode whose
parent
+;; is comint, but that seems drastic.
+;; Instead we take the various minor modes and add a debugger menu to that.
+(defun realgud-populate-debugger-menu (map)
+ "Populate the 'Debugger' menu inside an existing menu (short-key or
track-mode)."
+ (let ((debugger-map (make-sparse-keymap "Debugger")))
+ (define-key map [menu-bar debugger] (cons "Debugger" debugger-map))
+ (define-key debugger-map [command]
+ (realgud-menu-item debugger-map "Go to Command Buffer"
+ 'realgud-window-cmd-undisturb-src
+ :enable '(and (realgud-get-process) (not
(realgud-cmdbuf?)))
+ :help (documentation 'realgud-window-cmd-undisturb-src)
+ ))
+
+ (define-key debugger-map [source]
+ (realgud-menu-item debugger-map "Go to Source Buffer"
+ 'realgud-window-src-undisturb-cmd
+ :enable '(and (realgud-get-process) (not
(realgud-srcbuf?)))
+ :help (documentation 'realgud-window-src-undisturb-cmd)
+ ))
+
+ (define-key debugger-map [info]
+ (realgud-menu-item debugger-map "Debugger Info"
+ 'realgud:cmdbuf-info-describe
+ :help (documentation 'realgud:cmdbuf-info-describe)
+ ))
+
+ (define-key debugger-map [backtrace]
+ (realgud-menu-item debugger-map "Backtrace" 'realgud:window-bt
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:window-bt)
+ ))
+
+ (define-key debugger-map [arrow3]
+ (realgud-menu-item debugger-map "Arrow 3" 'realgud-goto-arrow3
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud-goto-arrow3)
+ ))
+
+ (define-key debugger-map [arrow2]
+ (realgud-menu-item debugger-map "Arrow 2" 'realgud-goto-arrow2
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud-goto-arrow2)
+ ))
+
+ (define-key debugger-map [arrow1]
+ (realgud-menu-item debugger-map "Arrow 1" 'realgud-goto-arrow1
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud-goto-arrow1)
+ ))
+
+ (define-key debugger-map [break]
+ (realgud-menu-item debugger-map "Set Breakpoint" 'realgud:cmd-break
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-break)
+ ))
+
+ (define-key debugger-map [continue]
+ (realgud-menu-item debugger-map "Continue" 'realgud:cmd-continue
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-continue)
+ ))
+
+ (define-key debugger-map [until]
+ (realgud-menu-item debugger-map "Continue to Line" 'realgud:cmd-until
+ :enable '(and (realgud-get-process)
realgud-short-key-mode)
+ :help (documentation 'realgud:cmd-until)
+ ))
+
+ (define-key debugger-map [next]
+ (realgud-menu-item debugger-map "Next (step through)" 'realgud:cmd-next
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-next)
+ ))
+
+ (define-key debugger-map [finish]
+ (realgud-menu-item debugger-map "Finish (step out)" 'realgud:cmd-finish
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-finish)
+ ))
+
+ (define-key debugger-map [step]
+ (realgud-menu-item debugger-map "Step (step into)" 'realgud:cmd-step
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-step)
+ ))
+
+ (define-key debugger-map [menu-bar debugger line1] '(menu-item "--"))
+
+ (define-key debugger-map [down]
+ (realgud-menu-item debugger-map "Down Stack" 'realgud:cmd-newer-frame
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-newer-frame)
+ ))
+
+ (define-key debugger-map [up]
+ (realgud-menu-item debugger-map "Up Stack" 'realgud:cmd-older-frame
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-older-frame)
+ ))
+
+ (define-key debugger-map [menu-bar debugger line1] '(menu-item "--"))
+
+ (define-key debugger-map [quit]
+ (realgud-menu-item debugger-map "Quit" 'realgud:cmd-quit
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-quit)
+ ))
+
+ (define-key debugger-map [restart]
+ (realgud-menu-item debugger-map "Restart" 'realgud:cmd-restart
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-restart)
+ ))
+
+ (define-key debugger-map [eval]
+ (realgud-menu-item debugger-map "Evaluate Region"
'realgud:cmd-eval-region
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud:cmd-eval-region)
+ ))
+
+ (define-key debugger-map [Recenter]
+ (realgud-menu-item debugger-map "Recenter" 'realgud-recenter-arrow
+ :enable '(realgud-get-process)
+ :help (documentation 'realgud-recenter-arrow)
+ ))
+ ;; Put them in the menu bar:
+ (setq menu-bar-final-items (append '(debugger) menu-bar-final-items))
+ map
+ ))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/regexp.el
b/packages/realgud/realgud/common/regexp.el
new file mode 100644
index 0000000..5239adf
--- /dev/null
+++ b/packages/realgud/realgud/common/regexp.el
@@ -0,0 +1,63 @@
+;;; Copyright (C) 2010-2011, 2014-2015 Rocky Bernstein <address@hidden>
+;;; FIXME - think of a better name.
+;;;
+;;; Debugger regular expressions for many kinds of
+;;; debuggers
+
+;;; Here we have hash tables used in each kind of debugger
+;;; and names for patterns matching fields in a location
+;;; structure
+
+;;; Code:
+
+;; -------------------------------------------------------------------
+;; Variables defining regular expressions (regexp:s).
+;;
+
+(eval-when-compile (require 'cl))
+
+(defstruct realgud-loc-pat
+ "Information to match and extract position and other related information
typically
+output by a debugger inside a process shell"
+ (num) ;; General number. Could be for example
+ ;; breakpoint number,
+ (string) ;; General string, Could be for example a list of
+ ;; breakpoint number. Or can be used if for example
+ ;; if we need more than one in a complicated re
+ ;; where we can't assign a single number to a
+ ;; file position as in Perl locations.
+ (regexp) ;; a stack position, or thread number.
+ (file-group) ;; Filename position in struct
+ (line-group) ;; Line number position in struct
+ (alt-file-group) ;; Used when regexp is too complicated and use \|
+ ;; e.g. perldb file loc regexps
+ (alt-line-group) ;; ditto
+ (char-offset-group) ;; Character offset position in struct
+ (instruction-address-group)
+ (column-group)
+ (ignore-file-re) ;; Some debuggers create pseudo files in eval strings
+ ;; for example "(eval)" in Ruby and Perl
+ (text-group) ;; Some source text that should found at position
+ (class-group) ;; Java doesn't refer to files, but class names
+ (event-group) ;; Stopping event, e.g.statement, breakpoint,
+ ;; call, return, exception, etc.
+)
+
+(defconst realgud:regexp-captured-num "\\([0-9]+\\)")
+
+(defvar realgud-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the debugger name, a string. The values of a hash entry
+ is a realgud-loc-pat struct")
+
+(defvar realgud-command-hash (make-hash-table :test 'equal)
+ "Hash key is the debugger name, a string. The value of a hash
+ entry is a hash table mapping cannonic command name
+ debugger-specific command name. For example, for trepanning:
+ 'quit' -> 'quit!'")
+
+(defvar realgud:variable-basename-hash (make-hash-table :test 'equal)
+ "Hash key is the debugger name, a string. The value of a hash
+ entry is the base name to use that variables of that debugger use.
+ For example, for 'gdb' it is 'realgud:gdb'.")
+
+(provide 'realgud-regexp)
diff --git a/packages/realgud/realgud/common/reset.el
b/packages/realgud/realgud/common/reset.el
new file mode 100644
index 0000000..c5c06b4
--- /dev/null
+++ b/packages/realgud/realgud/common/reset.el
@@ -0,0 +1,45 @@
+;;; Copyright (C) 2010, 2014 Rocky Bernstein <address@hidden>
+;; reset state on quit or restart
+
+(require 'load-relative)
+(require 'loc-changes)
+(require-relative-list '("bp" "fringe" "helper") "realgud-")
+(require-relative-list '("buffer/helper" "buffer/command" "buffer/source")
+ "realgud-buffer-")
+
+(declare-function loc-changes-clear-buffer 'loc-changes)
+(declare-function realgud-bp-remove-icons 'realgud-buffer-command)
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud-get-cmdbuf-from-srcbuf 'realgud-buffer-helper)
+(declare-function realgud-fringe-erase-history-arrows
+ 'realgud-buffer-command)
+
+(defun realgud:reset (&optional opt-buffer)
+ "Reset state prior to quitting or restarting"
+ (interactive)
+ (let* ((buf (or opt-buffer (current-buffer)))
+ (cmdbuf
+ (cond ((realgud-cmdbuf? buf) buf)
+ ((realgud-get-cmdbuf-from-srcbuf buf))
+ ('t nil))))
+ (if cmdbuf
+ (with-current-buffer cmdbuf
+ (realgud-fringe-erase-history-arrows)
+ (let ((buf-list (realgud-sget 'cmdbuf-info 'srcbuf-list)))
+ (dolist (buf buf-list buf-list)
+ (with-current-buffer buf
+ (loc-changes-clear-buffer)
+ (realgud-fringe-erase-history-arrows)
+ ;; FIXME: iterate over specific breakpoints.
+ (realgud-bp-remove-icons (point-min) (point-max))
+ )
+ (message "buffer %s" buf)
+ ))
+ (setq realgud-cmdbuf-info nil)
+ )
+ ;; else
+ (error "Unable to find command buffer from %s" buf)
+ ))
+ )
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/run.el
b/packages/realgud/realgud/common/run.el
new file mode 100644
index 0000000..1108673
--- /dev/null
+++ b/packages/realgud/realgud/common/run.el
@@ -0,0 +1,190 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Copyright (C) 2014-2015 Rocky Bernstein <address@hidden>
+
+; (require 'term)
+
+(require 'shell)
+(require 'list-utils)
+(require 'load-relative)
+(require-relative-list '("core" "track" "utils") "realgud-")
+(require-relative-list '("buffer/command") "realgud-buffer-")
+
+(declare-function realgud-cmdbuf-info-in-debugger?= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-cmd-args= 'realgud-buffer-command)
+(declare-function realgud:track-set-debugger 'realgud-track)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud:flatten 'realgud-utils)
+
+(defun realgud:parse-cmd-args(args two-args opt-two-args interp-regexp
debugger-regexp
+ path-args-list annotate-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing:
+* the command processor (e.g. bash) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. bashdb) and its arguments - a list of
strings.
+ If there is no debugger, for example gdb, nodejs then nil is returned.
+* the script name and its arguments - list of strings
+* whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+The script name and options mentioning paths are file expanded
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(bash --norc bashdb -l . --emacs ./gcd.sh a b))
+
+we might return:
+ ((\"bash\" \"--norc\") (\"bashdb\" \"-l\" \"/tmp\" \"--emacs\")
(\"/tmp/gcd.sh\" \"a\" \"b\") t)
+
+Note that path elements have been expanded via `expand-file-name'.
+"
+ ;; Parse the following kind of pattern:
+ ;; [bash bash-options] bashdb bashdb-options script-name script-options
+ (let (
+ (pair)
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil nil nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional interpreter name
+ (when (and interp-regexp
+ (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args)))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off compiler/intepreter-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args two-args opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; path-like options
+ ((member arg path-args-list)
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
+ ;; Other options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args two-args opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuffer-history
+ &optional no-reset)
+ "Runs `realgud-exec-shell' with DEBUGGER-NAME SCRIPT-FILENAME
+and CMD-ARGS If this succeeds, we save CMD-ARGS in command-buffer
+for use if we want to restart. If we don't succeed in running
+the program, we will switch to the command buffer which shows
+details of the error. The command buffer or nil is returned."
+
+ (let ((cmd-buf))
+ (setq cmd-buf
+ (apply 'realgud-exec-shell debugger-name script-filename
+ (car cmd-args) no-reset (cdr cmd-args)))
+ ;; FIXME: Is there probably is a way to remove the
+ ;; below test and combine in condition-case?
+ (let ((process (get-buffer-process cmd-buf)))
+ (if (and process (eq 'run (process-status process)))
+ (progn
+ (switch-to-buffer cmd-buf)
+ (realgud:track-set-debugger debugger-name)
+ (realgud-cmdbuf-info-in-debugger?= 't)
+ (realgud-cmdbuf-info-cmd-args= cmd-args)
+ (when cmd-buf
+ (switch-to-buffer cmd-buf)
+ (when realgud-cmdbuf-info
+ (let* ((info realgud-cmdbuf-info)
+ (cmd-args (realgud-cmdbuf-info-cmd-args info))
+ (cmd-str (mapconcat 'identity cmd-args " ")))
+ (set minibuffer-history
+ (list-utils-uniq (cons cmd-str
+ (eval minibuffer-history)))
+ ))
+ )))
+ ;; else
+ (progn
+ (if cmd-buf (switch-to-buffer cmd-buf))
+ (message "Error running command: %s" (mapconcat 'identity cmd-args "
"))
+ )
+ )
+ )
+ cmd-buf
+ )
+ )
+
+(defun realgud:run-debugger (debugger-name query-cmdline-fn parse-cmd-args-fn
+ minibuffer-history
+ &optional opt-command-line
+ no-reset)
+ "Invoke the a debugger and start the Emacs user interface.
+
+String OPT-COMMAND-LINE specifies how to run DEBUGGER-NAME. You
+will be prompted for a command line using QUERY-CMDLINE-FN is one
+isn't supplied.
+
+OPT-COMMAND-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by PARSE-CMD-FN and path elements found by that
+are expanded using `expand-file-name'.
+
+If successful, The command buffer of the debugger process is returned.
+Otherwise nil is returned.
+"
+ (let* ((cmd-str (or opt-command-line (funcall query-cmdline-fn
debugger-name)))
+ (cmd-args (split-string-and-unquote cmd-str))
+ (parsed-args (funcall parse-cmd-args-fn cmd-args))
+ (script-args (caddr parsed-args))
+ (script-name (car script-args))
+ (parsed-cmd-args
+ (remove-if 'nil (realgud:flatten parsed-args)))
+ )
+ (realgud:run-process debugger-name script-name parsed-cmd-args
+ minibuffer-history no-reset)
+ )
+ )
+
+(provide-me "realgud:")
+
+;; Local Variables:
+;; byte-compile-warnings: (not cl-functions)
+;; End:
diff --git a/packages/realgud/realgud/common/send.el
b/packages/realgud/realgud/common/send.el
new file mode 100644
index 0000000..39ac519
--- /dev/null
+++ b/packages/realgud/realgud/common/send.el
@@ -0,0 +1,257 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(require 'comint)
+(require 'eshell)
+(require 'load-relative)
+(require-relative-list '("utils" "window") "realgud-")
+(require-relative-list '("buffer/helper") "realgud-buffer-")
+
+(declare-function realgud-get-cmdbuf 'realgud-buffer-helper)
+(declare-function realgud-window-cmd-undisturb-src 'realgud-window)
+(declare-function comint-goto-process-mark 'comint)
+(declare-function comint-send-input 'comint)
+(declare-function realgud:canonic-major-mode 'realgud-utils)
+
+(defun realgud:send-input ()
+ "Sends command buffer line either to comint or eshell"
+ (interactive)
+ (let ((mode (realgud:canonic-major-mode)))
+ (cond ((eq mode 'eshell)
+ (eshell-send-input))
+ ((eq mode 'comint)
+ (comint-send-input))
+ )))
+
+(defun realgud:send-command-common (process command-str)
+ "Assume we are in a comint buffer. Insert COMMAND-STR and
+send that input onto the process."
+ (if (eq 'run (process-status process))
+ (let ((mode (realgud:canonic-major-mode)))
+ (cond ((eq mode 'eshell)
+ (goto-char eshell-last-output-end)
+ (setq eshell-last-output-start
+ (setq realgud-last-output-start (point-marker))))
+ ((eq mode 'comint)
+ (comint-check-proc (current-buffer))
+ (comint-goto-process-mark)
+ (setq comint-last-output-start
+ (setq realgud-last-output-start (point-marker)))))
+ (insert command-str)
+ (realgud:send-input)
+ )
+ ;; else
+ (message "Process %s not in `run' state; not issuing %s"
+ process command-str)
+ )
+ )
+
+(defalias 'comint-output-filter-orig
+ (symbol-function 'comint-output-filter))
+
+(defvar realgud-last-output-start)
+(defun fake-output-filter(process string)
+ "A process output filter that saves the results into a temporary buffer."
+ (with-current-buffer (get-buffer-create "*realgud-process-output-temp*")
+ (goto-char (point-max))
+ (set (make-local-variable 'realgud-last-output-start)
+ (point-marker))
+ (insert (concat "\n" string))
+ (goto-char (point-max))))
+
+(defun realgud-send-command-process (process command-str)
+ "Invoke debugger COMMAND adding that command and the
+results into the command buffer."
+ (fset 'comint-output-filter (symbol-function 'fake-output-filter))
+ (apply comint-input-sender (list process command-str))
+ (sit-for 0.25) ;; FIXME with something better
+ (fset 'comint-output-filter (symbol-function 'comint-output-filter-orig))
+ )
+
+;; Here are some other possibilities for functions.
+;; Comint-specific: doesn't insert input into the buffer which is
+;; what gud-call does.
+;; (apply comint-input-sender (list proc command))
+;;
+;; Works on any process-oriented buffer, not just comint.
+;; (process-send-string (get-buffer-process (current-buffer))
+;; (concat command "\n"))
+
+
+(defun realgud-send-command (command &optional opt-send-fn opt-buffer)
+ "Invoke the debugger COMMAND adding that command and the
+results into the command buffer."
+ (let* ((cmdbuf (realgud-get-cmdbuf opt-buffer))
+ (send-command-fn (or opt-send-fn (function
realgud:send-command-common)))
+ )
+ (if cmdbuf
+ (with-current-buffer cmdbuf
+ (let ((process (get-buffer-process cmdbuf)))
+ (unless process
+ (realgud-cmdbuf-info-in-debugger?= nil)
+ (error "Command process buffer is not running")
+ )
+ (if (realgud-sget 'cmdbuf-info 'in-debugger?)
+ (funcall send-command-fn process command)
+ (error "Command buffer doesn't think a debugger is running - Use
`realgud-cmdbuf-toggle-in-debugger?' to toggle")
+ )
+ ))
+ (error "Can't find command process buffer")
+ )))
+
+(defun realgud-send-command-invisible (command-str)
+ (realgud-send-command command-str (function realgud-send-command-process)))
+
+
+(defun realgud-expand-format (fmt-str &optional opt-str opt-buffer)
+ "Expands commands format characters inside FMT-STRING using values
+from the debugging session. OPT-STR is an optional string.
+Some %-escapes in the string arguments are expanded. These are:
+
+ %f -- Name without directory of current source file.
+ %F -- Name without directory or extension of current source file.
+ %x -- Name of current source file.
+ %X -- Expanded name of current source file.
+ %d -- Directory of current source file.
+ %l -- Number of current source line.
+ %p -- Numeric prefix argument converted to a string
+ If no prefix argument %p is the null string.
+ %c -- Fully qualified class name derived from the expression
+ surrounding point.
+ %s -- value of opt-str.
+
+"
+ (let* ((buffer (or opt-buffer (current-buffer)))
+ (srcbuf (realgud-get-srcbuf buffer))
+ (src-file-name (and srcbuf (buffer-file-name srcbuf)))
+ result)
+ (while (and fmt-str
+ (let ((case-fold-search nil))
+ (string-match "\\([^%]*\\)%\\([dfFlpxXs]\\)" fmt-str)))
+ (let* ((key-str (match-string 2 fmt-str))
+ (key (string-to-char key-str)))
+ (setq result
+ (concat
+ result (match-string 1 fmt-str)
+ (cond
+ ((eq key ?d)
+ (or (and src-file-name
+ (file-name-directory src-file-name))
+ "*source-file-not-found-for-%d"))
+ ((eq key ?f)
+ (or (and src-file-name
+ (file-name-nondirectory src-file-name))
+ "*source-file-not-found-for-%f*"))
+ ((eq key ?F)
+ (or (and src-file-name
+ (file-name-sans-extension
+ (file-name-nondirectory src-file-name)))
+ "*source-file-not-found-for-%F"))
+ ((eq key ?l)
+ (if srcbuf
+ (with-current-buffer srcbuf
+ (int-to-string
+ (save-restriction
+ (widen)
+ (+ (count-lines (point-min) (point))
+ (if (bolp) 1 0)))))
+ "source-buffer-not-found-for-%l"))
+ ((eq key ?x)
+ (or (and src-file-name src-file-name)
+ "*source-file-not-found-for-%x"))
+ ((eq key ?X)
+ (or (and src-file-name (expand-file-name src-file-name))
+ "*source-file-not-found-for-%X"))
+ ;; ((eq key ?e)
+ ;; (gud-find-expr))
+ ;; ((eq key ?a)
+ ;; (gud-read-address))
+ ;; ((eq key ?c)
+ ;; (gud-find-class srcbuf))
+ ((eq key ?p) (if opt-str (int-to-string opt-str) ""))
+ ((eq key ?s) opt-str)
+ (t key)))))
+ (setq fmt-str (substring fmt-str (match-end 2))))
+ ;; There might be text left in FMT-STR when the loop ends.
+ (concat result fmt-str)))
+
+(defun realgud-command (fmt &optional arg no-record? frame-switch?
realgud-prompts?)
+ "Sends a command to the process associated with the command
+buffer of the current buffer. A bit of checking is done before
+sending the command to make sure that we can find a command
+buffer, and that it has a running process associated with it.
+
+FMT is a string which may contain format characters that are
+expanded. See `realgud-expand-format' for a list of the format
+characters and their meanings.
+
+If NO-RECORD? is set, the command won't be recorded in the
+position history. This is often done in status and information
+gathering or frame setting commands and is generally *not* done
+in commands that continue execution.
+
+If FRAME-SWITCH? is set, the fringe overlay array icon is set to
+indicate the depth of the frame.
+
+If REALGUD-PROMPTS? is set, then then issuing the command will cause a
+debugger prompt.
+"
+ (interactive "sCommand (may contain format chars): ")
+ (let* ((command-str (realgud-expand-format fmt arg))
+ (cmd-buff (realgud-get-cmdbuf))
+ )
+ (unless cmd-buff
+ (error "Can't find command buffer for buffer %s" (current-buffer)))
+
+ ;; Display the expanded command in the message area unless the
+ ;; current buffer is the command buffer.
+ (unless (realgud-cmdbuf?)
+ (message "Command: %s" command-str))
+
+ (with-current-buffer cmd-buff
+ (let* ((process (get-buffer-process cmd-buff))
+ (last-output-end (point-marker))
+ (in-srcbuf? (realgud-sget 'cmdbuf-info 'in-srcbuf?))
+ )
+ (unless process
+ (error "Can't find process for command buffer %s" cmd-buff))
+ (unless (eq 'run (process-status process))
+ (error "Process %s isn't running; status %s" process
+ (process-status process)))
+
+ (realgud-cmdbuf-info-no-record?= no-record?)
+ (realgud-cmdbuf-info-frame-switch?= frame-switch?)
+
+ ;; Down the line we may handle prompting in a more
+ ;; sophisticated way. But for now, we handle this by forcing
+ ;; display of the command buffer.
+ (if realgud-prompts? (realgud-window-cmd-undisturb-src nil 't))
+
+ (realgud-send-command command-str (function
realgud:send-command-common))
+
+ ;; Wait for the process-mark to change before changing variables
+ ;; that effect the hook processing.
+ (while (and (eq 'run (process-status process))
+ (equal last-output-end (process-mark process)))
+ (sit-for 0))
+
+ ;; Reset temporary hook-processing variables to their default state.
+ (realgud-cmdbuf-info-no-record?= nil)
+ (realgud-cmdbuf-info-frame-switch?= nil)
+ ))))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/shortkey.el
b/packages/realgud/realgud/common/shortkey.el
new file mode 100644
index 0000000..4adecc2
--- /dev/null
+++ b/packages/realgud/realgud/common/shortkey.el
@@ -0,0 +1,221 @@
+;;; Copyright (C) 2010-2015 Rocky Bernstein <address@hidden>
+(require 'load-relative)
+(require-relative-list '("custom" "eval" "helper" "key" "lochist" "loc"
+ "menu")
+ "realgud-")
+(require-relative-list '("buffer/command" "buffer/helper" "buffer/source")
+ "realgud-buffer-")
+
+(eval-when-compile
+ (defvar realgud:tool-bar-map) ;; Fully defined in track-mode
+)
+
+
+(declare-function realgud-cmdbuf?
'realgud-buffer-command)
+(declare-function realgud:debugger-name-transform 'realgud-helper)
+(declare-function realgud-get-cmdbuf 'realgud-buffer-helper)
+(declare-function realgud:loc-follow 'realgud-loc)
+(declare-function realgud-loc-hist-item-at 'realgud-lochist)
+(declare-function realgud-cmdbuf-loc-hist 'realgud-command)
+(declare-function realgud-populate-debugger-menu 'realgud-menu)
+(declare-function realgud-populate-common-keys 'realgud-key)
+(declare-function realgud-populate-src-buffer-map-plain 'realgud-key)
+(declare-function realgud-srcbuf-info-short-key?=, 'realgud-source)
+(declare-function realgud-srcbuf-info-was-read-only?= 'realgud-source)
+(declare-function realgud-srcbuf? 'realgud-buffer-source)
+
+;; (defvar realgud::tool-bar-map) ;; fully defined in track-mode.el
+
+(defvar realgud:shortkey-mode-map
+ (let ((map (make-sparse-keymap)))
+ (suppress-keymap map)
+ (realgud-populate-debugger-menu map)
+ (realgud-populate-common-keys map)
+ (realgud-populate-src-buffer-map-plain map)
+ (define-key map "1" 'realgud-goto-arrow1)
+ (define-key map "2" 'realgud-goto-arrow2)
+ (define-key map "3" 'realgud-goto-arrow3)
+ (define-key map "4" 'realgud:goto-loc-hist-4)
+ (define-key map "5" 'realgud:goto-loc-hist-5)
+ (define-key map "6" 'realgud:goto-loc-hist-6)
+ (define-key map "7" 'realgud:goto-loc-hist-7)
+ (define-key map "8" 'realgud:goto-loc-hist-8)
+ (define-key map "9" 'realgud:goto-loc-hist-9)
+ (define-key map "b" 'realgud:cmd-break)
+ (define-key map "c" 'realgud:cmd-continue)
+ (define-key map "e" 'realgud:cmd-eval-region)
+ (define-key map "U" 'realgud:cmd-until)
+ (define-key map [mouse-2] 'realgud:tooltip-eval)
+
+ ;; FIXME: these can go to a common routine
+ (define-key map "<" 'realgud:cmd-newer-frame)
+ (define-key map ">" 'realgud:cmd-older-frame)
+ (define-key map "d" 'realgud:cmd-newer-frame)
+ (define-key map "u" 'realgud:cmd-older-frame)
+ (define-key map "l" 'realgud-recenter-arrow)
+ (define-key map "C" 'realgud-window-cmd-undisturb-src)
+ (define-key map "I" 'realgud:cmdbuf-info-describe)
+ (define-key map "S" 'realgud-window-src-undisturb-cmd)
+
+ (define-key map "R" 'realgud:cmd-restart)
+ (define-key map "!" 'realgud:cmd-shell)
+ (define-key map [insert] 'realgud-short-key-mode)
+ (define-key map [(control x)(control q)] 'realgud-short-key-mode)
+ map)
+ "Keymap used in `realgud-short-key-mode'.")
+
+;; Implementation note: This is the mode that does all the work, it's
+;; local to the buffer that is affected.
+(define-minor-mode realgud-short-key-mode
+ "Minor mode with short keys for source buffers for the `dbgr' debugger.
+The buffer is read-only when the minor mode is active.
+
+\\{realgud:shortkey-mode-map}"
+ :group 'realgud
+ :global nil
+ :init-value nil
+ :lighter " ShortKeys"
+ :keymap realgud:shortkey-mode-map
+ ;; executed on activation/deactivation:
+ (realgud-short-key-mode-setup realgud-short-key-mode))
+
+(defun realgud-get-short-key-mode-map (cmdbuf)
+ (when (realgud-cmdbuf? cmdbuf)
+ (with-current-buffer cmdbuf
+ (let* ((info realgud-cmdbuf-info)
+ (debugger-name (realgud-cmdbuf-info-debugger-name info))
+ (base-variable-name
+ (or (gethash debugger-name realgud:variable-basename-hash)
+ debugger-name))
+ (keymap-symbol
+ (intern
+ (replace-regexp-in-string
+ "\\." ""
+ (concat base-variable-name "-short-key-mode-map"))))
+ (keymap (eval keymap-symbol))
+ )
+ (cond ((keymapp keymap) keymap)
+ ('t nil))
+ ))
+ ))
+
+(defun realgud-short-key-mode-setup (mode-on?)
+ "Called when entering or leaving `realgud-short-key-mode'. Variable
+MODE-ON? a boolean which specifies if we are going into or out of this mode."
+ (if (realgud-srcbuf?)
+ (let* ((cmdbuf (realgud-get-cmdbuf))
+ (shortkey-keymap (realgud-get-short-key-mode-map cmdbuf))
+ )
+
+ ;; If there's a shortkey keymap that is custom
+ ;; for this debugger mode, use it.
+ (when shortkey-keymap
+ (cond
+ (mode-on?
+ (set (make-local-variable 'tool-bar-map) realgud:tool-bar-map)
+ (use-local-map shortkey-keymap))
+ ('t
+ (kill-local-variable 'realgud:tool-bar-map)
+ (use-local-map nil))
+ ))
+
+ ;; Ensure action only is performed when the state actually is toggled.
+ ;; or when not read-only
+ (when (or (not buffer-read-only)
+ (not (eq (realgud-sget 'srcbuf-info 'short-key?) mode-on?)))
+ ;; Save the current state, so we can determine when the
+ ;; state is toggled in the future.
+ (when (not (eq (realgud-sget 'srcbuf-info 'short-key?) mode-on?))
+ (realgud-srcbuf-info-short-key?= mode-on?)
+ (setq realgud-short-key-mode mode-on?)
+ (if mode-on?
+ ;; mode is being turned on.
+ (progn
+ (realgud-srcbuf-info-was-read-only?= buffer-read-only)
+
+ ;; If there's a shortkey keymap that is custom
+ ;; for this debugger mode, use it.
+ (if shortkey-keymap (use-local-map shortkey-keymap))
+
+ (local-set-key [m-insert] 'realgud-short-key-mode)
+ (when realgud-srcbuf-lock (setq buffer-read-only t))
+ (run-mode-hooks 'realgud-short-key-mode-hook))
+ ;; mode is being turned off: restore read-only state.
+ (setq buffer-read-only
+ (realgud-sget 'srcbuf-info 'was-read-only?))))
+ ;; (with-current-buffer-safe cmdbuf
+ ;; (realgud-cmdbuf-info-src-shortkey?= mode-on?)
+ ;; (realgud-cmdbuf-info-in-srcbuf?= mode-on?)
+ ;; )
+ ))
+ (progn
+ (setq realgud-short-key-mode nil)
+ (error "buffer %s does not seem to be attached to a debugger"
+ (buffer-name)))))
+
+(defun realgud-short-key-mode-off ()
+ "Turn off `realgud-short-key-mode' in all buffers."
+ (interactive)
+ (save-excursion
+ (dolist (buf (buffer-list))
+ (set-buffer buf)
+ (when realgud-short-key-mode
+ (realgud-short-key-mode-setup 0)))))
+
+(defun realgud-populate-src-buffer-map (map)
+ "Bind all common keys and menu used in the dbgr src buffers.
+This includes the keys bound to `realgud-key-prefix' (typically C-x
+C-a)."
+ (realgud-populate-src-buffer-map-plain map)
+ (realgud-populate-common-keys map)
+ (let ((prefix-map (make-sparse-keymap)))
+ (realgud-populate-debugger-menu map)
+ (realgud-populate-src-buffer-map-plain prefix-map)
+ (define-key map realgud-key-prefix prefix-map)))
+
+(defun realgud:goto-loc-hist(num)
+ "Go to position nth from the newest position."
+ (let ((cmdbuf (realgud-get-cmdbuf)))
+ (if cmdbuf
+ (let* ((loc-hist (realgud-cmdbuf-loc-hist cmdbuf))
+ (loc (realgud-loc-hist-item-at loc-hist (- num)))
+ (loc-marker (realgud-loc-marker loc)))
+ (realgud:loc-follow loc-marker))
+ ;; else
+ (message "No command buffer associated with this buffer")
+ )))
+
+
+(defun realgud:goto-loc-hist-4 ()
+ "Go to position 4th from the newest position."
+ (interactive "")
+ (realgud:goto-loc-hist 4))
+
+(defun realgud:goto-loc-hist-5 ()
+ "Go to position 5th from the newest position."
+ (interactive "")
+ (realgud:goto-loc-hist 5))
+
+(defun realgud:goto-loc-hist-6 ()
+ (interactive "")
+ (realgud:goto-loc-hist 6))
+
+(defun realgud:goto-loc-hist-7 ()
+ "Go to position 7th from the newest position."
+ (interactive "")
+ (realgud:goto-loc-hist 7))
+
+(defun realgud:goto-loc-hist-8 ()
+ "Go to position 8th from the newest position."
+ (interactive "")
+ (realgud:goto-loc-hist 8))
+
+(defun realgud:goto-loc-hist-9 ()
+ "Go to position 9th from the newest position."
+ (interactive "")
+ (realgud:goto-loc-hist 9))
+
+(provide-me "realgud-")
+
+;;; Local variables:
+;;; End:
diff --git a/packages/realgud/realgud/common/track-mode.el
b/packages/realgud/realgud/common/track-mode.el
new file mode 100644
index 0000000..bf0888b
--- /dev/null
+++ b/packages/realgud/realgud/common/track-mode.el
@@ -0,0 +1,240 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; tracks shell output
+
+(eval-when-compile (require 'cl))
+(require 'shell)
+
+(require 'load-relative)
+(require-relative-list
+ '("core" "helper" "track" "loc" "lochist" "file"
+ "fringe" "window" "regexp" "menu" "backtrace-mode"
+ "send" "shortkey" "utils") "realgud-")
+
+(require-relative-list '("buffer/command") "realgud-buffer-")
+
+;; FIXME figure out if I can put this in something like a header file.
+(declare-function realgud-fringe-erase-history-arrows 'realgud-buffer-command)
+(declare-function realgud:track-set-debugger 'realgud-track)
+(declare-function realgud-populate-debugger-menu 'realgud-menu)
+(declare-function realgud-cmdbuf-info-divert-output?=
+ 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-prior-prompt-regexp=
+ 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-set?
+ 'realgud-buffer-command)
+(declare-function realgud:canonic-major-mode
+ 'realgud-utils)
+
+(defvar realgud-track-mode-map
+ (let ((map (copy-keymap shell-mode-map)))
+ (realgud-populate-debugger-menu map)
+ (define-key map "\r" 'realgud:send-input)
+ (define-key map [M-right] 'realgud-track-hist-newest)
+ (define-key map [M-down] 'realgud-track-hist-newer)
+ (define-key map [M-up] 'realgud-track-hist-older)
+ (define-key map [M-print] 'realgud-track-hist-older)
+ (define-key map [M-S-down] 'realgud-track-hist-newest)
+ (define-key map [M-S-up] 'realgud-track-hist-oldest)
+ (define-key map "\C-cS" 'realgud-window-src-undisturb-cmd)
+ (define-key map (kbd "C-c !d") 'realgud:goto-debugger-loc-line)
+ map)
+ "Keymap used in `realgud-track-minor-mode'.
+
+\\{realgud-track-mode-map}")
+
+
+(defvar realgud:tool-bar-map
+ (let ((map (make-sparse-keymap)))
+ (dolist (x '((realgud:cmd-break . "gud/break")
+ ;; (realgud:cmd-remove . "gud/remove")
+ ;; (realgud:cmd-print . "gud/print")
+ ;; (realgud:cmd-pstar . "gud/pstar")
+ ;; (realgud:cmd-pp . "gud/pp")
+ ;; (realgud:cmd-watch . "gud/watch")
+ (realgud:cmd-restart . "gud/run")
+ ;; (realgud:cmd-go . "gud/go")
+ ;; (realgud:cmd-stop-subjob . "gud/stop")
+ (realgud:cmd-continue . "gud/cont")
+ (realgud:cmd-until . "gud/until")
+ (realgud:cmd-next . "gud/next")
+ (realgud:cmd-step . "gud/step")
+ (realgud:cmd-finish . "gud/finish")
+ ;; (realgud:cmd-nexti . "gud/nexti")
+ ;; (realgud:cmd-stepi . "gud/stepi")
+ (realgud:cmd-older-frame . "gud/up")
+ (realgud:cmd-newer-frame . "gud/down")
+ (realgud:cmdbuf-info-describe . "info"))
+ map)
+ (tool-bar-local-item-from-menu
+ (car x) (cdr x) map realgud-track-mode-map)))
+ "toolbar use when `realgud' interface is active"
+ )
+
+(define-minor-mode realgud-track-mode
+ "Minor mode for tracking debugging inside a process shell."
+ :init-value nil
+ :global nil
+ :group 'realgud
+
+ :lighter
+ (:eval (progn
+ (concat " "
+ (if (realgud-cmdbuf-info-set?)
+ (realgud-sget 'cmdbuf-info 'debugger-name)
+ "dbgr??"))))
+
+ :keymap realgud-track-mode-map
+ ;; Setup/teardown
+ (realgud-track-mode-setup realgud-track-mode)
+ )
+
+;; FIXME: this should have been picked up by require'ing track.
+(defvar realgud-track-divert-string)
+
+(defun realgud-track-mode-setup (mode-on?)
+ "Called when entering or leaving `realgud-track-mode'. Variable
+MODE-ON is a boolean which specifies if we are going into or out
+of this mode."
+ (if mode-on?
+ (let ((process (get-buffer-process (current-buffer))))
+ (unless process
+ (setq realgud-track-mode nil)
+ (error "Can't find a process for buffer %s" (current-buffer)))
+
+ (setq realgud-track-divert-string "")
+ (setq realgud-track-mode 't)
+
+ ;; FIXME: save and chain process-sentinel via
+ ;; (process-sentinel (get-buffer-process (current-buffer)))
+ (set-process-sentinel process 'realgud-term-sentinel)
+ (unless (and (realgud-cmdbuf-info-set?)
+ (realgud-sget 'cmdbuf-info 'debugger-name))
+ (call-interactively 'realgud:track-set-debugger))
+ (if (boundp 'comint-last-output-start)
+ (progn
+ (realgud-cmdbuf-info-prior-prompt-regexp= comint-prompt-regexp)
+ (realgud-cmdbuf-info-divert-output?= nil)
+ (let* ((regexp-hash
+ (and (realgud-cmdbuf-info? realgud-cmdbuf-info)
+ (realgud-sget 'cmdbuf-info 'regexp-hash)))
+ (prompt-pat (and regexp-hash
+ (gethash "prompt" regexp-hash))))
+ (if prompt-pat
+ (setq comint-prompt-regexp
+ (realgud-loc-pat-regexp prompt-pat)))))
+ (set-marker comint-last-output-start (point)))
+
+ (set (make-local-variable 'tool-bar-map) realgud:tool-bar-map)
+ (let ((mode (realgud:canonic-major-mode)))
+ (cond ((eq mode 'eshell)
+ (add-hook 'eshell-output-filter-functions
+ 'realgud-track-eshell-output-filter-hook))
+ ((eq mode 'comint)
+ (add-hook 'comint-output-filter-functions
+ 'realgud-track-comint-output-filter-hook))
+ ))
+ (run-mode-hooks 'realgud-track-mode-hook))
+ ;; else
+ (progn
+ (if (and (boundp 'comint-last-output-start) realgud-cmdbuf-info)
+ (setq comint-prompt-regexp
+ (realgud-sget 'cmdbuf-info 'prior-prompt-regexp))
+ )
+ (kill-local-variable 'realgud:tool-bar-map)
+ (realgud-fringe-erase-history-arrows)
+ (let ((mode (realgud:canonic-major-mode)))
+ (cond ((eq mode 'eshell)
+ (remove-hook 'eshell-output-filter-functions
+ 'realgud-track-eshell-output-filter-hook))
+ ((eq mode 'comint)
+ (remove-hook 'comint-output-filter-functions
+ 'realgud-track-comint-output-filter-hook))
+ ))
+ (let* ((cmd-process (get-buffer-process (current-buffer)))
+ (status (if cmd-process
+ (list (propertize (format ":%s"
+ (process-status cmd-process))
+ 'face 'debugger-running))
+ ""))
+ )
+ (setq mode-line-process status)
+ ;; Force mode line redisplay soon.
+ (force-mode-line-update)
+ ;; FIXME: This is a workaround. Without this, we comint doesn't
+ ;; process commands
+ (unless (member 'comint-mode minor-mode-list) (comint-mode))
+ )
+
+ ;; FIXME: restore/unchain old process sentinels.
+ )
+ )
+ )
+
+;; For name == "trepan", produces:
+;; (defvar trepan-track-mode nil
+;; "Non-nil if using trepan track-mode ... "
+;; (defvar trepan-track-mode-map (make-sparse-keymap))
+;; (defvar trepan-short-key-mode-map (make-sparse-keymap))
+;; (set-keymap-parent trepan-short-key-mode-map realgud-short-key-mode-map)
+(defmacro realgud-track-mode-vars (name)
+ `(progn
+ (defvar ,(intern (concat name "-track-mode")) nil
+ ,(format "Non-nil if using %s-track-mode as a minor mode of some other
mode.
+Use the command `%s-track-mode' to toggle or set this variable." name name))
+ (defvar ,(intern (concat name "-track-mode-map")) (make-sparse-keymap)
+ ,(format "Keymap used in `%s-track-mode'." name))
+ (defvar ,(intern (concat name "-short-key-mode-map"))
(make-sparse-keymap))
+ ))
+
+;; FIXME: The below could be a macro? I have a hard time getting
+;; macros right.
+(defun realgud-track-mode-body(name)
+ "Used in by custom debuggers: pydbgr, trepan, gdb, etc. NAME is
+the name of the debugger which is used to preface variables."
+ (realgud:track-set-debugger name)
+ (funcall (intern (concat "realgud-define-" name "-commands")))
+ (if (intern (concat name "-track-mode"))
+ (progn
+ (setq realgud-track-mode 't)
+ (run-mode-hooks (intern (concat name "-track-mode-hook"))))
+ (progn
+ (setq realgud-track-mode nil)
+ )))
+
+(defun realgud:track-mode-disable()
+ "Disable the debugger track-mode hook"
+ (interactive "")
+ (if realgud-track-mode
+ (progn
+ (setq realgud-track-mode nil)
+ ;; FIXME: for some reason, disabling trak mode also
+ ;; disables shell mode. Reinitialize it?
+ (if (equal mode-name "Shell")
+ (shell-mode))
+ )
+ (message "Debugger is not in track mode")))
+
+(defun realgud:track-mode-enable()
+ "Enable the debugger track-mode hook"
+ (interactive "")
+ (if realgud-track-mode
+ (message "Debugger track mode is already enabled.")
+ (setq realgud-track-mode t))
+ )
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/track.el
b/packages/realgud/realgud/common/track.el
new file mode 100644
index 0000000..f49b909
--- /dev/null
+++ b/packages/realgud/realgud/common/track.el
@@ -0,0 +1,729 @@
+;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(declare-function realgud:terminate &optional cmdbuf)
+
+(defconst realgud-track-char-range 10000
+ "Max number of characters from end of buffer to search for stack entry.")
+
+;; Shell process buffers that we can hook into:
+(require 'esh-mode)
+(require 'ansi-color)
+(require 'comint)
+
+(require 'load-relative)
+(require-relative-list
+ '("core" "file" "fringe"
+ "helper" "init" "loc" "lochist"
+ "regexp" "shortkey" "window"
+ "bp"
+ ) "realgud-")
+
+(require-relative-list
+ '("buffer/command" "buffer/helper" "buffer/source") "realgud-buffer-")
+
+(defcustom realgud-short-key-on-tracing? nil
+"If non-nil, set short-key mode for any source buffer that is traced into"
+ :type 'symbolp
+ :group 'realgud)
+
+(declare-function fn-p-to-fn?-alias 'realgud-helper)
+(declare-function realgud-bp-add-info 'realgud-bp)
+(declare-function realgud-bp-del-info 'realgud-bp)
+(declare-function realgud-cmdbuf-add-srcbuf 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-debugger-name 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-bp-list= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-divert-output?= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-in-debugger? 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-in-debugger?= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-last-input-end= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-init 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-loc-hist 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-mode-line-update 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-mode-line-update 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-pat 'realgud-buffer-command)
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-in-srcbuf?= 'realgud-buffer-command)
+(declare-function realgud:debugger-name-transform 'realgud-helper)
+(declare-function realgud:terminate 'realgud-core)
+(declare-function realgud:file-loc-from-line 'realgud-file)
+(declare-function realgud-fringe-history-set 'realgud-fringe)
+(declare-function realgud-get-cmdbuf 'realgud-buffer-command)
+(declare-function realgud-get-srcbuf-from-cmdbuf 'realgud-buffer-helper)
+(declare-function realgud-loc-goto 'realgud-loc)
+(declare-function realgud-loc-hist-add 'realgud-lochist)
+(declare-function realgud-loc-hist-index 'realgud-lochist)
+(declare-function realgud-loc-hist-item 'realgud-lochist)
+(declare-function realgud-loc? 'realgud-loc)
+(declare-function realgud-short-key-mode-setup 'realgud-shortkey)
+(declare-function realgud-srcbuf-init-or-update 'realgud-source)
+(declare-function realgud-srcbuf-loc-hist 'realgud-source)
+(declare-function realgud-window-src 'realgud-window)
+(declare-function realgud-window-src-undisturb-cmd 'realgud-window)
+(declare-function realgud-window-update-position 'realgud-window)
+
+(make-variable-buffer-local (defvar realgud-track-mode))
+(fn-p-to-fn?-alias 'realgud-loc-p)
+
+(defvar realgud-track-divert-string)
+
+(defun realgud-track-comint-output-filter-hook(text)
+ "An output-filter hook custom for comint shells. Find
+location/s, if any, and run the action(s) associated with
+finding a new location/s. The parameter TEXT appears because it
+is part of the comint-output-filter-functions API. Instead we use
+marks set in buffer-local variables to extract text"
+
+ ;; Instead of trying to piece things together from partial text
+ ;; (which can be almost useless depending on Emacs version), we
+ ;; monitor to the point where we have the next dbgr prompt, and then
+ ;; check all text from comint-last-input-end to process-mark.
+
+ ;; FIXME: Add unwind-protect?
+ (if (and realgud-track-mode (realgud-cmdbuf? (current-buffer)))
+ (let* ((cmd-buff (current-buffer))
+ (cmd-mark (point-marker))
+ (shortkey
+ (realgud-cmdbuf-info-src-shortkey?
+ realgud-cmdbuf-info))
+ (curr-proc (get-buffer-process cmd-buff))
+ (cmdbuf-last-output-end
+ (realgud-cmdbuf-info-last-input-end realgud-cmdbuf-info))
+ (last-output-end
+ (if curr-proc
+ (process-mark curr-proc)
+ cmdbuf-last-output-end))
+ (last-output-start (max comint-last-input-start
+ (- last-output-end
realgud-track-char-range))))
+ ;; Sometimes we get called twice and the second time nothing
+ ;; changes. Guard against this.
+ (unless (= last-output-start last-output-end)
+ (unless (= last-output-end cmdbuf-last-output-end)
+ (setq last-output-start (max last-output-start
+ cmdbuf-last-output-end))
+ )
+ ;; Done with using old command buffer's last-input-end.
+ ;; Update that for next time.
+ (realgud-cmdbuf-info-last-input-end= last-output-start)
+ (realgud:track-from-region last-output-start
+ last-output-end cmd-mark cmd-buff
+ shortkey 't))
+ )
+ )
+ )
+
+(defun realgud-track-eshell-output-filter-hook()
+ "An output-filter hook custom for eshell shells. Find
+location(s), if any, and run the action(s) associated with We use
+marks set in buffer-local variables to extract text"
+
+ ;; FIXME: Add unwind-protect?
+ (if realgud-track-mode
+ (lexical-let* ((cmd-buff (current-buffer))
+ (cmd-mark (point-marker))
+ (shortkey
+ (realgud-cmdbuf-info-src-shortkey?
+ realgud-cmdbuf-info))
+ (loc (realgud:track-from-region
+ eshell-last-output-start
+ eshell-last-output-end cmd-mark cmd-buff
+ shortkey)))
+ (realgud-track-loc-action loc cmd-buff 't shortkey))
+ ))
+
+(defun realgud-track-term-output-filter-hook(text)
+ "An output-filter hook custom for ansi-term shells. Find
+location/s, if any, and run the action(s) associated with
+finding a new location/s. The parameter TEXT appears because it
+is part of the comint-output-filter-functions API. Instead we use
+marks set in buffer-local variables to extract text"
+ (if (and realgud-track-mode (realgud-cmdbuf? (current-buffer)))
+ (realgud-track-loc text (point-marker))
+ ))
+
+(defun realgud:track-from-region(from to &optional cmd-mark opt-cmdbuf
+ shortkey-on-tracing? no-warn-if-no-match?)
+ "Find and position a buffer at the location found in the marked region.
+
+You might want to use this function interactively after marking a
+region in a debugger-tracked shell buffer (see `realgud-track-mode')
+or a more dedicated debugger command buffer.
+
+The marked region location should match the regexp found in the
+buffer-local variable `realgud-cmdbuf-info' structure under the
+field loc-regexp. You can see what this is by
+evaluating (realgud-cmdbuf-info-loc-regexp realgud-cmdbuf-info)"
+
+ (interactive "r")
+ (if (> from to) (psetq to from from to))
+ (let* ((text (buffer-substring-no-properties from to))
+ (loc (realgud-track-loc text cmd-mark))
+ ;; If we see a selected frame number, it is stored
+ ;; in frame-num. Otherwise, nil.
+ (frame-num)
+ (text-sans-loc)
+ (bp-loc)
+ (cmdbuf (or opt-cmdbuf (current-buffer)))
+ )
+ (if (realgud-cmdbuf? cmdbuf)
+ (if (not (equal "" text))
+ (with-current-buffer cmdbuf
+ (if (realgud-sget 'cmdbuf-info 'divert-output?)
+ (realgud-track-divert-prompt text cmdbuf to))
+ ;; FIXME: instead of these fixed filters,
+ ;; put into a list and iterate over that.
+ (realgud-track-termination? text)
+ (setq text-sans-loc (or (realgud-track-loc-remaining text) text))
+ (setq frame-num (realgud-track-selected-frame text) text)
+ (setq bp-loc (realgud-track-bp-loc text-sans-loc cmd-mark cmdbuf))
+ (if bp-loc
+ (let ((src-buffer (realgud-loc-goto bp-loc)))
+ (realgud-cmdbuf-add-srcbuf src-buffer cmdbuf)
+ (with-current-buffer src-buffer
+ (realgud-bp-add-info bp-loc)
+ )))
+ (if loc
+ (let ((selected-frame
+ (or (not frame-num)
+ (eq frame-num (realgud-cmdbuf-pat
"top-frame-num")))))
+ (realgud-track-loc-action loc cmdbuf (not selected-frame)
+ shortkey-on-tracing?)
+ (realgud-cmdbuf-info-in-debugger?= 't)
+ (realgud-cmdbuf-mode-line-update)
+ )
+ (progn
+ (setq bp-loc (realgud-track-bp-delete text-sans-loc cmd-mark
cmdbuf))
+ (if bp-loc
+ (let ((src-buffer (realgud-loc-goto bp-loc)))
+ (realgud-cmdbuf-add-srcbuf src-buffer cmdbuf)
+ (with-current-buffer src-buffer
+ (realgud-bp-del-info bp-loc)
+ ))))
+ )
+ )
+ )
+ ;; else
+ (error "Buffer %s is not a debugger command buffer" cmdbuf))
+ )
+ )
+
+(defun realgud-track-hist-fn-internal(fn)
+ "Update both command buffer and a source buffer to reflect the
+selected location in the location history. If we started in a
+command buffer, we stay in a command buffer. Moving inside a
+command buffer always shows the corresponding source
+file. However it is possible in shortkey mode to show only the
+source code window, even the commmand buffer is updated albeit
+unshown."
+
+ (let ((cmdbuf (realgud-get-cmdbuf (current-buffer))))
+ (if cmdbuf
+ (let* ((loc-hist (realgud-cmdbuf-loc-hist cmdbuf))
+ (window (selected-window))
+ (position (funcall fn loc-hist))
+ (stay-in-cmdbuf?
+ (or (eq (current-buffer) cmdbuf)
+ (with-current-buffer cmdbuf
+ (not (realgud-sget 'cmdbuf-info 'in-srcbuf?)))))
+ (loc (realgud-loc-hist-item loc-hist))
+ (srcbuf (realgud-get-srcbuf-from-cmdbuf cmdbuf loc))
+ )
+ (set-buffer (realgud-loc-goto loc))
+
+ ;; Make sure command buffer is updated
+ (realgud-window-update-position cmdbuf
+ (realgud-loc-cmd-marker loc))
+
+ ;; FIXME turn into fn. combine with realgud-track-loc-action.
+ (if stay-in-cmdbuf?
+ (let ((cmd-window (realgud-window-src-undisturb-cmd srcbuf)))
+ (if cmd-window (select-window cmd-window)))
+ (realgud-window-src srcbuf)
+ )
+
+ ;; Make sure source buffer is updated
+ (realgud-window-update-position srcbuf
+ (realgud-loc-marker loc))
+
+ (message "history position %s line %s"
+ (realgud-loc-hist-index loc-hist)
+ (realgud-loc-line-number loc))
+ (select-window window)))
+ ))
+
+;; FIXME: Can we dry code more via a macro?
+(defun realgud-track-hist-newer()
+ (interactive)
+ (realgud-track-hist-fn-internal 'realgud-loc-hist-newer))
+
+(defun realgud-track-hist-newest()
+ (interactive)
+ (realgud-track-hist-fn-internal 'realgud-loc-hist-newest))
+
+(defun realgud-track-hist-older()
+ (interactive)
+ (realgud-track-hist-fn-internal 'realgud-loc-hist-older))
+
+(defun realgud-track-hist-oldest()
+ (interactive)
+ (realgud-track-hist-fn-internal 'realgud-loc-hist-oldest))
+
+(defun realgud-track-loc-action (loc cmdbuf &optional not-selected-frame
+ shortkey-on-tracing?)
+ "If loc is valid, show loc and do whatever actions we do for
+encountering a new loc."
+ (if (realgud-loc? loc)
+ (let*
+ ((cmdbuf-loc-hist (realgud-cmdbuf-loc-hist cmdbuf))
+ (cmdbuf-local-overlay-arrow?
+ (with-current-buffer cmdbuf
+ (local-variable-p 'overlay-arrow-variable-list)))
+ (stay-in-cmdbuf?
+ (with-current-buffer cmdbuf
+ (not (realgud-sget 'cmdbuf-info 'in-srcbuf?))))
+ (shortkey-mode?
+ (with-current-buffer cmdbuf
+ (realgud-sget 'cmdbuf-info 'src-shortkey?)))
+ (srcbuf)
+ (srcbuf-loc-hist)
+ )
+
+ (setq srcbuf (realgud-loc-goto loc))
+ (realgud-srcbuf-init-or-update srcbuf cmdbuf)
+ (setq srcbuf-loc-hist (realgud-srcbuf-loc-hist srcbuf))
+ (realgud-cmdbuf-add-srcbuf srcbuf cmdbuf)
+
+ (with-current-buffer srcbuf
+ (realgud-short-key-mode-setup
+ (and shortkey-on-tracing?
+ (or realgud-short-key-on-tracing? shortkey-mode?))
+ ))
+
+ ;; Do we need to go back to the process/command buffer because other
+ ;; output-filter hooks run after this may assume they are in that
+ ;; buffer? If so, we may have to use set-buffer rather than
+ ;; switch-to-buffer in some cases.
+ (set-buffer cmdbuf)
+
+ (unless (realgud-sget 'cmdbuf-info 'no-record?)
+ (realgud-loc-hist-add srcbuf-loc-hist loc)
+ (realgud-loc-hist-add cmdbuf-loc-hist loc)
+ (realgud-fringe-history-set cmdbuf-loc-hist
cmdbuf-local-overlay-arrow?)
+ )
+
+ ;; FIXME turn into fn. combine with realgud-track-hist-fn-internal
+ (if stay-in-cmdbuf?
+ (let ((cmd-window (realgud-window-src-undisturb-cmd srcbuf)))
+ (with-current-buffer srcbuf
+ (if (and (boundp 'realgud-overlay-arrow1)
+ (markerp realgud-overlay-arrow1))
+ (progn
+ ;; Doesn't work
+ ;; (if not-selected-frame
+ ;; (set-fringe-bitmap-face 'hollow-right-triangle
+ ;;
'realgud-overlay-arrow1)
+ ;; ; else
+ ;; (set-fringe-bitmap-face 'realgud-right-triangle1
+ ;; 'realgud-overlay-arrow1)
+ ;; )
+ (realgud-window-update-position srcbuf
realgud-overlay-arrow1)))
+ )
+ (if cmd-window (select-window cmd-window)))
+ ; else
+ (with-current-buffer srcbuf
+ (realgud-window-src srcbuf)
+ (realgud-window-update-position srcbuf realgud-overlay-arrow1))
+ ;; reset 'in-srcbuf' to allow the command buffer to keep point focus
+ ;; when used directly. 'in-srcbuf' is set 't' early in the stack
+ ;; (prior to common command code, e.g. this) when any command is run
+ ;; from a source buffer
+ (with-current-buffer cmdbuf
+ (realgud-cmdbuf-info-in-srcbuf?= nil))
+ )
+ ))
+ )
+
+(defun realgud-track-loc(text cmd-mark &optional opt-regexp opt-file-group
+ opt-line-group no-warn-on-no-match?
+ opt-ignore-file-re)
+ "Do regular-expression matching to find a file name and line number inside
+string TEXT. If we match, we will turn the result into a realgud-loc struct.
+Otherwise return nil."
+
+ ;; NOTE: realgud-cmdbuf-info is a buffer variable local to the process
running
+ ;; the debugger. It contains a realgud-cmdbuf-info "struct". In that struct
are
+ ;; the fields loc-regexp, file-group, line-group, alt-file-group, and
alt-line-group.
+ ;;
+ ;; By setting the the fields of realgud-cmdbuf-info appropriately, we
+ ;; can accomodate a family of debuggers -- one at a time -- for the
+ ;; buffer process.
+
+ (if (realgud-cmdbuf?)
+ (let
+ ((loc-regexp (or opt-regexp
+ (realgud-sget 'cmdbuf-info 'loc-regexp)))
+ (file-group (or opt-file-group
+ (realgud-sget 'cmdbuf-info 'file-group)))
+ (line-group (or opt-line-group
+ (realgud-sget 'cmdbuf-info 'line-group)))
+ (alt-file-group (realgud-sget 'cmdbuf-info 'alt-file-group))
+ (alt-line-group (realgud-sget 'cmdbuf-info 'alt-line-group))
+ (text-group (realgud-sget 'cmdbuf-info 'text-group))
+ (ignore-file-re (or opt-ignore-file-re
+ (realgud-sget 'cmdbuf-info 'ignore-file-re)))
+ (callback-loc-fn (realgud-sget 'cmdbuf-info 'callback-loc-fn))
+ )
+ (if loc-regexp
+ (if (string-match loc-regexp text)
+ (let* ((filename (or (match-string file-group text)
+ (match-string alt-file-group text)))
+ (line-str (or (match-string line-group text)
+ (match-string alt-line-group text)))
+ (source-str (and text-group
+ (match-string text-group text)))
+ (lineno (string-to-number (or line-str "1"))))
+ (when source-str
+ (setq source-str (ansi-color-filter-apply
+ source-str)))
+ (cond (callback-loc-fn
+ (funcall callback-loc-fn text
+ filename lineno source-str
+ ignore-file-re cmd-mark))
+ ('t
+ (unless line-str
+ (message "line number not found -- using 1"))
+ (if (and filename lineno)
+ (realgud:file-loc-from-line filename lineno
+ cmd-mark
+ source-str nil
+ ignore-file-re)
+ ;; else
+ nil)))))
+ ;; else
+ (and (message
+ (concat "Buffer variable for regular expression pattern not"
+ " given and not passed as a parameter")) nil)))
+ ;; else
+ (and (message "Current buffer %s is not a debugger command buffer"
+ (current-buffer)) nil)
+ )
+ )
+
+(defun realgud-track-bp-loc(text &optional cmd-mark cmdbuf ignore-file-re)
+ "Do regular-expression matching to find a file name and line number inside
+string TEXT. If we match, we will turn the result into a realgud-loc struct.
+Otherwise return nil. CMD-MARK is set in the realgud-loc object created.
+"
+
+ ; NOTE: realgud-cmdbuf-info is a buffer variable local to the process
+ ; running the debugger. It contains a realgud-cmdbuf-info "struct". In
+ ; that struct is the regexp hash to match positions. By setting the
+ ; the fields of realgud-cmdbuf-info appropriately we can accomodate a
+ ; family of debuggers -- one at a time -- for the buffer process.
+
+ (setq cmdbuf (or cmdbuf (current-buffer)))
+ (with-current-buffer cmdbuf
+ (if (realgud-cmdbuf?)
+ (let* ((loc-pat (realgud-cmdbuf-pat "brkpt-set")))
+ (if loc-pat
+ (let ((bp-num-group (realgud-loc-pat-num loc-pat))
+ (loc-regexp (realgud-loc-pat-regexp loc-pat))
+ (file-group (realgud-loc-pat-file-group loc-pat))
+ (line-group (realgud-loc-pat-line-group loc-pat))
+ (text-group (realgud-loc-pat-text-group loc-pat))
+ (ignore-file-re (realgud-loc-pat-ignore-file-re loc-pat))
+ )
+ (if loc-regexp
+ (if (string-match loc-regexp text)
+ (let* ((bp-num (match-string bp-num-group text))
+ (filename (match-string file-group text))
+ (line-str (match-string line-group text))
+ (source-str (and text-group (match-string
text-group text)))
+ (lineno (string-to-number (or line-str "1")))
+ )
+ (unless line-str
+ (message "line number not found -- using 1"))
+ (if (and filename lineno)
+ (let ((loc-or-error
+ (realgud:file-loc-from-line
+ filename lineno
+ cmd-mark
+ source-str
+ (string-to-number bp-num)
+ ignore-file-re
+ )))
+ (if (stringp loc-or-error)
+ (progn
+ (message loc-or-error)
+ ;; set to return nil
+ nil)
+ ;; else
+ (progn
+ ;; Add breakpoint to list of breakpoints
+ (realgud-cmdbuf-info-bp-list=
+ (cons loc-or-error (realgud-sget
'cmdbuf-info 'bp-list)))
+ ;; Set to return location
+ loc-or-error)))
+ nil)))
+ nil))
+ nil))
+ (and (message "Current buffer %s is not a debugger command buffer"
+ (current-buffer)) nil)
+ )
+ )
+)
+
+(defun realgud-track-bp-delete(text &optional cmd-mark cmdbuf ignore-file-re)
+ "Do regular-expression matching see if a breakpoint has been delete inside
+string TEXT. If we match, we will return the location of the breakpoint found
+from in command buffer. Otherwise nil is returned."
+
+ ; NOTE: realgud-cmdbuf-info is a buffer variable local to the process
+ ; running the debugger. It contains a realgud-cmdbuf-info "struct". In
+ ; that struct is the regexp hash to match positions. By setting the
+ ; the fields of realgud-cmdbuf-info appropriately we can accomodate a
+ ; family of debuggers -- one at a time -- for the buffer process.
+
+ (setq cmdbuf (or cmdbuf (current-buffer)))
+ (with-current-buffer cmdbuf
+ (if (realgud-cmdbuf?)
+ (let* ((loc-pat (realgud-cmdbuf-pat "brkpt-del"))
+ (found-loc nil)
+ )
+ (if loc-pat
+ (let ((bp-num-group (realgud-loc-pat-num loc-pat))
+ (loc-regexp (realgud-loc-pat-regexp loc-pat))
+ (loc))
+ (if (and loc-regexp (string-match loc-regexp text))
+ (let* ((bp-num (string-to-number (match-string bp-num-group
text)))
+ (info realgud-cmdbuf-info)
+ (bp-list (realgud-cmdbuf-info-bp-list info))
+ )
+ (while (and (not found-loc) (setq loc (car-safe bp-list)))
+ (setq bp-list (cdr bp-list))
+ (if (eq (realgud-loc-num loc) bp-num)
+ (progn
+ (setq found-loc loc)
+ ;; Remove loc from breakpoint list
+ (realgud-cmdbuf-info-bp-list=
+ (remove loc (realgud-cmdbuf-info-bp-list info))))
+ ))
+ ;; return the location:
+ found-loc)
+ nil))
+ nil))
+ (and (message "Current buffer %s is not a debugger command buffer"
+ (current-buffer)) nil)
+ )
+ )
+)
+
+(defun realgud-track-loc-remaining(text)
+ "Return the portion of TEXT starting with the part after the
+loc-regexp pattern"
+ (if (realgud-cmdbuf?)
+ (let* ((loc-pat (realgud-cmdbuf-pat "loc"))
+ (loc-regexp (realgud-loc-pat-regexp loc-pat))
+ )
+ (if loc-regexp
+ (if (string-match loc-regexp text)
+ (substring text (match-end 0))
+ nil)
+ nil))
+ nil)
+ )
+
+(defun realgud-track-selected-frame(text)
+ "Return a selected frame number found in TEXT or nil if none found."
+ (if (realgud-cmdbuf?)
+ (let ((selected-frame-pat (realgud-cmdbuf-pat "selected-frame"))
+ (frame-num-regexp)
+ )
+ (if (and selected-frame-pat
+ (setq frame-num-regexp (realgud-loc-pat-regexp
+ selected-frame-pat)))
+ (if (string-match frame-num-regexp text)
+ (let ((frame-num-group (realgud-loc-pat-num
selected-frame-pat)))
+ (string-to-number (match-string frame-num-group text)))
+ nil)
+ nil))
+ nil)
+ )
+
+
+(defun realgud-track-termination?(text)
+ "Return 't and call `realgud:terminate' we we have a termination message"
+ (if (realgud-cmdbuf?)
+ (let ((termination-re (realgud-cmdbuf-pat "termination"))
+ )
+ (if (and termination-re (string-match termination-re text))
+ (progn
+ (realgud:terminate (current-buffer))
+ 't)
+ nil)
+ )
+ )
+ )
+
+(defun realgud-track-divert-prompt(text cmdbuf to)
+ "Return a cons node of the part before the prompt-regexp and the part
+ after the prompt-regexp-prompt. If not found return nil."
+ (with-current-buffer cmdbuf
+ ;; (message "+++3 %s, buf: %s" text (buffer-name))
+ (if (realgud-cmdbuf?)
+ (let* ((prompt-pat (realgud-cmdbuf-pat "prompt"))
+ (prompt-regexp (realgud-loc-pat-regexp prompt-pat))
+ )
+ (if prompt-regexp
+ (if (string-match prompt-regexp text)
+ (progn
+ (setq realgud-track-divert-string
+ (substring text 0 (match-beginning 0)))
+ ;; We've got desired output, so reset divert output.
+ (realgud-cmdbuf-info-divert-output?= nil)
+ (cond ((search-backward-regexp prompt-regexp)
+ (kill-region realgud-last-output-start (point))
+ (goto-char (point-max)))
+ ('t (kill-region realgud-last-output-start to)))
+ )
+ ))
+ )
+ )
+ )
+ )
+
+(defun realgud-goto-line-for-loc-pat (pt &optional opt-realgud-loc-pat)
+ "Display the location mentioned in line described by
+PT. OPT-REALGUD-LOC-PAT is used to get regular-expresion pattern
+matching information. If not supplied we use the current buffer's \"location\"
+pattern found via realgud-cmdbuf information. nil is returned if we can't
+find a location. non-nil if we can find a location.
+"
+ (interactive "d")
+ (save-excursion
+ (goto-char pt)
+ (let*
+ ((cmdbuf (current-buffer))
+ (cmd-mark (point-marker))
+ (curr-proc (get-buffer-process cmdbuf))
+ (start (line-beginning-position))
+ (end (line-end-position))
+ (loc-pat (or opt-realgud-loc-pat (realgud-cmdbuf-pat "loc")))
+ (loc)
+ )
+ (unless (and loc-pat (realgud-loc-pat-p loc-pat))
+ (error "Can't find location information for %s" cmdbuf))
+ (setq loc (realgud-track-loc (buffer-substring-no-properties start end)
+ cmd-mark
+ (realgud-loc-pat-regexp loc-pat)
+ (realgud-loc-pat-file-group loc-pat)
+ (realgud-loc-pat-line-group loc-pat)
+ nil
+ (realgud-loc-pat-ignore-file-re loc-pat)
+ ))
+ (if (stringp loc)
+ (message loc)
+ (if loc (or (realgud-track-loc-action loc cmdbuf) 't)
+ nil))
+ ))
+ )
+
+(defun realgud:track-set-debugger (debugger-name)
+ "Set debugger name and information associated with that
+debugger for the buffer process. This info is returned or nil if
+we can't find a debugger with that information.`.
+"
+ ;; FIXME: turn into fn which can be used by realgud-backtrack-set-debugger
+ (interactive
+ (list (completing-read "Debugger name: " realgud-pat-hash)))
+ (let* ((base-variable-name
+ (or (gethash debugger-name realgud:variable-basename-hash)
+ debugger-name))
+ (regexp-hash (gethash debugger-name realgud-pat-hash))
+ (command-hash (gethash debugger-name realgud-command-hash))
+ )
+ (unless regexp-hash
+ ;; FIXME: phase out realgud:debugger-name-transform
+ (setq base-variable-name (realgud:debugger-name-transform debugger-name))
+ (setq regexp-hash (gethash base-variable-name realgud-pat-hash))
+ (setq command-hash (gethash base-variable-name realgud-command-hash))
+ )
+ (if regexp-hash
+ (let* (
+ (mode-name (concat " " (capitalize base-variable-name) "-Track"))
+ (specific-track-mode (intern (concat base-variable-name
"-track-mode")))
+ )
+ (realgud-cmdbuf-init (current-buffer)
+ debugger-name regexp-hash
+ command-hash base-variable-name)
+ (if (and (not (eval specific-track-mode))
+ (functionp specific-track-mode))
+ (funcall specific-track-mode 't))
+ )
+ (progn
+ (message "I don't have %s listed as a debugger." debugger-name)
+ nil)
+ )))
+
+;; FIXME: need better name for this and next fn.
+(defun realgud-goto-line-for-pt-and-type (pt type pat-hash)
+ "Position the source code at the location that is matched by
+PAT-HASH with key TYPE. The line at PT is used as the string
+to match against and has location info embedded in it"
+ (realgud-goto-line-for-loc-pat pt (gethash type pat-hash)))
+
+
+(defun realgud-goto-line-for-pt (pt pattern-key)
+ "Position the source code at the location indicated by a
+pattern found in the command buffer with pattern-key
+PATTERN-KEY. (PATTERN-KEY is something like 'debugger-backtrace'
+or 'loc'.) The line at PT is used as the string to match against
+and has location info embedded in it"
+ (interactive "d")
+ (unless (realgud-cmdbuf?)
+ (error "You need to be in a debugger command buffer to run this"))
+ (let* ((debugger-name (realgud-cmdbuf-debugger-name))
+ (debugger-pat-hash (gethash debugger-name realgud-pat-hash)))
+ (realgud-goto-line-for-pt-and-type pt pattern-key debugger-pat-hash)
+ )
+ )
+
+(defun realgud:goto-debugger-backtrace-line (pt)
+ "Position the source code at the location indicated by matching a
+command buffer's debugger backtrace pattern against the line at PT."
+ (interactive "d")
+ (unless (realgud-goto-line-for-pt pt "debugger-backtrace")
+ (message "Line didn't match a debugger backtrace location.")
+ ))
+
+(defun realgud:goto-lang-backtrace-line (pt)
+ "Position the source code at the location indicated by matching a
+command buffer's programming-language backtrace pattern against the line at
PT."
+ (interactive "d")
+ (unless (realgud-goto-line-for-pt pt "lang-backtrace")
+ (message "Line didn't match a programming-language backtrace location.")
+ ))
+
+(defun realgud:goto-debugger-loc-line (pt)
+ "Position the source-code at the location indicated by matching a
+command buffer's debugger location pattern against the line at PT."
+ (interactive "d")
+ (unless (realgud-goto-line-for-pt pt "loc")
+ (message "Line didn't match a debugger location indicator line.")
+ ))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/utils.el
b/packages/realgud/realgud/common/utils.el
new file mode 100644
index 0000000..1f52bed
--- /dev/null
+++ b/packages/realgud/realgud/common/utils.el
@@ -0,0 +1,33 @@
+(require 'load-relative)
+(require 'comint)
+(require 'eshell)
+
+(defun realgud:strip (str)
+ "Remove leading and tailing whitespace from STR."
+ (while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'"
+ str)
+ (setq str (replace-match "" t t str)))
+ str)
+
+;; From http://rosettacode.org/wiki/Flatten_a_list#Emacs_Lisp
+(defun realgud:flatten (mylist)
+ (cond
+ ((null mylist) nil)
+ ((atom mylist) (list mylist))
+ (t
+ (append (realgud:flatten (car mylist)) (realgud:flatten (cdr mylist))))))
+
+(defun realgud:canonic-major-mode()
+ "Return
+ - 'eshell if we are in eshell-mode,
+ - 'comint if the major comint-mode or shell-mode
+Or raise an error if neither."
+
+ (cond ((eq major-mode 'eshell-mode)
+ 'eshell)
+ ((or (eq major-mode 'comint-mode) (eq major-mode 'shell-mode))
+ 'comint)
+ ('t (error "We can only handle comint, shell, or eshell buffers"))
+ ))
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/common/window.el
b/packages/realgud/realgud/common/window.el
new file mode 100644
index 0000000..d7d083b
--- /dev/null
+++ b/packages/realgud/realgud/common/window.el
@@ -0,0 +1,167 @@
+;;; Copyright (C) 2010, 2014-2015 Rocky Bernstein <address@hidden>
+(require 'load-relative)
+(require-relative-list '("helper") "realgud-")
+(require-relative-list '("buffer/helper") "realgud-buffer-")
+
+(declare-function realgud:backtrace-init 'realgud-buffer-helper)
+(declare-function realgud-get-backtrace-buf 'realgud-buffer-helper)
+(declare-function realgud-get-cmdbuf 'realgud-buffer-helper)
+(declare-function realgud-get-srcbuf 'realgud-buffer-helper)
+(declare-function buffer-killed? 'realgud-helper)
+
+(declare-function one-window-p(bool))
+
+(defun realgud-window-update-position (buffer marker)
+ "Update BUFFER to position specified with MARKER.
+We assume MARKER points inside BUFFER"
+ (with-current-buffer buffer
+ (goto-char marker)
+ (let ((window (get-buffer-window buffer)))
+ (if window (set-window-point window marker))
+ )))
+
+
+(defun realgud-window-src ( &optional opt-buffer )
+ "Make sure the source buffer is displayed in a window
+We don't care if the command buffer is also displayed.
+See also `realgud-window-src-undisturb-cmd'"
+ (let* ((buffer (or opt-buffer (current-buffer)))
+ (src-buffer (realgud-get-srcbuf buffer))
+ (src-window (get-buffer-window src-buffer 'visible))
+ (window (selected-window)))
+ (if src-buffer
+ (unless (and src-window (not (window-minibuffer-p)))
+ (set-window-buffer window src-buffer))
+ )
+ ))
+
+(defun realgud-window-src-undisturb-cmd ( &optional opt-buffer )
+ "Make sure the source buffers is displayed in windows without
+disturbing the command window if it is also displayed. Returns
+the command window
+See also `realgud-window-src'"
+ (interactive)
+ (let* ((buffer (or opt-buffer (current-buffer)))
+ (src-buffer (realgud-get-srcbuf buffer))
+ (src-window (get-buffer-window src-buffer))
+ (cmd-buffer (realgud-get-cmdbuf buffer))
+ (cmd-window (get-buffer-window cmd-buffer))
+ (window (selected-window))
+ )
+ (if src-buffer
+ (unless src-window
+ (setq src-window
+ (if (eq window cmd-window)
+ ;; FIXME: generalize what to do here.
+ (if (one-window-p 't)
+ (split-window)
+ (next-window window 'no-minibuf))
+ window))
+ (set-window-buffer src-window src-buffer))
+ )
+ (select-window src-window)
+ cmd-window)
+ )
+
+(defun realgud-window-cmd-undisturb-src ( &optional opt-buffer switch?)
+ "Make sure the source buffer is displayed in windows without
+disturbing the command window if it is also displayed. Returns
+the source window.
+See also `realgud-window-src'"
+ (interactive)
+ (let* ((buffer (or opt-buffer (current-buffer)))
+ (src-buffer (realgud-get-srcbuf buffer))
+ (src-window (get-buffer-window src-buffer))
+ (cmd-buffer (realgud-get-cmdbuf buffer))
+ (cmd-window (get-buffer-window cmd-buffer))
+ (window (selected-window))
+ )
+ (when cmd-buffer
+ (unless cmd-window
+ (setq cmd-window
+ (if (eq window src-window)
+ ;; FIXME: generalize what to do here.
+ (if (one-window-p 't)
+ (split-window)
+ (next-window window 'no-minibuf))
+ window))
+ (set-window-buffer cmd-window cmd-buffer)
+ )
+ (if switch?
+ (and (select-window cmd-window)
+ (switch-to-buffer cmd-buffer)))
+
+ )
+ (select-window cmd-window)
+ src-window)
+ )
+
+(defun realgud:window-bt-undisturb-src ( &optional opt-buffer switch?)
+ "Make sure the backtrace buffer is displayed in windows without
+disturbing the source window if it is also displayed. Returns
+the source window
+See also `realgud-window-src'"
+ (interactive)
+ (let* ((buffer (or opt-buffer (current-buffer)))
+ (src-buffer (realgud-get-srcbuf buffer))
+ (src-window (get-buffer-window src-buffer))
+ (cmd-buffer (realgud-get-cmdbuf buffer))
+ (cmd-window (get-buffer-window cmd-buffer))
+ (bt-buffer (realgud-get-backtrace-buf cmd-buffer))
+ (bt-window (get-buffer-window bt-buffer))
+ (window (selected-window))
+ )
+ (when cmd-buffer
+ (unless bt-window
+ (setq bt-window
+ (if (eq window src-window)
+ ;; FIXME: generalize what to do here.
+ (if (one-window-p 't)
+ (split-window)
+ (next-window window 'no-minibuf))
+ window))
+ (set-window-buffer bt-window bt-buffer)
+ )
+ (if switch?
+ (and (select-window bt-window)
+ (switch-to-buffer bt-buffer)))
+
+ )
+ src-window)
+ )
+
+(defun realgud:window-bt()
+ "Refresh backtrace information and display that in a buffer"
+ (interactive)
+ (with-current-buffer-safe (realgud-get-cmdbuf)
+ (realgud:backtrace-init)
+ (realgud:window-bt-undisturb-src)
+ )
+ )
+
+
+;; (defun realgud-window-src-and-cmd ( &optional opt-buffer )
+;; "Make sure the source buffers is displayed in windows without
+;; disturbing the command window if it is also displayed. Returns
+;; the command window
+;; See also `realgud-window-src-window'"
+;; (interactive)
+;; (let* ((buffer (or opt-buffer (current-buffer)))
+;; (src-buffer (realgud-get-srcbuf buffer))
+;; (src-window (get-buffer-window src-buffer))
+;; (cmd-buffer (realgud-get-cmdbuf buffer))
+;; (cmd-window (get-buffer-window cmd-buffer))
+;; (window (selected-window))
+;; )
+;; (if src-buffer
+;; (unless src-window
+;; (setq src-window
+;; (if (eq window cmd-window)
+;; (if (one-window-p 't) (split-window) (next-window window))
+;; window))
+;; (set-window-buffer src-window src-buffer))
+;; )
+;; cmd-window)
+;; )
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/Makefile.am
b/packages/realgud/realgud/debugger/Makefile.am
new file mode 100644
index 0000000..5f7a769
--- /dev/null
+++ b/packages/realgud/realgud/debugger/Makefile.am
@@ -0,0 +1,8 @@
+SUBDIRS = \
+ bashdb gdb gub ipdb jdb kshdb nodejs \
+ pdb perldb rdebug remake \
+ trepan trepan2 trepan3k trepan.pl trepanjs \
+ zshdb
+EXTRA_DIST = common.mk
+
+.PHONY: check all
diff --git a/packages/realgud/realgud/debugger/bashdb/Makefile.am
b/packages/realgud/realgud/debugger/bashdb/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/bashdb/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/bashdb/bashdb.el
b/packages/realgud/realgud/debugger/bashdb/bashdb.el
new file mode 100644
index 0000000..372aa76
--- /dev/null
+++ b/packages/realgud/realgud/debugger/bashdb/bashdb.el
@@ -0,0 +1,82 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; `bashdb' Main interface to bashdb via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:bashdb-")
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:bashdb nil
+ "The realgud interface to bashdb"
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:bashdb-command-name
+ ;;"bashdb --emacs 3"
+ "bashdb"
+ "File name for executing the bash debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:bashdb)
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function bashdb-track-mode 'realgud-bashdb-track-mode)
+(declare-function bashdb-query-cmdline 'realgud:bashdb-core)
+(declare-function bashdb-parse-cmd-args 'realgud:bashdb-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;;;###autoload
+(defun realgud:bashdb (&optional opt-cmd-line no-reset)
+ "Invoke the bashdb shell debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run bash. You will be prompted
+for a command line is one isn't supplied.
+
+OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `bashdb-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "bashdb"
+ 'bashdb-query-cmdline
+ 'bashdb-parse-cmd-args
+ 'realgud:bashdb-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+(defalias 'bashdb 'realgud:bashdb)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/bashdb/core.el
b/packages/realgud/realgud/debugger/bashdb/core.el
new file mode 100644
index 0000000..899eec0
--- /dev/null
+++ b/packages/realgud/realgud/debugger/bashdb/core.el
@@ -0,0 +1,198 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track" "../../common/core")
+ "realgud-")
+(require-relative-list '("init") "realgud:bashdb-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:bashdb-minibuffer-history nil
+ "minibuffer history list for the command `realgud:bashdb'.")
+
+(easy-mmode-defmap bashdb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of bashdb startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun bashdb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'bashdb-suggest-invocation
+ bashdb-minibuffer-local-map
+ 'realgud:bashdb-minibuffer-history
+ opt-debugger))
+
+;;; FIXME: DRY this with other *-parse-cmd-args routines
+(defun bashdb-parse-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS for the annotate level and name of script to
debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing:
+* the command processor (e.g. bash) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. bashdb) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+* whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+The script name and options mentioning paths are file expanded
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(bash --norc bashdb -l . --emacs ./gcd.sh a b))
+
+we might return:
+ ((\"bash\" \"--norc\") (\"bashdb\" \"-l\" \"/tmp\" \"--emacs\")
(\"/tmp/gcd.sh\" \"a\" \"b\") t)
+
+Note that path elements have been expanded via
`realgud:expand-file-name-if-exists'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [bash bash-options] bashdb bashdb-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ ;; bash doesn't have any optional two-arg options
+ (bash-opt-two-args '())
+ (bash-two-args '("o" "c"))
+
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (bashdb-two-args '("A" "-annotate" "l" "-library"
+ "c" "-command" "-t" "-tty"
+ "x" "-eval-command"))
+ (bashdb-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^bash*\\(.exe\\)?$"
+ "^bash*$"))
+ (bashdb-two-arg-name)
+ (debugger-flag nil) ;; 't if "bash --debugger" given
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "bash" or "bash4" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off bash-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args bash-two-args bash-opt-two-args))
+ (if (equal "--debugger" (caar pair))
+ (setq debugger-flag 't))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "bashdb" from "bashdb --bashdb-options script
+ ;; --script-options"
+ (unless debugger-flag
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^bashdb$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `bashdb'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+ )
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((member arg '("--annotate" "-A" "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args)) )
+ (setq annotate-p t))
+ ;; Library option
+ ((member arg '("--library" "-l"))
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
+ ;; Other options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args bashdb-two-args bashdb-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:bashdb-command-name)
+
+(defun bashdb-suggest-invocation (debugger-name)
+ "Suggest a bashdb command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:bashdb-command-name
+ realgud:bashdb-minibuffer-history
+ "sh" "\\.\\(?:ba\\)?sh$"
+ realgud:bashdb-command-name))
+
+(defun bashdb-reset ()
+ "Bashdb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (bashdb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*bashdb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun bashdb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'bashdb-debugger-support-minor-mode minor-mode-map-alist)
+;; bashdb-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:bashdb-customize ()
+ "Use `customize' to edit the settings of the `bashdb' debugger."
+ (interactive)
+ (customize-group 'realgud:bashdb))
+
+(provide-me "realgud:bashdb-")
diff --git a/packages/realgud/realgud/debugger/bashdb/init.el
b/packages/realgud/realgud/debugger/bashdb/init.el
new file mode 100644
index 0000000..81cf9b5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/bashdb/init.el
@@ -0,0 +1,92 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; Regular expressions for Bash shell debugger: bashdb
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/posix-shell") "realgud-lang-")
+
+(defvar realgud:bashdb-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:bashdb-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; Regular expression that describes a bashdb location generally shown
+;; before a command prompt.
+;; For example:
+;; (/etc/init.d/apparmor:35):
+(setf (gethash "loc" realgud:bashdb-pat-hash) realgud:POSIX-debugger-loc-pat)
+
+;; Regular expression that describes a bashdb command prompt
+;; For example:
+;; bashdb<10>
+;; bashdb<(5)>
+;; bashdb<<1>>
+(setf (gethash "prompt" realgud:bashdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^bashdb[<]+[(]*%s[)]*[>]+ "
+ realgud:regexp-captured-num)
+ :num 1
+ ))
+
+;; Regular expression that describes a "breakpoint set" line
+(setf (gethash "brkpt-set" realgud:bashdb-pat-hash)
+ realgud:POSIX-debugger-brkpt-set-pat)
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Removed 1 breakpoint(s).
+(setf (gethash "brkpt-del" realgud:bashdb-pat-hash)
+ realgud:POSIX-debugger-brkpt-del-pat)
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; ->0 in file `../bashdb/test/example/subshell.sh' at line 6
+;; ##1 source("../bashdb/shell.sh") called from file `/bin/bashdb' at line
140
+;; ##2 main() called from file `/bin/bashdb' at line 0
+(setf (gethash "debugger-backtrace" realgud:bashdb-pat-hash)
+ realgud:POSIX-debugger-backtrace-pat)
+
+;; Regular expression for a termination message.
+(setf (gethash "termination" realgud:bashdb-pat-hash)
+ "^bashdb: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:bashdb-pat-hash)
+ realgud:POSIX-debugger-font-lock-keywords)
+
+(setf (gethash "bashdb" realgud-pat-hash) realgud:bashdb-pat-hash)
+
+(defvar realgud:bashdb-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the bashdb command to use, like 'quit!'")
+
+(setf (gethash "bashdb" realgud-command-hash) realgud:bashdb-command-hash)
+
+(setf (gethash "clear" realgud:bashdb-command-hash) "clear %l")
+(setf (gethash "quit" realgud:bashdb-command-hash) "quit!")
+(setf (gethash "until" realgud:bashdb-command-hash) "continue %l")
+
+(provide-me "realgud:bashdb-")
diff --git a/packages/realgud/realgud/debugger/bashdb/track-mode.el
b/packages/realgud/realgud/debugger/bashdb/track-mode.el
new file mode 100644
index 0000000..7904d25
--- /dev/null
+++ b/packages/realgud/realgud/debugger/bashdb/track-mode.el
@@ -0,0 +1,76 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Copyright (C) 2012-2015 Rocky Bernstein <address@hidden>
+
+;; Bash Debugger tracking in a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:bashdb-")
+(require-relative "../../lang/posix-shell" nil "realgud-lang-")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-hook 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-posix-shell-populate-command-keys
+ 'realgud-lang-posix-shell)
+
+(realgud-track-mode-vars "bashdb")
+
+(defun bashdb-track-mode-hook()
+ (if bashdb-track-mode
+ (progn
+ (use-local-map bashdb-track-mode-map)
+ (message "using bashdb mode map")
+ )
+ (message "bashdb track-mode-hook disable called"))
+)
+
+(define-minor-mode bashdb-track-mode
+ "Minor mode for tracking bashdb source locations inside a process shell via
realgud. bashdb is a Bash debugger. See URL `http://bashdb.sf.net'.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{bashdb-track-mode-map}"
+ :init-value nil
+ ;; :lighter " bashdb" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:bashdb
+ :keymap bashdb-track-mode-map
+
+ (realgud:track-set-debugger "bashdb")
+ (if bashdb-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (bashdb-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(define-key bashdb-short-key-mode-map "T" 'realgud:cmd-backtrace)
+
+(provide-me "realgud:bashdb-")
diff --git a/packages/realgud/realgud/debugger/common.mk
b/packages/realgud/realgud/debugger/common.mk
new file mode 100644
index 0000000..b09deeb
--- /dev/null
+++ b/packages/realgud/realgud/debugger/common.mk
@@ -0,0 +1,3 @@
+include $(top_srcdir)/common.mk
+
+lispdir = @lispdir_realgud@/debugger/$(notdir $(subdir))
diff --git a/packages/realgud/realgud/debugger/gdb/Makefile.am
b/packages/realgud/realgud/debugger/gdb/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gdb/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/gdb/core.el
b/packages/realgud/realgud/debugger/gdb/core.el
new file mode 100644
index 0000000..3b66ad5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gdb/core.el
@@ -0,0 +1,219 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Copyright (C) 2014-2015 Rocky Bernstein <address@hidden>
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:gdb-minibuffer-history nil
+ "minibuffer history list for the command `gdb'.")
+
+(easy-mmode-defmap realgud:gdb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun realgud:gdb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'realgud:gdb-suggest-invocation
+ realgud:gdb-minibuffer-local-map
+ 'realgud:gdb-minibuffer-history
+ opt-debugger))
+
+(defun realgud:gdb-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ORIG_ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+* the name of the debugger given (e.g. gdb) and its arguments - a list of
strings
+* nil (a placehoder in other routines of this ilk for a debugger
+* the script name and its arguments - list of strings
+* whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(gdb --tty /dev/pts/1 -cd ~ --emacs ./gcd.py a b))
+
+we might return:
+ ((\"gdb\" \"--tty\" \"/dev/pts/1\" \"-cd\" \"home/rocky\' \"--emacs\") nil
\"(/tmp/gcd.py a b\") 't\")
+
+Note that path elements have been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; gdb gdb-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (gdb-two-args '("x" "-command" "b" "-exec"
+ "cd" "-pid" "-core" "-directory"
+ "-annotate"
+ "se" "-symbols" "-tty"))
+ ;; gdb doesn't optionsl 2-arg options.
+ (gdb-opt-two-args '())
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil nil nil nil)
+ (list debugger-args nil script-args annotate-p)
+ ;; else
+ (progn
+
+ ;; Remove "gdb" from "gdb --gdb-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^gdb.*" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `gdb'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args) (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args) (pop args)) )
+ (setq annotate-p t))
+ ;; path-argument ooptions
+ ((member arg '("-cd" ))
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args gdb-two-args gdb-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name arg)
+ (setq script-args args))
+ )))
+ (list debugger-args nil script-args annotate-p)))))
+
+(defvar realgud:gdb-command-name)
+
+(defun realgud:gdb-executable (file-name)
+"Return a priority for wehther file-name is likely we can run gdb on"
+ (let ((output (shell-command-to-string (format "file %s" file-name))))
+ (cond
+ ((string-match "ASCII" output) 2)
+ ((string-match "ELF" output) 7)
+ ((string-match "executable" output) 6)
+ ('t 5))))
+
+
+(defun realgud:gdb-suggest-invocation (&optional debugger-name)
+ "Suggest a gdb command invocation. Here is the priority we use:
+* an executable file with the name of the current buffer stripped of its
extension
+* any executable file in the current directory with no extension
+* the last invocation in gdb:minibuffer-history
+* any executable in the current directory
+When all else fails return the empty string."
+ (let* ((file-list (directory-files default-directory))
+ (priority 2)
+ (best-filename nil)
+ (try-filename (file-name-base (or (buffer-file-name) "gdb"))))
+ (when (member try-filename (directory-files default-directory))
+ (setq best-filename try-filename)
+ (setq priority (+ (realgud:gdb-executable try-filename) 2)))
+
+ ;; FIXME: I think a better test would be to look for
+ ;; c-mode in the buffer that have a corresponding executable
+ (while (and (setq try-filename (car-safe file-list)) (< priority 8))
+ (setq file-list (cdr file-list))
+ (if (and (file-executable-p try-filename)
+ (not (file-directory-p try-filename)))
+ (if (equal try-filename (file-name-sans-extension try-filename))
+ (progn
+ (setq best-filename try-filename)
+ (setq priority (1+ (realgud:gdb-executable best-filename))))
+ ;; else
+ (progn
+ (setq best-filename try-filename)
+ (setq priority (realgud:gdb-executable best-filename))
+ ))
+ ))
+ (if (< priority 8)
+ (cond
+ (realgud:gdb-minibuffer-history
+ (car realgud:gdb-minibuffer-history))
+ ((equal priority 7)
+ (concat "gdb " best-filename))
+ (t "gdb "))
+ ;; else
+ (concat "gdb " best-filename))
+ ))
+
+(defun realgud:gdb-reset ()
+ "Gdb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (gdb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*gdb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun gdb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'gdb-debugger-support-minor-mode minor-mode-map-alist)
+;; gdb-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:gdb-customize ()
+ "Use `customize' to edit the settings of the `realgud:gdb' debugger."
+ (interactive)
+ (customize-group 'realgud:gdb))
+
+(provide-me "realgud:gdb-")
diff --git a/packages/realgud/realgud/debugger/gdb/gdb.el
b/packages/realgud/realgud/debugger/gdb/gdb.el
new file mode 100644
index 0000000..19963a3
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gdb/gdb.el
@@ -0,0 +1,142 @@
+;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; `realgud:gdb' Main interface to gdb via Emacs
+(require 'cl)
+(require 'load-relative)
+(require-relative-list '("../../common/helper" "../../common/utils")
+ "realgud-")
+
+(require-relative-list '("../../common/buffer/command"
+ "../../common/buffer/source")
+ "realgud-buffer-")
+
+(require-relative-list '("core" "track-mode") "realgud:gdb-")
+
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud:cmdbuf-associate 'realgud-buffer-source)
+(declare-function realgud-parse-command-arg 'realgud-core)
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:gdb nil
+ "The realgud interface to gdb"
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User definable variables
+;;
+
+(defcustom realgud:gdb-command-name
+ ;;"gdb --emacs 3"
+ "gdb"
+ "File name for executing the and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:gdb)
+
+(declare-function realgud:gdb-track-mode 'realgud:gdb-track-mode)
+(declare-function realgud-command 'realgud:gdb-core)
+(declare-function realgud:gdb-parse-cmd-args 'realgud:gdb-core)
+(declare-function realgud:gdb-query-cmdline 'realgud:gdb-core)
+(declare-function realgud:run-process 'realgud-core)
+(declare-function realgud:flatten 'realgud-utils)
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(defun realgud:gdb-pid-command-buffer (pid)
+ "Return the command buffer used when gdb -p PID is invoked"
+ (format "*gdb %d shell*" pid)
+ )
+
+(defun realgud:gdb-find-command-buffer (pid)
+ "Find the among current buffers a buffer that is a realgud command buffer
+running gdb on process number PID"
+ (let ((find-cmd-buf (realgud:gdb-pid-command-buffer pid)))
+ (dolist (buf (buffer-list))
+ (if (and (equal find-cmd-buf (buffer-name buf))
+ (realgud-cmdbuf? buf)
+ (get-buffer-process buf))
+ (return buf)))))
+
+(defun realgud:gdb-pid (pid)
+ "Start debugging gdb process with pid PID."
+ (interactive "nEnter the pid that gdb should attach to: ")
+ (realgud:gdb (format "%s -p %d" realgud:gdb-command-name pid))
+ ;; FIXME: should add code to test if attach worked.
+ )
+
+(defun realgud:gdb-pid-associate (pid)
+ "Start debugging gdb process with pid PID and associate the
+current buffer to that realgud command buffer."
+ (interactive "nEnter the pid that gdb should attach to and associate the
current buffer to: ")
+ (let* ((command-buf)
+ (source-buf (current-buffer))
+ )
+ (realgud:gdb-pid pid)
+ (setq command-buf (realgud:gdb-find-command-buffer pid))
+ (if command-buf
+ (with-current-buffer source-buf
+ (realgud:cmdbuf-associate (buffer-name command-buf)))
+ )))
+
+;;;###autoload
+(defun realgud:gdb (&optional opt-cmd-line no-reset)
+ "Invoke the gdb debugger and start the Emacs user interface.
+
+OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+
+ (interactive)
+ (let* ((cmd-str (or opt-cmd-line (realgud:gdb-query-cmdline "gdb")))
+ (cmd-args (split-string-and-unquote cmd-str))
+ (parsed-args (realgud:gdb-parse-cmd-args cmd-args))
+ (script-args (caddr parsed-args))
+ (script-name (or (car script-args) ""))
+ (parsed-cmd-args
+ (cl-remove-if-not 'stringp (realgud:flatten parsed-args)))
+ (cmd-buf (realgud:run-process realgud:gdb-command-name
+ script-name parsed-cmd-args
+ 'realgud:gdb-minibuffer-history
+ nil))
+ )
+ (if cmd-buf
+ (let ((process (get-buffer-process cmd-buf)))
+ (if (and process (eq 'run (process-status process)))
+ (with-current-buffer cmd-buf
+ (realgud-command "set annotate 1" nil nil nil)
+ )))
+ )
+ ))
+
+(provide-me "realgud-")
+
+;; Local Variables:
+;; byte-compile-warnings: (not cl-functions)
+;; End:
diff --git a/packages/realgud/realgud/debugger/gdb/init.el
b/packages/realgud/realgud/debugger/gdb/init.el
new file mode 100644
index 0000000..adef823
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gdb/init.el
@@ -0,0 +1,155 @@
+;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; gdb debugger
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:gdb-pat-hash (make-hash-table :test 'equal)
+ "hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. the values of a hash entry is a
+realgud-loc-pat struct")
+
+(declare-function make-realgud-loc "realgud-loc" (a b c d e f))
+
+(defconst realgud:gdb-frame-file-regexp
+ (format "\\(.+\\):%s" realgud:regexp-captured-num))
+
+;; Regular expression that describes a lldb location generally shown
+;; before a command prompt. NOTE: we assume annotate 1!
+;; For example:
+;; /src/build/ruby-2.1.5/main.c:24:454:beg:0x55555557659f
+(setf (gethash "loc" realgud:gdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^%s:%s:beg:0x\\([0-9a-f]+\\)"
+ realgud:gdb-frame-file-regexp
realgud:regexp-captured-num)
+ :file-group 1
+ :line-group 2
+ :char-offset-group 3))
+
+;; Regular expression that describes a gdb prompt
+;; For example:
+;; (gdb)
+(setf (gethash "prompt" realgud:gdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^(gdb) "
+ ))
+
+;; Regular expression that describes a "breakpoint set" line
+;; For example:
+;; Breakpoint 1, main (argc=1, argv=0x7fffffffdbd8) at main.c:24
+(setf (gethash "brkpt-set" realgud:gdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Breakpoint %s at 0x\\([0-9a-f]*\\): file \\(.+\\),
line %s.\n"
+ realgud:regexp-captured-num realgud:regexp-captured-num)
+ :num 1
+ :file-group 3
+ :line-group 4))
+
+;; Regular expression that describes a debugger "delete" (breakpoint)
+;; response.
+;; For example:
+;; Deleted breakpoint 1
+(setf (gethash "brkpt-del" realgud:gdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Deleted breakpoint %s.\n"
+ realgud:regexp-captured-num)
+ :num 1))
+
+
+;; Regular expression that describes a debugger "delete" (breakpoint)
+;; list response.
+;; For example:
+;; Deleted breakpoints 1 2 3
+(setf (gethash "brkpts-del" realgud:gdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Deleted breakpoints %s.\n"
+ realgud:regexp-captured-num)
+ :string 1))
+
+
+(defconst realgud:gdb-frame-start-regexp
+ "\\(?:^\\|\n\\)")
+
+(defconst realgud:gdb-frame-num-regexp
+ (format "#%s " realgud:regexp-captured-num))
+
+;; Regular expression that describes a gdb "backtrace" command line.
+;; For example:
+;; #0 main (argc=2, argv=0xbffff564, envp=0xbffff570) at main.c:935
+;; #1 0xb7e9f4a5 in *__GI___strdup (s=0xbffff760 "/tmp/remake/remake") at
strdup.c:42
+;; #2 0x080593ac in main (argc=2, argv=0xbffff5a4, envp=0xbffff5b0)
+;; at main.c:952
+;; #46 0xb7f51b87 in vm_call_cfunc (th=0x804d188, reg_cfp=0xb7ba9e88, num=0,
+;; recv=157798080, blockptr=0x0, me=0x80d12a0) at vm_insnhelper.c:410
+
+(setf (gethash "debugger-backtrace" realgud:gdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat realgud:gdb-frame-start-regexp
+ realgud:gdb-frame-num-regexp
+ "\\(?:.\\|\\(?:[\n] \\)\\)+[ ]+at "
+ realgud:gdb-frame-file-regexp
+ )
+ :num 1
+ :file-group 2
+ :line-group 3)
+ )
+
+(setf (gethash "font-lock-keywords" realgud:gdb-pat-hash)
+ '(
+ ;; #2 0x080593ac in main (argc=2, argv=0xbffff5a4, envp=0xbffff5b0)
+ ;; at main.c:952
+ ("[ \n]+at \\(.*\\):\\([0-9]+\\)"
+ (1 realgud-file-name-face)
+ (2 realgud-line-number-face))
+
+ ;; The frame number and first type name, if present.
+ ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
+ ;; ---^
+ ( "#\\(?:^\\|\n\\)\\([0-9]+\\) "
+ (1 realgud-backtrace-number-face))
+ ))
+
+(setf (gethash "gdb" realgud-pat-hash) realgud:gdb-pat-hash)
+
+;; Prefix used in variable names (e.g. short-key-mode-map) for
+;; this debugger
+
+(setf (gethash "gdb" realgud:variable-basename-hash) "realgud:gdb")
+
+(defvar realgud:gdb-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'continue' and the value is
+ the gdb command to use, like 'continue'")
+
+(setf (gethash "break" realgud:gdb-command-hash) "break %X:%l")
+(setf (gethash "clear" realgud:gdb-command-hash) "clear %X:%l")
+(setf (gethash "continue" realgud:gdb-command-hash) "continue")
+(setf (gethash "eval" realgud:gdb-command-hash) "print %s")
+(setf (gethash "quit" realgud:gdb-command-hash) "quit")
+(setf (gethash "run" realgud:gdb-command-hash) "run")
+(setf (gethash "step" realgud:gdb-command-hash) "step %p")
+(setf (gethash "gdb" realgud-command-hash) realgud:gdb-command-hash)
+
+(setf (gethash "gdb" realgud-pat-hash) realgud:gdb-pat-hash)
+
+(provide-me "realgud:gdb-")
diff --git a/packages/realgud/realgud/debugger/gdb/track-mode.el
b/packages/realgud/realgud/debugger/gdb/track-mode.el
new file mode 100644
index 0000000..d56e4b2
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gdb/track-mode.el
@@ -0,0 +1,75 @@
+;;; track-mode.el ---
+
+;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; gdb tracking a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:gdb-")
+
+(realgud-track-mode-vars "realgud:gdb")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud:track-mode-hook 'realgud-track-mode)
+(declare-function realgud:track-mode-enable 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+
+(define-key realgud:gdb-track-mode-map
+ (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+
+(defun realgud:gdb-track-mode-hook()
+ (use-local-map realgud:gdb-track-mode-map)
+ (realgud-track-mode-setup 't)
+ (message "realgud:gdb track-mode-hook called")
+)
+
+(define-minor-mode realgud:gdb-track-mode
+ "Minor mode for tracking gdb inside a process shell via realgud.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+Key bindings:
+\\{realgud:gdb-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " gdb" ;; mode-line indicator from realgud-track is sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:gdb
+ :keymap realgud:gdb-track-mode-map
+ (if realgud:gdb-track-mode
+ (progn
+ (realgud:track-set-debugger "gdb")
+ (realgud:gdb-track-mode-hook)
+ (realgud:track-mode-enable))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:gdb-")
+;;; track-mode.el ends here
diff --git a/packages/realgud/realgud/debugger/gub/Makefile.am
b/packages/realgud/realgud/debugger/gub/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gub/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/gub/core.el
b/packages/realgud/realgud/debugger/gub/core.el
new file mode 100644
index 0000000..a2a63d5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gub/core.el
@@ -0,0 +1,175 @@
+;;; Copyright (C) 2013-2014 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track" "../../common/lang"
+ "../../common/core") "realgud-")
+(require-relative-list '("init") "realgud:gub-")
+
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+(declare-function realgud-lang-mode? 'realgud-lang)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:gub-minibuffer-history nil
+ "minibuffer history list for the command `gub'.")
+
+(easy-mmode-defmap gub-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun gub-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'gub-suggest-invocation
+ gub-minibuffer-local-map
+ 'realgud:gub-minibuffer-history
+ opt-debugger))
+
+(defun gub-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the name of script to debug and its args.
+
+ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+
+- the command processor (e.g. gub.sh) and it's arguments if any - a list of
strings
+For example for the following input
+ \'./gub.sh --gub=\"-I\" -- ./gcd.go a b\'
+
+we might return:
+ (gub (\"-gub=-I\") (./gcd.rb a b))
+
+NOTE: the above should have each item listed in quotes.
+"
+
+ (let (
+ (args orig-args)
+ (interp-regexp ".*\\(^gub\.sh\\|tortoise\\)$")
+
+ ;; Things returned
+ (gub-name "gub.sh")
+ (gub-args '())
+ (go-prog-and-args '())
+ )
+
+ (if (not (and args))
+ ;; Got nothing
+ (list gub-name gub-args go-prog-and-args)
+ ;; else
+ ;; Strip off "gub.sh"
+ (when (string-match interp-regexp
+ (file-name-nondirectory (car args)))
+ (setq gub-name (pop args))
+ )
+
+ ;; parse options
+ (while args
+ (let ((arg (pop args)))
+ (cond
+ ((string-match "^-[-]?gub=" arg)
+ (setq gub-args (nconc gub-args (list arg))))
+
+ ((string-match "^-run" arg)
+ (setq gub-args (nconc gub-args (list arg))))
+
+ ((string-match "^-interp=SS" arg)
+ (setq gub-args (nconc gub-args (list arg))))
+
+ ((equal arg "--")) ;; Ignore
+
+ ;; Anything else add to gub-args
+ ('t (setq go-prog-and-args (nconc go-prog-and-args (list arg))))
+ ))))
+ (list gub-name gub-args go-prog-and-args)
+ ))
+
+(defconst realgud:gub-auto-suffix-regexp
+ "\\.go$"
+ "Go file suffix"
+)
+
+(defun gub-suggest-file-priority(filename)
+ (let ((priority 2)
+ (is-not-directory)
+ )
+ (if (realgud-lang-mode? filename "go")
+ (progn
+ (if (string-match realgud:gub-auto-suffix-regexp filename)
+ (setq priority 5)
+ (setq priority 7))
+ ))
+ priority
+ )
+)
+
+;; To silence Warning: reference to free variable
+(defvar realgud:gub-command-name)
+
+(defun gub-suggest-invocation (debugger-name)
+ "Suggest a command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:gub-command-name
+ realgud:gub-minibuffer-history
+ "go" "\\.go$"))
+
+;; Convert a command line as would be typed normally to run a script
+;; into one that invokes an Emacs-enabled debugging session.
+;; "--debugger" in inserted as the first switch.
+
+(defun realgud:gub-massage-args (command-line)
+ (let* ((new-args (list "--debugger"))
+ (args (split-string-and-unquote command-line))
+ (program (car args))
+ (seen-e nil)
+ (shift (lambda ()
+ (setq new-args (cons (car args) new-args))
+ (setq args (cdr args)))))
+
+ ;; Pass all switches and -e scripts through.
+ (while (and args
+ (string-match "^-" (car args))
+ (not (equal "-" (car args)))
+ (not (equal "--" (car args))))
+ (funcall shift))
+
+ (if (or (not args)
+ (string-match "^-" (car args)))
+ (error "Can't use stdin as the script to debug"))
+ ;; This is the program name.
+ (funcall shift)
+
+ (while args
+ (funcall shift))
+
+ (nreverse new-args)
+ )
+ )
+
+(defun gub-reset ()
+ "Gub cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (gub-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*gub-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun gub-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'gub-debugger-support-minor-mode minor-mode-map-alist)
+;; gub-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:gub-customize ()
+ "Use `customize' to edit the settings of the `gub' debugger."
+ (interactive)
+ (customize-group 'realgud:gub))
+
+(provide-me "realgud:gub-")
diff --git a/packages/realgud/realgud/debugger/gub/gub.el
b/packages/realgud/realgud/debugger/gub/gub.el
new file mode 100644
index 0000000..6a7ad15
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gub/gub.el
@@ -0,0 +1,86 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see
+;; <http://www.gnu.org/licenses/>.
+
+;; `gub' Main interface to Go gub via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/track") "realgud-")
+(require-relative-list '("core" "track-mode") "realgud:gub-")
+
+(eval-when-compile (require 'cl-lib))
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:gub nil
+ "The realgud interface to the Go SSA interpreter debugger, gub"
+ :group 'realgud
+ :version "23.4")
+
+;; -------------------------------------------------------------------
+;; User definable variables
+;;
+
+(defcustom realgud:gub-command-name
+ "tortoise -run -gub= -interp=SS --"
+ "File name for executing the Go SSA interpreter/debugger, gub, and command
options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:gub)
+
+(declare-function gub-query-cmdline 'realgud-gub-core)
+(declare-function gub-parse-cmd-args 'realgud-gub-core)
+(declare-function realgud:run-process 'realgud-core)
+
+
+(defun realgud-gub-fn (&optional opt-command-line no-reset)
+ "See `realgud-gub' for details"
+
+ (let* ((cmd-str (or opt-command-line (gub-query-cmdline "gub")))
+ (cmd-args (split-string-and-unquote cmd-str))
+ (parsed-args (gub-parse-cmd-args cmd-args))
+ (gub-program (car parsed-args))
+ (gub-args (cadr parsed-args))
+ (go-prog-and-args (caddr parsed-args))
+ (script-filename (car go-prog-and-args))
+ (cmd-buf))
+ (realgud:run-process gub-program script-filename cmd-args
+ 'gub-track-mode no-reset)
+ )
+ )
+
+;;;###autoload
+(defun realgud-gub (&optional opt-command-line no-reset)
+ "Invoke the Go SSA debugger, gub and start the Emacs user interface.
+
+String COMMAND-LINE specifies how to run gub.
+
+Normally command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset."
+
+
+ (interactive)
+ (realgud-gub-fn opt-command-line no-reset)
+ )
+
+(defalias 'gub 'realgud-gub)
+
+(provide-me "realgud-")
+;;; gub.el ends here
diff --git a/packages/realgud/realgud/debugger/gub/init.el
b/packages/realgud/realgud/debugger/gub/init.el
new file mode 100644
index 0000000..01f71a3
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gub/init.el
@@ -0,0 +1,206 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see
+;; <http://www.gnu.org/licenses/>.
+
+;; Regular expressions for Go SSA debugger: gub
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:gub-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; Regular expression that describes a gub location generally shown
+;; before a command prompt.
+;; For example:
+;; interp/testdata/square.go:16:2-17
+(setf (gethash "loc" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp
+
"\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\
]*\\.go\\):\\([0-9]+\\)"
+ :file-group 1
+ :line-group 2))
+
+;; Regular expression that describes a Go backtrace line.
+;; For example:
+;; ssa-interp/interp/interp.go:202 (0x506c84)
+;; visitInstr: *fr.get(instr.Addr).(*Value) = copyVal(fr.get(instr.Val))
+;; sa-interp/interp/interp.go:604 (0x50b5b1)
+;; runFrame: switch visitInstr(fr, instr) {
+(setf (gethash "lang-backtrace" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp
+
"\\(?:^\\|\n\\)\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\]*\\.go\\):\\([0-9]+\\)"
+ :file-group 1
+ :line-group 2))
+
+
+;; Regular expression that describes a gub location generally shown
+;; before a command prompt.
+;; For example:
+;; gub[1]:
+;; address@hidden:
+(setf (gethash "prompt" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^gub\\[%s\\(?:@%s\\)?\\]: "
+ realgud:regexp-captured-num
+ realgud:regexp-captured-num)
+ :num 1
+ ))
+
+;; Regular expression that describes a "breakpoint set" line
+(setf (gethash "brkpt-set" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format
+ "^Breakpoint %s set\\(?:in function \\) in file
\\([a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\) line %s, column %s"
+ realgud:regexp-captured-num realgud:regexp-captured-num
+ realgud:regexp-captured-num)
+ :num 1
+ :file-group 2
+ :line-group 3
+ :char-offset-group 4))
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Deleted breakpoint 1.
+(setf (gethash "brkpt-del" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format
+ "^Deleted breakpoint %s\n"
+ realgud:regexp-captured-num)
+ :num 1))
+
+;; Regular expression describes general location. In contrast to loc
+;; which triggers automatically, we bind this to a key like C-c !s
+;; For example:
+;; interp/testdata/square.go:16:2-17
+; ^^^^^^ spaces
+(setf (gethash "general-location" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp
+ (format
+ "\\(?:^\\|\n\\)[
\t]*\\(\\(?:[a-zA-Z]:\\)?[a-zA-Z0-9_/.\\\\][-a-zA-Z0-9_/.\\\\ ]*\\.go\\):%s"
realgud:regexp-captured-num)
+ :file-group 1
+ :line-group 2))
+
+(defconst realgud:gub-selected-frame-arrow "=>"
+"String that describes which frame is selected in a debugger
+backtrace listing.")
+(defconst realgud:gub-frame-arrow (format "\\(%s\\| \\)"
+ realgud:gub-selected-frame-arrow))
+(defconst realgud:gub-frame-num-regexp
+ (format " #%s " realgud:regexp-captured-num))
+
+(defconst realgud:gub-frame-file-regexp
+ (format " at \\(.*\\):%s" realgud:regexp-captured-num))
+
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; => #0 square(n)
+;; #1 main()
+(setf (gethash "debugger-backtrace" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat "^"
+ realgud:gub-frame-arrow
+ realgud:gub-frame-num-regexp
+ "\\(.*\\)"
+ realgud:gub-frame-file-regexp
+ )
+ :num 2
+ :file-group 4
+ :line-group 5)
+ )
+
+(setf (gethash "selected-frame-indicator" realgud:gub-pat-hash)
+ realgud:gub-selected-frame-arrow)
+
+;; Regular expression that describes a Go backtrace line
+;; For example:
+;; /usr/local/go/src/pkg/runtime/panic.c:482 (0x805c956)
+;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^^-----------
+(setf (gethash "lang-backtrace" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^\\(/.+\\):\\([0-9]+\\) \\((0x[0-9a-f]+)\\)?$"
+ :file-group 1
+ :line-group 2))
+
+;; Regular expression that describes a Go runtime panic
+;; For example:
+;; /tmp/github.com/rocky/ssa-interp/eval/selectorexpr.go:18 +0x9f
+;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^------
+(setf (gethash "panic-backtrace" realgud:gub-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^[ \t]*\\(/.+\\):%s \\(+0x[0-9a-f]+\\)?$"
+ realgud:regexp-captured-num)
+ :file-group 1
+ :line-group 2))
+
+;; Regular expression for a termination message.
+(setf (gethash "termination" realgud:gub-pat-hash)
+ "^gub: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:gub-pat-hash)
+ '(
+ ;; File name and line number
+ ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
+ ;; ---^^^^^^^^^^^^^-^^^
+ (" at \\(.*\\):\\([0-9]+\\)"
+ (1 realgud-file-name-face)
+ (2 realgud-line-number-face))
+
+ ;; The frame number and first type name, if present.
+ ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
+ ;; ---^
+ ("#\\([0-9]+\\) "
+ (1 realgud-backtrace-number-face))
+ ))
+
+(setf (gethash "gub" realgud-pat-hash) realgud:gub-pat-hash)
+
+;; Prefix used in variable names (e.g. short-key-mode-map) for
+;; this debugger
+
+(setf (gethash "tortoise" realgud:variable-basename-hash) "realgud:gub")
+
+(defvar realgud:gub-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the gub command to use, like 'q'")
+
+(setf (gethash "backtrace" realgud:gub-command-hash) "backtrace")
+(setf (gethash "break" realgud:gub-command-hash) "break %l")
+(setf (gethash "continue" realgud:gub-command-hash) "continue")
+;;(setf (gethash "eval" realgud:gub-command-hash) "x %s")
+(setf (gethash "quit" realgud:gub-command-hash) "quit")
+(setf (gethash "restart" realgud:gub-command-hash) "R")
+(setf (gethash "run" realgud:gub-command-hash) "R")
+(setf (gethash "step" realgud:gub-command-hash) "step")
+(setf (gethash "next" realgud:gub-command-hash) "next")
+(setf (gethash "until" realgud:gub-command-hash) "until %l")
+(setf (gethash "gub" realgud-command-hash) realgud:gub-command-hash)
+
+
+(provide-me "realgud:gub-")
diff --git a/packages/realgud/realgud/debugger/gub/track-mode.el
b/packages/realgud/realgud/debugger/gub/track-mode.el
new file mode 100644
index 0000000..f926916
--- /dev/null
+++ b/packages/realgud/realgud/debugger/gub/track-mode.el
@@ -0,0 +1,78 @@
+;;; Copyright (C) 2013-2016 Rocky Bernstein <address@hidden>
+;;; Golang SSA gub tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:gub-")
+
+(realgud-track-mode-vars "gub")
+
+(declare-function realgud-goto-line-for-pt 'realgud-track-mode)
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+
+(defun realgud:gub-goto-location (pt)
+ "Display the location mentioned in a location
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "general-location"))
+
+
+(defun realgud:gub-goto-panic-location (pt)
+ "Display the location mentioned in a location
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "panic-backtrace"))
+
+
+(define-key gub-track-mode-map
+ (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+(define-key gub-track-mode-map
+ (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+(define-key gub-track-mode-map
+ (kbd "C-c !s") 'realgud:gub-goto-location)
+(define-key gub-track-mode-map
+ (kbd "C-c !p") 'realgud:gub-goto-panic-location)
+
+(defun gub-track-mode-hook()
+ (if gub-track-mode
+ (progn
+ (use-local-map gub-track-mode-map)
+ (message "using gub mode map")
+ )
+ (message "gub track-mode-hook disable called"))
+)
+
+(define-minor-mode gub-track-mode
+ "Minor mode for tracking gub source locations inside a process shell via
realgud. gub is a Go language debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{gub-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " gub" ;; mode-line indicator from realgud-track is sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:gub
+ :keymap gub-track-mode-map
+
+ (realgud:track-set-debugger "gub")
+ (if gub-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (gub-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:gub-")
diff --git a/packages/realgud/realgud/debugger/ipdb/Makefile.am
b/packages/realgud/realgud/debugger/ipdb/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/ipdb/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/ipdb/core.el
b/packages/realgud/realgud/debugger/ipdb/core.el
new file mode 100644
index 0000000..43a42c5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/ipdb/core.el
@@ -0,0 +1,269 @@
+;; Copyright (C) 2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+;; Author: Sean Farley <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Copyright (C) 2014-2015 Rocky Bernstein <address@hidden>
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:ipdb-")
+
+
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:ipdb-minibuffer-history nil
+ "minibuffer history list for the command `ipdb'.")
+
+(defvar realgud:ipdb-remote-minibuffer-history nil
+ "minibuffer history list for the command `ipdb-remote'.")
+
+(easy-mmode-defmap ipdb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun ipdb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'ipdb-suggest-invocation
+ ipdb-minibuffer-local-map
+ 'realgud:ipdb-minibuffer-history
+ opt-debugger))
+
+(defun ipdb-parse-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS for the annotate level and name of script to
debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing:
+* the command processor (e.g. python) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. ipdb) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+* whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(python2.6 -O -Qold ./gcd.py a b))
+
+we might return:
+ ((\"python2.6\" \"-O\" \"-Qold\") (\"ipdb\") (\"/tmp/gcd.py\" \"a\" \"b\")
nil)
+
+Note that the script name path has been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [python python-options] ipdb ipdb-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (python-opt-two-args '())
+ ;; Python doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (python-two-args '())
+ ;; ipdb doesn't have any arguments
+ (ipdb-two-args '())
+ (ipdb-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^python[-0-9.]*\\(.exe\\)?$"
+ "^python[-0-9.]*$"))
+
+ ;; Things returned
+ (annotate-p nil)
+ (debugger-args '())
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ (script-name nil)
+ )
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "python" or "python182" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off Python-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args python-two-args python-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "ipdb" from "ipdb --ipdb-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^\\(ipdb\\|cli.py\\)$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `ipdb' or `cli.py'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args ipdb-two-args ipdb-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (expand-file-name arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+(defun ipdb-parse-remote-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing:
+* the command processor (e.g. python) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. ipdb) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+* nil
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(telnet localhost 6900))
+
+we might return:
+ ((\"telnet\" \"localhost\" \"6900\") (\"ipdb\") (\"\") nil)
+
+Note that the script name path has been expanded via `expand-file-name'.
+"
+ (list orig-args '("ipdb") '("") nil)
+ )
+
+ ;; To silence Warning: reference to free variable
+(defvar realgud:ipdb-command-name)
+
+(defun ipdb-suggest-invocation (debugger-name)
+ "Suggest a ipdb command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:ipdb-command-name
+ realgud:ipdb-minibuffer-history
+ "python" "\\.py"))
+
+(defun ipdb-reset ()
+ "Ipdb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (ipdb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*ipdb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun ipdb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'ipdb-debugger-support-minor-mode minor-mode-map-alist)
+;; ipdb-debugger-support-minor-mode-map-when-deactive))
+
+(defun realgud:ipdb-backend-complete ()
+ "Send a command to the ipdb buffer and parse the output.
+
+The idea here is to rely on the
+`comint-redirect-send-command-to-process' function to send a
+python command that will return the completions for the given
+input. Specifically, here is the python code:
+
+>>> from IPython import get_ipython
+>>> comp = '''%s'''
+>>> ';'.join(get_ipython().complete(comp.split()[-1] if len(comp)else '',
comp)[1])
+
+This returns a list of strings that match the current word (hence
+why we need the `bounds-of-thing-at-point')."
+ (interactive)
+ (let ((buffer (current-buffer))
+ (cmdbuf (realgud-get-cmdbuf))
+ (process (get-buffer-process (current-buffer)))
+ (end-position (point))
+ (bounds (bounds-of-thing-at-point 'word))
+ )
+
+ ;; get the input string
+ (save-excursion
+ (comint-goto-process-mark)
+ (let* ((start-position (point))
+ (input-str (buffer-substring-no-properties start-position
+ end-position))
+ )
+ (when (not (= (length input-str) 0))
+ (let* ((python-str (concat
+ "from IPython import get_ipython; "
+ "comp = '''%s''';"
+ "';'.join(get_ipython()"
+ ".complete(comp.split()[-1] if len(comp)"
+ "else '', comp)[1])"))
+ (command-str (format python-str input-str))
+ (output-str (with-temp-buffer
+ (let ((tmpbuf (current-buffer)))
+ (comint-redirect-send-command-to-process
+ command-str tmpbuf process nil t)
+ ;; Wait for the process to complete
+ (set-buffer (process-buffer process))
+ (while (null comint-redirect-completed)
+ (accept-process-output nil 0 5)) ;; wait 5ms
+ (set-buffer tmpbuf)
+ (buffer-substring (1+ (point-min))
+ (1- (1- (point-max)))))))
+ )
+
+ ;; we need to change the start position to that of the current word
+ ;; since python returns just the word (and not the whole line)
+ (setq start-position (car bounds))
+
+ (list start-position
+ end-position
+ (split-string output-str ";"))))))))
+
+(defun realgud:ipdb-completion-at-point ()
+ (let ((ipdb (realgud:ipdb-backend-complete)))
+ (when ipdb
+ (list (nth 0 ipdb)
+ (nth 1 ipdb)
+ (nth 2 ipdb)
+ :exclusive 'yes))))
+
+(defun realgud:ipdb-customize ()
+ "Use `customize' to edit the settings of the `ipdb' debugger."
+ (interactive)
+ (customize-group 'realgud:ipdb))
+
+(provide-me "realgud:ipdb-")
diff --git a/packages/realgud/realgud/debugger/ipdb/init.el
b/packages/realgud/realgud/debugger/ipdb/init.el
new file mode 100644
index 0000000..c854f68
--- /dev/null
+++ b/packages/realgud/realgud/debugger/ipdb/init.el
@@ -0,0 +1,120 @@
+;; Copyright (C) 2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+;; Author: Sean Farley <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; Stock Python debugger ipdb
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/python") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:ipdb-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(declare-function make-realgud-loc "realgud-loc" (a b c d e f))
+
+;; Regular expression that describes a ipdb location generally shown
+;; before a command prompt.
+;;
+;; Program-location lines look like this:
+;; > /usr/bin/zonetab2pot.py(15)<module>()
+;; or MS Windows:
+;; > c:\\mydirectory\\gcd.py(10)<module>
+(setf (gethash "loc" realgud:ipdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^> \\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\)(\\([0-9]+\\))"
+ :file-group 1
+ :line-group 2))
+
+(setf (gethash "prompt" realgud:ipdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^ipdb[>] "
+ ))
+
+;; Regular expression that describes a Python backtrace line.
+(setf (gethash "lang-backtrace" realgud:ipdb-pat-hash)
+ realgud-python-backtrace-loc-pat)
+
+;; Regular expression that describes location in a pytest error
+(setf (gethash "pytest-error" realgud:ipdb-pat-hash)
+ realgud-pytest-error-loc-pat)
+
+;; Regular expression that describes a "breakpoint set" line. For example:
+;; Breakpoint 1 at /usr/bin/ipdb:7
+(setf (gethash "brkpt-set" realgud:ipdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) at[
\t\n]+\\(.+\\):\\([0-9]+\\)\\(\n\\|$\\)"
+ :num 1
+ :file-group 2
+ :line-group 3))
+
+;; Regular expression that describes a "delete breakpoint" line
+(setf (gethash "brkpt-del" realgud:ipdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
+ :num 1))
+
+(setf (gethash "font-lock-keywords" realgud:ipdb-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)?
*\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
+ (2 realgud-backtrace-number-face)
+ (4 font-lock-function-name-face nil t)) ; t means optional.
+
+ ;; Parameter sequence, E.g. gcd(a=3, b=5)
+ ;; ^^^^^^^^^
+ ("(\\(.+\\))"
+ (1 font-lock-variable-name-face))
+
+ ;; File name. E.g file '/test/gcd.py'
+ ;; ------^^^^^^^^^^^^-
+ ("[ \t]+file '\\([^ ]+*\\)'"
+ (1 realgud-file-name-face))
+
+ ;; Line number. E.g. at line 28
+ ;; ---------^^
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+
+ ;; Function name.
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))
+ ;; (ipdb-frames-match-current-line
+ ;; (0 ipdb-frames-current-frame-face append))
+ ))
+
+(setf (gethash "ipdb" realgud-pat-hash) realgud:ipdb-pat-hash)
+
+(defvar realgud:ipdb-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'shell' and the value is
+ the ipdb command to use, like 'python'")
+
+(setf (gethash "shell" realgud:ipdb-command-hash) "python")
+(setf (gethash "eval" realgud:ipdb-command-hash) "p %s")
+(setf (gethash "ipdb" realgud-command-hash) realgud:ipdb-command-hash)
+
+(provide-me "realgud:ipdb-")
diff --git a/packages/realgud/realgud/debugger/ipdb/ipdb.el
b/packages/realgud/realgud/debugger/ipdb/ipdb.el
new file mode 100644
index 0000000..0cc8eb7
--- /dev/null
+++ b/packages/realgud/realgud/debugger/ipdb/ipdb.el
@@ -0,0 +1,118 @@
+;; Copyright (C) 2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+;; Author: Sean Farley <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; `ipdb' Main interface to ipdb via Emacs
+(require 'load-relative)
+(require-relative-list '("core" "track-mode") "realgud:ipdb-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:ipdb-")
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:ipdb nil
+ "The realgud interface to the Python ipdb debugger"
+ :group 'realgud
+ :version "24.1")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:ipdb-command-name
+ "ipdb"
+ "File name for executing the stock Python debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:ipdb)
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function ipdb-track-mode 'realgud:ipdb-track)
+(declare-function ipdb-query-cmdline 'realgud:ipdb-core)
+(declare-function ipdb-parse-cmd-args 'realgud:ipdb-core)
+(declare-function realgud:ipdb-completion-at-point 'realgud:ipdb-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;;;###autoload
+(defun realgud:ipdb (&optional opt-cmd-line no-reset)
+ "Invoke the ipdb Python debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run ipdb. You will be prompted
+for a command line is one isn't supplied.
+
+OPT-COMMAND-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `ipdb-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (let ((cmd-buf (realgud:run-debugger "ipdb" 'ipdb-query-cmdline
+ 'ipdb-parse-cmd-args
+ 'realgud:ipdb-minibuffer-history
+ opt-cmd-line no-reset))
+ )
+ (add-hook 'completion-at-point-functions
+ 'realgud:ipdb-completion-at-point nil t)
+ cmd-buf)
+ )
+
+
+;;;###autoload
+(defun realgud:ipdb-remote (&optional opt-cmd-line no-reset)
+ "Invoke the ipdb Python debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run ipdb. You will be prompted
+for a command line is one isn't supplied.
+
+OPT-COMMAND-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `ipdb-parse-remote-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (let ((cmd-buf (realgud:run-debugger "ipdb" 'ipdb-remote-query-cmdline
+ 'ipdb-parse-remote-cmd-args
+ 'realgud:ipdb-remote-minibuffer-history
+ opt-cmd-line no-reset))
+ )
+ (add-hook 'completion-at-point-functions
+ 'realgud:ipdb-completion-at-point nil t)
+ cmd-buf)
+ )
+
+
+(defalias 'ipdb 'realgud:ipdb)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/ipdb/track-mode.el
b/packages/realgud/realgud/debugger/ipdb/track-mode.el
new file mode 100644
index 0000000..17133b3
--- /dev/null
+++ b/packages/realgud/realgud/debugger/ipdb/track-mode.el
@@ -0,0 +1,78 @@
+;; Copyright (C) 2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+;; Author: Sean Farley <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; Python "ipdb" Debugger tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:ipdb-")
+
+(realgud-track-mode-vars "ipdb")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-python-populate-command-keys 'realgud-lang-python)
+(declare-function realgud:ipdb-completion-at-point 'realgud:ipdb-core)
+
+(realgud-python-populate-command-keys ipdb-track-mode-map)
+
+(defun ipdb-track-mode-hook()
+ (if ipdb-track-mode
+ (progn
+ (use-local-map ipdb-track-mode-map)
+ (add-hook 'completion-at-point-functions
+ 'realgud:ipdb-completion-at-point nil t)
+ (message "using ipdb mode map")
+ )
+ (message "ipdb track-mode-hook disable called")
+ )
+)
+
+(define-minor-mode ipdb-track-mode
+ "Minor mode for tracking ipdb source locations inside a process shell via
realgud. ipdb is a Python debugger based on ipython.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+a process shell.
+
+\\{ipdb-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " ipdb" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:ipdb
+ :keymap ipdb-track-mode-map
+ (realgud:track-set-debugger "ipdb")
+ (if ipdb-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (ipdb-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:ipdb-")
diff --git a/packages/realgud/realgud/debugger/jdb/Makefile.am
b/packages/realgud/realgud/debugger/jdb/Makefile.am
new file mode 100644
index 0000000..9a343a5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/Makefile.am
@@ -0,0 +1 @@
+include $(srcdir)/../common.mk
diff --git a/packages/realgud/realgud/debugger/jdb/README
b/packages/realgud/realgud/debugger/jdb/README
new file mode 100644
index 0000000..d37044a
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/README
@@ -0,0 +1,2 @@
+Supporting JDB is going to be a mess.
+Consider using something else. Eclipse anyone?
diff --git a/packages/realgud/realgud/debugger/jdb/backtrack-mode.el
b/packages/realgud/realgud/debugger/jdb/backtrack-mode.el
new file mode 100644
index 0000000..179ac63
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/backtrack-mode.el
@@ -0,0 +1,79 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; Mode for parsing various kinds of backtraces found in Java
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track-mode"
+ "../../common/backtrack-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:jdb-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(realgud-backtrack-mode-vars "jdb")
+(set-keymap-parent jdb-backtrack-mode-map realgud-backtrack-mode-map)
+
+(declare-function realgud-backtrack-mode
'realgud-common-backtrack-mode)
+(declare-function realgud-backtrack-set-debugger
'realgud-common-backtrack-mode)
+(declare-function realgud-goto-line-for-pt
'realgud-common-backtrack-mode)
+(declare-function realgud:ruby-populate-command-keys 'realgud-lang-ruby)
+
+(defun realgud:jdb-goto-control-frame-line (pt)
+ "Display the location mentioned by a control-frame line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "control-frame"))
+
+(realgud:ruby-populate-command-keys jdb-backtrack-mode-map)
+(define-key jdb-backtrack-mode-map
+ (kbd "C-c !c") 'realgud:jdb-goto-control-frame-line)
+
+(define-minor-mode jdb-backtrack-mode
+ "Minor mode for tracking ruby debugging inside a file which may not have
process shell.
+
+\\{jdb-backtrack-mode-map}"
+ :init-value nil
+ ;; :lighter " jdb" ;; mode-line indicator from realgud-track is sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:jdb
+ :keymap jdb-backtrack-mode-map
+
+ (realgud-backtrack-set-debugger "jdb")
+ (if jdb-backtrack-mode
+ (progn
+ (realgud-backtrack-mode 't)
+ (run-mode-hooks (intern (jdb-backtrack-mode-hook))))
+ (progn
+ (realgud-backtrack-mode nil)
+ ))
+)
+
+(defun jdb-backtrack-mode-hook()
+ (if jdb-backtrack-mode
+ (progn
+ (use-local-map jdb-backtrack-mode-map)
+ (message "using jdb mode map")
+ )
+ (message "jdb backtrack-mode-hook disable called"))
+)
+
+(provide-me "realgud:jdb-")
diff --git a/packages/realgud/realgud/debugger/jdb/core.el
b/packages/realgud/realgud/debugger/jdb/core.el
new file mode 100644
index 0000000..5fd2d61
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/core.el
@@ -0,0 +1,186 @@
+;;; Copyright (C) 2014 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+;; We use gud to handle the classpath-to-filename mapping
+(require 'gud)
+(require 'compile) ;; for compilation-find-file
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/file"
+ "../../common/lang"
+ "../../common/utils")
+ "realgud-")
+(require-relative-list '("init") "realgud:jdb-")
+
+(declare-function gud-find-source 'gud)
+
+(declare-function realgud:strip 'realgud-utils)
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+(declare-function realgud:file-loc-from-line 'realgud-file)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:jdb-minibuffer-history nil
+ "minibuffer history list for the command `realgud:jdb'.")
+
+(easy-mmode-defmap jdb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun realgud:jdb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'jdb-suggest-invocation
+ jdb-minibuffer-local-map
+ 'realgud:jdb-minibuffer-history
+ opt-debugger))
+
+(defun realgud:jdb-dot-to-slash (str)
+ "Change '.' to '/' in STR but chop off from the last . to the end. For
example
+ca.mgcill.rocky.snpEff.main => ca/mcgill/rocky/snpEff"
+ ;;(setq str (replace-regexp-in-string "\\([^\\.]+\\.\\)[^\\.]+$" "\\1"
str))
+ ;;(setq str (replace-regexp-in-string "\\.$" "" str))
+ (setq str (replace-regexp-in-string "\\." "/" str))
+ str)
+
+(defvar realgud:jdb-file-remap (make-hash-table :test 'equal)
+ "How to remap Java files in jdb when we otherwise can't find in
+ the filesystem. The hash key is the file string we saw, and the
+ value is associated filesystem string presumably in the
+ filesystem")
+
+(defun realgud:jdb-find-file(filename)
+ "A find-file specific for java/jdb. We use `gdb-jdb-find-source' to map a
+name to a filename. Failing that we can add on .java to the name. Failing that
+we will prompt for a mapping and save that in `realgud:jdb-file-remap' when
+that works."
+ (let* ((transformed-file)
+ (stripped-filename (realgud:strip filename))
+ (gud-jdb-filename (gud-jdb-find-source stripped-filename))
+ )
+ (cond
+ ((and gud-jdb-filename (file-exists-p gud-jdb-filename))
+ gud-jdb-filename)
+ ((file-exists-p (setq transformed-file (concat stripped-filename
".java")))
+ transformed-file)
+ ('t
+ (if (gethash stripped-filename realgud:jdb-file-remap)
+ (let ((remapped-filename))
+ (setq remapped-filename (gethash stripped-filename
realgud:jdb-file-remap))
+ (if (file-exists-p remapped-filename)
+ remapped-filename
+ ;; else
+ (and (remhash filename realgud-file-remap) nil)))
+ ;; else
+ (let ((remapped-filename)
+ (guess-filename (realgud:jdb-dot-to-slash filename)))
+ (setq remapped-filename
+ (buffer-file-name
+ (compilation-find-file (point-marker) guess-filename
+ nil "%s.java")))
+ (when (and remapped-filename (file-exists-p remapped-filename))
+ (puthash stripped-filename remapped-filename realgud:jdb-file-remap)
+ remapped-filename
+ ))
+ ))
+ ))
+ )
+
+(defun realgud:jdb-loc-fn-callback(text filename lineno source-str
+ ignore-file-re cmd-mark)
+ (realgud:file-loc-from-line filename lineno
+ cmd-mark source-str nil
+ ignore-file-re 'realgud:jdb-find-file))
+
+(defun realgud:jdb-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+
+* the command debugger (e.g. jdb)
+
+* debugger command rguments if any - a list of strings
+
+* the script name and its arguments - list of strings
+
+For example for the following input
+ '(\"jdb\" \"-classpath . ./TestMe.java a b\"))
+
+we might return:
+ (\"jdb\" nil \"TestMe\"))
+
+Note that the script name path has been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [ruby ruby-options] jdb jdb-options script-name script-options
+ (let (
+ (args orig-args)
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^jdb*\\(.exe\\)?$"
+ "^jdb*$"))
+ (jdb-name)
+ ;;
+ ;; One dash is added automatically to the below, so
+ ;; attach is really -attach
+ (jdb-two-args '("attach" "sourcepath" "classpath" "dbgtrace"))
+
+ ;; Things returned
+ (debugger-args '())
+ (program-args '()))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil nil nil)
+ (list jdb-name nil debugger-args program-args)
+ ;; else
+ ;; Strip off optional "jdb" or "jdb.exe" etc.
+ (when (string-match interp-regexp (car args))
+ (setq jdb-name (car args))
+ (setq program-args (nconc program-args (cdr args))))
+
+ (list jdb-name debugger-args program-args))))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:jdb-command-name)
+
+(defun jdb-suggest-invocation (debugger-name)
+ "Suggest a jdb command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:jdb-command-name
+ realgud:jdb-minibuffer-history
+ "java" "\\.java$" "jdb"))
+
+(defun jdb-reset ()
+ "Jdb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (jdb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*jdb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun jdb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'jdb-debugger-support-minor-mode minor-mode-map-alist)
+;; jdb-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:jdb-customize ()
+ "Use `customize' to edit the settings of the `jdb' debugger."
+ (interactive)
+ (customize-group 'realgud:jdb))
+
+(provide-me "realgud:jdb-")
diff --git a/packages/realgud/realgud/debugger/jdb/file.el
b/packages/realgud/realgud/debugger/jdb/file.el
new file mode 100644
index 0000000..635d844
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/file.el
@@ -0,0 +1,228 @@
+;; Association list of fully qualified class names (package + class name)
+;; and their source files.
+(defvar gud-jdb-class-source-alist nil
+ "Association list of fully qualified class names and source files.")
+
+;; This is used to hold a source file during analysis.
+(defvar gud-jdb-analysis-buffer nil)
+
+(defvar gud-jdb-classpath-string nil
+ "Holds temporary classpath values.")
+
+(defun gud-jdb-build-source-files-list (path extn)
+ "Return a list of java source files (absolute paths).
+PATH gives the directories in which to search for files with
+extension EXTN. Normally EXTN is given as the regular expression
+ \"\\.java$\" ."
+ (apply 'nconc (mapcar (lambda (d)
+ (when (file-directory-p d)
+ (directory-files d t extn nil)))
+ path)))
+
+;; Move point past whitespace.
+(defun gud-jdb-skip-whitespace ()
+ (skip-chars-forward " \n\r\t\014"))
+
+;; Move point past a "// <eol>" type of comment.
+(defun gud-jdb-skip-single-line-comment ()
+ (end-of-line))
+
+;; Move point past a "/* */" or "/** */" type of comment.
+(defun gud-jdb-skip-traditional-or-documentation-comment ()
+ (forward-char 2)
+ (catch 'break
+ (while (not (eobp))
+ (if (eq (following-char) ?*)
+ (progn
+ (forward-char)
+ (if (not (eobp))
+ (if (eq (following-char) ?/)
+ (progn
+ (forward-char)
+ (throw 'break nil)))))
+ (forward-char)))))
+
+;; Move point past any number of consecutive whitespace chars and/or comments.
+(defun gud-jdb-skip-whitespace-and-comments ()
+ (gud-jdb-skip-whitespace)
+ (catch 'done
+ (while t
+ (cond
+ ((looking-at "//")
+ (gud-jdb-skip-single-line-comment)
+ (gud-jdb-skip-whitespace))
+ ((looking-at "/\\*")
+ (gud-jdb-skip-traditional-or-documentation-comment)
+ (gud-jdb-skip-whitespace))
+ (t (throw 'done nil))))))
+
+;; Move point past things that are id-like. The intent is to skip regular
+;; id's, such as class or interface names as well as package and interface
+;; names.
+(defun gud-jdb-skip-id-ish-thing ()
+ (skip-chars-forward "^ /\n\r\t\014,;{"))
+
+;; Move point past a string literal.
+(defun gud-jdb-skip-string-literal ()
+ (forward-char)
+ (while (not (cond
+ ((eq (following-char) ?\\)
+ (forward-char))
+ ((eq (following-char) ?\042))))
+ (forward-char))
+ (forward-char))
+
+;; Move point past a character literal.
+(defun gud-jdb-skip-character-literal ()
+ (forward-char)
+ (while
+ (progn
+ (if (eq (following-char) ?\\)
+ (forward-char 2))
+ (not (eq (following-char) ?\')))
+ (forward-char))
+ (forward-char))
+
+;; Move point past the following block. There may be (legal) cruft before
+;; the block's opening brace. There must be a block or it's the end of life
+;; in petticoat junction.
+(defun gud-jdb-skip-block ()
+
+ ;; Find the beginning of the block.
+ (while
+ (not (eq (following-char) ?{))
+
+ ;; Skip any constructs that can harbor literal block delimiter
+ ;; characters and/or the delimiters for the constructs themselves.
+ (cond
+ ((looking-at "//")
+ (gud-jdb-skip-single-line-comment))
+ ((looking-at "/\\*")
+ (gud-jdb-skip-traditional-or-documentation-comment))
+ ((eq (following-char) ?\042)
+ (gud-jdb-skip-string-literal))
+ ((eq (following-char) ?\')
+ (gud-jdb-skip-character-literal))
+ (t (forward-char))))
+
+ ;; Now at the beginning of the block.
+ (forward-char)
+
+ ;; Skip over the body of the block as well as the final brace.
+ (let ((open-level 1))
+ (while (not (eq open-level 0))
+ (cond
+ ((looking-at "//")
+ (gud-jdb-skip-single-line-comment))
+ ((looking-at "/\\*")
+ (gud-jdb-skip-traditional-or-documentation-comment))
+ ((eq (following-char) ?\042)
+ (gud-jdb-skip-string-literal))
+ ((eq (following-char) ?\')
+ (gud-jdb-skip-character-literal))
+ ((eq (following-char) ?{)
+ (setq open-level (+ open-level 1))
+ (forward-char))
+ ((eq (following-char) ?})
+ (setq open-level (- open-level 1))
+ (forward-char))
+ (t (forward-char))))))
+
+;; Find the package and class definitions in Java source file FILE. Assumes
+;; that FILE contains a legal Java program. BUF is a scratch buffer used
+;; to hold the source during analysis.
+(defun gud-jdb-analyze-source (buf file)
+ (let ((l nil))
+ (set-buffer buf)
+ (insert-file-contents file nil nil nil t)
+ (goto-char 0)
+ (catch 'abort
+ (let ((p ""))
+ (while (progn
+ (gud-jdb-skip-whitespace)
+ (not (eobp)))
+ (cond
+
+ ;; Any number of semi's following a block is legal. Move point
+ ;; past them. Note that comments and whitespace may be
+ ;; interspersed as well.
+ ((eq (following-char) ?\073)
+ (forward-char))
+
+ ;; Move point past a single line comment.
+ ((looking-at "//")
+ (gud-jdb-skip-single-line-comment))
+
+ ;; Move point past a traditional or documentation comment.
+ ((looking-at "/\\*")
+ (gud-jdb-skip-traditional-or-documentation-comment))
+
+ ;; Move point past a package statement, but save the PackageName.
+ ((looking-at "package")
+ (forward-char 7)
+ (gud-jdb-skip-whitespace-and-comments)
+ (let ((s (point)))
+ (gud-jdb-skip-id-ish-thing)
+ (setq p (concat (buffer-substring s (point)) "."))
+ (gud-jdb-skip-whitespace-and-comments)
+ (if (eq (following-char) ?\073)
+ (forward-char))))
+
+ ;; Move point past an import statement.
+ ((looking-at "import")
+ (forward-char 6)
+ (gud-jdb-skip-whitespace-and-comments)
+ (gud-jdb-skip-id-ish-thing)
+ (gud-jdb-skip-whitespace-and-comments)
+ (if (eq (following-char) ?\073)
+ (forward-char)))
+
+ ;; Move point past the various kinds of ClassModifiers.
+ ((looking-at "public")
+ (forward-char 6))
+ ((looking-at "abstract")
+ (forward-char 8))
+ ((looking-at "final")
+ (forward-char 5))
+
+ ;; Move point past a ClassDeclaration, but save the class
+ ;; Identifier.
+ ((looking-at "class")
+ (forward-char 5)
+ (gud-jdb-skip-whitespace-and-comments)
+ (let ((s (point)))
+ (gud-jdb-skip-id-ish-thing)
+ (setq
+ l (nconc l (list (concat p (buffer-substring s (point)))))))
+ (gud-jdb-skip-block))
+
+ ;; Move point past an interface statement.
+ ((looking-at "interface")
+ (forward-char 9)
+ (gud-jdb-skip-block))
+
+ ;; Anything else means the input is invalid.
+ (t
+ (message "Error parsing file %s." file)
+ (throw 'abort nil))))))
+ l))
+
+(defun gud-jdb-build-class-source-alist-for-file (file)
+ (mapcar
+ (lambda (c)
+ (cons c file))
+ (gud-jdb-analyze-source gud-jdb-analysis-buffer file)))
+
+;; Return an alist of fully qualified classes and the source files
+;; holding their definitions. SOURCES holds a list of all the source
+;; files to examine.
+(defun gud-jdb-build-class-source-alist (sources)
+ (setq gud-jdb-analysis-buffer (get-buffer-create " *gud-jdb-scratch*"))
+ (prog1
+ (apply
+ 'nconc
+ (mapcar
+ 'gud-jdb-build-class-source-alist-for-file
+ sources))
+ (kill-buffer gud-jdb-analysis-buffer)
+ (setq gud-jdb-analysis-buffer nil)))
diff --git a/packages/realgud/realgud/debugger/jdb/init.el
b/packages/realgud/realgud/debugger/jdb/init.el
new file mode 100644
index 0000000..37ea2a8
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/init.el
@@ -0,0 +1,217 @@
+;;; Copyright (C) 2014-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+
+;; (require-relative-list '("../../lang/java") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defconst realgud:jdb-identifier "[A-Za-z_][A-Za-z0-9_.]+"
+"Regexp string that matches a Java identifier possily with class
+name. For example java.lang.Class.getDeclaredMethods")
+
+(defvar realgud:jdb-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(setf (gethash "loc-callback-fn" realgud:jdb-pat-hash)
'realgud:jdb-loc-fn-callback)
+
+;; Regular expression that describes a jdb location generally shown
+;; before a command prompt. For example:
+;; Breakpoint hit: "thread=main", TestMe.main(), line=7 bci=0
+;; Step completed: "thread=main", TestMe.<init>(), line=15 bci=0
+
+(setf (gethash "loc" realgud:jdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "\\(?:Breakpoint hit\\|Step completed\\): \"thread=.+\",
\\(.+\\)?[.]\\(.+\\)(), line=\\([0-9]+\\)
bci=\\([0-9]+\\)\\(?:\n\\([0-9]+\\)\\(.*\\)\\)?"
+ :file-group 1
+ :line-group 3
+ :text-group 6))
+
+;; Regular expression that describes a jdb command prompt
+;; For example:
+;; main[1]
+;; main[2]
+;; >
+;; FIXME: I think the pattern is thread-name[stack-level]
+;; Here, we only deal with main.
+(setf (gethash "prompt" realgud:jdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^\\(?:main\\[\\([0-9]+\\)\\]\\|>\\) "
+ :num 1
+ ))
+
+;; Regular expression that describes a Java syntax error line.
+;; (setf (gethash "syntax-error" realgud:jdb-pat-hash)
+;; realgud-java-syntax-error-pat)
+
+;; Regular expression that describes a Java backtrace line.
+;; For example:
+;; [1] ca.snpEffect.commandLine.SnpEff.run (SnpEff.java:7)
+(setf (gethash "lang-backtrace" realgud:jdb-pat-hash)
+ (make-realgud-loc-pat
+ ;; FIXME: use realgud:jdb-identifier
+ :regexp "^\\(?:[ ]*[\\[0-9\\]+]\\) \\([A-Za-z_.][A-Za-z0-9.]+\\)
(\\([A-Za-z_.][A-Za-z0-9.]+\\):\\([0-9]+\\))"
+ :file-group 1
+ :line-group 2))
+
+;; Regular expression that describes a "breakpoint set" line.
+;; For example:
+;; Set breakpoint TestMe:7
+(setf (gethash "brkpt-set" realgud:jdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Set breakpoint \\(.+\\):\\([0-9]+\\)"
+ :num 1
+ :line-group 2))
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Removed: breakpoint TestMe:7
+(setf (gethash "brkpt-del" realgud:jdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Removed breakpoint \\(.+\\):\\([0-9]+\\)\n"
+ :line-group 1))
+
+(defconst realgud:jdb-selected-frame-indicator "-->"
+"String that describes which frame is selected in a debugger
+backtrace listing.")
+
+(defconst realgud:jdb-frame-file-regexp
+ "[ \t\n]+in file \\([^ \n]+\\)")
+
+(defconst realgud:jdb-debugger-name "jdb" "Name of debugger")
+
+;; Top frame number
+(setf (gethash "top-frame-num" realgud:jdb-pat-hash) 0)
+
+;; Regular expression that describes a debugger "selected" frame in in
+;; a frame-motion command.
+;; For example:
+;; --> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/irb at
line 9
+(setf (gethash "selected-frame" realgud:jdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp
+ (format "^%s #\\([0-9]+\\) .*%s"
+ realgud:jdb-selected-frame-indicator
+ realgud:jdb-frame-file-regexp)
+ :num 1))
+
+;; Regular expression that describes a jdb backtrace line.
+;; For example:
+;; [1] TestMe.main (TestMe.java:7)
+;; [2] java.lang.Class.privateGetDeclaredMethods (Class.java:2,570)
+;; [3] java.lang.Class.getMethod0 (Class.java:2,813)
+;; [4] java.lang.Class.getMethod (Class.java:1,663)
+;; [5] sun.launcher.LauncherHelper.getMainMethod (LauncherHelper.java:494)
+;; [6] sun.launcher.LauncherHelper.checkAndLoadMain (LauncherHelper.java:486)
+(setf (gethash "debugger-backtrace" realgud:jdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^\\(?:[\t ]*[\\[[0-9]+\\]
\\)\\([A-Za-z_.][A-Za-z0-9.]+\\):\\([0-9]+\\)"
+ :file-group 1
+ :line-group 2))
+
+(setf (gethash "font-lock-keywords" realgud:jdb-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ;; FIXME: use realgud:jdb-identifier
+ ("^\\(-->\\| \\)? #\\([0-9]+\\) \\([A-Z]+\\)
*\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?"
+ (2 realgud-backtrace-number-face)
+ (3 font-lock-keyword-face) ; e.g. METHOD, TOP
+ (4 font-lock-constant-face) ; e.g. Object
+ (5 font-lock-function-name-face nil t)) ; t means optional
+ ;; Instruction sequence
+ ("<\\(.+\\)>"
+ (1 font-lock-variable-name-face))
+ ;; "::Type", which occurs in class name of function and in parameter
list.
+ ;; Parameter sequence
+ ("(\\(.+\\))"
+ (1 font-lock-variable-name-face))
+ ;; "::Type", which occurs in class name of function and in parameter
list.
+ ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face))
+ ;; File name.
+ ("[ \t]+in file \\([^ ]+*\\)"
+ (1 realgud-file-name-face))
+ ;; Line number.
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+ ;; Function name.
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))
+ ;; (jdb-frames-match-current-line
+ ;; (0 jdb-frames-current-frame-face append))
+ ))
+
+;; (setf (gethash "font-lock-keywords" realgud:jdb-pat-hash)
+;; '(
+;; ;; The frame number and first type name, if present.
+;; ((concat realgud:jdb-frame-start-regexp " "
+;; realgud:jdb-frame-num-regexp " "
+;; "\\([A-Z]+\\)
*\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?")
+;; (2 realgud-backtrace-number-face)
+;; (3 font-lock-keyword-face) ; e.g. METHOD, TOP
+;; (4 font-lock-constant-face) ; e.g. Object
+;; (5 font-lock-function-name-face nil t)) ; t means optional
+;; ;; Instruction sequence
+;; ("<\\(.+\\)>"
+;; (1 font-lock-variable-name-face))
+;; ;; "::Type", which occurs in class name of function and in
+;; ;; parameter list. Parameter sequence
+;; ("(\\(.+\\))"
+;; (1 font-lock-variable-name-face))
+;; ;; "::Type", which occurs in class name of function and in
+;; ;; parameter list.
+;; ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+;; (1 font-lock-type-face))
+;; ;; File name.
+;; (realgud:jdb-frame-file-regexp (1 realgud-file-name-face))
+;; ;; Line number.
+;; (realgud:jdb-frame-line-regexp (1 realgud-line-number-face))
+;; ;; Function name.
+;; ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+;; (1 font-lock-type-face)
+;; (2 font-lock-function-name-face))
+;; ;; (jdb-frames-match-current-line
+;; ;; (0 jdb-frames-current-frame-face append))
+;; ))
+
+(setf (gethash realgud:jdb-debugger-name realgud-pat-hash)
realgud:jdb-pat-hash)
+
+(defvar realgud:jdb-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the jdb command to use, like 'quit!'")
+
+(setf (gethash realgud:jdb-debugger-name
+ realgud-command-hash) realgud:jdb-command-hash)
+
+;; Prefix used in variable names (e.g. short-key-mode-map) for
+;; this debugger
+
+(setf (gethash "jdb" realgud:variable-basename-hash) "realgud:jdb")
+
+
+(setf (gethash "backtrace" realgud:jdb-command-hash) "where")
+
+;; For these we need to deal with java classpaths.
+;; Also jdb is pretty sucky when it comes to giving an prompt that
+;; we can write a regex for. So we don't even know often when there
+;; is a prompt!
+(setf (gethash "break" realgud:jdb-command-hash) "*not-implemented*")
+(setf (gethash "clear" realgud:jdb-command-hash) "*not-implemented*")
+(setf (gethash "restart" realgud:jdb-command-hash) "*not-implemented*")
+
+(setf (gethash "continue" realgud:jdb-command-hash) "cont")
+(setf (gethash "finish" realgud:jdb-command-hash) "step up")
+(setf (gethash "up" realgud:jdb-command-hash) "up\C-Mwhere")
+(setf (gethash "down" realgud:jdb-command-hash) "down\C-Mwhere")
+
+
+(provide-me "realgud:jdb-")
diff --git a/packages/realgud/realgud/debugger/jdb/jdb.el
b/packages/realgud/realgud/debugger/jdb/jdb.el
new file mode 100644
index 0000000..b9ef62a
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/jdb.el
@@ -0,0 +1,97 @@
+;;; Copyright (C) 2014-2015 Rocky Bernstein <address@hidden>
+;; `jdb' Main interface to jdb via Emacs
+
+(require 'gud) ;; For class-path and source-path handling
+(require 'cl)
+
+(require 'load-relative)
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("../../common/helper" "../../common/utils")
+ "realgud-")
+(require-relative-list '("core" "track-mode") "realgud:jdb-")
+
+(declare-function realgud:jdb-query-cmdline 'realgud:jdb-core)
+(declare-function realgud:jdb-parse-cmd-args 'realgud:jdb-core)
+(declare-function realgud:run-process 'realgud:core)
+(declare-function realgud:flatten 'realgud-utils)
+
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:jdb nil
+ "The realgud interface to the Java's jdb debugger"
+ :group 'java
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:jdb-command-name
+ ;;"jdb --emacs 3"
+ "jdb"
+ "File name for executing the Java debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:jdb)
+
+;;;###autoload
+(defun realgud:jdb (&optional opt-cmd-line no-reset)
+ "Invoke the Java jdb debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `jdb-parse-cmd-args' and path elements found by that
+are expanded using `expand-file-name'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+
+ (setq gud-jdb-classpath nil)
+ (setq gud-jdb-sourcepath nil)
+ ;; Set gud-jdb-classpath from the CLASSPATH environment variable,
+ ;; if CLASSPATH is set.
+ (setq gud-jdb-classpath-string (or (getenv "CLASSPATH") "."))
+ (if gud-jdb-classpath-string
+ (setq gud-jdb-classpath
+ (gud-jdb-parse-classpath-string gud-jdb-classpath-string)))
+
+ (setq gud-jdb-class-source-alist
+ (gud-jdb-build-class-source-alist
+ (setq gud-jdb-source-files
+ (gud-jdb-build-source-files-list gud-jdb-directories
+ "\\.java$"))))
+ (fset 'gud-jdb-find-source 'gud-jdb-find-source-file)
+
+
+ ;; reset for future invocations
+ (setq gud-jdb-classpath-string nil)
+
+ (let* (
+ (cmd-str (or opt-cmd-line (realgud:jdb-query-cmdline "jdb")))
+ (cmd-args (split-string-and-unquote cmd-str))
+ (parsed-args (realgud:jdb-parse-cmd-args cmd-args))
+ (script-args (caddr parsed-args))
+ (script-name (car script-args))
+ (parsed-cmd-args
+ (cl-remove-if 'nil (realgud:flatten parsed-args)))
+ )
+ (realgud:run-process "jdb" script-name parsed-cmd-args
+ 'realgud:jdb-track-mode-hook no-reset)
+ )
+ )
+
+(defalias 'jdb 'realgud:jdb)
+(provide-me "realgud-")
+
+;; Local Variables:
+;; byte-compile-warnings: (not cl-functions)
+;; End:
diff --git a/packages/realgud/realgud/debugger/jdb/track-mode.el
b/packages/realgud/realgud/debugger/jdb/track-mode.el
new file mode 100644
index 0000000..ed11913
--- /dev/null
+++ b/packages/realgud/realgud/debugger/jdb/track-mode.el
@@ -0,0 +1,82 @@
+;;; Copyright (C) 2015-2016 Rocky Bernstein <address@hidden>
+;;; Java "jdb" Debugger tracking a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:jdb-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-hook 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-goto-line-for-pt 'realgud-track-mode)
+
+(realgud-track-mode-vars "realgud:jdb")
+;;(defvaralias 'jdb-short-key-mode-map 'realgud:jdb-short-key-mode-map)
+;;(defvaralias 'jdb-track-mode 'realgud:track-mode)
+
+(define-key realgud-track-mode-map
+ (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+(define-key realgud-track-mode-map
+ (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+
+(defun realgud:jdb-goto-control-frame-line (pt)
+ "Display the location mentioned by a control-frame line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "control-frame"))
+
+(defun realgud:jdb-goto-syntax-error-line (pt)
+ "Display the location mentioned in a Syntax error line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "syntax-error"))
+
+(define-key realgud:jdb-track-mode-map
+ (kbd "C-c !c") 'realgud:jdb-goto-control-frame-line)
+(define-key realgud:jdb-track-mode-map
+ (kbd "C-c !s") 'realgud:jdb-goto-syntax-error-line)
+
+(defun realgud:jdb-track-mode-hook()
+ (if realgud:jdb-track-mode
+ (progn
+ (use-local-map realgud:jdb-track-mode-map)
+ (message "using realgud:jdb-track-mode-map"))
+ ;; else
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(define-minor-mode realgud:jdb-track-mode
+ "Minor mode for tracking jdb source locations inside a process shell via
realgud. jdb is a Ruby debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{realgud:jdb-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " jdb" ;; mode-line indicator from realgud-track is sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:jdb
+ :keymap realgud:jdb-track-mode-map
+ (realgud:track-set-debugger "jdb")
+ (if realgud:jdb-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (realgud:jdb-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:jdb-")
diff --git a/packages/realgud/realgud/debugger/kshdb/Makefile.am
b/packages/realgud/realgud/debugger/kshdb/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/kshdb/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/kshdb/core.el
b/packages/realgud/realgud/debugger/kshdb/core.el
new file mode 100644
index 0000000..445dd97
--- /dev/null
+++ b/packages/realgud/realgud/debugger/kshdb/core.el
@@ -0,0 +1,169 @@
+;;; Copyright (C) 2010, 2014-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track" "../../common/core") "realgud-")
+(require-relative-list '("init") "realgud:kshdb-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:kshdb-minibuffer-history nil
+ "minibuffer history list for the command `kshdb'.")
+
+(easy-mmode-defmap kshdb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun kshdb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'kshdb-suggest-invocation
+ kshdb-minibuffer-local-map
+ 'realgud:kshdb-minibuffer-history
+ opt-debugger))
+
+;;; FIXME: DRY this with other *-parse-cmd-args routines
+(defun kshdb-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+- the command processor (e.g. kshdb) and it's arguments if any - a list of
strings
+- the name of the debugger given (e.g. kshdb) and its arguments - a list of
strings
+- the script name and its arguments - list of strings
+- whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(ksh -W -C /tmp kshdb --emacs ./gcd.rb a b))
+
+we might return:
+ ((ksh -W -C) (kshdb --emacs) (./gcd.rb a b) 't)
+
+NOTE: the above should have each item listed in quotes.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [ksh ksh-options] kshdb kshdb-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ ;; ksh doesn't have any optional two-arg options
+ (ksh-opt-two-args '())
+ (ksh-two-args '("o" "c"))
+
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (kshdb-two-args '("A" "-annotate" "l" "-library"
+ "-highlight" "-no-highlight"
+ "c" "-command" "-t" "-tty"
+ "x" "-eval-command"))
+ (kshdb-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^ksh*\\(.exe\\)?$"
+ "^ksh*$"))
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "ruby" or "ruby182" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off Ruby-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args ksh-two-args ksh-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "kshdb" from "kshdb --kshdb-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^kshdb$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `kshdb'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args)) )
+ (setq annotate-p t))
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args kshdb-two-args kshdb-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+;;To silence Warning: reference to free variable
+(defvar realgud:kshdb-command-name)
+
+(defun kshdb-suggest-invocation (debugger-name)
+ "Suggest a kshdb command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:kshdb-command-name
+ realgud:kshdb-minibuffer-history
+ "sh" "\\.\\(?:k\\)?sh$"))
+
+(defun kshdb-reset ()
+ "Kshdb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (kshdb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*kshdb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun kshdb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'kshdb-debugger-support-minor-mode minor-mode-map-alist)
+;; kshdb-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:kshdb-customize ()
+ "Use `customize' to edit the settings of the `kshdb' debugger."
+ (interactive)
+ (customize-group 'realgud:kshdb))
+
+(provide-me "realgud:kshdb-")
diff --git a/packages/realgud/realgud/debugger/kshdb/init.el
b/packages/realgud/realgud/debugger/kshdb/init.el
new file mode 100644
index 0000000..f141b75
--- /dev/null
+++ b/packages/realgud/realgud/debugger/kshdb/init.el
@@ -0,0 +1,114 @@
+;;; Copyright (C) 2010-2011, 2016 Rocky Bernstein <address@hidden> Regular
+;;; expressions for Korn shell debugger: kshdb
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/posix-shell") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:kshdb-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; Regular expression that describes a kshdb location generally shown
+;; before a command prompt.
+;; For example:
+;; (/etc/init.d/apparmor:35):
+(setf (gethash "loc" realgud:kshdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "\\(^\\|\n\\)(\\([^:]+\\):\\([0-9]*\\))"
+ :file-group 2
+ :line-group 3))
+
+;; For example:
+;; kshdb<10>
+;; kshdb<(5)>
+;; kshdb<<1>>
+(setf (gethash "prompt" realgud:kshdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^kshdb[<]+[(]*\\([0-9]+\\)[)]*[>]+ "
+ :num 1
+ ))
+
+;; Regular expression that describes a "breakpoint set" line
+(setf (gethash "brkpt-set" realgud:kshdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) set in file \\(.+\\), line
\\([0-9]+\\).\n"
+ :num 1
+ :file-group 2
+ :line-group 3))
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Removed 1 breakpoint(s).
+(setf (gethash "brkpt-del" realgud:kshdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Removed \\([0-9]+\\) breakpoints(s).\n"
+ :num 1))
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; ->0 in file `/etc/apparmor/fns' at line 24
+;; ##1 /etc/apparmor/fns called from file `/etc/init.d/apparmor' at line 35
+;; ##2 /etc/init.d/apparmor called from file `/usr/bin/kshdb' at line 129
+(setf (gethash "debugger-backtrace" realgud:kshdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat realgud-shell-frame-start-regexp
+ realgud-shell-frame-num-regexp "[ ]?"
+ "\\(.*\\)"
+ realgud-shell-frame-file-regexp
+ "\\(?:" realgud-shell-frame-line-regexp "\\)?"
+ )
+ :num 2
+ :file-group 4
+ :line-group 5)
+ )
+
+;; Regular expression that for a termination message.
+(setf (gethash "termination" realgud:kshdb-pat-hash)
+ "^kshdb: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:kshdb-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --^-
+ ("^\\(->\\|##\\)\\([0-9]+\\) "
+ (2 realgud-backtrace-number-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; ---------^^^^^^^^^^^^^^^^^^^^-
+ ("[ \t]+\\(in\\|from\\) file `\\(.+\\)'"
+ (2 realgud-file-name-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --------^^
+ ;; Line number.
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+ ;; (trepan-frames-match-current-line
+ ;; (0 trepan-frames-current-frame-face append))
+ ))
+
+(setf (gethash "kshdb" realgud-pat-hash) realgud:kshdb-pat-hash)
+
+(defvar realgud:kshdb-command-hash (make-hash-table :test 'equal)
+ "hash key is command name like 'quit' and the value is
+ the trepan command to use, like 'quit!'")
+
+;; (setf (gethash "quit" realgud:kshdb-command-hash) "quit!")
+
+(setf (gethash "kshdb" realgud-pat-hash) realgud:kshdb-pat-hash)
+(setf (gethash "clear" realgud:kshdb-command-hash) "clear %l")
+
+(provide-me "realgud:kshdb-")
diff --git a/packages/realgud/realgud/debugger/kshdb/kshdb.el
b/packages/realgud/realgud/debugger/kshdb/kshdb.el
new file mode 100644
index 0000000..9c57637
--- /dev/null
+++ b/packages/realgud/realgud/debugger/kshdb/kshdb.el
@@ -0,0 +1,62 @@
+;;; Copyright (C) 2011, 2014-2015 Rocky Bernstein <address@hidden>
+;; `kshdb' Main interface to kshdb via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/track") "realgud-")
+(require-relative-list '("core" "track-mode") "realgud:kshdb-")
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:kshdb nil
+ "The realgud interface to the Korn shell debugger, kshdb"
+ :group 'realgud
+ :version "24.1")
+
+;; -------------------------------------------------------------------
+;; User definable variables
+;;
+
+(defcustom realgud:kshdb-command-name
+ ;;"kshdb --emacs 3"
+ "kshdb"
+ "File name for executing the kshdb and its command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:kshdb)
+
+(declare-function kshdb-track-mode (bool))
+(declare-function kshdb-query-cmdline 'realgud:kshdb-core)
+(declare-function kshdb-parse-cmd-args 'realgud:kshdb-core)
+(declare-function realgud:run-process 'realgud-run)
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+;;;###autoload
+(defun realgud:kshdb (&optional opt-command-line no-reset)
+ "Invoke the Korn shell debugger, kshdb, and start the Emacs user interface.
+
+String COMMAND-LINE specifies how to run kshdb.
+
+Normally command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset."
+ (interactive)
+ (let* ((cmd-str (or opt-command-line (kshdb-query-cmdline "kshdb")))
+ (cmd-args (split-string-and-unquote cmd-str))
+ (parsed-args (kshdb-parse-cmd-args cmd-args))
+ (script-args (cdr cmd-args))
+ (script-name (car script-args))
+ (cmd-buf))
+ (realgud:run-process "kshdb" script-name cmd-args
+ 'realgud:kshdb-minibuffer-history
+ no-reset)
+ ))
+
+(defalias 'kshdb 'realgud:kshdb)
+(provide-me "realgud-")
+
+;;; kshdb.el ends here
diff --git a/packages/realgud/realgud/debugger/kshdb/track-mode.el
b/packages/realgud/realgud/debugger/kshdb/track-mode.el
new file mode 100644
index 0000000..ea62baf
--- /dev/null
+++ b/packages/realgud/realgud/debugger/kshdb/track-mode.el
@@ -0,0 +1,73 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; "kshdb" Debugger tracking a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:kshdb-")
+
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud-posix-shell-populate-command-keys
+ 'realgud-lang-posix-shell)
+
+(realgud-track-mode-vars "kshdb")
+(realgud-posix-shell-populate-command-keys kshdb-track-mode-map)
+
+(declare-function realgud-track-mode(bool))
+
+(defun kshdb-track-mode-hook()
+ (if kshdb-track-mode
+ (progn
+ (use-local-map kshdb-track-mode-map)
+ (message "using kshdb mode map")
+ )
+ (message "kshdb track-mode-hook disable called"))
+)
+
+(define-minor-mode kshdb-track-mode
+ "Minor mode for tracking kshdb source locations inside a process shell via
realgud. kshdb is a Korn Shell debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{kshdb-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " kshdb" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'kshdb
+ :keymap kshdb-track-mode-map
+
+ (realgud:track-set-debugger "kshdb")
+ (if kshdb-track-mode
+ (progn
+ (realgud-track-mode 't)
+ (kshdb-track-mode-hook))
+ (progn
+ (realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:kshdb-")
diff --git a/packages/realgud/realgud/debugger/nodejs/Makefile.am
b/packages/realgud/realgud/debugger/nodejs/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/nodejs/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/nodejs/core.el
b/packages/realgud/realgud/debugger/nodejs/core.el
new file mode 100644
index 0000000..1ff8b71
--- /dev/null
+++ b/packages/realgud/realgud/debugger/nodejs/core.el
@@ -0,0 +1,168 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track" "../../common/core")
+ "realgud-")
+(require-relative-list '("init") "realgud:nodejs-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:nodejs-minibuffer-history nil
+ "minibuffer history list for the command `nodejs'.")
+
+(easy-mmode-defmap realgud:nodejs-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of nodejs startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun nodejs-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'realgud:nodejs-suggest-invocation
+ realgud:nodejs-minibuffer-local-map
+ 'realgud:nodejs-minibuffer-history
+ opt-debugger))
+
+;;; FIXME: DRY this with other *-parse-cmd-args routines
+(defun nodejs-parse-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS for the name of script to debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+* the name of the debugger given (e.g. nodejs) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(node --interactive --debugger-port 5858 /tmp nodejs ./gcd.js a b))
+
+we might return:
+ ((\"node\" \"--interactive\" \"--debugger-port\" \"5858\") nil
(\"/tmp/gcd.js\" \"a\" \"b\"))
+
+Note that path elements have been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; node nodejs-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (node-two-args '("-debugger_port" "C" "D" "i" "l" "m" "-module" "x"))
+ ;; node doesn't have any optional two-arg options
+ (node-opt-two-args '())
+
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -debugger_port is really --debugger_port.
+ (nodejs-two-args '("-debugger_port"))
+ (nodejs-opt-two-args '())
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ )
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil, nil)
+ (list interpreter-args nil script-args)
+ ;; else
+ (progn
+ ;; Remove "nodejs" (or "nodemon" or "node") from invocation like:
+ ;; nodejs --nodejs-options script --script-options
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^node\\(?:js\\|mon\\)?$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `node', `nodemon', or `nodejs'"
+ debugger-name))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ((equal "debug" arg)
+ (nconc interpreter-args (list arg))
+ (setq args (cdr args))
+ )
+
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args nodejs-two-args nodejs-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args nil script-args)))
+ ))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:nodejs-command-name)
+
+(defun realgud:nodejs-suggest-invocation (debugger-name)
+ "Suggest a nodejs command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:nodejs-command-name
+ realgud:nodejs-minibuffer-history
+ "js" "\\.js$"))
+
+(defun realgud:nodejs-remove-ansi-shmutz()
+ "Remove ASCII escape sequences that node.js 'decorates' in
+prompts and interactive output with"
+ (add-to-list
+ 'comint-preoutput-filter-functions
+ (lambda (output)
+ (replace-regexp-in-string "\033\\[[0-9]+[GKJ]" "" output)))
+ )
+
+(defun realgud:nodejs-reset ()
+ "Nodejs cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (nodejs-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*nodejs-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun nodejs-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'nodejs-debugger-support-minor-mode minor-mode-map-alist)
+;; nodejs-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:nodejs-customize ()
+ "Use `customize' to edit the settings of the `nodejs' debugger."
+ (interactive)
+ (customize-group 'realgud:nodejs))
+
+(provide-me "realgud:nodejs-")
diff --git a/packages/realgud/realgud/debugger/nodejs/init.el
b/packages/realgud/realgud/debugger/nodejs/init.el
new file mode 100644
index 0000000..9712b75
--- /dev/null
+++ b/packages/realgud/realgud/debugger/nodejs/init.el
@@ -0,0 +1,164 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Regular expressions for nodejs Javascript debugger.
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/js") "realgud-lang-")
+
+(defvar realgud:nodejs-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:nodejs-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; before a command prompt.
+;; For example:
+;; break in /home/indutny/Code/git/indutny/myscript.js:1
+(setf (gethash "loc" realgud:nodejs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format
+ "\\(?:%s\\)*\\(?:break\\|exception\\) in %s:%s"
+ realgud:js-term-escape "\\([^:]+\\)"
+ realgud:regexp-captured-num)
+ :file-group 1
+ :line-group 2))
+
+;; Regular expression that describes a nodejs command prompt
+;; For example:
+;; debug>
+(setf (gethash "prompt" realgud:nodejs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^\\(?:%s\\)*debug> " realgud:js-term-escape)
+ ))
+
+;; Regular expression that describes a "breakpoint set" line
+;;
+;; (setf (gethash "brkpt-set" realgud:nodejs-pat-hash)
+;; (make-realgud-loc-pat
+;; :regexp "^[*] \\([0-9]+\\) "
+;; :line-group 1))
+
+;; Regular expression that describes a V8 backtrace line.
+;; For example:
+;; at repl:1:7
+;; at Interface.controlEval
(/src/external-vcs/github/trepanjs/lib/interface.js:352:18)
+;; at REPLServer.b [as eval] (domain.js:183:18)
+(setf (gethash "lang-backtrace" realgud:nodejs-pat-hash)
+ realgud:js-backtrace-loc-pat)
+
+;; Regular expression that describes a debugger "delete" (breakpoint)
+;; response.
+;; For example:
+;; Removed 1 breakpoint(s).
+(setf (gethash "brkpt-del" realgud:nodejs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Removed %s breakpoint(s).\n"
+ realgud:regexp-captured-num)
+ :num 1))
+
+
+(defconst realgud:nodejs-frame-start-regexp "\\(?:^\\|\n\\)\\(?:#\\)")
+(defconst realgud:nodejs-frame-num-regexp realgud:regexp-captured-num)
+(defconst realgud:nodejs-frame-module-regexp "[^ \t\n]+")
+(defconst realgud:nodejs-frame-file-regexp "[^ \t\n]+")
+
+;; Regular expression that describes a nodejs location generally shown
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; #0 module.js:380:17
+;; #1 dbgtest.js:3:9
+;; #2 Module._compile module.js:456:26
+;; #3 Module._extensions..js module.js:474:10
+;; #4 Module.load module.js:356:32
+;; #5 Module._load module.js:312:12
+;; #6 Module.runMain module.js:497:10
+; ;#7 timers.js:110:15
+(setf (gethash "debugger-backtrace" realgud:nodejs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat realgud:nodejs-frame-start-regexp
+ realgud:nodejs-frame-num-regexp " "
+ "\\(?:" realgud:nodejs-frame-module-regexp " \\)?"
+ "\\(" realgud:nodejs-frame-file-regexp "\\)"
+ ":"
+ realgud:regexp-captured-num
+ ":"
+ realgud:regexp-captured-num
+ )
+ :num 1
+ :file-group 2
+ :line-group 3
+ :char-offset-group 4))
+
+(defconst realgud:nodejs-debugger-name "nodejs" "Name of debugger")
+
+;; ;; Regular expression that for a termination message.
+;; (setf (gethash "termination" realgud:nodejs-pat-hash)
+;; "^nodejs: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:nodejs-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --^-
+ ("^\\(->\\|##\\)\\([0-9]+\\) "
+ (2 realgud-backtrace-number-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; ---------^^^^^^^^^^^^^^^^^^^^-
+ ("[ \t]+\\(in\\|from\\) file `\\(.+\\)'"
+ (2 realgud-file-name-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --------^^
+ ;; Line number.
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+ ))
+
+(setf (gethash realgud:nodejs-debugger-name realgud-pat-hash)
+ realgud:nodejs-pat-hash)
+
+(defvar realgud:nodejs-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'finish' and the value is
+ the nodejs command to use, like 'out'")
+
+(setf (gethash "backtrace" realgud:nodejs-command-hash) "T")
+(setf (gethash "break" realgud:nodejs-command-hash)
+ "setBreakpoint(%l)")
+(setf (gethash "continue" realgud:nodejs-command-hash) "cont")
+(setf (gethash "quit" realgud:nodejs-command-hash) "quit")
+(setf (gethash "finish" realgud:nodejs-command-hash) "out")
+(setf (gethash "shell" realgud:nodejs-command-hash) "repl")
+(setf (gethash "eval" realgud:nodejs-command-hash) "*not-implemented*")
+
+;; We need aliases for step and next because the default would
+;; do step 1 and nodejs doesn't handle this. And if it did,
+;; it would probably look like step(1).
+(setf (gethash "step" realgud:nodejs-command-hash) "step")
+(setf (gethash "next" realgud:nodejs-command-hash) "next")
+
+(provide-me "realgud:nodejs-")
diff --git a/packages/realgud/realgud/debugger/nodejs/nodejs.el
b/packages/realgud/realgud/debugger/nodejs/nodejs.el
new file mode 100644
index 0000000..eddb5c5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/nodejs/nodejs.el
@@ -0,0 +1,92 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Regular expressions for nodejs Javascript debugger.
+;;; Copyright (C) 2014-2015 Rocky Bernstein <address@hidden>
+
+;; `nodejs' Main interface to nodejs debugger via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:nodejs-")
+(require-relative-list '("../../lang/js") "realgud-lang-")
+
+(declare-function realgud:js-remove-ansi-schmutz 'realgud-lang-js)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:nodejs nil
+ "The realgud interface to the nodejs debugger"
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:nodejs-command-name
+ "node debug"
+ "File name for executing the Javascript debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:nodejs)
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function nodejs-track-mode 'realgud-nodejs-track-mode)
+(declare-function nodejs-query-cmdline 'realgud:nodejs-core)
+(declare-function nodejs-parse-cmd-args 'realgud:nodejs-core)
+
+;;;###autoload
+(defun realgud:nodejs (&optional opt-cmd-line no-reset)
+ "Invoke the nodejs shell debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run nodejs.
+
+OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `nodejs-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (let ((cmd-buf
+ (realgud:run-debugger "nodejs"
+ 'nodejs-query-cmdline 'nodejs-parse-cmd-args
+ 'realgud:nodejs-minibuffer-history
+ opt-cmd-line no-reset)))
+ (if cmd-buf
+ (with-current-buffer cmd-buf
+ ;; FIXME should allow customization whether to do or not
+ ;; and also only do if hook is not already there.
+ (realgud:js-remove-ansi-schmutz)
+ )
+ )))
+
+;; There is already a nodejs command in `nodejs-repl'.
+;; (defalias 'nodejs 'realgud:nodejs)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/nodejs/track-mode.el
b/packages/realgud/realgud/debugger/nodejs/track-mode.el
new file mode 100644
index 0000000..ff7465c
--- /dev/null
+++ b/packages/realgud/realgud/debugger/nodejs/track-mode.el
@@ -0,0 +1,98 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; nodejs tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:nodejs-")
+;; (require-relative-list '("../../lang/js") "realgud-lang-")
+
+(declare-function realgud:cmd-remap 'realgud-cmds)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+
+(realgud-track-mode-vars "nodejs")
+
+(declare-function realgud-track-mode(bool))
+
+(defun nodejs-track-mode-hook()
+ (if nodejs-track-mode
+ (progn
+ (use-local-map nodejs-track-mode-map)
+ (message "using nodejs mode map")
+ )
+ (message "nodejs track-mode-hook disable called"))
+)
+
+(define-minor-mode nodejs-track-mode
+ "Minor mode for tracking nodejs source locations inside a nodejs shell via
realgud.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{nodejs-track-mode-map}"
+ :init-value nil
+ ;; :lighter " nodejs" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:nodejs
+
+ :keymap nodejs-track-mode-map
+
+ (realgud:track-set-debugger "nodejs")
+ (realgud:nodejs-track-mode-internal)
+)
+
+(defun realgud:nodejs-track-mode-internal (&optional arg)
+ (realgud:track-set-debugger "nodejs")
+ (if nodejs-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (nodejs-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+ )
+
+(defun realgud:nodejs-set-break(arg)
+ "Set a breakpoint at the current line"
+ (interactive "p")
+ (realgud:cmd-remap arg "break" "setBreakpoint('%X',%l)" "b")
+ )
+
+;; ;; Debugger commands that nodejs doesn't have
+;; (define-key nodejs-track-mode-map
+;; [remap realgud:cmd-newer-frame] 'undefined)
+;; (define-key nodejs-track-mode-map
+;; [remap realgud:cmd-older-frame] 'undefined)
+(define-key nodejs-short-key-mode-map
+ [remap realgud:cmd-step] 'realgud:cmd-step-no-arg)
+(define-key nodejs-short-key-mode-map
+ [remap realgud:cmd-step] 'realgud:cmd-step-no-arg)
+(define-key nodejs-short-key-mode-map
+ [remap realgud:cmd-next] 'realgud:cmd-next-no-arg)
+(define-key nodejs-short-key-mode-map
+ [remap realgud:cmd-break] 'realgud:nodejs-set-break)
+(define-key nodejs-short-key-mode-map "T" 'realgud:cmd-backtrace)
+
+(provide-me "realgud:nodejs-")
diff --git a/packages/realgud/realgud/debugger/pdb/Makefile.am
b/packages/realgud/realgud/debugger/pdb/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/pdb/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/pdb/core.el
b/packages/realgud/realgud/debugger/pdb/core.el
new file mode 100644
index 0000000..520c7c7
--- /dev/null
+++ b/packages/realgud/realgud/debugger/pdb/core.el
@@ -0,0 +1,203 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Copyright (C) 2014-2015 Rocky Bernstein <address@hidden>
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:pdb-")
+
+
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:pdb-minibuffer-history nil
+ "minibuffer history list for the command `pdb'.")
+
+(defvar realgud:pdb-remote-minibuffer-history nil
+ "minibuffer history list for the command `pdb-remote'.")
+
+(easy-mmode-defmap pdb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun pdb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'pdb-suggest-invocation
+ pdb-minibuffer-local-map
+ 'realgud:pdb-minibuffer-history
+ opt-debugger))
+
+(defun pdb-parse-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS for the annotate level and name of script to
debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing:
+* the command processor (e.g. python) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. pdb) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+* whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(python2.6 -O -Qold ./gcd.py a b))
+
+we might return:
+ ((\"python2.6\" \"-O\" \"-Qold\") (\"pdb\") (\"/tmp/gcd.py\" \"a\" \"b\")
nil)
+
+Note that the script name path has been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [python python-options] pdb pdb-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (python-opt-two-args '())
+ ;; Python doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (python-two-args '())
+ ;; pdb doesn't have any arguments
+ (pdb-two-args '())
+ (pdb-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^python[-0-9.]*\\(.exe\\)?$"
+ "^python[-0-9.]*$"))
+
+ ;; Things returned
+ (annotate-p nil)
+ (debugger-args '())
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ (script-name nil)
+ )
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "python" or "python182" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off Python-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args python-two-args python-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "pdb" from "pdb --pdb-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^\\(pdb\\|cli.py\\)$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `pdb' or `cli.py'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args pdb-two-args pdb-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (expand-file-name arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+(defun pdb-parse-remote-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing:
+* the command processor (e.g. python) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. pdb) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+* nil
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(telnet localhost 6900))
+
+we might return:
+ ((\"telnet\" \"localhost\" \"6900\") (\"pdb\") (\"\") nil)
+
+Note that the script name path has been expanded via `expand-file-name'.
+"
+ (list orig-args '("pdb") '("") nil)
+ )
+
+ ;; To silence Warning: reference to free variable
+(defvar realgud:pdb-command-name)
+
+(defun pdb-suggest-invocation (debugger-name)
+ "Suggest a pdb command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:pdb-command-name
+ realgud:pdb-minibuffer-history
+ "python" "\\.py"))
+
+(defun pdb-reset ()
+ "Pdb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (pdb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*pdb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun pdb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'pdb-debugger-support-minor-mode minor-mode-map-alist)
+;; pdb-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:pdb-customize ()
+ "Use `customize' to edit the settings of the `pdb' debugger."
+ (interactive)
+ (customize-group 'realgud:pdb))
+
+(provide-me "realgud:pdb-")
diff --git a/packages/realgud/realgud/debugger/pdb/init.el
b/packages/realgud/realgud/debugger/pdb/init.el
new file mode 100644
index 0000000..4ad8230
--- /dev/null
+++ b/packages/realgud/realgud/debugger/pdb/init.el
@@ -0,0 +1,119 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; Stock Python debugger pdb
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/python") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:pdb-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(declare-function make-realgud-loc "realgud-loc" (a b c d e f))
+
+;; Regular expression that describes a pdb location generally shown
+;; before a command prompt.
+;;
+;; Program-location lines look like this:
+;; > /usr/bin/zonetab2pot.py(15)<module>()
+;; or MS Windows:
+;; > c:\\mydirectory\\gcd.py(10)<module>
+(setf (gethash "loc" realgud:pdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^> \\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\)(\\([0-9]+\\))"
+ :file-group 1
+ :line-group 2))
+
+(setf (gethash "prompt" realgud:pdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^[(]+Pdb[)]+ "
+ ))
+
+;; Regular expression that describes a Python backtrace line.
+(setf (gethash "lang-backtrace" realgud:pdb-pat-hash)
+ realgud-python-backtrace-loc-pat)
+
+;; Regular expression that describes location in a pytest error
+(setf (gethash "pytest-error" realgud:pdb-pat-hash)
+ realgud-pytest-error-loc-pat)
+
+;; Regular expression that describes a "breakpoint set" line. For example:
+;; Breakpoint 1 at /usr/bin/pdb:7
+(setf (gethash "brkpt-set" realgud:pdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) at[
\t\n]+\\(.+\\):\\([0-9]+\\)\\(\n\\|$\\)"
+ :num 1
+ :file-group 2
+ :line-group 3))
+
+;; Regular expression that describes a "delete breakpoint" line
+(setf (gethash "brkpt-del" realgud:pdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
+ :num 1))
+
+(setf (gethash "font-lock-keywords" realgud:pdb-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)?
*\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
+ (2 realgud-backtrace-number-face)
+ (4 font-lock-function-name-face nil t)) ; t means optional.
+
+ ;; Parameter sequence, E.g. gcd(a=3, b=5)
+ ;; ^^^^^^^^^
+ ("(\\(.+\\))"
+ (1 font-lock-variable-name-face))
+
+ ;; File name. E.g file '/test/gcd.py'
+ ;; ------^^^^^^^^^^^^-
+ ("[ \t]+file '\\([^ ]+*\\)'"
+ (1 realgud-file-name-face))
+
+ ;; Line number. E.g. at line 28
+ ;; ---------^^
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+
+ ;; Function name.
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))
+ ;; (pdb-frames-match-current-line
+ ;; (0 pdb-frames-current-frame-face append))
+ ))
+
+(setf (gethash "pdb" realgud-pat-hash) realgud:pdb-pat-hash)
+
+(defvar realgud:pdb-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'shell' and the value is
+ the pdb command to use, like 'python'")
+
+(setf (gethash "shell" realgud:pdb-command-hash) "python")
+(setf (gethash "eval" realgud:pdb-command-hash) "p %s")
+(setf (gethash "pdb" realgud-command-hash) realgud:pdb-command-hash)
+
+(provide-me "realgud:pdb-")
diff --git a/packages/realgud/realgud/debugger/pdb/pdb.el
b/packages/realgud/realgud/debugger/pdb/pdb.el
new file mode 100644
index 0000000..4e907b7
--- /dev/null
+++ b/packages/realgud/realgud/debugger/pdb/pdb.el
@@ -0,0 +1,108 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; `pdb' Main interface to pdb via Emacs
+(require 'load-relative)
+(require-relative-list '("core" "track-mode") "realgud:pdb-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:pdb-")
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:pdb nil
+ "The realgud interface to the Python pdb debugger"
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:pdb-command-name
+ "pdb"
+ "File name for executing the stock Python debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:pdb)
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function pdb-track-mode 'realgud:pdb-track)
+(declare-function pdb-query-cmdline 'realgud:pdb-core)
+(declare-function pdb-parse-cmd-args 'realgud:pdb-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;;;###autoload
+(defun realgud:pdb (&optional opt-cmd-line no-reset)
+ "Invoke the pdb Python debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run pdb. You will be prompted
+for a command line is one isn't supplied.
+
+OPT-COMMAND-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `pdb-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "pdb" 'pdb-query-cmdline
+ 'pdb-parse-cmd-args
+ 'realgud:pdb-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+
+;;;###autoload
+(defun realgud:pdb-remote (&optional opt-cmd-line no-reset)
+ "Invoke the pdb Python debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run pdb. You will be prompted
+for a command line is one isn't supplied.
+
+OPT-COMMAND-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `pdb-parse-remote-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "pdb" 'pdb-remote-query-cmdline
+ 'pdb-parse-remote-cmd-args
+ 'realgud:pdb-remote-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+
+(defalias 'pdb 'realgud:pdb)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/pdb/track-mode.el
b/packages/realgud/realgud/debugger/pdb/track-mode.el
new file mode 100644
index 0000000..7958eae
--- /dev/null
+++ b/packages/realgud/realgud/debugger/pdb/track-mode.el
@@ -0,0 +1,74 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; Python "pdb" Debugger tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:pdb-")
+
+(realgud-track-mode-vars "pdb")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-python-populate-command-keys 'realgud-lang-python)
+
+(realgud-python-populate-command-keys pdb-track-mode-map)
+
+(defun pdb-track-mode-hook()
+ (if pdb-track-mode
+ (progn
+ (use-local-map pdb-track-mode-map)
+ (message "using pdb mode map")
+ )
+ (message "pdb track-mode-hook disable called")
+ )
+)
+
+(define-minor-mode pdb-track-mode
+ "Minor mode for tracking pdb source locations inside a process shell via
realgud. pdb is the stock Python debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+a process shell.
+
+\\{pdb-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " pdb" ;; mode-line indicator from realgud-track is sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:pdb
+ :keymap pdb-track-mode-map
+ (realgud:track-set-debugger "pdb")
+ (if pdb-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (pdb-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:pdb-")
diff --git a/packages/realgud/realgud/debugger/perldb/Makefile.am
b/packages/realgud/realgud/debugger/perldb/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/perldb/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/perldb/core.el
b/packages/realgud/realgud/debugger/perldb/core.el
new file mode 100644
index 0000000..c18b276
--- /dev/null
+++ b/packages/realgud/realgud/debugger/perldb/core.el
@@ -0,0 +1,145 @@
+;;; Copyright (C) 2011, 2013-2014 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:perldb-")
+
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:perldb-minibuffer-history nil
+ "minibuffer history list for the command `perldb'.")
+
+(easy-mmode-defmap realgud:perldb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of perldb startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun realgud:perldb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'realgud:perldb-suggest-invocation
+ realgud:perldb-minibuffer-local-map
+ 'realgud:perldb-minibuffer-history
+ opt-debugger))
+
+;;; FIXME: DRY this with other *-parse-cmd-args routines
+(defun realgud:perldb-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+
+* the command processor (e.g. perl) and it's arguments if any - a
+ list of strings
+
+* the script name and its arguments - list of strings
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(perl -W -C /tmp -d ./gcd.pl a b))
+
+we might return:
+ ((\"perl\" \"-W\" \"-C\" \"-d\") nil (\"/tmp/gcd.pl\" \"a\" \"b\"))
+
+Note that path elements have been expanded via
`realgud:expand-file-name-if-exists'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [perl perl-options] perldb perldb-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (perl-opt-two-args '("0" "C" "D" "i" "l" "m" "-module" "x"))
+ ;; Perl doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (perl-two-args '())
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (perldb-two-args '("e" "E"))
+ (perldb-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^perl\\(?:5[0-9.]*\\)\\(.exe\\)?$"
+ "^perl\\(?:5[0-9.]*\\)?$"))
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ )
+
+ (if (not (and args))
+ ;; Got nothing
+ (list interpreter-args nil script-args)
+ ;; else
+ ;; Remove "perl" or "perl5.10.1" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Skip to the first non-option argument
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Options with arguments.
+ ((string-match "^-" (car args))
+ (setq pair (realgud-parse-command-arg
+ args perl-two-args perl-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args nil script-args)))
+ ))
+
+; # To silence Warning: reference to free variable
+(defvar realgud:perldb-command-name)
+
+(defun realgud:perldb-suggest-invocation (debugger-name)
+ "Suggest a perldb command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:perldb-command-name
+ realgud:perldb-minibuffer-history
+ "perl" "\\.pl$"))
+
+(defun realgud:perldb-reset ()
+ "Perldb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (perldb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*perldb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun perldb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'perldb-debugger-support-minor-mode minor-mode-map-alist)
+;; perldb-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:perldb-customize ()
+ "Use `customize' to edit the settings of the `perldb' debugger."
+ (interactive)
+ (customize-group 'realgud:perldb))
+
+(provide-me "realgud:perldb-")
diff --git a/packages/realgud/realgud/debugger/perldb/init.el
b/packages/realgud/realgud/debugger/perldb/init.el
new file mode 100644
index 0000000..537703d
--- /dev/null
+++ b/packages/realgud/realgud/debugger/perldb/init.el
@@ -0,0 +1,122 @@
+;;; Copyright (C) 2011, 2014-2015 Rocky Bernstein <address@hidden>
+;;; Stock Perl debugger perldb
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
+(require-relative-list '("../../lang/perl") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:perldb-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+lang-backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(declare-function make-realgud-loc "realgud-loc" (a b c d e f))
+
+;; Program-location lines look like these:
+;; File::Basename::dirname(/usr/share/perl/5.16.0/File/Basename.pm:284):
+;; File::Basename::dirname(/usr/share/perl/5.16.0/File/Basename.pm:284):
my $path;
+;; main::(/usr/bin/latex2html:102):
+;; main::(/usr/bin/latex2html:102): @ARGV=2;
+;; main::CODE(0x9407ac8)(l2hconf.pm:6):;;
+;; main::((eval 8)[/tmp/eval.pl:2]:1):
+;;
+;; And what are complications MS Windows adds?
+
+;; Hnadle eval form first, e.g.:
+;; main::((eval 8)[/tmp/eval.pl:2]:1):
+
+(defconst realgud:perldb-loc-eval-regexp
+ (format "(eval [0-9]+)\\[\\(.+\\):%s\\]"
+ realgud:regexp-captured-num))
+
+;; Hnadle non eval form
+;; main::CODE(0x9407ac8)(l2hconf.pm:6):;;
+
+(defconst realgud:perldb-loc-noeval-regexp
+ (format "\\(?:CODE(0x[0-9a-h]+)\\)?(\\(.+\\):%s):\\(?:\t\\(.*\\)\\)?\n"
+ realgud:regexp-captured-num))
+
+;; Note that eval form has to come before non-eval form as the non-eval
+;; form encompases the eval form. The two clauses makes it hard
+;; to match file and line positions, so we ned to result to the
+;; "alt" forms of file and lines as well as the non-alt formes
+(defconst realgud:perldb-loc-regexp
+ (format "\\(?:%s\\)\\|\\(?:%s\\)"
+ realgud:perldb-loc-eval-regexp realgud:perldb-loc-noeval-regexp))
+
+;; Regular expression that describes a perldb location generally shown
+;; before a command prompt. We include matching the source text so we
+;; can save that.
+(setf (gethash "loc" realgud:perldb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp realgud:perldb-loc-regexp
+ :alt-file-group 1
+ :alt-line-group 2
+ :file-group 3
+ :line-group 4
+ :text-group 5))
+
+;; perldb debugger prompt.
+;; Examples:
+;; DB<4>
+;; [pid=6489->6502] DB<1>
+;;
+(setf (gethash "prompt" realgud:perldb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "\\(?:\\[pid=[0-9]+->[0-9]+\\]\\)? DB<\\([0-9]+\\)> "
+ :num 1
+ ))
+
+;; Regular expression that describes a Perl debugger backtrace line.
+;; $ = main::top_navigation_panel called from file `./latex2html' line 7400
+;; $ = main::BEGIN() called from file `(eval 19)[/usr/bin/latex2html:126]'
line 2
+(setf (gethash "debugger-backtrace" realgud:perldb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "\s+called from file `\\(.+\\)' line \\([0-9]+\\)"
+ :file-group 1
+ :line-group 2))
+
+;; Regular expression that describes location in a Perl errmsg
+(setf (gethash "perl-errmsg" realgud:perldb-pat-hash)
+ realgud-perl-errmsg-loc-pat)
+
+;; Regular expression that describes a Perl Carp backtrace line.
+;; at /tmp/foo.pl line 7
+;; main::__ANON__('Illegal division by zero at /tmp/foo.pl line 4.\x{a}')
called at /tmp/foo.pl line 4
+;; main::foo(3) called at /tmp/foo.pl line 8
+(setf (gethash "lang-backtrace" realgud:perldb-pat-hash)
+ realgud-perl-carp-loc-pat)
+
+(defvar realgud:perldb-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the perldb command to use, like 'q'")
+
+(setf (gethash "font-lock-keywords" realgud:perldb-pat-hash)
+ '(
+ ("\s+called from file `\\(.+\\)' line \\([0-9]+\\)"
+ (1 realgud-file-name-face)
+ (2 realgud-line-number-face))
+ ))
+
+
+(setf (gethash "perldb" realgud-pat-hash) realgud:perldb-pat-hash)
+
+(setf (gethash "backtrace" realgud:perldb-command-hash) "T")
+(setf (gethash "break" realgud:perldb-command-hash) "b %l")
+(setf (gethash "clear" realgud:perldb-command-hash) "B %l")
+(setf (gethash "continue" realgud:perldb-command-hash) "c")
+(setf (gethash "eval" realgud:perldb-command-hash) "x %s")
+(setf (gethash "quit" realgud:perldb-command-hash) "q")
+(setf (gethash "restart" realgud:perldb-command-hash) "R")
+(setf (gethash "run" realgud:perldb-command-hash) "R")
+(setf (gethash "step" realgud:perldb-command-hash) "s")
+(setf (gethash "next" realgud:perldb-command-hash) "n")
+(setf (gethash "until" realgud:perldb-command-hash) "c %l")
+(setf (gethash "perldb" realgud-command-hash) realgud:perldb-command-hash)
+
+(provide-me "realgud:perldb-")
diff --git a/packages/realgud/realgud/debugger/perldb/perldb.el
b/packages/realgud/realgud/debugger/perldb/perldb.el
new file mode 100644
index 0000000..049a6b2
--- /dev/null
+++ b/packages/realgud/realgud/debugger/perldb/perldb.el
@@ -0,0 +1,63 @@
+;;; Copyright (C) 2011, 2014-2015 Rocky Bernstein <address@hidden>
+;; `perldb' Main interface to perl debugger via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:perldb-")
+
+(declare-function realgud:run-debugger 'realgud:run)
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:perldb nil
+ "The realgud interface to the Perl debugger, perldb"
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:perldb-command-name
+ "perl -d"
+ "Option to needed to run the Perl debugger"
+ :type 'string
+ :group 'realgud:perldb)
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function perldb-track-mode (bool))
+(declare-function realgud:perldb-query-cmdline 'realgud:perldb-core)
+(declare-function realgud:perldb-parse-cmd-args 'realgud:perldb-core)
+
+;;;###autoload
+(defun realgud:perldb (&optional opt-cmd-line no-reset)
+ "Invoke the Perl debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run nodejs.
+
+OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `perldb-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "perldb"
+ 'realgud:perldb-query-cmdline
+ 'realgud:perldb-parse-cmd-args
+ 'realgud:perldb-minibuffer-history
+ opt-cmd-line no-reset))
+
+;; (defalias 'perldb 'realgud:perldb)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/perldb/track-mode.el
b/packages/realgud/realgud/debugger/perldb/track-mode.el
new file mode 100644
index 0000000..3d27722
--- /dev/null
+++ b/packages/realgud/realgud/debugger/perldb/track-mode.el
@@ -0,0 +1,87 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; Stock Perl Debugger "perldb5" tracking a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:perldb-")
+(require-relative-list '("../../lang/perl") "realgud-lang-")
+
+(realgud-track-mode-vars "perldb")
+
+(declare-function realgud:cmd-remap 'realgud-cmds)
+(declare-function realgud-perl-populate-command-keys
+ 'realgud:perldb)
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-setup realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+
+(realgud-perl-populate-command-keys perldb-track-mode-map )
+
+(defun perldb-track-mode-hook()
+ (if perldb-track-mode
+ (progn
+ (use-local-map perldb-track-mode-map)
+ (message "using perldb mode map")
+ )
+ (message "perldb track-mode-hook disable called"))
+)
+
+(define-minor-mode perldb-track-mode
+ "Minor mode for tracking perl5db source locations inside a process shell via
realgud. perl5db is the stock Perl debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{perldb-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " perldb" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:perldb
+ :keymap perldb-track-mode-map
+
+ (realgud:track-set-debugger "perldb")
+ (if perldb-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (perldb-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(defun realgud:perldb-backtrace(arg)
+ (interactive "p")
+ (realgud:cmd-remap arg "backtrace" "T" "T")
+)
+
+;; Perldb doesn't have stack switching commands.
+(define-key perldb-short-key-mode-map
+ [remap realgud:cmd-newer-frame] 'undefined)
+(define-key perldb-short-key-mode-map
+ [remap realgud:cmd-older-frame] 'undefined)
+(define-key perldb-short-key-mode-map "T" 'realgud:perldb-backtrace)
+
+(provide-me "realgud:perldb-")
diff --git a/packages/realgud/realgud/debugger/rdebug/Makefile.am
b/packages/realgud/realgud/debugger/rdebug/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/rdebug/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/rdebug/core.el
b/packages/realgud/realgud/debugger/rdebug/core.el
new file mode 100644
index 0000000..6612a7d
--- /dev/null
+++ b/packages/realgud/realgud/debugger/rdebug/core.el
@@ -0,0 +1,165 @@
+;;; Copyright (C) 2010, 2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud-rdebug-")
+
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:rdebug-minibuffer-history nil
+ "minibuffer history list for the command `rdebug'.")
+
+(easy-mmode-defmap rdebug-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun rdebug-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'rdebug-suggest-invocation
+ rdebug-minibuffer-local-map
+ 'realgud:rdebug-minibuffer-history
+ opt-debugger))
+
+(defun rdebug-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+- the command processor (e.g. ruby) and it's arguments if any - a list of
strings
+- the name of the debugger given (e.g. rdebug) and its arguments - a list of
strings
+- the script name and its arguments - list of strings
+- whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(ruby1.9 -W -C /tmp rdebug --emacs ./gcd.rb a b))
+
+we might return:
+ ((ruby1.9 -W -C) (rdebug --emacs) (./gcd.rb a b) 't)
+
+NOTE: the above should have each item listed in quotes.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [ruby ruby-options] rdebug rdebug-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (ruby-opt-two-args '("0" "C" "e" "E" "F" "i"))
+ ;; Ruby doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (ruby-two-args '())
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (rdebug-two-args '("h" "-host" "p" "-port"
+ "I" "-include" "-r" "-require"))
+ (rdebug-opt-two-args '())
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "ruby" or "ruby182" etc.
+ (when (string-match "^ruby[-0-9]*$"
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off Ruby-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args ruby-two-args ruby-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "rdebug" from "rdebug --rdebug-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^rdebug$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `rdebug'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args)) )
+ (setq annotate-p t))
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args rdebug-two-args rdebug-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name arg)
+ (setq script-args args))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+(defvar realgud:rdebug-command-name)
+(defun rdebug-suggest-invocation (debugger-name)
+ "Suggest a rdebug command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:rdebug-command-name
+ realgud:rdebug-minibuffer-history
+ "ruby" "\\.rb$"
+ realgud:rdebug-command-name))
+
+(defun rdebug-reset ()
+ "Rdebug cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (rdebug-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*rdebug-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun rdebug-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
+;; rdebug-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:rdebug-customize ()
+ "Use `customize' to edit the settings of the `rdebug' debugger."
+ (interactive)
+ (customize-group 'realgud:rdebug))
+
+(provide-me "realgud-rdebug-")
diff --git a/packages/realgud/realgud/debugger/rdebug/init.el
b/packages/realgud/realgud/debugger/rdebug/init.el
new file mode 100644
index 0000000..3eb495b
--- /dev/null
+++ b/packages/realgud/realgud/debugger/rdebug/init.el
@@ -0,0 +1,135 @@
+;;; Copyright (C) 2010, 2011, 2016 Rocky Bernstein <address@hidden>
+;;; Ruby 1.8 debugger: ruby-debug (rdebug)
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud-rdebug-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; Regular expression that describes a rdebug location generally shown
+;; before a command prompt.
+;; For example:
+;; /usr/lib/ruby/1.8/rubygems/custom_require.rb:31 # in Emacs
+;; /usr/bin/irb:12
+(setf (gethash "loc" realgud-rdebug-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "\\(?:source
\\)?\\(\\(?:[a-zA-Z]:\\)?\\(?:.+\\)\\):\\([0-9]+\\).*\\(?:\n\\|$\\)"
+ :file-group 1
+ :line-group 2
+ :ignore-file-re "(eval)"
+ ))
+
+;; Regular expression that describes a rdebug command prompt
+;; For example:
+;; (rdb:1)
+(setf (gethash "prompt" realgud-rdebug-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^(rdb:[0-9]+) "
+ ))
+
+;; Regular expression that describes a Ruby backtrace line.
+(setf (gethash "lang-backtrace" realgud-rdebug-pat-hash)
+ realgud-ruby-backtrace-loc-pat)
+
+;; Regular expression that describes a ruby $! backtrace
+(setf (gethash "dollar-bang-backtrace" realgud-rdebug-pat-hash)
+ realgud-ruby-dollar-bang-loc-pat)
+
+;; Regular expression that describes a rdebug "breakpoint set" line
+;; For example:
+;; Breakpoint 1 file /test/gcd.rb, line 6
+;; -----------^------^^^^^^^^^^^^-------^
+(setf (gethash "brkpt-set" realgud-rdebug-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) file \\(.+\\), line \\([0-9]+\\)\n"
+ :num 1
+ :file-group 2
+ :line-group 3))
+
+(defconst realgud-rdebug-frame-file-line-regexp
+ "[ \t\n]+at line \\(.*\\):\\([0-9]+\\)$")
+
+(defconst realgud-rdebug-frame-start-regexp realgud:trepan-frame-start-regexp)
+(defconst realgud-rdebug-frame-num-regexp realgud:trepan-frame-num-regexp)
+
+;; Regular expression that describes a Ruby $! string
+(setf (gethash "dollar-bang" realgud-rdebug-pat-hash)
+ realgud-ruby-dollar-bang-loc-pat)
+
+;; Regular expression that describes a Ruby $! string
+(setf (gethash "rails-backtrace" realgud-rdebug-pat-hash)
+ realgud-rails-backtrace-loc-pat)
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; e.g.
+;; --> #0 at line /usr/bin/irb:12
+;; #1 main.__script__ at /tmp/fact.rb:1
+;; #1 main.__script__ at /tmp/fact.rb:1
+;; #0 IRB.start(ap_path#String) at line /usr/lib/ruby/1.8/irb.rb:52
+(setf (gethash "debugger-backtrace" realgud-rdebug-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat realgud-rdebug-frame-start-regexp " "
+ realgud-rdebug-frame-num-regexp
+ "\\(?: \\(?:\\(.+\\)(\\(.*\\))\\)\\)?"
+ realgud-rdebug-frame-file-line-regexp
+ )
+ :num 2
+ :file-group 5
+ :line-group 6)
+ )
+
+(setf (gethash "font-lock-keywords" realgud-rdebug-pat-hash)
+ '(
+ ;; Parameters and first type entry. E.g Object.gcd(a#Fixnum, b#Fixnum)
+ ;; ^-^^^^^^ ^-^^^^^^
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)#\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\>"
+ (1 font-lock-variable-name-face)
+ (2 font-lock-constant-face))
+
+ ;; "::Type", which occurs in class name of function and in
+ ;; parameter list.
+ ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face))
+
+ ;; The frame number and first type name, if present.
+ ;; E.g. --> #0 Object.gcd(a#Fixnum, b#Fixnum)
+ ;; -----^-^^^^^^.^^^
+ ("^\\(-->\\)? *#\\([0-9]+\\) *\\(\\([a-zA-Z_][a-zA-Z0-9_]*\\)[.:]\\)?"
+ (2 realgud-backtrace-number-face)
+ (4 font-lock-constant-face nil t)) ; t means optional.
+
+ ;; File name and line number. E.g. at line /test/gcd.rb:6
+ ;; -------^^^^^^^^^^^^^-^
+ ("at line \\(.*\\):\\([0-9]+\\)$"
+ (1 realgud-file-name-face)
+ (2 realgud-line-number-face))
+
+ ;; Function name.
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))
+ ;; (rdebug-frames-match-current-line
+ ;; (0 rdebug-frames-current-frame-face append))
+ ))
+
+
+(setf (gethash "rdebug" realgud-pat-hash) realgud-rdebug-pat-hash)
+
+(defvar realgud-rdebug-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the trepanx command to use, like 'quit!'")
+
+(setf (gethash "quit" realgud-rdebug-command-hash) "quit!")
+(setf (gethash "shell" realgud-rdebug-command-hash) "irb")
+(setf (gethash "rdebug" realgud-command-hash) realgud-rdebug-command-hash)
+
+(provide-me "realgud-rdebug-")
diff --git a/packages/realgud/realgud/debugger/rdebug/rdebug.el
b/packages/realgud/realgud/debugger/rdebug/rdebug.el
new file mode 100644
index 0000000..955fe85
--- /dev/null
+++ b/packages/realgud/realgud/debugger/rdebug/rdebug.el
@@ -0,0 +1,115 @@
+;;; Copyright (C) 2010-2011, 2014-2015 Rocky Bernstein <address@hidden>
+;; `rdebug' Main interface to rdebug via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper"
+ "../../common/track") "realgud-")
+(require-relative-list '("core" "track-mode") "realgud-rdebug-")
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:rdebug nil
+ "The realgud interface to the Ruby debugger, rdebug"
+ :group 'realgud
+ :version "24.3")
+
+(declare-function rdebug-query-cmdline 'realgud-rdebug-core)
+(declare-function rdebug-parse-cmd-args 'realgud-rdebug-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;; -------------------------------------------------------------------
+;; User definable variables
+;;
+
+(defcustom realgud:rdebug-command-name
+ ;;"rdebug --emacs 3"
+ "rdebug"
+ "File name for executing the Ruby debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:rdebug)
+
+(declare-function rdebug-track-mode (bool))
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(defun rdebug-get-script-name (args)
+ "Parse command line ARGS.
+
+ARGS is a list of strings containing the rdebug command name. We
+return a list containing the script name, and whether the
+annotate option was set is returned.
+
+Initially annotate should be set to nil. Argument ARGS contains
+a tokenized list of the command line."
+ ;; Parse the following:
+ ;;
+ ;; [ruby ruby-options] rdebug rdebug-options script-name script-options
+ (and args
+ (let ((name nil)
+ (annotate-p nil))
+ ;; Strip of optional "ruby" or "ruby182" etc.
+ (when (string-match "^ruby[0-9]*$"
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (pop args)
+ (while (and args
+ (string-match "^-" (car args)))
+ (if (member (car args) '("-e" "-r" "-I" "-C" "-F" "-K"))
+ (pop args))
+ (pop args)))
+ ;; Remove "rdebug" from "rdebug --rdebug-options script
+ ;; --script-options"
+ (pop args)
+ ;; Skip to the first non-option argument.
+ (while (and args
+ (not name))
+ (let ((arg (pop args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (pop args))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (setq annotate-p t))
+ ;; Options with arguments.
+ ((member arg '("-h" "--host" "-p" "--port"
+ "-I" "--include" "-r" "--require"))
+ (pop args))
+ ((string-match "^-" arg)
+ nil)
+ (t
+ (setq name arg)))))
+ (and name
+ (list name annotate-p)))))
+
+
+;;;###autoload
+(defun realgud:rdebug (&optional opt-cmd-line no-reset)
+ "Invoke the rdebug Ruby debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `trepan8-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "rdebug" 'rdebug-query-cmdline
+ 'rdebug-parse-cmd-args
+ 'realgud:rdebug-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+
+(defalias 'rdebug 'realgud:rdebug)
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/rdebug/track-mode.el
b/packages/realgud/realgud/debugger/rdebug/track-mode.el
new file mode 100644
index 0000000..61afa3f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/rdebug/track-mode.el
@@ -0,0 +1,63 @@
+;;; Copyright (C) 2010, 2012, 2015 Rocky Bernstein <address@hidden>
+;;; Ruby "rdebug" Debugger tracking a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud-rdebug-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(realgud-track-mode-vars "rdebug")
+
+(declare-function realgud:ruby-populate-command-keys 'realgud-track-lang-ruby)
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-hook 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+
+(realgud:ruby-populate-command-keys rdebug-track-mode-map)
+
+(defun rdebug-track-mode-hook()
+ (if rdebug-track-mode
+ (progn
+ (use-local-map rdebug-track-mode-map)
+ (message "using rdebug mode map")
+ )
+ (message "rdebug track-mode-hook disable called"))
+)
+
+(define-minor-mode rdebug-track-mode
+ "Minor mode for tracking rdebug source locations inside a process shell via
realgud. rdebug is a Ruby debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{rdebug-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " rdebug" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:rdebug
+ :keymap rdebug-track-mode-map
+ (rdebug-track-mode-internal rdebug-track-mode)
+)
+
+;; Broken out as a function for debugging
+(defun rdebug-track-mode-internal (&optional arg)
+ (realgud:track-set-debugger "rdebug")
+ (if rdebug-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (rdebug-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud-rdebug-")
diff --git a/packages/realgud/realgud/debugger/remake/Makefile.am
b/packages/realgud/realgud/debugger/remake/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/remake/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/remake/core.el
b/packages/realgud/realgud/debugger/remake/core.el
new file mode 100644
index 0000000..a755726
--- /dev/null
+++ b/packages/realgud/realgud/debugger/remake/core.el
@@ -0,0 +1,253 @@
+;;; Copyright (C) 2011, 2014-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track" "../../common/core"
"../../common/lang")
+ "realgud-")
+(require-relative-list '("../../common/buffer/command")
+ "realgud-buffer-")
+(require-relative-list '("init") "realgud:remake-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function realgud-cmdbuf-command-string
+ 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-debugger-name
+ 'realgud-buffer-command)
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:remake-minibuffer-history nil
+ "minibuffer history list for the command `remake'.")
+
+(easy-mmode-defmap remake-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun remake-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'remake-suggest-invocation
+ remake-minibuffer-local-map
+ 'realgud:remake-minibuffer-history
+ opt-debugger))
+
+(defun remake-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+
+- the command processor (e.g. make)
+- the Makefile name
+- command args (which includes the makefile name)
+
+For example for the following input
+ '(\"remake\" \"-x\" \"/tmp/Makefile\")
+
+we might return:
+ (\"remake\" \"/tmp/Makefile\" (\"-x\" \"/tmp/Makefile\"))
+
+"
+
+ (let (
+ (args orig-args)
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^\\(re\\)?make*\\(.exe\\)?$"
+ "^\\(re\\)?make*$"))
+
+ ;; Things returned
+ (remake-name nil)
+ (makefile-name nil)
+ (remake-args '())
+ )
+
+ (if (not (and args))
+ ;; Got nothing
+ (list remake-name makefile-name remake-args)
+ ;; else
+ ;; Strip off "make" or "remake" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq remake-name (pop args))
+ )
+
+ ;; parse options
+ (while args
+ (let ((arg (pop args)))
+ (cond
+ ;; ;; Annotation or emacs option with level number.
+ ;; ((or (member arg '("--annotate" "-A"))
+ ;; (equal arg "--emacs"))
+ ;; (setq annotate-p t)
+ ;; (nconc debugger-args (list (pop args))))
+ ;; ;; Combined annotation and level option.
+ ;; ((string-match "^--annotate=[0-9]" arg)
+ ;; (nconc debugger-args (list (pop args)) )
+ ;; (setq annotate-p t))
+
+ ((member arg '("--file" "--makefile" "-f"))
+ (setq remake-args (nconc remake-args (list arg)))
+ (setq makefile-name (realgud:expand-file-name-if-exists
+ (pop args)))
+ (setq remake-args (nconc remake-args
+ (list (format "%s" makefile-name)))))
+
+ ;; Anything else add to remake-args
+ ('t (setq remake-args (nconc remake-args (list arg))))
+ )))
+ (list remake-name makefile-name remake-args))))
+
+(defconst realgud:remake-auto-suffix-regexp
+ "\\.\\(am\\|in\\)$"
+ "Common automake and autoconf Makefile suffixes"
+)
+
+(defconst realgud:remake-makefile-regexp
+ "\\(^[Mm]akefile$\\|\\.Makefile$\\|\\.mk\\)$"
+ "Regular expression matching common Makefile names"
+)
+
+(defun remake-suggest-file-priority(filename)
+ (let ((priority 2)
+ (is-not-directory)
+ )
+ (if (realgud-lang-mode? filename "makefile")
+ (progn
+ (if (string-match realgud:remake-makefile-regexp filename)
+ (setq priority 8)
+ (if (string-match realgud:remake-auto-suffix-regexp filename)
+ (setq priority 5)
+ (setq priority 7)))
+ ))
+ ;; The file isn't in a makefile-mode buffer,
+ ;; Check for an executable file with a .mk extension.
+ (if (setq is-not-directory (not (file-directory-p filename)))
+ (if (and (string-match realgud:remake-makefile-regexp filename))
+ (if (< priority 6)
+ (progn
+ (setq priority 6)))))
+ priority
+ )
+)
+
+(defun remake-suggest-Makefile ()
+ "Suggest a Makefile to debug.
+
+The first priority is given to the current buffer. If the major
+mode matches GNUMakefile and doesn't end in .am or .in, then we
+are done. If not, we'll set priority 2 (a low or easily
+overridden priority) and we keep going. Then we will try files
+in the default-directory. Of those that we are visiting we check
+the major mode. There are demerits for a file ending in .in or
+.am which are used by 'configure' and 'automake' respectively.
+
+If the current buffer isn't a success, we see if the file matches
+REGEXP. These have priority 9, 8 or 7 depending on whether there
+is a .in or .am sufifx and there is a REGEXP match'. Within a
+given priority, we use the first one we find."
+ (let* ((file)
+ (file-list (directory-files default-directory))
+ (priority 2)
+ (is-not-directory)
+ (result (buffer-file-name)))
+ (if (not (realgud-lang-mode? result "makefile"))
+ (progn
+ (while (and (setq file (car-safe file-list)) (< priority 8))
+ (setq file-list (cdr file-list))
+ (let ((try-priority (remake-suggest-file-priority file)))
+ (if (> try-priority priority)
+ (progn
+ (setq priority try-priority)
+ (setq result file)))
+ ))
+ ))
+ result)
+ )
+
+;; To silence Warning: reference to free variable
+(defvar realgud:remake-command-name)
+
+;; Note opt-debugger is not used. It has to be there because
+;; realgud-suggest-invocation passes an argument.
+(defun remake-suggest-invocation (&optional opt-debugger)
+ "Suggest a remake command invocation via `realgud-suggest-invocaton'"
+
+ (let* ((buf (current-buffer))
+ (debugger-name realgud:remake-command-name)
+ (cmd-str-cmdbuf (realgud-cmdbuf-command-string buf))
+ )
+ (cond
+ ((and cmd-str-cmdbuf (equal debugger-name (realgud-cmdbuf-debugger-name
buf)))
+ cmd-str-cmdbuf)
+ ((and minibuffer-history (listp minibuffer-history))
+ (car minibuffer-history))
+ (t (concat debugger-name " --debugger -f "
+ (remake-suggest-Makefile)))
+ )))
+
+;; Convert a command line as would be typed normally to run a script
+;; into one that invokes an Emacs-enabled debugging session.
+;; "--debugger" in inserted as the first switch.
+
+(defun realgud:remake-massage-args (command-line)
+ (let* ((new-args (list "--debugger"))
+ (args (split-string-and-unquote command-line))
+ (program (car args))
+ (seen-e nil)
+ (shift (lambda ()
+ (setq new-args (cons (car args) new-args))
+ (setq args (cdr args)))))
+
+ ;; Pass all switches and -e scripts through.
+ (while (and args
+ (string-match "^-" (car args))
+ (not (equal "-" (car args)))
+ (not (equal "--" (car args))))
+ (funcall shift))
+
+ (if (or (not args)
+ (string-match "^-" (car args)))
+ (error "Can't use stdin as the script to debug"))
+ ;; This is the program name.
+ (funcall shift)
+
+ (while args
+ (funcall shift))
+
+ (nreverse new-args)
+ )
+ )
+
+(defun remake-reset ()
+ "Remake cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (remake-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*remake-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun remake-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'remake-debugger-support-minor-mode minor-mode-map-alist)
+;; remake-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:remake-customize ()
+ "Use `customize' to edit the settings of the `remake' debugger."
+ (interactive)
+ (customize-group 'realgud:remake))
+
+(provide-me "realgud:remake-")
diff --git a/packages/realgud/realgud/debugger/remake/init.el
b/packages/realgud/realgud/debugger/remake/init.el
new file mode 100644
index 0000000..d2888c1
--- /dev/null
+++ b/packages/realgud/realgud/debugger/remake/init.el
@@ -0,0 +1,135 @@
+;;; Copyright (C) 2011, 2014 Rocky Bernstein <address@hidden>
+;;; Regular expressions for GNU Make debugger: remake
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:remake-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; Regular expression that describes a remake location generally shown
+;; before a command prompt.
+;; For example:
+;; -- (emacs-dbgr/realgud/debugger/Makefile:168)
+(setf (gethash "loc" realgud:remake-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "\\(?:^\\|\n\\)\\(?:..
\\)?(\\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\
]+\\):\\([0-9]+\\))\\(?:\n\\(.*?\\)\n\\)?"
+ :file-group 1
+ :line-group 2
+ :text-group 3))
+
+;; For example:
+;; remake<10>
+;; remake<<1>>
+(setf (gethash "prompt" realgud:remake-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^remake[<]+\\([0-9]+\\)[>]+ "
+ :num 1
+ ))
+
+;; Regular expression that describes a "breakpoint set" line
+(setf (gethash "brkpt-set" realgud:remake-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) on target \\([^:]*\\): file \\(.+\\),
line \\([0-9]+\\).\n"
+ :num 1
+ :file-group 3
+ :line-group 4))
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Removed 1 breakpoint(s).
+(setf (gethash "brkpt-del" realgud:remake-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) on target .* cleared\n"
+ :num 1))
+
+(defconst realgud:remake-selected-frame-arrow "=>"
+"String that describes which frame is selected in a debugger
+backtrace listing.")
+(defconst realgud:remake-frame-arrow (format "\\(%s\\| \\)"
+ realgud:remake-selected-frame-arrow))
+(defconst realgud:remake-frame-num-regexp
+ "#\\([0-9]+\\) ")
+
+(defconst realgud:remake-frame-file-regexp " at \\(.*\\):\\([0-9]+\\)")
+
+;; Regular expression that describes a remake "backtrace" command line.
+;; For example:
+;; #0 Makefile.in at /tmp/Makefile:216
+;; #1 Makefile at /tmp/Makefile:230
+(setf (gethash "lang-backtrace" realgud:remake-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat "^"
+ realgud:remake-frame-num-regexp
+ "\\(.*\\)"
+ realgud:remake-frame-file-regexp
+ )
+ :num 1
+ :file-group 3
+ :line-group 4)
+ )
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; =>#0 Makefile.in at /tmp/Makefile:216
+;; #1 Makefile at /tmp/Makefile:230
+(setf (gethash "debugger-backtrace" realgud:remake-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat "^"
+ realgud:remake-frame-arrow
+ realgud:remake-frame-num-regexp
+ "\\(.*\\)"
+ realgud:remake-frame-file-regexp
+ )
+ :num 2
+ :file-group 4
+ :line-group 5)
+ )
+
+;; Regular expression that describes which frame is selected in
+;; a debugger backtrace listing.
+(setf (gethash "selected-frame-indicator" realgud:remake-pat-hash)
+ realgud:remake-selected-frame-arrow)
+
+;; Regular expression for a termination message.
+(setf (gethash "termination" realgud:remake-pat-hash)
+ "^remake: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:remake-pat-hash)
+ '(
+ ;; ;; File name and line number
+ ;; ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
+ ;; ;; ----^^^^^^^^^^^^^^^^^
+ (" at \\(.*\\):\\([0-9]+\\)"
+ (1 realgud-file-name-face)
+ (2 realgud-line-number-face))
+
+ ;; The frame number and first type name, if present.
+ ;; E.g. =>#0 Makefile.in at /tmp/Makefile:216
+ ;; ---^
+ ("#\\([0-9]+\\) "
+ (1 realgud-backtrace-number-face))
+ ))
+
+(setf (gethash "remake" realgud-pat-hash) realgud:remake-pat-hash)
+
+(defvar realgud:remake-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the remake command to use, like 'q'")
+
+(setf (gethash "break" realgud:remake-command-hash) "break %l")
+(setf (gethash "eval" realgud:remake-command-hash) "expand %s")
+(setf (gethash "remake" realgud-command-hash) realgud:remake-command-hash)
+
+
+(provide-me "realgud:remake-")
diff --git a/packages/realgud/realgud/debugger/remake/remake.el
b/packages/realgud/realgud/debugger/remake/remake.el
new file mode 100644
index 0000000..fad66bc
--- /dev/null
+++ b/packages/realgud/realgud/debugger/remake/remake.el
@@ -0,0 +1,89 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; `remake' Main interface to remake via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/track") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:remake-")
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:remake nil
+ "The realgud interface to the GNU Make debugger"
+ :group 'realgud
+ :group 'make
+ :version "24.1")
+
+(eval-when-compile (require 'cl-lib))
+
+(declare-function remake-query-cmdline 'realgud:remake-core)
+(declare-function remake-parse-cmd-args 'realgud:remake-core)
+(declare-function realgud:run-debugger 'realgud:run)
+(declare-function realgud:run-process 'realgud:run)
+
+(defun realgud:remake-run-debugger (&optional opt-command-line
+ no-reset)
+ "Invoke the a debugger and start the Emacs user interface.
+
+String OPT-COMMAND-LINE specifies how to run DEBUGGER-NAME. You
+will be prompted for a command line using QUERY-CMDLINE-FN is one
+isn't supplied.
+
+OPT-COMMAND-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by PARSE-CMD-FN and path elements found by that
+are expanded using `expand-file-name'.
+
+If successful, The command buffer of the debugger process is returned.
+Otherwise nil is returned.
+"
+ (let* ((cmd-str (or opt-command-line (remake-query-cmdline "remake")))
+ (cmd-args (split-string-and-unquote cmd-str))
+ (parsed-args (remake-parse-cmd-args cmd-args))
+ (debugger (car parsed-args))
+ (script-args (caddr parsed-args))
+ (script-name (cadr parsed-args))
+ )
+ (realgud:run-process debugger script-name cmd-args
+ realgud:remake-minibuffer-history no-reset)
+ )
+ )
+
+;; -------------------------------------------------------------------
+;; User definable variables
+;;
+
+(defcustom realgud:remake-command-name
+ ;;"remake --emacs 3"
+ "remake"
+ "File name for executing the GNU make debugger, remake, and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:remake)
+
+;;;###autoload
+(defun realgud:remake (&optional opt-cmd-line no-reset)
+ "See `realgud:remake' for details"
+ (interactive)
+ (realgud:remake-run-debugger opt-cmd-line no-reset)
+ )
+
+(defalias 'remake 'realgud:remake)
+
+(provide-me "realgud-")
+;;; remake.el ends here
diff --git a/packages/realgud/realgud/debugger/remake/track-mode.el
b/packages/realgud/realgud/debugger/remake/track-mode.el
new file mode 100644
index 0000000..b2b6b97
--- /dev/null
+++ b/packages/realgud/realgud/debugger/remake/track-mode.el
@@ -0,0 +1,63 @@
+;;; Copyright (C) 2012, 2014-2015 Rocky Bernstein <address@hidden>
+;;; GNU Make Debugger tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:remake-")
+
+(declare-function realgud:cmd-remap 'realgud-cmds)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+
+(realgud-track-mode-vars "remake")
+
+(define-key remake-track-mode-map
+ (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+(define-key remake-track-mode-map
+ (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+
+(defun remake-track-mode-hook()
+ (if remake-track-mode
+ (progn
+ (use-local-map remake-track-mode-map)
+ (message "using remake mode map")
+ )
+ (message "remake track-mode-hook disable called"))
+)
+
+(define-minor-mode remake-track-mode
+ "Minor mode for tracking remake source locations inside a process shell via
realgud. remake is a GNU Make debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{remake-track-mode-map}
+"
+ "Minor mode for tracking ruby debugging inside a process shell."
+ :init-value nil
+ ;; :lighter " remake" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:remake
+ :keymap remake-track-mode-map
+
+ (realgud:track-set-debugger "remake")
+ (if remake-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (remake-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(define-key remake-short-key-mode-map "T" 'realgud:cmd-backtrace)
+
+(provide-me "realgud:remake-")
diff --git a/packages/realgud/realgud/debugger/trepan.pl/Makefile.am
b/packages/realgud/realgud/debugger/trepan.pl/Makefile.am
new file mode 100644
index 0000000..9a343a5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan.pl/Makefile.am
@@ -0,0 +1 @@
+include $(srcdir)/../common.mk
diff --git a/packages/realgud/realgud/debugger/trepan.pl/backtrack-mode.el
b/packages/realgud/realgud/debugger/trepan.pl/backtrack-mode.el
new file mode 100644
index 0000000..97dfff4
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan.pl/backtrack-mode.el
@@ -0,0 +1,67 @@
+;;; Copyright (C) 2011, 2014 Rocky Bernstein <address@hidden>
+
+;;; Mode for parsing various kinds of backtraces found in Perl
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track-mode"
+ "../../common/backtrack-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepanpl-")
+(require-relative-list '("../../lang/perl") "realgud-lang-")
+
+(declare-function realgud-goto-line-for-pt
+ 'realgud-track-mode)
+(declare-function realgud-backtrack-set-debugger
+ 'realgud-common-backtrack-mode)
+(declare-function realgud-perl-populate-command-keys
+ 'realgud-lang-perl)
+
+(realgud-backtrack-mode-vars "trepanpl")
+(set-keymap-parent trepanpl-backtrack-mode-map realgud-backtrack-mode-map)
+
+(declare-function realgud-backtrack-mode(bool))
+
+(defun realgud:trepanpl-goto-control-frame-line (pt)
+ "Display the location mentioned by a control-frame line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "control-frame"))
+
+(realgud-perl-populate-command-keys trepanpl-backtrack-mode-map)
+(define-key trepanpl-backtrack-mode-map
+ (kbd "C-c !c") 'realgud:trepanpl-goto-control-frame-line)
+
+(define-minor-mode trepanpl-backtrack-mode
+ "Minor mode for tracking ruby debugging inside a file which may not have
process shell."
+ :init-value nil
+ ;; :lighter " trepanpl" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepanpl
+ :keymap trepanpl-backtrack-mode-map
+
+ (realgud-backtrack-set-debugger "trepan.pl")
+ (if trepanpl-backtrack-mode
+ (progn
+ (realgud-backtrack-mode 't)
+ (run-mode-hooks (intern (trepanpl-backtrack-mode-hook))))
+ (progn
+ (realgud-backtrack-mode nil)
+ ))
+)
+
+(defun trepanpl-backtrack-mode-hook()
+ (if trepanpl-backtrack-mode
+ (progn
+ (use-local-map trepanpl-backtrack-mode-map)
+ (message "using trepanpl mode map")
+ )
+ (message "trepan.pl backtrack-mode-hook disable called"))
+)
+
+(provide-me "realgud:trepanpl-")
diff --git a/packages/realgud/realgud/debugger/trepan.pl/core.el
b/packages/realgud/realgud/debugger/trepan.pl/core.el
new file mode 100644
index 0000000..a5c90e7
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan.pl/core.el
@@ -0,0 +1,176 @@
+;;; Copyright (C) 2011-2012, 2014 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/eval"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:trepanpl-")
+
+(declare-function realgud:eval-strip-default 'realgud-eval)
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:trepanpl-minibuffer-history nil
+ "minibuffer history list for the command `realgud:trepan.pl'.")
+
+(easy-mmode-defmap realgud:trepanpl-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of trepanpl startup command."
+ :inherit minibuffer-local-map)
+
+(defun realgud:trepanpl-eval-filter-callback(output-str)
+ (realgud:eval-strip-default realgud:trepanpl-prompt-regexp
+ (if (string-match realgud:trepanpl-eval-result-prefix-regexp output-str)
+ (substring output-str (match-end 0))
+ output-str)))
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun realgud:trepanpl-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'realgud:trepanpl-suggest-invocation
+ realgud:trepanpl-minibuffer-local-map
+ 'realgud:trepanpl-minibuffer-history
+ opt-debugger))
+
+;;; FIXME: DRY this with other *-parse-cmd-args routines
+(defun realgud:trepanpl-parse-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS for the annotate level and name of script to
debug.
+
+ORIG_ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing:
+* the command processor (e.g. perl) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. trepan.pl) and its arguments - a list
of strings
+* the script name and its arguments - list of strings
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(perl5.10 -w -I . trepan.pl --cd . ./gcd.pl a b))
+
+we might return:
+ ((\"perl\" \"-w\" \"-I\" \"/tmp\") (\"trepan.pl\" \"cd\" \"/tmp\")
(\"/tmp/gcd.pl\" \"a\" \"b\"))
+
+Note that the script name path has been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [perl perl-options] trepanpl trepanpl-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (perl-opt-two-args '("0" "C" "D" "i" "I" "l" "m" "-module" "x"))
+ ;; Perl doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (perl-two-args '())
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (trepanpl-two-args '("h" "-host" "p" "-port"
+ "I" "-include"))
+ (trepanpl-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^perl\\(?:5[0-9.]*\\)\\(.exe\\)?$"
+ "^perl\\(?:5[0-9.]*\\)?$"))
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "perl" or "perl5.10.1" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off optional "perl" or "perl5.10.1" etc.
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args perl-two-args perl-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "trepan.pl" from "trepan.pl --trepan.pl-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-nondirectory (car args)))
+ (unless (string-match "^trepan.pl$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `trepan.pl'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ((member arg
+ '("--cmddir" "--batch" "--cd" "--include" "-I" "--module"
"-M"
+ "-c" "--command"))
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (expand-file-name (pop args)))))
+ ;; Other options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args trepanpl-two-args trepanpl-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args))
+ ))
+
+; # To silence Warning: reference to free variable
+(defvar realgud:trepanpl-command-name)
+
+(defun realgud:trepanpl-suggest-invocation (debugger-name)
+ "Suggest a trepanpl command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:trepanpl-command-name
+ realgud:trepanpl-minibuffer-history
+ "perl" "\\.pl$" "trepan.pl"))
+
+(defun realgud:trepanpl-reset ()
+ "Trepanpl cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (trepanpl-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*trepanpl-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun trepanpl-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'trepanpl-debugger-support-minor-mode minor-mode-map-alist)
+;; trepanpl-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:trepanpl-customize ()
+ "Use `customize' to edit the settings of the
+`realgud:trepan.pl' debugger."
+ (interactive)
+ (customize-group 'realgud:trepanpl))
+
+(provide-me "realgud:trepanpl-")
diff --git a/packages/realgud/realgud/debugger/trepan.pl/init.el
b/packages/realgud/realgud/debugger/trepan.pl/init.el
new file mode 100644
index 0000000..8092120
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan.pl/init.el
@@ -0,0 +1,259 @@
+;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; Trepanning Perl debugger
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/perl") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:trepanpl-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; Regular expression that describes a trepan.pl location generally shown
+;; before a command prompt. We include matching the source text so we
+;; can save that.
+;;
+;; Program-location lines look like this:
+;; -- File::Basename::(/usr/share/perl/5.14/File/Basename.pm:284 @0x8918b70)
+;; my $dirname = dirname(__FILE__);
+;;
+;; or for an eval'd expression:
+;; -- main::((eval 1189)[/tmp/test.pl:2] remapped /tmp/JLlH.pl:1 @0xadcbda0)
+;; $x = 1 + 2;
+;;
+;; or at a function call without the Perl OpCode position or source text:
+;; -> main::(example/gcd.pl:8)
+
+(setf (gethash "loc" realgud:trepanpl-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format ".. \\(?:.+::\\)?(\\(?:.+ \\(?:via\\|remapped\\)
\\)?\\(.+\\):%s\\(?: @0x[0-9a-f]+\\)?)\\(?:\n\\(.*?\\)\n\\)?"
+ realgud:regexp-captured-num)
+ :file-group 1
+ :line-group 2
+ :text-group 3
+ :ignore-file-re realgud-perl-ignore-file-re)
+ )
+
+(defconst realgud:trepanpl-frame-start-regexp
+ "\\(^\\|\n\\)\\(?:-->\\| \\) #")
+
+;; Regular expression that describes a trepanpl command prompt
+;; For example:
+;; (trepanpl):
+;; ((trepanpl)):
+;; (address@hidden):
+;; (address@hidden):
+(defconst realgud:trepanpl-prompt-regexp
+ "^(+trepanpl\\(@[0-9]+\\|@main\\)?)+: ")
+
+(setf (gethash "prompt" realgud:trepanpl-pat-hash)
+ (make-realgud-loc-pat
+ :regexp realgud:trepanpl-prompt-regexp
+ ))
+
+(defconst realgud:trepanpl-eval-result-prefix-regexp
+ "^\\$DB::D\\[[0-9]+\\] = ")
+
+(setf (gethash "prompt" realgud:trepanpl-pat-hash)
+ (make-realgud-loc-pat
+ :regexp realgud:trepanpl-prompt-regexp
+ ))
+
+
+(defconst realgud:trepanpl-frame-num-regexp
+ realgud:regexp-captured-num)
+
+;; Regular expression that describes a Perl backtrace line.
+;; For example:
+;; --> #0 @ = File::Basename::fileparse('/usr/local/bin/trepan.pl') in
+;; file `/usr/share/perl/5.18.2/File/Basename.pm' at line 107
+;; #1 @ = File::Basename::dirname('/usr/local/bin/trepan.pl') in
+;; file `/usr/share/perl/5.18.2/File/Basename.pm' at line 294
+;; #2 file `/usr/local/bin/trepan.pl' at line 11
+(setf (gethash "debugger-backtrace" realgud:trepanpl-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat
+ realgud:trepanpl-frame-start-regexp
+ realgud:trepanpl-frame-num-regexp
+ "\\(?: address@hidden = .* in\\)?"
+ "[\n\t ]+?file `"
+ "\\(.*\\)' at line "
+ realgud:regexp-captured-num)
+ :num 2
+ :file-group 3
+ :line-group 4
+ :ignore-file-re realgud-perl-ignore-file-re)
+ )
+
+;; Regular expression that describes location in a Perl errmsg
+(setf (gethash "perl-errmsg" realgud:trepanpl-pat-hash)
+ realgud-perl-errmsg-loc-pat)
+
+;; Regular expression that describes a Perl Carp backtrace line.
+;; at /tmp/foo.pl line 7
+;; main::__ANON__('Illegal division by zero at /tmp/foo.pl line 4.\x{a}')
called at /tmp/foo.pl line 4
+;; main::foo(3) called at /tmp/foo.pl line 8
+(setf (gethash "lang-backtrace" realgud:trepanpl-pat-hash)
+ realgud-perl-carp-loc-pat)
+
+;; Regular expression that describes a "breakpoint set" line.
+;; For example:
+;; Breakpoint 1 set in (eval 1177)[/Eval.pm:94] at line 5"
+;; Breakpoint 2 set in /tmp/File/Basename.pm at line 215
+(setf (gethash "brkpt-set" realgud:trepanpl-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Breakpoint %s set in[\n\t ]+\\(.+\\)[ \t\n]+at line
\\([0-9]+\\)"
+ realgud:regexp-captured-num)
+ :num 1
+ :file-group 2
+ :line-group 3
+ :ignore-file-re realgud-perl-ignore-file-re)
+ )
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Deleted breakpoint 1.
+(setf (gethash "brkpt-del" realgud:trepanpl-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Deleted breakpoint %s\n"
+ realgud:regexp-captured-num)
+ :num 1))
+
+(defconst realgud:trepanpl-selected-frame-indicator "-->"
+"String that describes which frame is selected in a debugger
+backtrace listing.")
+
+(defconst realgud:trepanpl-frame-file-regexp
+ "[ \t\n]+in file \\([^ \n]+\\)")
+
+(defconst realgud:trepanpl-debugger-name "trepan.pl" "Name of debugger")
+
+;; Top frame number
+(setf (gethash "top-frame-num" realgud:trepanpl-pat-hash) 0)
+
+;; Regular expression that describes a debugger "selected" frame in in
+;; a frame-motion command.
+;; For example:
+;; --> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/ipl at
line 9
+(setf (gethash "selected-frame" realgud:trepanpl-pat-hash)
+ (make-realgud-loc-pat
+ :regexp
+ (format "^%s #\\([0-9]+\\) .*%s"
+ realgud:trepanpl-selected-frame-indicator
+ realgud:trepanpl-frame-file-regexp)
+ :num 1))
+
+;; Regular expression that for a termination message.
+(setf (gethash "termination" realgud:trepanpl-pat-hash)
+ "^trepan.pl: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:trepanpl-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ("^\\(-->\\| \\)? #\\([0-9]+\\) \\([A-Z]+\\)
*\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?"
+ (2 realgud-backtrace-number-face)
+ (3 font-lock-keyword-face) ; e.g. METHOD, TOP
+ (4 font-lock-constant-face) ; e.g. Object
+ (5 font-lock-function-name-face nil t)) ; t means optional
+ ;; Instruction sequence
+ ("<\\(.+\\)>"
+ (1 font-lock-variable-name-face))
+ ;; "::Type", which occurs in class name of function and in parameter
list.
+ ;; Parameter sequence
+ ("(\\(.+\\))"
+ (1 font-lock-variable-name-face))
+ ;; "::Type", which occurs in class name of function and in parameter
list.
+ ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face))
+ ;; File name.
+ ("[ \t]+in file \\([^ ]+*\\)"
+ (1 realgud-file-name-face))
+ ;; Line number.
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+ ;; Function name.
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))
+ ;; (trepanpl-frames-match-current-line
+ ;; (0 trepanpl-frames-current-frame-face append))
+ ))
+
+;; (setf (gethash "font-lock-keywords" realgud:trepanpl-pat-hash)
+;; '(
+;; ;; The frame number and first type name, if present.
+;; ((concat realgud:trepanpl-frame-start-regexp " "
+;; realgud:trepanpl-frame-num-regexp " "
+;; "\\([A-Z]+\\)
*\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?")
+;; (2 realgud-backtrace-number-face)
+;; (3 font-lock-keyword-face) ; e.g. METHOD, TOP
+;; (4 font-lock-constant-face) ; e.g. Object
+;; (5 font-lock-function-name-face nil t)) ; t means optional
+;; ;; Instruction sequence
+;; ("<\\(.+\\)>"
+;; (1 font-lock-variable-name-face))
+;; ;; "::Type", which occurs in class name of function and in
+;; ;; parameter list. Parameter sequence
+;; ("(\\(.+\\))"
+;; (1 font-lock-variable-name-face))
+;; ;; "::Type", which occurs in class name of function and in
+;; ;; parameter list.
+;; ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+;; (1 font-lock-type-face))
+;; ;; File name.
+;; (realgud:trepanpl-frame-file-regexp (1 realgud-file-name-face))
+;; ;; Line number.
+;; (realgud:trepanpl-frame-line-regexp (1 realgud-line-number-face))
+;; ;; Function name.
+;; ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+;; (1 font-lock-type-face)
+;; (2 font-lock-function-name-face))
+;; ;; (trepanpl-frames-match-current-line
+;; ;; (0 trepanpl-frames-current-frame-face append))
+;; ))
+
+(setf (gethash "callback-eval-filter" realgud:trepanpl-pat-hash)
+ 'realgud:trepanpl-eval-filter-callback)
+
+(setf (gethash realgud:trepanpl-debugger-name realgud-pat-hash)
realgud:trepanpl-pat-hash)
+
+;; Prefix used in variable names (e.g. short-key-mode-map) for
+;; this debugger
+
+(setf (gethash "trepan.pl" realgud:variable-basename-hash) "realgud:trepanpl")
+
+(defvar realgud:trepanpl-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the trepanpl command to use, like 'quit!'")
+
+(setf (gethash "break" realgud:trepanpl-command-hash) "break %x %l")
+(setf (gethash "quit" realgud:trepanpl-command-hash) "quit!")
+(setf (gethash "until" realgud:trepanpl-command-hash) "continue %l")
+(setf (gethash realgud:trepanpl-debugger-name
+ realgud-command-hash) realgud:trepanpl-command-hash)
+
+(provide-me "realgud:trepanpl-")
diff --git a/packages/realgud/realgud/debugger/trepan.pl/track-mode.el
b/packages/realgud/realgud/debugger/trepan.pl/track-mode.el
new file mode 100644
index 0000000..3fe2f09
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan.pl/track-mode.el
@@ -0,0 +1,74 @@
+;;; Copyright (C) 2011-2014 Rocky Bernstein <address@hidden>
+;;; Perl trepanning Debugger tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepanpl-")
+(require-relative-list '("../../lang/perl") "realgud-lang-")
+
+(realgud-track-mode-vars "realgud:trepanpl")
+
+(declare-function realgud-goto-line-for-pt 'realgud-track-mode)
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-mode-hook 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-perl-populate-command-keys 'realgud-lang-perl)
+
+
+(defun realgud:trepanpl-goto-syntax-error-line (pt)
+ "Display the location mentioned in a Syntax error line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "syntax-error"))
+
+(define-key realgud:trepanpl-track-mode-map
+ (kbd "C-c !s") 'realgud:trepanpl-goto-syntax-error-line)
+
+(realgud-perl-populate-command-keys realgud:trepanpl-track-mode-map)
+
+(defun realgud:trepanpl-track-mode-hook()
+ (if realgud:trepanpl-track-mode
+ (progn
+ (use-local-map realgud:trepanpl-track-mode-map)
+ (message "using trepanpl mode map")
+ )
+ (message "trepan.pl track-mode-hook disable called"))
+)
+
+(define-minor-mode realgud:trepanpl-track-mode
+ "Minor mode for tracking trepan.pl source locations inside a
+process shell via realgud. trepan.pl is a Perl debugger see URL
+`https://metacpan.org/pod/Devel::Trepan'.
+
+If called interactively with no prefix argument, the mode is
+toggled. A prefix argument, captured as ARG, enables the mode if
+the argument is positive, and disables it otherwise.
+"
+ :init-value nil
+ ;; :lighter " trepanpl" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepanpl
+ :keymap realgud:trepanpl-track-mode-map
+
+ (realgud:track-set-debugger "trepan.pl")
+ (if realgud:trepanpl-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (realgud:trepanpl-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(define-key realgud:trepanpl-short-key-mode-map "T" 'realgud:cmd-backtrace)
+
+(provide-me "realgud:trepanpl-")
diff --git a/packages/realgud/realgud/debugger/trepan.pl/trepanpl.el
b/packages/realgud/realgud/debugger/trepan.pl/trepanpl.el
new file mode 100644
index 0000000..de8cb20
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan.pl/trepanpl.el
@@ -0,0 +1,65 @@
+;;; Copyright (C) 2011, 2014 Rocky Bernstein <address@hidden>
+;; `trepanpl' Main interface to trepanpl via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/track") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:trepanpl-")
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:trepanpl nil
+ "The realgud interface to the Perl \"trepanning\" debugger"
+ :group 'perl
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User definable variables
+;;
+
+(defcustom realgud:trepanpl-command-name
+ "trepan.pl"
+ "File name for executing the Perl debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:trepanpl)
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function realgud:trepanpl-track-mode 'realgud-trepanpl-track)
+(declare-function realgud:trepanpl-query-cmdline 'realgud-trepanpl-core)
+(declare-function realgud:trepanpl-parse-cmd-args 'realgud-trepanpl-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;;;###autoload
+(defun realgud:trepan.pl (&optional opt-cmd-line no-reset)
+ "Invoke the trepan.pl Perl debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run trepan.pl. You will be prompted
+for a command line is one isn't supplied.
+
+OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `realgud:trepanpl-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "trepan.pl" 'realgud:trepanpl-query-cmdline
+ 'realgud:trepanpl-parse-cmd-args
+ 'realgud:trepanpl-minibuffer-history
+ opt-cmd-line no-reset))
+
+(defalias 'trepan.pl 'realgud:trepan.pl)
+(provide-me "realgud-")
+;;; trepanpl.el ends here
diff --git a/packages/realgud/realgud/debugger/trepan/Makefile.am
b/packages/realgud/realgud/debugger/trepan/Makefile.am
new file mode 100644
index 0000000..9a343a5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan/Makefile.am
@@ -0,0 +1 @@
+include $(srcdir)/../common.mk
diff --git a/packages/realgud/realgud/debugger/trepan/backtrack-mode.el
b/packages/realgud/realgud/debugger/trepan/backtrack-mode.el
new file mode 100644
index 0000000..c655779
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan/backtrack-mode.el
@@ -0,0 +1,81 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Mode for parsing various kinds of backtraces found in Ruby
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track-mode"
+ "../../common/backtrack-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepan-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(realgud-backtrack-mode-vars "trepan")
+(set-keymap-parent trepan-backtrack-mode-map realgud-backtrack-mode-map)
+
+(declare-function realgud-backtrack-mode
'realgud-common-backtrack-mode)
+(declare-function realgud-backtrack-set-debugger
'realgud-common-backtrack-mode)
+(declare-function realgud-goto-line-for-pt
'realgud-common-backtrack-mode)
+(declare-function realgud:ruby-populate-command-keys 'realgud-lang-ruby)
+
+(defun realgud:trepan-goto-control-frame-line (pt)
+ "Display the location mentioned by a control-frame line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "control-frame"))
+
+(realgud:ruby-populate-command-keys trepan-backtrack-mode-map)
+(define-key trepan-backtrack-mode-map
+ (kbd "C-c !c") 'realgud:trepan-goto-control-frame-line)
+
+(define-minor-mode trepan-backtrack-mode
+ "Minor mode for tracking ruby debugging inside a file which may not have
process shell.
+
+\\{trepan-backtrack-mode-map}
+"
+ :init-value nil
+ ;; :lighter " trepan" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepan
+ :keymap trepan-backtrack-mode-map
+
+ (realgud-backtrack-set-debugger "trepan")
+ (if trepan-backtrack-mode
+ (progn
+ (realgud-backtrack-mode 't)
+ (run-mode-hooks (intern (trepan-backtrack-mode-hook))))
+ (progn
+ (realgud-backtrack-mode nil)
+ ))
+)
+
+(defun trepan-backtrack-mode-hook()
+ (if trepan-backtrack-mode
+ (progn
+ (use-local-map trepan-backtrack-mode-map)
+ (message "using trepan mode map")
+ )
+ (message "trepan backtrack-mode-hook disable called"))
+)
+
+(provide-me "realgud:trepan-")
diff --git a/packages/realgud/realgud/debugger/trepan/core.el
b/packages/realgud/realgud/debugger/trepan/core.el
new file mode 100644
index 0000000..269af1e
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan/core.el
@@ -0,0 +1,236 @@
+;;; Copyright (C) 2010, 2012, 2014-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'compile) ;; for compilation-find-file
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:trepan-")
+
+(declare-function realgud:strip 'realgud)
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+(declare-function realgud:file-loc-from-line 'realgud-file)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:trepan-minibuffer-history nil
+ "minibuffer history list for the command `realgud:trepan'.")
+
+(easy-mmode-defmap trepan-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+(defvar realgud:trepan-file-remap (make-hash-table :test 'equal)
+ "How to remap Python files in trepan when we otherwise can't
+ find in the filesystem. The hash key is the file string we saw,
+ and the value is associated filesystem string presumably in the
+ filesystem")
+
+;; FIXME: this code could be generalized and put in a common place.
+(defun realgud:trepan-find-file(filename)
+ "A find-file specific for trepan. We strip off trailing
+blanks. Failing that we will prompt for a mapping and save that
+in variable `realgud:trepan-file-remap' when that works. In the
+future, we may also consult RUBYPATH."
+ (let* ((transformed-file)
+ (stripped-filename (realgud:strip filename))
+ ;; (ignore-file-re)
+ )
+ (cond
+ ((file-exists-p filename) filename)
+ ((file-exists-p stripped-filename) stripped-filename)
+ ;; ((string-match ((ignore-file-re filename)
+ ;; (message "tracking ignored for psuedo-file: %s" filename) nil)
+ ('t
+ ;; FIXME search RUBYLIB if not absolute file?
+ (if (gethash filename realgud-file-remap)
+ (let ((remapped-filename))
+ (setq remapped-filename (gethash filename
realgud:trepan-file-remap))
+ (if (file-exists-p remapped-filename)
+ remapped-filename
+ ;; else
+ (and (remhash filename realgud-file-remap)) nil)
+ ;; else
+ (let ((remapped-filename))
+ (setq remapped-filename
+ (buffer-file-name
+ (compilation-find-file (point-marker) stripped-filename
+ nil "%s.rb")))
+ (when (and remapped-filename (file-exists-p remapped-filename))
+ (puthash filename remapped-filename realgud-file-remap)
+ remapped-filename
+ ))
+ ))
+ ))
+ ))
+
+(defun realgud:trepan-loc-fn-callback(text filename lineno source-str
+ ignore-file-re cmd-mark)
+ (realgud:file-loc-from-line filename lineno
+ cmd-mark source-str nil nil
+ 'realgud:trepan-find-file))
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun realgud:trepan-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'trepan-suggest-invocation
+ trepan-minibuffer-local-map
+ 'realgud:trepan-minibuffer-history
+ opt-debugger))
+
+(defun realgud:trepan-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+
+* the command processor (e.g. ruby) and it's arguments if any - a
+ list of strings
+
+* the name of the debugger given (e.g. trepan) and its arguments
+ - a list of strings
+
+* the script name and its arguments - list of strings
+
+* whether the annotate or emacs option was given ('-A',
+ '--annotate' or '--emacs) - a boolean
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(ruby1.9 -W -C /tmp trepan --emacs ./gcd.rb a b))
+
+we might return:
+ ((ruby1.9 -W -C) (trepan --emacs) (./gcd.rb a b) 't)
+
+Note that the script name path has been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [ruby ruby-options] trepan trepan-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (ruby-opt-two-args '("0" "C" "e" "E" "F" "i"))
+ ;; Ruby doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (ruby-two-args '())
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (trepan-two-args '("h" "-host" "p" "-port"
+ "I" "-include" "-r" "-require"))
+ (trepan-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^ruby[-0-9]*\\(.exe\\)?$"
+ "^ruby[-0-9]*$"))
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "ruby" or "ruby182" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off Ruby-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args ruby-two-args ruby-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "trepan" from "trepan --trepan-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^trepan$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `trepan'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args)) )
+ (setq annotate-p t))
+ ;; path-argument options
+ ((member arg '("--include" "-I" "--require" "-I"))
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args trepan-two-args trepan-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:trepan-command-name)
+
+(defun trepan-suggest-invocation (debugger-name)
+ "Suggest a trepan command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:trepan-command-name
+ realgud:trepan-minibuffer-history
+ "ruby" "\\.rb$" "trepan"))
+
+(defun trepan-reset ()
+ "Trepan cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (trepan-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*trepan-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun trepan-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'trepan-debugger-support-minor-mode minor-mode-map-alist)
+;; trepan-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:trepan-customize ()
+ "Use `customize' to edit the settings of the `trepan' debugger."
+ (interactive)
+ (customize-group 'realgud:trepan))
+
+(provide-me "realgud:trepan-")
diff --git a/packages/realgud/realgud/debugger/trepan/init.el
b/packages/realgud/realgud/debugger/trepan/init.el
new file mode 100644
index 0000000..f2148fa
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan/init.el
@@ -0,0 +1,213 @@
+;;; Copyright (C) 2010, 2014-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:trepan-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(setf (gethash "loc-callback-fn" realgud:trepan-pat-hash)
'realgud:trepan-loc-fn-callback)
+
+;; Regular expression that describes a trepan location generally shown
+;; before a command prompt.
+;; For example:
+;; -- (/tmp/linecache.rb:64)
+;; C> (/tmp/eval.rb:2)
+(setf (gethash "loc" realgud:trepan-pat-hash)
+ (make-realgud-loc-pat
+ :regexp ".. (\\(?:.+ \\(?:via\\|remapped\\)
\\)?\\(.+\\):\\([0-9]+\\)\\(?: @[0-9]+\\)?)\\(?:\n\\(.*?\\)\n\\)?"
+ :file-group 1
+ :line-group 2
+ :text-group 3
+ :ignore-file-re "(eval: .*)"
+ ))
+
+;; Regular expression that describes a trepan command prompt
+;; For example:
+;; (trepan):
+;; ((trepan)):
+;; (address@hidden):
+;; (address@hidden):
+(setf (gethash "prompt" realgud:trepan-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^(+trepan\\(@[0-9]+\\|@main\\)?)+: "
+ ))
+
+;; Regular expression that describes a Ruby YARV 1.9 syntax error line.
+(setf (gethash "syntax-error" realgud:trepan-pat-hash)
+ realgud-ruby-YARV-syntax-error-pat)
+
+;; Regular expression that describes a Ruby YARV backtrace line.
+;; For example:
+;; from /ruby/gems/2.2.0/gems/fog-1.32.0/lib/fog/digitalocean.rb:1:in
`<top (required)>'
+;; from /Users/fog-1.32.0/lib/fog.rb:28:in `require'
+(setf (gethash "lang-backtrace" realgud:trepan-pat-hash)
+ realgud-ruby-backtrace-loc-pat)
+
+;; Regular expression that describes a ruby $! backtrace
+(setf (gethash "dollar-bang-backtrace" realgud:trepan-pat-hash)
+ realgud-ruby-dollar-bang-loc-pat)
+
+;; Regular expression that describes a "breakpoint set" line.
+;; For example:
+;; Breakpoint 1 set at VM offset 2 of instruction sequence "require",
+;; line 29 in file <internal:lib/rubygems/custom_require>.
+;; Breakpoint 2 set at VM offset 29 of instruction sequence "<top /xx.rb>",
+;; line 64 in file /src/external-vcs/linecache/trunk/lib/linecache.rb.
+(setf (gethash "brkpt-set" realgud:trepan-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) set at .*[\n\t ]+line \\([0-9]+\\)[
\t\n]+in file \\(.+\\)."
+ :num 1
+ :file-group 3
+ :line-group 2))
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Deleted breakpoint 1.
+(setf (gethash "brkpt-del" realgud:trepan-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^Deleted breakpoint \\([0-9]+\\).\n"
+ :num 1))
+
+(defconst realgud:trepan-selected-frame-indicator "-->"
+"String that describes which frame is selected in a debugger
+backtrace listing.")
+
+(defconst realgud:trepan-frame-file-regexp
+ "[ \t\n]+in file \\([^ \n]+\\)")
+
+(defconst realgud:trepan-debugger-name "trepan" "Name of debugger")
+
+;; Top frame number
+(setf (gethash "top-frame-num" realgud:trepan-pat-hash) 0)
+
+;; Regular expression that describes a debugger "selected" frame in in
+;; a frame-motion command.
+;; For example:
+;; --> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/irb at
line 9
+(setf (gethash "selected-frame" realgud:trepan-pat-hash)
+ (make-realgud-loc-pat
+ :regexp
+ (format "^%s #\\([0-9]+\\) .*%s"
+ realgud:trepan-selected-frame-indicator
+ realgud:trepan-frame-file-regexp)
+ :num 1))
+
+(setf (gethash "control-frame" realgud:trepan-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^c:\\([0-9]+\\) p:\\([0-9]+\\) s:\\([0-9]+\\) b:\\([0-9]+\\)
l:\\([0-9a-f]+\\) d:\\([0-9a-f]+\\) \\([A-Z]+\\) \\(.+\\):\\([0-9]+\\)"
+ :file-group 8
+ :line-group 9))
+
+;; Regular expression that describes a Ruby $! string
+(setf (gethash "dollar-bang" realgud:trepan-pat-hash)
+ realgud-ruby-dollar-bang-loc-pat)
+
+;; Regular expression that describes debugger "backtrace" command line.
+;; e.g.
+;; --> #0 METHOD Object#require(path) in file <internal:lib/require> at line 28
+;; #1 TOP Object#<top /tmp/linecache.rb> in file /tmp/linecache.rb
+(setf (gethash "debugger-backtrace" realgud:trepan-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat realgud:trepan-frame-start-regexp " "
+ realgud:trepan-frame-num-regexp " "
+ "\\([A-Z]+\\) *\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\(.*\\)"
+ realgud:trepan-frame-file-regexp
+ "\\(?:" realgud:trepan-frame-line-regexp "\\)?"
+ )
+ :num 2
+ :file-group 6
+ :line-group 7)
+ )
+
+;; Regular expression that for a termination message.
+(setf (gethash "termination" realgud:trepan-pat-hash)
+ "^trepan: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:trepan-pat-hash)
+ '(
+ ;; The frame number and first type name, if present.
+ ("^\\(-->\\| \\)? #\\([0-9]+\\) \\([A-Z]+\\)
*\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?"
+ (2 realgud-backtrace-number-face)
+ (3 font-lock-keyword-face) ; e.g. METHOD, TOP
+ (4 font-lock-constant-face) ; e.g. Object
+ (5 font-lock-function-name-face nil t)) ; t means optional
+ ;; Instruction sequence
+ ("<\\(.+\\)>"
+ (1 font-lock-variable-name-face))
+ ;; "::Type", which occurs in class name of function and in parameter
list.
+ ;; Parameter sequence
+ ("(\\(.+\\))"
+ (1 font-lock-variable-name-face))
+ ;; "::Type", which occurs in class name of function and in parameter
list.
+ ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face))
+ ;; File name.
+ ("[ \t]+in file \\([^ ]+*\\)"
+ (1 realgud-file-name-face))
+ ;; Line number.
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+ ;; Function name.
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))
+ ;; (trepan-frames-match-current-line
+ ;; (0 trepan-frames-current-frame-face append))
+ ))
+
+;; (setf (gethash "font-lock-keywords" realgud:trepan-pat-hash)
+;; '(
+;; ;; The frame number and first type name, if present.
+;; ((concat realgud:trepan-frame-start-regexp " "
+;; realgud:trepan-frame-num-regexp " "
+;; "\\([A-Z]+\\)
*\\([A-Z_][a-zA-Z0-9_]*\\)[#]\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?")
+;; (2 realgud-backtrace-number-face)
+;; (3 font-lock-keyword-face) ; e.g. METHOD, TOP
+;; (4 font-lock-constant-face) ; e.g. Object
+;; (5 font-lock-function-name-face nil t)) ; t means optional
+;; ;; Instruction sequence
+;; ("<\\(.+\\)>"
+;; (1 font-lock-variable-name-face))
+;; ;; "::Type", which occurs in class name of function and in
+;; ;; parameter list. Parameter sequence
+;; ("(\\(.+\\))"
+;; (1 font-lock-variable-name-face))
+;; ;; "::Type", which occurs in class name of function and in
+;; ;; parameter list.
+;; ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+;; (1 font-lock-type-face))
+;; ;; File name.
+;; (realgud:trepan-frame-file-regexp (1 realgud-file-name-face))
+;; ;; Line number.
+;; (realgud:trepan-frame-line-regexp (1 realgud-line-number-face))
+;; ;; Function name.
+;; ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+;; (1 font-lock-type-face)
+;; (2 font-lock-function-name-face))
+;; ;; (trepan-frames-match-current-line
+;; ;; (0 trepan-frames-current-frame-face append))
+;; ))
+
+(setf (gethash realgud:trepan-debugger-name realgud-pat-hash)
realgud:trepan-pat-hash)
+
+(defvar realgud:trepan-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the trepan command to use, like 'quit!'")
+
+(setf (gethash "quit" realgud:trepan-command-hash) "quit!")
+(setf (gethash "shell" realgud:trepan-command-hash) "irb")
+(setf (gethash realgud:trepan-debugger-name
+ realgud-command-hash) realgud:trepan-command-hash)
+
+(provide-me "realgud:trepan-")
diff --git a/packages/realgud/realgud/debugger/trepan/track-mode.el
b/packages/realgud/realgud/debugger/trepan/track-mode.el
new file mode 100644
index 0000000..b4b2ddf
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan/track-mode.el
@@ -0,0 +1,82 @@
+;;; Copyright (C) 2010, 2012-2015 Rocky Bernstein <address@hidden>
+;;; Ruby "trepan" Debugger tracking a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepan-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-hook 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-goto-line-for-pt 'realgud-track-mode)
+
+(realgud-track-mode-vars "trepan")
+
+(define-key realgud-track-mode-map
+ (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+(define-key realgud-track-mode-map
+ (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+
+(declare-function realgud:ruby-populate-command-keys 'realgud-lang-ruby)
+
+(defun realgud:trepan-goto-control-frame-line (pt)
+ "Display the location mentioned by a control-frame line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "control-frame"))
+
+(defun realgud:trepan-goto-syntax-error-line (pt)
+ "Display the location mentioned in a Syntax error line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "syntax-error"))
+
+(realgud:ruby-populate-command-keys trepan-track-mode-map)
+
+(define-key trepan-track-mode-map
+ (kbd "C-c !c") 'realgud:trepan-goto-control-frame-line)
+(define-key trepan-track-mode-map
+ (kbd "C-c !s") 'realgud:trepan-goto-syntax-error-line)
+
+(defun trepan-track-mode-hook()
+ (if trepan-track-mode
+ (progn
+ (use-local-map trepan-track-mode-map)
+ (message "using trepan mode map")
+ )
+ (message "trepan track-mode-hook disable called"))
+)
+
+(define-minor-mode trepan-track-mode
+ "Minor mode for tracking trepan source locations inside a process shell via
realgud. trepan is a Ruby debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{trepan-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " trepan" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepan
+ :keymap trepan-track-mode-map
+ (realgud:track-set-debugger "trepan")
+ (if trepan-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (trepan-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:trepan-")
diff --git a/packages/realgud/realgud/debugger/trepan/trepan.el
b/packages/realgud/realgud/debugger/trepan/trepan.el
new file mode 100644
index 0000000..b62417d
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan/trepan.el
@@ -0,0 +1,58 @@
+;;; Copyright (C) 2010-2011, 2013-2015 Rocky Bernstein <address@hidden>
+;; `trepan' Main interface to trepan via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:trepan-")
+
+(declare-function realgud:trepan-query-cmdline 'realgud:trepan-core)
+(declare-function realgud:trepan-parse-cmd-args 'realgud:trepan-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:trepan nil
+ "The realgud interface to the Ruby 1.9.2 1.9.3 \"trepanning\" debugger"
+ :group 'ruby
+ :group 'realgud
+ :version "24.1")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:trepan-command-name
+ ;;"trepan --emacs 3"
+ "trepan"
+ "File name for executing the Ruby debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:trepan)
+
+;;;###autoload
+(defun realgud:trepan (&optional opt-cmd-line no-reset)
+ "Invoke the trepan Ruby debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `trepan-parse-cmd-args' and path elements found by that
+are expanded using `expand-file-name'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "trepan" 'realgud:trepan-query-cmdline
+ 'realgud:trepan-parse-cmd-args
+ 'realgud:trepan-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+(defalias 'trepan 'realgud:trepan)
+(provide-me "realgud-")
+;;; trepan.el ends here
diff --git a/packages/realgud/realgud/debugger/trepan2/Makefile.am
b/packages/realgud/realgud/debugger/trepan2/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan2/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/trepan2/core.el
b/packages/realgud/realgud/debugger/trepan2/core.el
new file mode 100644
index 0000000..2607935
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan2/core.el
@@ -0,0 +1,227 @@
+;;; Copyright (C) 2010, 2014-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'compile) ;; for compilation-find-file
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/file"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:trepan2-")
+
+(declare-function realgud:strip 'realgud)
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+(declare-function realgud:file-loc-from-line 'realgud-file)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:trepan2-minibuffer-history nil
+ "minibuffer history list for the command `realgud:trepan2'.")
+
+(easy-mmode-defmap trepan2-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+(defvar realgud:trepan2-file-remap (make-hash-table :test 'equal)
+ "How to remap Python files in trepan2 when we otherwise can't
+ find in the filesystem. The hash key is the file string we saw,
+ and the value is associated filesystem string presumably in the
+ filesystem")
+
+;; FIXME: this code could be generalized and put in a common place.
+(defun realgud:trepan2-find-file(filename)
+ "A find-file specific for python/trepan. We strip off trailing
+blanks. Failing that we will prompt for a mapping and save that
+in variable `realgud:trepan2-file-remap' when that works. In the future,
+we may also consult PYTHONPATH."
+ (let* ((transformed-file)
+ (stripped-filename (realgud:strip filename))
+ (ignore-file-re realgud-python-ignore-file-re)
+ )
+ (cond
+ ((file-exists-p filename) filename)
+ ((file-exists-p stripped-filename) stripped-filename)
+ ((string-match ignore-file-re filename)
+ (message "tracking ignored for psuedo-file: %s" filename) nil)
+ ('t
+ ;; FIXME search PYTHONPATH if not absolute file
+ (if (gethash filename realgud-file-remap)
+ (let ((remapped-filename))
+ (setq remapped-filename (gethash filename
realgud:trepan2-file-remap))
+ (if (file-exists-p remapped-filename)
+ remapped-filename
+ ;; else
+ (and (remhash filename realgud-file-remap)) nil)
+ ;; else
+ (let ((remapped-filename))
+ (setq remapped-filename
+ (buffer-file-name
+ (compilation-find-file (point-marker) stripped-filename
+ nil "%s.py")))
+ (when (and remapped-filename (file-exists-p remapped-filename))
+ (puthash filename remapped-filename realgud-file-remap)
+ remapped-filename
+ ))
+ ))
+ ))
+ ))
+
+(defun realgud:trepan2-loc-fn-callback(text filename lineno source-str
+ ignore-file-re cmd-mark)
+ (realgud:file-loc-from-line filename lineno
+ cmd-mark source-str nil nil
+ 'realgud:trepan2-find-file))
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun trepan2-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'trepan2-suggest-invocation
+ trepan2-minibuffer-local-map
+ 'realgud:trepan2-minibuffer-history
+ opt-debugger))
+
+(defun trepan2-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+- the command processor (e.g. python) and it's arguments if any - a list of
strings
+- the name of the debugger given (e.g. trepan2) and its arguments - a list of
strings
+- the script name and its arguments - list of strings
+- whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(python2.6 -O -Qold --emacs ./gcd.py a b))
+
+we might return:
+ ((python2.6 -O -Qold) (trepan2 --emacs) (./gcd.py a b) 't)
+
+NOTE: the above should have each item listed in quotes.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [python python-options] trepan2 trepan2-options script-name
script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (python-opt-two-args '("c" "m" "Q" "W"))
+ ;; Python doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (python-two-args '())
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (trepan2-two-args '("x" "-command" "e" "-execute"
+ "o" "-output" "t" "-target"
+ "a" "-annotate"))
+ (trepan2-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^python[-0-9.]*\\(.exe\\)?$"
+ "^python[-0-9.]*$"))
+
+ ;; Things returned
+ (annotate-p nil)
+ (debugger-args '())
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ (script-name nil)
+ )
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "python" or "python182" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off Python-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args python-two-args python-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "trepan2" from "trepan2 --trepan2-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^\\(trepan2\\|cli.py\\)$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `trepan2' or `cli.py'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args)) )
+ (setq annotate-p t))
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args trepan2-two-args trepan2-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:trepan2-command-name)
+
+(defun trepan2-suggest-invocation (debugger-name)
+ "Suggest a trepan2 command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:trepan2-command-name
+ realgud:trepan2-minibuffer-history
+ "python" "\\.py"
+ realgud:trepan2-command-name))
+
+(defun trepan2-reset ()
+ "Trepan2 cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (trepan2-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*trepan2-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun trepan2-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'trepan2-debugger-support-minor-mode minor-mode-map-alist)
+;; trepan2-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:trepan2-customize ()
+ "Use `customize' to edit the settings of the `trepan2' debugger."
+ (interactive)
+ (customize-group 'realgud:trepan2))
+
+(provide-me "realgud:trepan2-")
diff --git a/packages/realgud/realgud/debugger/trepan2/init.el
b/packages/realgud/realgud/debugger/trepan2/init.el
new file mode 100644
index 0000000..9fb9fec
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan2/init.el
@@ -0,0 +1,90 @@
+;;; Copyright (C) 2010-2012, 2014-2015 Rocky Bernstein <address@hidden>
+;;; trepan2: Python 2.5 but less than 3K
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/python") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:trepan2-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(declare-function make-realgud-loc 'realgud-loc)
+
+(setf (gethash "loc-callback-fn" realgud:trepan2-pat-hash)
'realgud:trepan2-loc-fn-callback)
+
+;; Regular expression that describes a trepan2 location generally shown
+;; before a command prompt.
+;;
+;; For example:
+;; (/usr/bin/zonetab2pot.py:15 @3): <module>
+;; (/usr/bin/zonetab2pot.py:15 remapped <string>): <module>
+;; or MS Windows:
+;; (c:\\mydirectory\\gcd.py:10): <module>
+(setf (gethash "loc" realgud:trepan2-pat-hash)
+ realgud:python-trepan-loc-pat)
+
+(setf (gethash "prompt" realgud:trepan2-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^(trepan2) "
+ ))
+
+;; Regular expression that describes a trepan2 backtrace line.
+;; For example:
+;; ->0 get_distribution(dist='trepan==0.3.9')
+;; called from file '/python2.7/dist-packages/pkg_res.py' at line 341
+;; ##1 load_entry_point(dist='tr=0.3.9', group='console_scripts', name='tr')
+;; called from file '/python2.7/dist-packages/pkg_res.py' at line 351
+;; ##2 <module> exec()
+
+(setf (gethash "debugger-backtrace" realgud:trepan2-pat-hash)
+ realgud:python-trepan-backtrace-pat)
+
+;; Regular expression that describes a Python backtrace line.
+(setf (gethash "lang-backtrace" realgud:trepan2-pat-hash)
+ realgud-python-backtrace-loc-pat)
+
+;; Regular expression that describes location in a pytest error
+(setf (gethash "pytest-error" realgud:trepan2-pat-hash)
+ realgud-pytest-error-loc-pat)
+
+;; Regular expression that describes a "breakpoint set" line
+(setf (gethash "brkpt-set" realgud:trepan2-pat-hash)
+ realgud:python-trepan-brkpt-set-pat)
+
+;; Regular expression that describes a "delete breakpoint" line
+(setf (gethash "brkpt-del" realgud:trepan2-pat-hash)
+ realgud:python-trepan-brkpt-del-pat)
+
+;; Regular expression for a termination message.
+(setf (gethash "termination" realgud:trepan2-pat-hash)
+ "^trepan2: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:trepan2-pat-hash)
+ realgud:python-debugger-font-lock-keywords)
+
+(setf (gethash "trepan2" realgud-pat-hash) realgud:trepan2-pat-hash)
+
+(defvar realgud:trepan2-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'shell' and the value is
+ the trepan2 command to use, like 'python'")
+
+(setf (gethash "shell" realgud:trepan2-command-hash) "python")
+(setf (gethash "until" realgud:trepan2-command-hash) "continue %l")
+
+;; If your version of trepan2 doesn't support "quit!",
+;; get a more recent version of trepan2
+(setf (gethash "quit" realgud:trepan2-command-hash) "quit!")
+
+(setf (gethash "trepan2" realgud-command-hash) realgud:trepan2-command-hash)
+
+(provide-me "realgud:trepan2-")
diff --git a/packages/realgud/realgud/debugger/trepan2/track-mode.el
b/packages/realgud/realgud/debugger/trepan2/track-mode.el
new file mode 100644
index 0000000..5a7947c
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan2/track-mode.el
@@ -0,0 +1,63 @@
+;; Copyright (C) 2010, 2012-2015 Rocky Bernstein <address@hidden>
+;;
+;; Python "trepan2" Debugger tracking in a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepan2-")
+(require-relative-list '("../../lang/python") "realgud-lang-")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-hook 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-python-populate-command-keys 'realgud-lang-python)
+
+(realgud-track-mode-vars "trepan2")
+
+(realgud-python-populate-command-keys trepan2-track-mode-map)
+
+(defun trepan2-track-mode-hook()
+ (if trepan2-track-mode
+ (progn
+ (use-local-map trepan2-track-mode-map)
+ (message "using trepan2 mode map")
+ )
+ (message "trepan2 track-mode-hook disable called")
+ )
+)
+
+(define-minor-mode trepan2-track-mode
+ "Minor mode for tracking trepan2 source locations inside a process shell via
realgud. trepan2 is a Python debugger. See URL
`https://github.com/rocky/emacs-dbgr/rocky/python2-trepan/'.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{trepan2-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " trepan2" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepan2
+ :keymap trepan2-track-mode-map
+
+ (realgud:track-set-debugger "trepan2")
+ (if trepan2-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (trepan2-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(define-key trepan2-short-key-mode-map "T" 'realgud:cmd-backtrace)
+
+(provide-me "realgud:trepan2-")
diff --git a/packages/realgud/realgud/debugger/trepan2/trepan2.el
b/packages/realgud/realgud/debugger/trepan2/trepan2.el
new file mode 100644
index 0000000..5bd8eb1
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan2/trepan2.el
@@ -0,0 +1,66 @@
+;;; Copyright (C) 2010-2012, 2014-2015 Rocky Bernstein <address@hidden>
+;; `trepan2' Main interface to trepan2 via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:trepan2-")
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:trepan2 nil
+ "The realgud interface to the Python trepan2 debugger"
+ :group 'realgud
+ :group 'python
+ :version "24.2")
+
+(declare-function trepan2-query-cmdline 'realgud:trepan2-core)
+(declare-function trepan2-parse-cmd-args 'realgud:trepan2-core)
+(declare-function trepan2-track-mode 'realgud:pydbgr-track-mode)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:trepan2-command-name
+ ;;"trepan2 --emacs 3"
+ "trepan2"
+ "File name for executing the Python debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:trepan2)
+
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+;;;###autoload
+(defun realgud:trepan2 (&optional opt-cmd-line no-reset)
+ "Invoke the trepan2 Python debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `trepan2-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "trepan2"
+ 'trepan2-query-cmdline
+ 'trepan2-parse-cmd-args
+ 'realgud:trepan2-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+
+(defalias 'trepan2 'realgud:trepan2)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/trepan3k/Makefile.am
b/packages/realgud/realgud/debugger/trepan3k/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan3k/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/trepan3k/core.el
b/packages/realgud/realgud/debugger/trepan3k/core.el
new file mode 100644
index 0000000..6198e1f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan3k/core.el
@@ -0,0 +1,173 @@
+;;; Copyright (C) 2010, 2013-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:trepan3k-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:trepan3k-minibuffer-history nil
+ "minibuffer history list for the command `realgud:trepan3k'.")
+
+(easy-mmode-defmap trepan3k-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of gud startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun trepan3k-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'trepan3k-suggest-invocation
+ trepan3k-minibuffer-local-map
+ 'realgud-trepan3k-minibuffer-history
+ opt-debugger))
+
+(defun trepan3k-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the annotate level and name of script to debug.
+
+ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+- the command processor (e.g. python) and it's arguments if any - a list of
strings
+- the name of the debugger given (e.g. trepan3k) and its arguments - a list of
strings
+- the script name and its arguments - list of strings
+- whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(python2.6 -O -Qold --emacs ./gcd.py a b))
+
+we might return:
+ ((python2.6 -O -Qold) (trepan3k --emacs) (./gcd.py a b) 't)
+
+NOTE: the above should have each item listed in quotes.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [python python-options] trepan3k trepan3k-options script-name
script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (python-opt-two-args '("c" "m" "Q" "W"))
+ ;; Python doesn't have mandatory 2-arg options in our sense,
+ ;; since the two args can be run together, e.g. "-C/tmp" or "-C /tmp"
+ ;;
+ (python-two-args '())
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (trepan3k-two-args '("x" "-command" "e" "-execute"
+ "o" "-output" "t" "-target"
+ "a" "-annotate"))
+ (trepan3k-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^python[-0-9.]*\\(.exe\\)?$"
+ "^python[-0-9.]*$"))
+
+ ;; Things returned
+ (annotate-p nil)
+ (debugger-args '())
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ (script-name nil)
+ )
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "python" or "python182" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off Python-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args python-two-args python-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "trepan3k" from "trepan3k --trepan3k-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^\\(trepan3k\\|cli.py\\)$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `trepan3k' or `cli.py'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args)) )
+ (setq annotate-p t))
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args trepan3k-two-args trepan3k-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:trepan3k-command-name)
+
+(defun trepan3k-suggest-invocation (debugger-name)
+ "Suggest a trepan3k command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:trepan3k-command-name
+ realgud:trepan3k-minibuffer-history
+ "python" "\\.py"
+ realgud:trepan3k-command-name))
+
+(defun trepan3k-reset ()
+ "Trepan3k cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (trepan3k-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*trepan3k-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun trepan3k-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'trepan3k-debugger-support-minor-mode minor-mode-map-alist)
+;; trepan3k-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:trepan3k-customize ()
+ "Use `customize' to edit the settings of the `trepan3k' debugger."
+ (interactive)
+ (customize-group 'realgud:trepan3k))
+
+(provide-me "realgud:trepan3k-")
diff --git a/packages/realgud/realgud/debugger/trepan3k/init.el
b/packages/realgud/realgud/debugger/trepan3k/init.el
new file mode 100644
index 0000000..b9d8f2a
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan3k/init.el
@@ -0,0 +1,88 @@
+;;; Copyright (C) 2010-2015 Rocky Bernstein <address@hidden>
+;;; trepan3k: Python 3.2 and beyond
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/python") "realgud-lang-")
+
+(defvar realgud-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:trepan3k-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(declare-function make-realgud-loc 'realgud-loc)
+
+;; Regular expression that describes a trepan3k location generally shown
+;; before a command prompt.
+;;
+;; For example:
+;; (/usr/bin/zonetab2pot.py:15): <module>
+;; (/usr/bin/zonetab2pot.py:15 remapped <string>): <module>
+;; or MS Windows:
+;; (c:\\mydirectory\\gcd.py:10): <module>
+(setf (gethash "loc" realgud:trepan3k-pat-hash)
+ realgud:python-trepan-loc-pat)
+
+(setf (gethash "prompt" realgud:trepan3k-pat-hash)
+ (make-realgud-loc-pat
+ :regexp "^(trepan3k) "
+ ))
+
+;; Regular expression that describes a trepan3k backtrace line.
+;; For example:
+;; ->0 get_distribution(dist='trepan==0.3.9')
+;; called from file '/python2.7/dist-packages/pkg_res.py' at line 341
+;; ##1 load_entry_point(dist='tr=0.3.9', group='console_scripts', name='tr')
+;; called from file '/python2.7/dist-packages/pkg_res.py' at line 351
+;; ##2 <module> exec()
+
+(setf (gethash "debugger-backtrace" realgud:trepan3k-pat-hash)
+ realgud:python-trepan-backtrace-pat)
+
+;; Regular expression that describes a Python backtrace line.
+(setf (gethash "lang-backtrace" realgud:trepan3k-pat-hash)
+ realgud-python-backtrace-loc-pat)
+
+;; Regular expression that describes location in a pytest error
+(setf (gethash "pytest-error" realgud:trepan3k-pat-hash)
+ realgud-pytest-error-loc-pat)
+
+;; Regular expression that describes a "breakpoint set" line
+(setf (gethash "brkpt-set" realgud:trepan3k-pat-hash)
+ realgud:python-trepan-brkpt-set-pat)
+
+;; Regular expression that describes a "delete breakpoint" line
+(setf (gethash "brkpt-del" realgud:trepan3k-pat-hash)
+ realgud:python-trepan-brkpt-del-pat)
+
+;; Regular expression for a termination message.
+(setf (gethash "termination" realgud:trepan3k-pat-hash)
+ "^trepan3k: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:trepan3k-pat-hash)
+ realgud:python-debugger-font-lock-keywords)
+
+(setf (gethash "trepan3k" realgud-pat-hash) realgud:trepan3k-pat-hash)
+
+(defvar realgud:trepan3k-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'shell' and the value is
+ the trepan3k command to use, like 'python'")
+
+(setf (gethash "shell" realgud:trepan3k-command-hash) "python")
+(setf (gethash "until" realgud-command-hash) "continue %l")
+
+;; If your version of trepan3k doesn't support "quit!",
+;; get a more recent version of trepan2
+(setf (gethash "quit" realgud:trepan3k-command-hash) "quit!")
+
+(setf (gethash "trepan3k" realgud-command-hash) realgud:trepan3k-command-hash)
+
+(provide-me "realgud:trepan3k-")
diff --git a/packages/realgud/realgud/debugger/trepan3k/track-mode.el
b/packages/realgud/realgud/debugger/trepan3k/track-mode.el
new file mode 100644
index 0000000..afb94f1
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan3k/track-mode.el
@@ -0,0 +1,78 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; Python "trepan3k" Debugger tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepan3k-")
+(require-relative-list '("../../lang/python") "realgud-lang-")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-hook 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-python-populate-command-keys 'realgud-lang-python)
+
+(realgud-track-mode-vars "trepan3k")
+
+(declare-function realgud-track-mode(bool))
+
+(realgud-python-populate-command-keys trepan3k-track-mode-map)
+
+(defun trepan3k-track-mode-hook()
+ (if trepan3k-track-mode
+ (progn
+ (use-local-map trepan3k-track-mode-map)
+ (message "using trepan3k mode map")
+ )
+ (message "trepan3k track-mode-hook disable called")
+ )
+)
+
+(define-minor-mode trepan3k-track-mode
+ "Minor mode for tracking trepan3k source locations inside a process shell
via realgud. trepan3k is a Python debugger. See URL
`http://code.google.com/p/python3-trepan/'.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{trepan3k-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " trepan3k" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepan3k
+ :keymap trepan3k-track-mode-map
+ (realgud:track-set-debugger "trepan3k")
+ (if trepan3k-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (trepan3k-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(define-key trepan3k-short-key-mode-map "T" 'realgud:cmd-backtrace)
+
+(provide-me "realgud:trepan3k-")
diff --git a/packages/realgud/realgud/debugger/trepan3k/trepan3k.el
b/packages/realgud/realgud/debugger/trepan3k/trepan3k.el
new file mode 100644
index 0000000..945bbb0
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepan3k/trepan3k.el
@@ -0,0 +1,66 @@
+;;; Copyright (C) 2010-2014 Rocky Bernstein <address@hidden>
+;; `trepan3k' Main interface to trepan3k via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:trepan3k-")
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:trepan3k nil
+ "The realgud interface to the Python debugger, trepan3k"
+ :group 'realgud
+ :group 'python
+ :version "24.1")
+
+(declare-function trepan3k-query-cmdline 'realgud:trepan3k-core)
+(declare-function trepan3k-parse-cmd-args 'realgud:trepan3k-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:trepan3k-command-name
+ ;;"trepan3k --emacs 3"
+ "trepan3k"
+ "File name for executing the Python debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:trepan3k)
+
+(declare-function trepan3k-track-mode (bool))
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+;;;###autoload
+(defun realgud:trepan3k (&optional opt-cmd-line no-reset)
+ "Invoke the trepan3k Python debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `trepan2-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger "trepan3k"
+ 'trepan3k-query-cmdline
+ 'trepan3k-parse-cmd-args
+ 'realgud:trepan3k-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+
+(defalias 'trepan3k 'realgud:trepan3k)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/debugger/trepanjs/Makefile.am
b/packages/realgud/realgud/debugger/trepanjs/Makefile.am
new file mode 100644
index 0000000..9a343a5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepanjs/Makefile.am
@@ -0,0 +1 @@
+include $(srcdir)/../common.mk
diff --git a/packages/realgud/realgud/debugger/trepanjs/backtrack-mode.el
b/packages/realgud/realgud/debugger/trepanjs/backtrack-mode.el
new file mode 100644
index 0000000..e3b7e6c
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepanjs/backtrack-mode.el
@@ -0,0 +1,81 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Mode for parsing various kinds of backtraces found in JavaScript
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track-mode"
+ "../../common/backtrack-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepanjs-")
+(require-relative-list '("../../lang/ruby") "realgud-lang-")
+
+(realgud-backtrack-mode-vars "trepanjs")
+(set-keymap-parent trepanjs-backtrack-mode-map realgud-backtrack-mode-map)
+
+(declare-function realgud-backtrack-mode
'realgud-common-backtrack-mode)
+(declare-function realgud-backtrack-set-debugger
'realgud-common-backtrack-mode)
+(declare-function realgud-goto-line-for-pt
'realgud-common-backtrack-mode)
+(declare-function realgud:ruby-populate-command-keys 'realgud-lang-ruby)
+
+(defun realgud:trepanjs-goto-control-frame-line (pt)
+ "Display the location mentioned by a control-frame line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "control-frame"))
+
+(realgud:ruby-populate-command-keys trepanjs-backtrack-mode-map)
+(define-key trepanjs-backtrack-mode-map
+ (kbd "C-c !c") 'realgud:trepanjs-goto-control-frame-line)
+
+(define-minor-mode trepanjs-backtrack-mode
+ "Minor mode for tracking ruby debugging inside a file which may not have
process shell.
+
+\\{trepanjs-backtrack-mode-map}
+"
+ :init-value nil
+ ;; :lighter " trepanjs" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepanjs
+ :keymap trepanjs-backtrack-mode-map
+
+ (realgud-backtrack-set-debugger "trepanjs")
+ (if trepanjs-backtrack-mode
+ (progn
+ (realgud-backtrack-mode 't)
+ (run-mode-hooks (intern (trepanjs-backtrack-mode-hook))))
+ (progn
+ (realgud-backtrack-mode nil)
+ ))
+)
+
+(defun trepanjs-backtrack-mode-hook()
+ (if trepanjs-backtrack-mode
+ (progn
+ (use-local-map trepanjs-backtrack-mode-map)
+ (message "using trepanjs mode map")
+ )
+ (message "trepanjs backtrack-mode-hook disable called"))
+)
+
+(provide-me "realgud:trepanjs-")
diff --git a/packages/realgud/realgud/debugger/trepanjs/core.el
b/packages/realgud/realgud/debugger/trepanjs/core.el
new file mode 100644
index 0000000..eac8a0e
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepanjs/core.el
@@ -0,0 +1,169 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track"
+ "../../common/core"
+ "../../common/lang")
+ "realgud-")
+(require-relative-list '("init") "realgud:trepanjs-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:trepanjs-minibuffer-history nil
+ "minibuffer history list for the command `realgud:trepanjs'.")
+
+(easy-mmode-defmap realgud:trepanjs-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of trepanjs startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun realgud:trepanjs-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'realgud:trepanjs-suggest-invocation
+ realgud:trepanjs-minibuffer-local-map
+ 'realgud:trepanjs-minibuffer-history
+ opt-debugger))
+
+(defun realgud:trepanjs-parse-cmd-args (orig-args)
+ "Parse command line ARGS for the name of script to debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+* the name of the debugger given (e.g. trepanjs) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+
+For example for the following input:
+ (map 'list 'symbol-name
+ '(trepanjs --no-highlight --port 5858 /tmp trepanjs ./gcd.js a b))
+
+we might return:
+ ((\"trepanjs\" \"--no-highlight\" \"--port\" \"5858\") nil (\"/tmp/gcd.js\"
\"a\" \"b\"))
+
+Note that path elements have been expanded via `expand-file-name'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; node trepanjs-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ (node-two-args '("-max-stack-size"))
+ ;; node doesn't have any optional two-arg options
+ (node-opt-two-args '())
+
+ ;; One dash is added automatically to the below, so
+ ;; p is really -p and -port is really --port.
+ (trepanjs-two-args '("-port" "-host" "-pid" "p"))
+ (trepanjs-opt-two-args '())
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (script-args '())
+ )
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil, nil)
+ (list interpreter-args nil script-args)
+ ;; else
+ (progn
+ ;; Remove "trepanjs" (or "nodemon" or "node") from invocation like:
+ ;; trepanjs --trepanjs-options script --script-options
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^node\\(?:js\\|mon\\)?$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `node', `nodemon', or `trepanjs'"
+ debugger-name))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ((equal "debug" arg)
+ (nconc interpreter-args (list arg))
+ (setq args (cdr args))
+ )
+
+ ;; Options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args trepanjs-two-args trepanjs-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args nil script-args)))
+ ))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:trepanjs-command-name)
+
+(defun realgud:trepanjs-suggest-invocation (debugger-name)
+ "Suggest a trepanjs command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:trepanjs-command-name
+ realgud:trepanjs-minibuffer-history
+ "js" "\\.js$"))
+
+(defun realgud:trepanjs-remove-ansi-shmutz()
+ "Remove ASCII escape sequences that node.js 'decorates' in
+prompts and interactive output with"
+ (add-to-list
+ 'comint-preoutput-filter-functions
+ (lambda (output)
+ (replace-regexp-in-string "\033\\[[0-9]+[GKJ]" "" output)))
+ )
+
+(defun realgud:trepanjs-reset ()
+ "Trepanjs cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (trepanjs-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*trepanjs-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun trepanjs-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'trepanjs-debugger-support-minor-mode minor-mode-map-alist)
+;; trepanjs-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:trepanjs-customize ()
+ "Use `customize' to edit the settings of the `trepanjs' debugger."
+ (interactive)
+ (customize-group 'realgud:trepanjs))
+
+(provide-me "realgud:trepanjs-")
diff --git a/packages/realgud/realgud/debugger/trepanjs/init.el
b/packages/realgud/realgud/debugger/trepanjs/init.el
new file mode 100644
index 0000000..77c7da6
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepanjs/init.el
@@ -0,0 +1,146 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Regular expressions for nodejs Javascript debugger.
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/js") "realgud-lang-")
+
+(defvar realgud:trepanjs-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defconst realgud:trepanjs-file-regexp "\\([^ \t\n]+\\)\\(?: \\[.*\\]\\)?")
+
+;; Regular expression that describes a trepanjs location generally shown
+;; before a command prompt.
+;; For example:
+;; break in /home/indutny/Code/git/indutny/myscript.js:1
+;; exception in /usr/lib/nodejs/module.js [module.js]:362
+(setf (gethash "loc" realgud:trepanjs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format
+ "\\(?:%s\\)*\\(?:break\\|exception\\|call\\) in %s at line
%s:%s"
+ realgud:js-term-escape realgud:trepanjs-file-regexp
+ realgud:regexp-captured-num
+ realgud:regexp-captured-num)
+ :file-group 1
+ :line-group 2
+ :char-offset-group 3
+ ))
+
+;; Regular expression that describes a trepanjs command prompt
+;; For example:
+;; (trepanjs):
+(setf (gethash "prompt" realgud:trepanjs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^\\(?:%s\\)*(+trepanjs)+ " realgud:js-term-escape)
+ ))
+
+;; Regular expression that describes a "breakpoint set" line
+;; For example:
+;; Breakpoint 2 set in file /tmp/gcd.js, line 2.
+;; Breakpoint 3 set in file /usr/lib/nodejs/module.js [module.js], line 380.
+(setf (gethash "brkpt-set" realgud:trepanjs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Breakpoint %s set in file %s, line %s.\n"
+ realgud:regexp-captured-num
+ realgud:trepanjs-file-regexp
+ realgud:regexp-captured-num)
+ :num 1
+ :file-group 2
+ :line-group 3))
+
+;; Regular expression that describes a V8 backtrace line.
+;; For example:
+;; at repl:1:7
+;; at Interface.controlEval
(/src/external-vcs/github/trepanjs/lib/interface.js:352:18)
+;; at REPLServer.b [as eval] (domain.js:183:18)
+(setf (gethash "lang-backtrace" realgud:trepanjs-pat-hash)
+ realgud:js-backtrace-loc-pat)
+
+;; Regular expression that describes a debugger "delete" (breakpoint)
+;; response.
+;; For example:
+;; Deleted breakpoint 1.
+(setf (gethash "brkpt-del" realgud:trepanjs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^Deleted breakpoint %s.\n"
+ realgud:regexp-captured-num)
+ :num 1))
+
+
+(defconst realgud:trepanjs-frame-start-regexp "\\(?:^\\|\n\\)\\(?: #\\)")
+(defconst realgud:trepanjs-frame-num-regexp realgud:regexp-captured-num)
+(defconst realgud:trepanjs-frame-module-regexp "[^ \t\n]+")
+
+;; Regular expression that describes debugger "backtrace" command line.
+;; e.g.
+;; ## require called from file /usr/lib/nodejs/module.js [module.js] at line
380:17
+;; ## in file /src/external-vcs/github/trepanjs/example/gcd.js
[/src/external-vcs/github/trepanjs/example/gcd.js] at line 2:12
+(setf (gethash "debugger-backtrace" realgud:trepanjs-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (concat realgud:trepanjs-frame-start-regexp " "
+ realgud:regexp-captured-num " "
+ "\\(?:" realgud:trepanjs-frame-module-regexp "[
\t\n]+called from file "
+ realgud:trepanjs-file-regexp
+ "\\)\\| in file "
+ realgud:regexp-captured-num
+ "\\)"
+ "at line \\(" realgud:regexp-captured-num "\\):"
+ realgud:regexp-captured-num
+ )
+ :num 1
+ :file-group 2
+ :line-group 3
+ :char-offset-group 4
+ ))
+
+(defconst realgud:trepanjs-debugger-name "trepanjs" "Name of debugger")
+
+;; Top frame number
+(setf (gethash "top-frame-num" realgud:trepanjs-pat-hash) 0)
+
+;; Regular expression that for a termination message.
+(setf (gethash "termination" realgud:trepanjs-pat-hash)
+ "^trepanjs: That's all, folks...\n")
+
+(setf (gethash realgud:trepanjs-debugger-name realgud-pat-hash)
realgud:trepanjs-pat-hash)
+
+(defvar realgud:trepanjs-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the trepanjs command to use, like 'quit!'")
+
+(setf (gethash realgud:trepanjs-debugger-name
+ realgud-command-hash) realgud:trepanjs-command-hash)
+
+(setf (gethash "break" realgud:trepanjs-command-hash)
+ "setBreakpoint(%l)")
+;; We need aliases for step and next because the default would
+;; do step 1 and trepanjs doesn't handle this. Or when it does,
+;; it will probably look like step(1)
+(setf (gethash "eval" realgud:trepanjs-command-hash) "eval('%s')")
+
+(provide-me "realgud:trepanjs-")
diff --git a/packages/realgud/realgud/debugger/trepanjs/track-mode.el
b/packages/realgud/realgud/debugger/trepanjs/track-mode.el
new file mode 100644
index 0000000..4c02965
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepanjs/track-mode.el
@@ -0,0 +1,88 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; "trepanjs" Debugger tracking a comint or eshell buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:trepanjs-")
+;; (require-relative-list '("../../lang/js") "realgud-lang-")
+
+(declare-function realgud-track-mode 'realgud-track-mode)
+(declare-function realgud-track-mode-hook 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-goto-line-for-pt 'realgud-track-mode)
+
+(realgud-track-mode-vars "trepanjs")
+
+(define-key realgud-track-mode-map
+ (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+(define-key realgud-track-mode-map
+ (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+
+(declare-function realgud:ruby-populate-command-keys 'realgud-lang-ruby)
+
+(defun realgud:trepanjs-goto-syntax-error-line (pt)
+ "Display the location mentioned in a Syntax error line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "syntax-error"))
+
+(define-key trepanjs-track-mode-map
+ (kbd "C-c !s") 'realgud:trepanjs-goto-syntax-error-line)
+
+(defun trepanjs-track-mode-hook()
+ (if trepanjs-track-mode
+ (progn
+ (use-local-map trepanjs-track-mode-map)
+ (message "using trepanjs mode map")
+ )
+ (message "trepanjs track-mode-hook disable called"))
+)
+
+(define-minor-mode trepanjs-track-mode
+ "Minor mode for tracking trepanjs source locations inside a process shell
via realgud. trepanjs is a Ruby debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{trepanjs-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " trepanjs" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:trepanjs
+ :keymap trepanjs-track-mode-map
+ (realgud:track-set-debugger "trepanjs")
+ (if trepanjs-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (trepanjs-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(provide-me "realgud:trepanjs-")
diff --git a/packages/realgud/realgud/debugger/trepanjs/trepanjs.el
b/packages/realgud/realgud/debugger/trepanjs/trepanjs.el
new file mode 100644
index 0000000..9742d1d
--- /dev/null
+++ b/packages/realgud/realgud/debugger/trepanjs/trepanjs.el
@@ -0,0 +1,84 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Regular expressions for nodejs Javascript debugger.
+
+;; `trepanjs' Main interface to trepanjs via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:trepanjs-")
+(require-relative-list '("../../lang/js") "realgud-lang-")
+
+(declare-function realgud:trepanjs-query-cmdline 'realgud:trepanjs-core)
+(declare-function realgud:trepanjs-parse-cmd-args 'realgud:trepanjs-core)
+(declare-function realgud:js-remove-ansi-schmutz 'realgud-lang-js)
+(declare-function realgud:run-debugger 'realgud:run)
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:trepanjs nil
+ "The realgud interface to the Ruby 1.9.2 1.9.3 \"trepanjsning\" debugger"
+ :group 'ruby
+ :group 'realgud
+ :version "24.1")
+
+;; -------------------------------------------------------------------
+;; User-definable variables
+;;
+
+(defcustom realgud:trepanjs-command-name
+ ;;"trepanjs --emacs 3"
+ "trepanjs"
+ "File name for executing the Ruby debugger and command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:trepanjs)
+
+;;;###autoload
+(defun realgud:trepanjs (&optional opt-cmd-line no-reset)
+ "Invoke the trepanjs Ruby debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `trepanjs-parse-cmd-args' and path elements found by that
+are expanded using `expand-file-name'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (let ((cmd-buf
+ (realgud:run-debugger "trepanjs" 'realgud:trepanjs-query-cmdline
+ 'realgud:trepanjs-parse-cmd-args
+ 'realgud:trepanjs-minibuffer-history
+ opt-cmd-line no-reset)))
+ (if cmd-buf
+ (with-current-buffer cmd-buf
+ ;; FIXME should allow customization whether to do or not
+ ;; and also only do if hook is not already there.
+ (realgud:js-remove-ansi-schmutz)
+ )
+ )))
+
+(defalias 'trepanjs 'realgud:trepanjs)
+(provide-me "realgud-")
+;;; trepanjs.el ends here
diff --git a/packages/realgud/realgud/debugger/zshdb/Makefile.am
b/packages/realgud/realgud/debugger/zshdb/Makefile.am
new file mode 100644
index 0000000..23f8a8f
--- /dev/null
+++ b/packages/realgud/realgud/debugger/zshdb/Makefile.am
@@ -0,0 +1 @@
+include ../common.mk
diff --git a/packages/realgud/realgud/debugger/zshdb/core.el
b/packages/realgud/realgud/debugger/zshdb/core.el
new file mode 100644
index 0000000..b07423a
--- /dev/null
+++ b/packages/realgud/realgud/debugger/zshdb/core.el
@@ -0,0 +1,176 @@
+;;; Copyright (C) 2010-2011, 2014-2015 Rocky Bernstein <address@hidden>
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/track" "../../common/core")
+ "realgud-")
+(require-relative-list '("init") "realgud:zshdb-")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg 'realgud-core)
+(declare-function realgud-query-cmdline 'realgud-core)
+(declare-function realgud-suggest-invocation 'realgud-core)
+(declare-function realgud-lang-mode? 'realgud-lang)
+
+;; FIXME: I think the following could be generalized and moved to
+;; realgud-... probably via a macro.
+(defvar realgud:zshdb-minibuffer-history nil
+ "minibuffer history list for the command `realgud:zshdb'.")
+
+(easy-mmode-defmap zshdb-minibuffer-local-map
+ '(("\C-i" . comint-dynamic-complete-filename))
+ "Keymap for minibuffer prompting of zshdb startup command."
+ :inherit minibuffer-local-map)
+
+;; FIXME: I think this code and the keymaps and history
+;; variable chould be generalized, perhaps via a macro.
+(defun zshdb-query-cmdline (&optional opt-debugger)
+ (realgud-query-cmdline
+ 'zshdb-suggest-invocation
+ zshdb-minibuffer-local-map
+ 'realgud:zshdb-minibuffer-history
+ opt-debugger))
+
+;;; FIXME: DRY this with other *-parse-cmd-args routines
+(defun zshdb-parse-cmd-args (orig-args)
+ "Parse command line ORIG-ARGS for the annotate level and name of script to
debug.
+
+ORIG-ARGS should contain a tokenized list of the command line to run.
+
+We return the a list containing
+* the command processor (e.g. zshdb) and it's arguments if any - a list of
strings
+* the name of the debugger given (e.g. zshdb) and its arguments - a list of
strings
+* the script name and its arguments - list of strings
+* whether the annotate or emacs option was given ('-A', '--annotate' or
'--emacs) - a boolean
+
+For example for the following input
+ (map 'list 'symbol-name
+ '(zsh -b /usr/local/bin/zshdb -A -L . ./gcd.sh a b))
+
+we might return:
+ ((\"zsh\" \"-b\") (\"/usr/local/bin/zshdb\" \"-A\") (\"-L\" \"/tmp\"
\"/tmp/gcd.sh\" \"a\" \"b\") 't)
+
+Note that path elements have been expanded via
`realgud:expand-file-name-if-exists'.
+"
+
+ ;; Parse the following kind of pattern:
+ ;; [zsh zsh-options] zshdb zshdb-options script-name script-options
+ (let (
+ (args orig-args)
+ (pair) ;; temp return from
+ ;; zsh doesn't have any optional two-arg options
+ (zsh-opt-two-args '())
+ (zsh-two-args '("o" "c"))
+
+ ;; One dash is added automatically to the below, so
+ ;; h is really -h and -host is really --host.
+ (zshdb-two-args '("A" "-annotate" "l" "-library"
+ "c" "-command" "-t" "-tty"
+ "x" "-eval-command"))
+ (zshdb-opt-two-args '())
+ (interp-regexp
+ (if (member system-type (list 'windows-nt 'cygwin 'msdos))
+ "^zsh*\\(.exe\\)?$"
+ "^zsh*$"))
+
+ ;; Things returned
+ (script-name nil)
+ (debugger-name nil)
+ (interpreter-args '())
+ (debugger-args '())
+ (script-args '())
+ (annotate-p nil))
+
+ (if (not (and args))
+ ;; Got nothing: return '(nil, nil)
+ (list interpreter-args debugger-args script-args annotate-p)
+ ;; else
+ ;; Strip off optional "zsh" or "zsh.exe" etc.
+ (when (string-match interp-regexp
+ (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (setq interpreter-args (list (pop args)))
+
+ ;; Strip off zsh-specific options
+ (while (and args
+ (string-match "^-" (car args)))
+ (setq pair (realgud-parse-command-arg
+ args zsh-two-args zsh-opt-two-args))
+ (nconc interpreter-args (car pair))
+ (setq args (cadr pair))))
+
+ ;; Remove "zshdb" from "zshdb --zshdb-options script
+ ;; --script-options"
+ (setq debugger-name (file-name-sans-extension
+ (file-name-nondirectory (car args))))
+ (unless (string-match "^zshdb$" debugger-name)
+ (message
+ "Expecting debugger name `%s' to be `zshdb'"
+ debugger-name))
+ (setq debugger-args (list (pop args)))
+
+ ;; Skip to the first non-option argument.
+ (while (and args (not script-name))
+ (let ((arg (car args)))
+ (cond
+ ;; Annotation or emacs option with level number.
+ ((or (member arg '("--annotate" "-A"))
+ (equal arg "--emacs"))
+ (setq annotate-p t)
+ (nconc debugger-args (list (pop args))))
+ ;; Combined annotation and level option.
+ ((string-match "^--annotate=[0-9]" arg)
+ (nconc debugger-args (list (pop args)) )
+ (setq annotate-p t))
+ ;; Library option
+ ((member arg '("--library" "-l"))
+ (setq arg (pop args))
+ (nconc debugger-args
+ (list arg (realgud:expand-file-name-if-exists
+ (pop args)))))
+ ;; Other options with arguments.
+ ((string-match "^-" arg)
+ (setq pair (realgud-parse-command-arg
+ args zshdb-two-args zshdb-opt-two-args))
+ (nconc debugger-args (car pair))
+ (setq args (cadr pair)))
+ ;; Anything else must be the script to debug.
+ (t (setq script-name (realgud:expand-file-name-if-exists arg))
+ (setq script-args (cons script-name (cdr args))))
+ )))
+ (list interpreter-args debugger-args script-args annotate-p))))
+
+;; To silence Warning: reference to free variable
+(defvar realgud:zshdb-command-name)
+
+(defun zshdb-suggest-invocation (debugger-name)
+ "Suggest a zshdb command invocation via `realgud-suggest-invocaton'"
+ (realgud-suggest-invocation realgud:zshdb-command-name
+ realgud:zshdb-minibuffer-history
+ "sh" "\\.\\(?:z\\)?sh$"))
+
+(defun zshdb-reset ()
+ "Zshdb cleanup - remove debugger's internal buffers (frame,
+breakpoints, etc.)."
+ (interactive)
+ ;; (zshdb-breakpoint-remove-all-icons)
+ (dolist (buffer (buffer-list))
+ (when (string-match "\\*zshdb-[a-z]+\\*" (buffer-name buffer))
+ (let ((w (get-buffer-window buffer)))
+ (when w
+ (delete-window w)))
+ (kill-buffer buffer))))
+
+;; (defun zshdb-reset-keymaps()
+;; "This unbinds the special debugger keys of the source buffers."
+;; (interactive)
+;; (setcdr (assq 'zshdb-debugger-support-minor-mode minor-mode-map-alist)
+;; zshdb-debugger-support-minor-mode-map-when-deactive))
+
+
+(defun realgud:zshdb-customize ()
+ "Use `customize' to edit the settings of the `zshdb' debugger."
+ (interactive)
+ (customize-group 'realgud:zshdb))
+
+(provide-me "realgud:zshdb-")
diff --git a/packages/realgud/realgud/debugger/zshdb/init.el
b/packages/realgud/realgud/debugger/zshdb/init.el
new file mode 100644
index 0000000..e8bc9ff
--- /dev/null
+++ b/packages/realgud/realgud/debugger/zshdb/init.el
@@ -0,0 +1,90 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../../common/regexp"
+ "../../common/loc"
+ "../../common/init")
+ "realgud-")
+(require-relative-list '("../../lang/posix-shell") "realgud-lang-")
+
+(defvar realgud:zshdb-pat-hash)
+(declare-function make-realgud-loc-pat (realgud-loc))
+
+(defvar realgud:zshdb-pat-hash (make-hash-table :test 'equal)
+ "Hash key is the what kind of pattern we want to match:
+backtrace, prompt, etc. The values of a hash entry is a
+realgud-loc-pat struct")
+
+;; Regular expression that describes a zshdb location generally shown
+;; before a command prompt.
+;; For example:
+;; (/etc/init.d/apparmor:35):
+(setf (gethash "loc" realgud:zshdb-pat-hash) realgud:POSIX-debugger-loc-pat)
+
+;; Regular expression that describes a zshdb command prompt
+;; For example:
+;; zshdb<10>
+;; zshdb<(5)>
+;; zshdb<<1>>
+(setf (gethash "prompt" realgud:zshdb-pat-hash)
+ (make-realgud-loc-pat
+ :regexp (format "^zshdb[<]+[(]*%s[)]*[>]+ "
+ realgud:regexp-captured-num)
+ :num 1
+ ))
+
+;; Regular expression that describes a "breakpoint set" line.
+(setf (gethash "brkpt-set" realgud:zshdb-pat-hash)
+ realgud:POSIX-debugger-brkpt-set-pat)
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Removed 1 breakpoint(s).
+(setf (gethash "brkpt-del" realgud:zshdb-pat-hash)
+ realgud:POSIX-debugger-brkpt-del-pat)
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; ->0 in file `/etc/apparmor/fns' at line 24
+;; ##1 /etc/apparmor/fns called from file `/etc/init.d/apparmor' at line 35
+;; ##2 /etc/init.d/apparmor called from file `/usr/bin/zshdb' at line 129
+(setf (gethash "debugger-backtrace" realgud:zshdb-pat-hash)
+ realgud:POSIX-debugger-backtrace-pat)
+
+;; Regular expression that for a termination message.
+(setf (gethash "termination" realgud:zshdb-pat-hash)
+ "^zshdb: That's all, folks...\n")
+
+(setf (gethash "font-lock-keywords" realgud:zshdb-pat-hash)
+ realgud:POSIX-debugger-font-lock-keywords)
+
+(setf (gethash "zshdb" realgud-pat-hash) realgud:zshdb-pat-hash)
+
+(defvar realgud:zshdb-command-hash (make-hash-table :test 'equal)
+ "Hash key is command name like 'quit' and the value is
+ the zshdb command to use, like 'quit!'")
+
+(setf (gethash "zshdb" realgud-command-hash) realgud:zshdb-command-hash)
+
+(setf (gethash "clear" realgud:zshdb-command-hash) "clear %l")
+(setf (gethash "quit" realgud:zshdb-command-hash) "quit")
+(setf (gethash "until" realgud:zshdb-command-hash) "continue %l")
+
+(provide-me "realgud:zshdb-")
diff --git a/packages/realgud/realgud/debugger/zshdb/track-mode.el
b/packages/realgud/realgud/debugger/zshdb/track-mode.el
new file mode 100644
index 0000000..fa2ffe5
--- /dev/null
+++ b/packages/realgud/realgud/debugger/zshdb/track-mode.el
@@ -0,0 +1,63 @@
+;;; Copyright (C) 2012, 2014-2015 Rocky Bernstein <address@hidden>
+;;; "zshdb" Debugger tracking a comint buffer.
+
+(eval-when-compile (require 'cl))
+(require 'load-relative)
+(require-relative-list '(
+ "../../common/cmds"
+ "../../common/menu"
+ "../../common/track"
+ "../../common/track-mode"
+ )
+ "realgud-")
+(require-relative-list '("core" "init") "realgud:zshdb-")
+(require-relative "../../lang/posix-shell" nil "realgud-lang-")
+
+(declare-function realgud:cmd-remap 'realgud-cmds)
+(declare-function realgud:track-set-debugger 'realgud-track-mode)
+(declare-function realgud-track-mode-setup 'realgud-track-mode)
+(declare-function realgud-posix-shell-populate-command-keys
+ 'realgud-lang-posix-shell)
+
+(realgud-track-mode-vars "zshdb")
+(realgud-posix-shell-populate-command-keys zshdb-track-mode-map)
+
+(declare-function realgud-track-mode(bool))
+
+
+(defun zshdb-track-mode-hook()
+ (if zshdb-track-mode
+ (progn
+ (use-local-map zshdb-track-mode-map)
+ (message "using zshdb mode map")
+ )
+ (message "zshdb track-mode-hook disable called"))
+)
+
+(define-minor-mode zshdb-track-mode
+ "Minor mode for tracking zshdb source locations inside a process shell via
realgud. zshdb is a zsh debugger.
+
+If called interactively with no prefix argument, the mode is toggled. A prefix
argument, captured as ARG, enables the mode if the argument is positive, and
disables it otherwise.
+
+\\{zshdb-track-mode-map}
+"
+ :init-value nil
+ ;; :lighter " zshdb" ;; mode-line indicator from realgud-track is
sufficient.
+ ;; The minor mode bindings.
+ :global nil
+ :group 'realgud:zshdb
+ :keymap zshdb-track-mode-map
+
+ (realgud:track-set-debugger "zshdb")
+ (if zshdb-track-mode
+ (progn
+ (realgud-track-mode-setup 't)
+ (zshdb-track-mode-hook))
+ (progn
+ (setq realgud-track-mode nil)
+ ))
+)
+
+(define-key zshdb-short-key-mode-map "T" 'realgud:cmd-backtrace)
+
+(provide-me "realgud:zshdb-")
diff --git a/packages/realgud/realgud/debugger/zshdb/zshdb.el
b/packages/realgud/realgud/debugger/zshdb/zshdb.el
new file mode 100644
index 0000000..db02985
--- /dev/null
+++ b/packages/realgud/realgud/debugger/zshdb/zshdb.el
@@ -0,0 +1,72 @@
+;;; Copyright (C) 2011, 2014-2015 Rocky Bernstein <address@hidden>
+;; `zshdb' Main interface to zshdb via Emacs
+(require 'load-relative)
+(require-relative-list '("../../common/helper") "realgud-")
+(require-relative-list '("../../common/track") "realgud-")
+(require-relative-list '("../../common/run") "realgud:")
+(require-relative-list '("core" "track-mode") "realgud:zshdb-")
+
+(declare-function zshdb-track-mode (bool))
+(declare-function zshdb-query-cmdline 'realgud:zshdb-core)
+(declare-function zshdb-parse-cmd-args 'realgud:zshdb-core)
+
+;; This is needed, or at least the docstring part of it is needed to
+;; get the customization menu to work in Emacs 24.
+(defgroup realgud:zshdb nil
+ "The realgud interface to the Zsh debugger, zshdb"
+ :group 'realgud
+ :version "24.3")
+
+;; -------------------------------------------------------------------
+;; User definable variables
+;;
+
+(defcustom realgud:zshdb-command-name
+ ;;"zshdb --emacs 3"
+ "zshdb"
+ "File name for executing the zshdb and its command options.
+This should be an executable on your path, or an absolute file name."
+ :type 'string
+ :group 'realgud:zshdb)
+
+(declare-function zshdb-track-mode (bool))
+
+;; -------------------------------------------------------------------
+;; The end.
+;;
+
+(declare-function zshdb-track-mode 'realgud-zshdb-track-mode)
+(declare-function zshdb-query-cmdline 'realgud:zshdb-core)
+(declare-function zshdb-parse-cmd-args 'realgud:zshdb-core)
+(declare-function realgud:run-debugger 'realgud:run)
+
+; ### FIXME: DRY with other top-level routines
+;;;###autoload
+(defun realgud:zshdb (&optional opt-cmd-line no-reset)
+ "Invoke the zshdb Z-shell debugger and start the Emacs user interface.
+
+String OPT-CMD-LINE specifies how to run zshdb.
+
+OPT-CMD-LINE is treated like a shell string; arguments are
+tokenized by `split-string-and-unquote'. The tokenized string is
+parsed by `zshdb-parse-cmd-args' and path elements found by that
+are expanded using `realgud:expand-file-name-if-exists'.
+
+Normally, command buffers are reused when the same debugger is
+reinvoked inside a command buffer with a similar command. If we
+discover that the buffer has prior command-buffer information and
+NO-RESET is nil, then that information which may point into other
+buffers and source buffers which may contain marks and fringe or
+marginal icons is reset. See `loc-changes-clear-buffer' to clear
+fringe and marginal icons.
+"
+ (interactive)
+ (realgud:run-debugger realgud:zshdb-command-name 'zshdb-query-cmdline
+ 'zshdb-parse-cmd-args
+ 'realgud:zshdb-minibuffer-history
+ opt-cmd-line no-reset)
+ )
+
+(defalias 'zshdb 'realgud:zshdb)
+
+(provide-me "realgud-")
diff --git a/packages/realgud/realgud/lang/Makefile.am
b/packages/realgud/realgud/lang/Makefile.am
new file mode 100644
index 0000000..a6f5e4c
--- /dev/null
+++ b/packages/realgud/realgud/lang/Makefile.am
@@ -0,0 +1,5 @@
+lispdir = @lispdir_realgud@/$(notdir $(subdir))
+lisp_files := $(wildcard *.el)
+lisp_LISP = $(lisp_files)
+EXTRA_DIST = $(lisp_files)
+MOSTLYCLEANFILES = *.elc
diff --git a/packages/realgud/realgud/lang/js.el
b/packages/realgud/realgud/lang/js.el
new file mode 100644
index 0000000..faaf716
--- /dev/null
+++ b/packages/realgud/realgud/lang/js.el
@@ -0,0 +1,54 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../common/regexp" "../common/loc" "../common/track")
+ "realgud-")
+
+(defconst realgud:js-term-escape "[[0-9]+[GKJ]"
+ "Escape sequence regular expression pattern trepanjs often puts
+ in around prompts")
+
+(declare-function realgud-goto-line-for-pt 'realgud-track)
+
+;; Regular expression that describes a Perl Carp backtrace line.
+;; at /tmp/foo.pl line 7
+;; main::__ANON__('Illegal division by zero at /tmp/foo.pl line 4.\x{a}')
called at /tmp/foo.pl line 4
+;; main::foo(3) called at /tmp/foo.pl line 8
+(defconst realgud:js-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp (format "^\\(?:[\t ]+at \\)?\\([^:]+\\) (\\(.*\\):%s:%s)"
+ realgud:regexp-captured-num realgud:regexp-captured-num)
+ :file-group 2
+ :line-group 3
+ :char-offset-group 4)
+ "A realgud-loc-pat struct that describes a V8 backtrace location")
+
+(defun realgud:js-remove-ansi-schmutz()
+ "Remove ASCII escape sequences that node.js 'decorates' in
+prompts and interactive output with"
+ (interactive "")
+ (add-to-list
+ 'comint-preoutput-filter-functions
+ (lambda (output)
+ (replace-regexp-in-string "\033\\[[0-9]+[GKJ]" "" output)))
+ )
+
+
+(provide-me "realgud-lang-")
diff --git a/packages/realgud/realgud/lang/perl.el
b/packages/realgud/realgud/lang/perl.el
new file mode 100644
index 0000000..41a1760
--- /dev/null
+++ b/packages/realgud/realgud/lang/perl.el
@@ -0,0 +1,54 @@
+;;; Copyright (C) 2011, 2014 Rocky Bernstein <address@hidden>
+;;; Common Perl constants and regular expressions.
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../common/regexp" "../common/loc" "../common/track")
+ "realgud-")
+
+(declare-function realgud-goto-line-for-pt 'realgud-track)
+
+;; Regular expression that describes a Perl Carp backtrace line.
+;; at /tmp/foo.pl line 7
+;; main::__ANON__('Illegal division by zero at /tmp/foo.pl line 4.\x{a}')
called at /tmp/foo.pl line 4
+;; main::foo(3) called at /tmp/foo.pl line 8
+(defconst realgud-perl-carp-loc-pat
+ (make-realgud-loc-pat
+ :regexp (concat
+ "\\(?:^\\|
+\\)"
+ "\\(?:[ \t]+\\(?:\\|.* called \\)at \\(.*\\) line
\\([0-9]+\\)\\)")
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a line used in a Carp message" )
+
+(defconst realgud-perl-errmsg-loc-pat
+ (make-realgud-loc-pat
+ :regexp (concat
+ " at \\(.+\\) line \\([0-9]+\\).$")
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a line used in an error message" )
+
+;; Regular expression that pseudo-files in caller. For example:
+;; (eval 1006)[../example/eval.pl:5]
+(defconst realgud-perl-ignore-file-re "(eval [0-9]+)\\(\\[.+\\]\\)?"
+ "Regular expression that pseudo-files of caller()")
+
+;; FIXME: there is probably a less redundant way to do the following
+;; FNS.
+(defun realgud:perl-goto-errmsg-line (pt)
+ "Display the location mentioned by the Perl error message described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "perl-errmsg"))
+
+(defun realgud-perl-populate-command-keys (&optional map)
+ "Bind the debugger function key layout used by many debuggers.
+
+\\{realgud-example-map-standard}"
+ (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+ (define-key map (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+ (define-key map (kbd "C-c !e") 'realgud:perl-goto-errmsg-line)
+ )
+
+(provide-me "realgud-lang-")
diff --git a/packages/realgud/realgud/lang/posix-shell.el
b/packages/realgud/realgud/lang/posix-shell.el
new file mode 100644
index 0000000..54216c2
--- /dev/null
+++ b/packages/realgud/realgud/lang/posix-shell.el
@@ -0,0 +1,134 @@
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <address@hidden>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;
+;; Common POSIX-Shell like constants and regular expressions.
+;; Actually a lot of this is not about POSIX shell as it is about the
+;; common-ness of bashdb, zshdb, and kshdb. But since those are the
+;; *only* debuggers I know of for POSIX shells, it's not too much of
+;; a stretch to think of this as for all "shell".
+
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../common/regexp" "../common/loc"
+ "../common/track" "../common/send")
+ "realgud-")
+
+(defconst realgud-shell-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^[ \t]+from \\([^:]+\\):\\([0-9]+\\)\\(?: in `.*'\\)?"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Shell backtrace (or
+traceback) line." )
+
+(defconst realgud-shell-frame-start-regexp
+ "\\(?:^\\|\n\\)\\(->\\|##\\)")
+
+(defconst realgud-shell-frame-num-regexp
+ realgud:regexp-captured-num)
+
+(defconst realgud-shell-frame-file-regexp
+ "[ \t\n]+\\(?:in\\|from\\) file `\\(.+\\)'")
+
+(defconst realgud-shell-frame-line-regexp
+ (format "[ \t\n]+at line %s\\(?:\n\\|$\\)" realgud:regexp-captured-num))
+
+(defun realgud-posix-shell-populate-command-keys (&optional map)
+ "Bind the debugger function key layout used by many debuggers.
+
+\\{realgud-example-map-standard}"
+ (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+ (define-key map (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+ )
+
+;; Regular expression that describes a bashdb/zshdb location generally shown
+;; before a command prompt.
+;; For example:
+;; (/etc/init.d/apparmor:35):
+(defconst realgud:POSIX-debugger-loc-pat
+ (make-realgud-loc-pat
+ :regexp "\\(?:^\\|\n\\)(\\([^:]+\\):\\([0-9]*\\)):\\(?:\n\\(.+\\)\\)?"
+ :file-group 1
+ :line-group 2
+ :text-group 3)
+ "A realgud-loc-pat struct that describes a POSIX shell debugger
+ location line.")
+
+;; Regular expression that describes a debugger "backtrace" command line.
+;; For example:
+;; ->0 in file `/etc/apparmor/fns' at line 24
+;; ##1 /etc/apparmor/fns called from file `/etc/init.d/apparmor' at line 35
+;; ##2 /etc/init.d/apparmor called from file `/usr/bin/zshdb' at line 129
+(defconst realgud:POSIX-debugger-backtrace-pat
+ (make-realgud-loc-pat
+ :regexp (concat realgud-shell-frame-start-regexp
+ realgud-shell-frame-num-regexp "[ ]?"
+ "\\(.*\\)"
+ realgud-shell-frame-file-regexp
+ "\\(?:" realgud-shell-frame-line-regexp "\\)?"
+ )
+ :num 2
+ :file-group 4
+ :line-group 5)
+ "A realgud-loc-pat struct that describes a Python trepan
+ backtrace location line." )
+
+;; Regular expression that describes a "breakpoint set" line
+(defconst realgud:POSIX-debugger-brkpt-set-pat
+ (make-realgud-loc-pat
+ :regexp (format "^Breakpoint \\([0-9]+\\) set in file \\(.+\\), line %s.\n"
+ realgud:regexp-captured-num)
+ :num 1
+ :file-group 2
+ :line-group 3))
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+;; For example:
+;; Removed 1 breakpoint(s).
+(defconst realgud:POSIX-debugger-brkpt-del-pat
+ (make-realgud-loc-pat
+ :regexp (format "^Removed %s breakpoint(s).\n"
+ realgud:regexp-captured-num)
+ :num 1))
+
+(defconst realgud:POSIX-debugger-font-lock-keywords
+ '(
+ ;; The frame number and first type name, if present.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --^-
+ ("^\\(->\\|##\\)\\([0-9]+\\) "
+ (2 realgud-backtrace-number-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; ---------^^^^^^^^^^^^^^^^^^^^-
+ ("[ \t]+\\(in\\|from\\) file `\\(.+\\)'"
+ (2 realgud-file-name-face))
+
+ ;; File name.
+ ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
+ ;; --------^^
+ ;; Line number.
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+ ;; (trepan-frames-match-current-line
+ ;; (0 trepan-frames-current-frame-face append))
+ ))
+
+(provide-me "realgud-lang-")
diff --git a/packages/realgud/realgud/lang/python.el
b/packages/realgud/realgud/lang/python.el
new file mode 100644
index 0000000..e3ae1cf
--- /dev/null
+++ b/packages/realgud/realgud/lang/python.el
@@ -0,0 +1,144 @@
+;;; Copyright (C) 2011, 2014-2015 Rocky Bernstein <address@hidden>
+;;; Common Python constants and regular expressions.
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../common/regexp" "../common/loc" "../common/track")
+ "realgud-")
+
+(declare-function realgud-goto-line-for-pt 'realgud-track)
+
+(defconst realgud-python-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^[ \t]+File \"\\(.+\\)\", line \\([0-9]+\\)"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Python backtrace (or
+traceback) line." )
+
+;; Regular expression that pseudo-files in caller. For example:
+;; <string>
+(defconst realgud-python-ignore-file-re "<string>"
+ "Regular expression that pseudo-files of caller()")
+
+(defun realgud-python-populate-command-keys (&optional map)
+ "Bind the debugger function key layout used by many debuggers.
+
+\\{realgud-example-map-standard}"
+ (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+ (define-key map (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
+ (define-key map (kbd "C-c !e") 'realgud:pytest-goto-errmsg-line)
+ )
+
+
+;; Things common to the trepan Python debuggers
+
+(defconst realgud:python-trepan-frame-start-regexp
+ "\\(?:^\\|\n\\)\\(->\\|##\\)")
+
+(defconst realgud:python-trepan-frame-num-regexp
+ "\\([0-9]+\\)")
+
+;; Regular expression that describes a trepan2/3k location generally shown
+;; before a command prompt.
+;;
+;; For example:
+;; (/usr/bin/zonetab2pot.py:15 @10): <module>
+;; (/usr/bin/zonetab2pot.py:15 remapped <string>): <module>
+;; or MS Windows:
+;; (c:\\mydirectory\\gcd.py:10): <module>
+
+(defconst realgud:python-trepan-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^(\\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\
]+\\):\\([0-9]+\\)\\(?: @[0-9]+\\)?\\(?: remapped .*?\\)?):
\\(?:<module>\\)?\\(?:\n.. [0-9]+ \\(.*?\\)\n\\)?"
+ :file-group 1
+ :line-group 2
+ :text-group 3
+ :ignore-file-re realgud-python-ignore-file-re)
+ "A realgud-loc-pat struct that describes a Python trepan
+ location line." )
+
+;; Regular expression that describes a trepan2/3k backtrace line.
+;; For example:
+;; ->0 get_distribution(dist='trepan==0.3.9')
+;; called from file '/python2.7/dist-packages/pkg_res.py' at line 341
+;; ##1 load_entry_point(dist='tr=0.3.9', group='console_scripts', name='tr')
+;; called from file '/python2.7/dist-packages/pkg_res.py' at line 351
+;; ##2 <module> exec()
+
+(defconst realgud:python-trepan-backtrace-pat
+ (make-realgud-loc-pat
+ :regexp (concat
+ realgud:python-trepan-frame-start-regexp
+ realgud:python-trepan-frame-num-regexp "[ ]"
+ "\\(?:.*?)\\)\\(?:[\n\t ]+?\\)"
+ "\\(?:called from file \\)?'\\([^:]+?\\)' at line \\([0-9]+\\)")
+ :num 2
+ :file-group 3
+ :line-group 4
+ :ignore-file-re realgud-python-ignore-file-re)
+ "A realgud-loc-pat struct that describes a Python trepan
+ backtrace location line." )
+
+;; Regular expression that describes a "breakpoint set" line
+(defconst realgud:python-trepan-brkpt-set-pat
+ (make-realgud-loc-pat
+ :regexp "^Breakpoint \\([0-9]+\\) set at line \\([0-9]+\\)[ \t\n]+of file
\\(.+\\)\\(\n\\|$\\)"
+ :num 1
+ :file-group 3
+ :line-group 2))
+
+;; Regular expression that describes a debugger "delete" (breakpoint) response.
+(defconst realgud:python-trepan-brkpt-del-pat
+ (make-realgud-loc-pat
+ :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
+ :num 1))
+
+(defconst realgud:python-debugger-font-lock-keywords
+ '(
+ ;; The frame number and first type name, if present.
+ ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)?
*\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
+ (2 realgud-backtrace-number-face)
+ (4 font-lock-function-name-face nil t)) ; t means optional.
+
+ ;; Parameter sequence, E.g. gcd(a=3, b=5)
+ ;; ^^^^^^^^^
+ ("(\\(.+\\))"
+ (1 font-lock-variable-name-face))
+
+ ;; File name. E.g file '/test/gcd.py'
+ ;; ------^^^^^^^^^^^^-
+ ("[ \t]+file '\\([^ ]+*\\)'"
+ (1 realgud-file-name-face))
+
+ ;; Line number. E.g. at line 28
+ ;; ---------^^
+ ("[ \t]+at line \\([0-9]+\\)$"
+ (1 realgud-line-number-face))
+
+ ;; Function name.
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))
+ ;; (trepan2-frames-match-current-line
+ ;; (0 trepan2-frames-current-frame-face append))
+ ))
+
+(defconst realgud-pytest-error-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^\\(.*\\):\\([0-9]+\\): in "
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Pytest error line"
+ )
+
+
+;; FIXME: there is probably a less redundant way to do the following
+;; FNS.
+(defun realgud:pytest-goto-errmsg-line (pt)
+ "Display the location mentioned by the pytest error at PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "pytest-error"))
+
+
+(provide-me "realgud-lang-")
diff --git a/packages/realgud/realgud/lang/ruby.el
b/packages/realgud/realgud/lang/ruby.el
new file mode 100644
index 0000000..6c11cc4
--- /dev/null
+++ b/packages/realgud/realgud/lang/ruby.el
@@ -0,0 +1,125 @@
+;;; Copyright (C) 2010, 2014 Rocky Bernstein <address@hidden>
+;;; Common Ruby constants and regular expressions.
+(eval-when-compile (require 'cl))
+
+(require 'load-relative)
+(require-relative-list '("../common/regexp" "../common/loc" "../common/track")
+ "realgud-")
+
+(declare-function realgud-goto-line-for-pt 'realgud-track)
+
+(defconst realgud-rails-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^\\([^:]+\\):\\([0-9]+\\)\\(?:[:]in `.*'\\)?"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Rails backtrace (or
+traceback) line." )
+
+(defconst realgud-rspec-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^[ ]*# \\([^:]+\\):\\([0-9]+\\)\\(?:[:]in `.*'\\)?"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes an rspec backtrace (or
+traceback) line." )
+
+;; Regular expression that describes a Ruby YARV 1.9 syntax error line.
+;; SyntaxError: /tmp/columnize.rb:270: syntax error, unexpected $end, ...
+(defconst realgud-ruby-YARV-syntax-error-pat
+ (make-realgud-loc-pat
+ :regexp "^SyntaxError: \\([^:]+\\):\\([0-9]+\\): syntax error"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Ruby YARV syntax error message")
+
+(defconst realgud-ruby-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^[ \t]+from \\([^:]+\\):\\([0-9]+\\)\\(?: in `.*'\\)?"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Ruby backtrace (or
+traceback) line." )
+
+(defconst realgud-rubinius-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^\\(?:\\[0;3[1-4]m\\)?[ \t]+.* at \\([^:]+\\):\\([0-9]+\\)"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Rubinius backtrace (or
+traceback) line." )
+
+(defconst realgud-rubinius-Xagent-backtrace-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^\\(?:\\[0;3[1-4]m\\)?0x[a-f0-9]\\{8\\}: .* in
\\([^:]+\\):\\([0-9]+\\) ([+][0-9]+)"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat struct that describes a Rubinius Xagent backtrace (or
+traceback) line." )
+
+(defconst realgud-ruby-dollar-bang-loc-pat
+ (make-realgud-loc-pat
+ :regexp "^[ \t]*[[]?\\(.+\\):\\([0-9]+\\):in `.*'"
+ :file-group 1
+ :line-group 2)
+ "A realgud-loc-pat that struct that describes a Ruby $! string."
+)
+
+;; FIXME: there is probably a less redundant way to do the following
+;; FNS.
+(defun realgud:rails-goto-backtrace-line (pt)
+ "Display the location mentioned by the Rails backtrace line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "rails-backtrace"))
+
+;; FIXME: there is probably a less redundant way to do the following
+;; FNS.
+(defun realgud:rspec-goto-backtrace-line (pt)
+ "Display the location mentioned by the Rails backtrace line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "rspec-backtrace"))
+
+(defun realgud:rubinius-goto-Xagent-backtrace-line (pt)
+ "Display the location mentioned by the Rubinius Xagent- backtrace line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "rubinius-backtrace-Xagent"))
+
+(defun realgud:ruby-goto-backtrace-line (pt)
+ "Display the location mentioned by the Ruby backtrace line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "lang-backtrace"))
+
+(defun realgud:ruby-goto-dollar-bang-line (pt)
+ "Display the location mentioned by the Ruby backtrace line
+described by PT."
+ (interactive "d")
+ (realgud-goto-line-for-pt pt "dollar-bang-backtrace"))
+
+(defun realgud:ruby-populate-command-keys (&optional map)
+ "Bind the debugger function key layout used by many debuggers.
+
+\\{realgud-example-map-standard}"
+ (define-key map (kbd "C-c !l") 'realgud:goto-lang-backtrace-line)
+ (define-key map (kbd "C-c !!") 'realgud:ruby-goto-dollar-bang-line)
+ (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
+ (define-key map (kbd "C-c !r") 'realgud:rails-goto-backtrace-line)
+ (define-key map (kbd "C-c !s") 'realgud:rspec-goto-backtrace-line)
+ )
+
+
+;; Some things common to all trepan debuggers (Rubinius and Ruby 1.9.2)
+(defconst realgud:trepan-frame-start-regexp
+ "\\(?:^\\|\n\\)\\(-->\\| \\)")
+
+(defconst realgud:trepan-frame-num-regexp
+ "#\\([0-9]+\\)")
+
+(defconst realgud:trepan-frame-line-regexp
+ "[ \t\n]+at line \\([0-9]+\\)\\(?:\n\\|$\\)")
+
+
+(provide-me "realgud-lang-")
diff --git a/packages/realgud/test/.gitignore b/packages/realgud/test/.gitignore
new file mode 100644
index 0000000..b616aaf
--- /dev/null
+++ b/packages/realgud/test/.gitignore
@@ -0,0 +1,5 @@
+/*.elc
+/*~
+/HelloWorld.class
+/Makefile
+/Makefile.in
diff --git a/packages/realgud/test/HelloWorld.java
b/packages/realgud/test/HelloWorld.java
new file mode 100644
index 0000000..27a5485
--- /dev/null
+++ b/packages/realgud/test/HelloWorld.java
@@ -0,0 +1,6 @@
+public class HelloWorld {
+ public static void main(String[] args) {
+ String msg = "Hello, World!";
+ System.out.println(msg); // Display the string.
+ }
+}
diff --git a/packages/realgud/test/Makefile.am
b/packages/realgud/test/Makefile.am
new file mode 100644
index 0000000..c0e7ede
--- /dev/null
+++ b/packages/realgud/test/Makefile.am
@@ -0,0 +1,69 @@
+include $(top_srcdir)/common.mk
+
+PHONY=check test all check-elget test-elget help
+EXTRA_DIST += gcd.py gcd.rb gdb
+
+#: overall help on running the make targets
+help:
+ @echo "The main function of this Makefile is to facilitate running
tests."
+ @echo
+ @echo "To run all of the tests, use targets \"test\", \"check\" or
\"check-short\"."
+ @echo "For example:"
+ @echo
+ @echo " make check"
+ @echo "or:"
+ @echo " make check-short"
+ @echo
+ @echo "The -short target uses a filter written in Ruby to remove
extreanous output."
+ @echo
+ @echo "To run a specific test like test-srcbuf.el, change \".el\" to"
+ @echo "\".run\". For example:"
+ @echo
+ @echo " make test-srcbuf.run"
+ @echo
+ @echo "Tests can also be run via the Emacs el-get package and this
loads dependent emacs "
+ @echo "package, like load-relative. To do this, use targets,
\"check-elget\","
+ @echo "\"test-elget\", or \"check-short-elget\"."
+ @echo
+ @echo "To run a specific test like test-srcbuf.el via el-get change
\".el\""
+ @echo "to \".elrun\" For example:"
+ @echo
+ @echo " make test-srcbuf.elrun"
+
+
+#: same thing as "check"
+test: check
+
+#: same thing as "check-elget"
+test-elget: check-elget
+
+test_files := $(wildcard test-*.el)
+
+CHECK_FILES = $(notdir $(test_files:.el=.run))
+EL_GET_CHECK_FILES = $(notdir $(test_files:.el=.elrun))
+
+#: Run all tests
+check: $(CHECK_FILES)
+
+#: Run all tests via el-get
+check-elget: $(EL_GET_CHECK_FILES)
+
+#: Run all tests with minimum verbosity
+check-short:
+ $(MAKE) check 2>&1 | ruby ../make-check-filter.rb
+
+#: Run all tests with minimum verbosity via el-get
+check-short-elget:
+ $(MAKE) check-elget 2>&1 | ruby ../make-check-filter.rb
+
+test-%.run:
+ (cd $(top_srcdir)/test && $(EMACS) --batch --no-site-file --no-splash
--load $(@:.run=.el))
+
+#: Run tests using el-get to specify external Lisp dependencies
+test-%.elrun:
+ (cd $(top_srcdir)/test && $(EMACS) --batch --no-site-file --no-splash
--load ../el-get-install.el --load $(@:.elrun=.el))
+
+# Whatever it is you want to do, it should be forwarded to the
+# to top-level directories
+# %:
+# $(MAKE) -C .. $@
diff --git a/packages/realgud/test/bt-helper.el
b/packages/realgud/test/bt-helper.el
new file mode 100644
index 0000000..5236a55
--- /dev/null
+++ b/packages/realgud/test/bt-helper.el
@@ -0,0 +1,48 @@
+(require 'test-simple)
+(require 'font-lock)
+
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/common/buffer/backtrace.el")
+(load-file "../realgud/common/backtrace-mode.el")
+
+(declare-function realgud-backtrace-mode 'realgud-backtrace-mode)
+(declare-function realgud-cmdbuf-init 'realgud-buffer-command)
+
+(eval-when-compile
+ (defvar temp-cmdbuf)
+ (defvar temp-bt)
+ (defvar realgud-pat-hash)
+)
+
+(defun setup-bt-vars(debugger-name)
+ "Sets up globals temp-cmdbuf and temp-bt with command buffer
+for DEBUGGER-NAME"
+ (setq temp-cmdbuf (generate-new-buffer "*cmdbuf-test*"))
+ (setq temp-bt (generate-new-buffer "*bt-test*"))
+ (with-current-buffer temp-cmdbuf
+ (switch-to-buffer temp-cmdbuf)
+ (realgud-cmdbuf-init temp-cmdbuf debugger-name
+ (gethash debugger-name realgud-pat-hash))
+
+ (switch-to-buffer nil)
+ ))
+
+
+(defun setup-bt(debugger-name string)
+ "Sets up globals temp-cmdbuf and temp-bt with command buffer
+for DEBUGGER-NAME and initializes it to STRING"
+ (setup-bt-vars debugger-name)
+ (with-current-buffer temp-bt
+ (realgud-backtrace-mode temp-cmdbuf)
+ (goto-char (point-min))
+ (setq buffer-read-only nil)
+ (insert string)
+ (font-lock-fontify-buffer)
+ ;; Newer emacs's use:
+ ;; (font-lock-ensure)
+ (goto-char (point-min))
+ )
+ temp-bt
+)
+
+(provide 'realgud-bt-helper)
diff --git a/packages/realgud/test/gcd.js b/packages/realgud/test/gcd.js
new file mode 100644
index 0000000..ee56555
--- /dev/null
+++ b/packages/realgud/test/gcd.js
@@ -0,0 +1,45 @@
+//!/usr/bin/env node
+var util = require("util");
+require("console");
+
+function ask(question, format, callback) {
+ var stdin = process.stdin, stdout = process.stdout;
+
+ stdin.resume();
+ stdout.write(question + ": ");
+
+ stdin.once('data', function(data) {
+ data = data.toString().trim();
+
+ if (format.test(data)) {
+ callback(data);
+ } else {
+ stdout.write("It should match: "+ format +"\n");
+ ask(question, format, callback);
+ }
+ });
+}
+
+// GCD. We assume positive numbers
+function gcd(a, b) {
+ // Make: a <= b
+ if (a > b) {
+ var temp = a;
+ a = b;
+ b = temp;
+ }
+
+ if (a <= 0) { return null };
+
+ if (a == 1 || b-a == 0) {
+ return a;
+ }
+ return gcd(b-a, a);
+}
+
+var a = parseInt(process.argv[0]) || 24,
+ b = parseInt(process.argv[0]) || 5;
+
+console.log(util.format("The GCD of %d and %d is %d", a, b,
+ gcd(a, b)));
+process.exit();
diff --git a/packages/realgud/test/gcd.pl b/packages/realgud/test/gcd.pl
new file mode 100644
index 0000000..df476a8
--- /dev/null
+++ b/packages/realgud/test/gcd.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+# GCD. We assume positive numbers
+sub gcd($$);
+sub gcd($$)
+{
+ my ($a, $b) = @_;
+ # Make: a <= b
+ ($a, $b) = ($b, $a) if ($a > $b);
+
+ return undef if $a <= 0;
+ return $a if ($a == 1) or ($b-$a == 0);
+ return gcd($b-$a, $a);
+}
+
+die sprintf "Need two integer arguments, got %d", scalar(@ARGV) unless
+ @ARGV == 2;
+my ($a, $b) = @ARGV[0,1];
+printf "The GCD of %d and %d is %d\n", $a, $b, gcd($a, $b);
diff --git a/packages/realgud/test/gcd.py b/packages/realgud/test/gcd.py
new file mode 100755
index 0000000..e64f284
--- /dev/null
+++ b/packages/realgud/test/gcd.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+"""Greatest Common Divisor
+
+Some characterstics of this program used for testing check_args() does
+not have a 'return' statement.
+
+check_args() raises an uncaught exception when given the wrong number
+of parameters.
+
+"""
+import sys
+
+def check_args():
+ if len(sys.argv) != 3:
+ # Rather than use sys.exit let's just raise an error
+ raise Exception("Need to give two numbers")
+ for i in range(2):
+ try:
+ sys.argv[i+1] = int(sys.argv[i+1])
+ except ValueError:
+ print("** Expecting an integer, got: %s" % repr(sys.argv[i]))
+ sys.exit(2)
+
+def gcd(a,b):
+ """ GCD. We assume positive numbers"""
+
+ # Make: a <= b
+ if a > b:
+ (a, b) = (b, a)
+
+ if a <= 0:
+ return None
+ if a == 1 or b-a == 0:
+ return a
+ return gcd(b-a, a)
+
+if __name__=='__main__':
+ check_args()
+
+ (a, b) = sys.argv[1:3]
+ print("The GCD of %d and %d is %d" % (a, b, gcd(a, b)))
diff --git a/packages/realgud/test/gcd.rb b/packages/realgud/test/gcd.rb
new file mode 100755
index 0000000..c780a31
--- /dev/null
+++ b/packages/realgud/test/gcd.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+# GCD. We assume positive numbers
+def gcd(a, b)
+ # Make: a <= b
+ if a > b
+ a, b = [b, a]
+ end
+
+ return nil if a <= 0
+
+ if a == 1 or b-a == 0
+ return a
+ end
+ return gcd(b-a, a)
+end
+
+a, b = ARGV[0..1].map {|arg| arg.to_i}
+puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
diff --git a/packages/realgud/test/gcd.sh b/packages/realgud/test/gcd.sh
new file mode 100755
index 0000000..497f33b
--- /dev/null
+++ b/packages/realgud/test/gcd.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Greatest Common Divisor in POSIX shell using Euclid's algorithm. On
+# return, variable gcd_value is set and is the gcd of parameters $1
+# and $2. The GCD of a negative number is the same as the GCD of its
+# absolute value, since a negative number is -1 times its positive
+# value. Negative numbers are set when there is an error; -1 is set
+# when the wrong number of parameters are given.
+gcd() {
+ typeset -i a=$1
+ typeset -i b=$2
+ if (( a > b )) ; then
+ a=$b
+ b=$1
+ fi
+ if (( a == 1 || (b-a) == 0)) ; then
+ gcd_value=$a
+ return 0
+ fi
+ typeset -i c
+ ((c=b-a))
+ gcd $c $a
+}
+
+gcd $1 $2
+echo $gcd_value
diff --git a/packages/realgud/test/gdb/bar.sh b/packages/realgud/test/gdb/bar.sh
new file mode 100755
index 0000000..6c961d1
--- /dev/null
+++ b/packages/realgud/test/gdb/bar.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo This Should get selected 3rd
diff --git a/packages/realgud/test/gdb/baz b/packages/realgud/test/gdb/baz
new file mode 100755
index 0000000..e69de29
diff --git a/packages/realgud/test/gdb/baz.c b/packages/realgud/test/gdb/baz.c
new file mode 100644
index 0000000..e69de29
diff --git a/packages/realgud/test/gdb/foo b/packages/realgud/test/gdb/foo
new file mode 100755
index 0000000..e69de29
diff --git a/packages/realgud/test/gdb/foo.c b/packages/realgud/test/gdb/foo.c
new file mode 100644
index 0000000..e69de29
diff --git a/packages/realgud/test/gdb/test2/bar.sh
b/packages/realgud/test/gdb/test2/bar.sh
new file mode 100755
index 0000000..6c961d1
--- /dev/null
+++ b/packages/realgud/test/gdb/test2/bar.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo This Should get selected 3rd
diff --git a/packages/realgud/test/gdb/test2/baz.c
b/packages/realgud/test/gdb/test2/baz.c
new file mode 100644
index 0000000..e69de29
diff --git a/packages/realgud/test/make-check-filter.rb
b/packages/realgud/test/make-check-filter.rb
new file mode 100644
index 0000000..508c8f6
--- /dev/null
+++ b/packages/realgud/test/make-check-filter.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+# Use this to cut out the crud from make check.
+# Use like this:
+# make check 2>&1 | ruby ../make-check-filter.rb
+# See Makefile.am
+pats = ["^(?:Loading",
+ '(re)?make\[',
+ "Making check in",
+ '\(cd \.\.',
+ "make -C",
+ "Test-Unit",
+ "Fontifying",
+ "`flet'",
+ '\s*$',
+ '##[<>]+$'
+ ].join('|') + ')'
+# puts pats
+skip_re = /#{pats}/
+
+while gets()
+ next if $_.encode!('UTF-8', 'binary',
+ invalid: :replace, undef: :replace, replace: '') =~
skip_re
+ puts $_
+end
diff --git a/packages/realgud/test/node_modules/gcd.js/gcd.js
b/packages/realgud/test/node_modules/gcd.js/gcd.js
new file mode 100644
index 0000000..6d7ce32
--- /dev/null
+++ b/packages/realgud/test/node_modules/gcd.js/gcd.js
@@ -0,0 +1,47 @@
+//!/usr/bin/env node
+var util = require("util");
+require("console");
+
+function ask(question, format, callback) {
+ var stdin = process.stdin, stdout = process.stdout;
+
+ stdin.resume();
+ stdout.write(question + ": ");
+
+ stdin.once('data', function(data) {
+ data = data.toString().trim();
+
+ if (format.test(data)) {
+ callback(data);
+ } else {
+ stdout.write("It should match: "+ format +"\n");
+ ask(question, format, callback);
+ }
+ });
+}
+
+// GCD. We assume positive numbers
+function gcd(a, b) {
+ // Make: a <= b
+ if (a > b) {
+ var temp = a;
+ a = b;
+ b = temp;
+ }
+
+ if (a <= 0) { return null };
+
+ if (a == 1 || b-a == 0) {
+ return a;
+ }
+ return gcd(b-a, a);
+}
+
+var a=24;
+
+ask("GCD of 24 and", /^\d+$/, function(b_str) {
+ var b = parseInt(b_str, 10);
+ console.log(util.format("The GCD of %d and %d is %d", a, b,
+ gcd(a, b)));
+ process.exit();
+});
diff --git a/packages/realgud/test/node_modules/gcd.js/package.json
b/packages/realgud/test/node_modules/gcd.js/package.json
new file mode 100644
index 0000000..06a4cee
--- /dev/null
+++ b/packages/realgud/test/node_modules/gcd.js/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "emacs-dbgr",
+ "private": false,
+ "version": "1.0.0",
+ "description": "Debugging is going to be realgud.",
+ "repository": "https://github.com/rocky/emacs-dbgr",
+ "dependencies": {},
+ "devDependencies": {},
+ "scripts": {
+ "start": "node --debug gcd.js"
+ }
+}
diff --git a/packages/realgud/test/regexp-helper.el
b/packages/realgud/test/regexp-helper.el
new file mode 100644
index 0000000..01dc7d2
--- /dev/null
+++ b/packages/realgud/test/regexp-helper.el
@@ -0,0 +1,50 @@
+(require 'test-simple)
+(load-file "../realgud/common/buffer/command.el")
+
+(eval-when-compile
+ (defvar helper-bps)
+ (defvar helper-loc)
+ (defvar helper-tb)
+ (defvar prompt-pat)
+)
+
+(declare-function realgud-loc-pat-regexp 'realgud-backtrace-mode)
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function test-simple-start 'test-simple)
+
+
+(defun setup-regexp-vars(pat-hash)
+ (setq helper-bps (gethash "brkpt-set" pat-hash))
+ (setq helper-loc (gethash "loc" pat-hash))
+ (setq helper-tb (gethash "lang-backtrace" pat-hash))
+)
+
+(defun loc-match(text var)
+ "Match TEXT against regexp field VAR"
+ (string-match (realgud-loc-pat-regexp var) text)
+)
+
+(defun bp-loc-match(text)
+ (string-match (realgud-loc-pat-regexp helper-bps) text)
+)
+
+(defun tb-loc-match(text)
+ (string-match (realgud-loc-pat-regexp helper-tb) text)
+)
+
+(defun cmdbuf-loc-match(text dbgr)
+ "Match TEXT against cmdbuf-info-loc field VAR"
+ (string-match (realgud-cmdbuf-info-loc-regexp dbgr) text)
+ )
+
+(defun prompt-match(prompt-str &optional num-str fmt-str)
+ (unless fmt-str (setq fmt-str "debugger prompt %s"))
+ (assert-equal 0 (string-match (realgud-loc-pat-regexp prompt-pat)
+ prompt-str)
+ (format fmt-str prompt-str))
+ (cond (num-str
+ (assert-equal num-str (substring prompt-str
+ (match-beginning 1) (match-end 1))))
+ ('t 't))
+ )
+(provide 'realgud-regexp-helper)
diff --git a/packages/realgud/test/test-bashdb.el
b/packages/realgud/test/test-bashdb.el
new file mode 100644
index 0000000..6dac5ad
--- /dev/null
+++ b/packages/realgud/test/test-bashdb.el
@@ -0,0 +1,60 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/debugger/bashdb/bashdb.el")
+(load-file "../realgud/debugger/bashdb/core.el")
+(load-file "../realgud/common/core.el")
+(load-file "../realgud/common/lang.el")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+
+(eval-when-compile
+ (defvar test:run-process-save)
+ (defvar realgud:bashdb-minibuffer-history)
+ )
+
+(declare-function bashdb-parse-cmd-args 'realgud:bashdb)
+(declare-function bashdb-suggest-invocation 'realgud:bzshdb)
+(declare-function realgud:bashdb 'realgud:bashdb)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+(make-local-variable 'realgud:bashdb-minibuffer-history)
+(setq realgud:bashdb-minibuffer-history nil)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:run-process-save (symbol-function 'realgud:run-process))
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuf-history
+ &optional no-reset)
+ "Fake realgud:run-process used in testing"
+ (note
+ (format "%s %s %s" debugger-name script-filename cmd-args))
+ (assert-equal "bashdb" debugger-name "debugger name gets passed")
+ (let ((expanded-name
+ (realgud:expand-file-name-if-exists "./gcd.sh")))
+ (assert-equal expanded-name script-filename "file name check")
+ (assert-equal (list "-l" (expand-file-name ".") expanded-name "3" "5")
+ (cdr cmd-args) "command args listified")
+ ))
+
+(note "bashdb-parse-cmd-args")
+(assert-equal (list nil '("bashdb")
+ (list (realgud:expand-file-name-if-exists "foo")) nil)
+ (bashdb-parse-cmd-args '("bashdb" "foo")))
+(assert-equal (list nil '("bashdb")
+ (list (realgud:expand-file-name-if-exists "program.sh")
+ "foo") nil)
+ (bashdb-parse-cmd-args
+ '("bashdb" "program.sh" "foo")))
+(with-current-buffer (find-file "gcd.sh")
+ (shell-script-mode)
+ (assert-matches "bashdb .*gcd.sh$" (bashdb-suggest-invocation "bashdb")))
+
+(realgud:bashdb "bashdb -l . ./gcd.sh 3 5")
+;; Restore the old value of realgud:run-process
+(fset 'realgud:run-process test:run-process-save)
+
+(end-tests)
diff --git a/packages/realgud/test/test-bp.el b/packages/realgud/test/test-bp.el
new file mode 100644
index 0000000..ae6047e
--- /dev/null
+++ b/packages/realgud/test/test-bp.el
@@ -0,0 +1,59 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/common/bp.el")
+(declare-function realgud-bp-remove-icons 'realgud-bp)
+
+(eval-when-compile
+ (defvar temp-srcbuf)
+)
+
+
+(test-simple-start)
+
+(note "breakpoints")
+
+(set (make-local-variable 'temp-srcbuf)
+ (generate-new-buffer "*srcbuf-test*"))
+(with-current-buffer temp-srcbuf
+ (insert "abc\ndef\n")
+ (note "breakpoint reset")
+ (realgud-bp-remove-icons (point-min) (point-max))
+ (assert-equal 0 (length (overlays-in (point-min) (point-max)))
+ "Should not have any breakpoints in buffer")
+ )
+ ;; (note "breakpoint set")
+ ;; (realgud-bp-put-icon (point-min) 't 1 temp-srcbuf)
+ ;; (realgud-bp-put-icon (point-max) nil 2 temp-srcbuf)
+ ;; (assert-equal 2 (length (overlays-in (point-min) (point-max)))
+ ;; (format
+ ;; "Should find breakpoints in buffer %s"
+ ;; temp-srcbuf))
+ ;; (let* ((ov-list (overlays-in (point-min) (point-min)))
+ ;; (ov (car-safe ov-list))
+ ;; (before-string)
+ ;; )
+ ;; (assert-equal 1 (length ov-list)
+ ;; "Should find 1 breakpoint at (point-min)")
+ ;; (setq before-string (overlay-get ov 'before-string))
+ ;; (assert-equal 1 (get-text-property 0 'realgud-bptno before-string)
+ ;; "Should find breakpoint number 1 in overlay's before-string")
+ ;; (assert-equal t (get-text-property 0 'enabled before-string)
+ ;; "Breakpoint 1 should be enabled")
+ ;; )
+ ;; (let* ((ov-list (overlays-in (point-max) (point-max)))
+ ;; (ov (car-safe ov-list))
+ ;; (before-string)
+ ;; )
+ ;; (assert-equal 1 (length ov-list)
+ ;; "Should find 1 breakpoint at (point-max)")
+ ;; (setq before-string (overlay-get ov 'before-string))
+ ;; (assert-equal 2 (get-text-property 0 'realgud-bptno before-string)
+ ;; "Should find breakpoint number 1 in overlay's before-string")
+ ;; (assert-equal nil (get-text-property 0 'enabled before-string)
+ ;; "Breakpoint 1 should be disabled")
+ ;; )
+
+(end-tests)
diff --git a/packages/realgud/test/test-bt-pdb.el
b/packages/realgud/test/test-bt-pdb.el
new file mode 100644
index 0000000..e5ee8a8
--- /dev/null
+++ b/packages/realgud/test/test-bt-pdb.el
@@ -0,0 +1,45 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./bt-helper.el")
+(load-file "../realgud/debugger/pdb/init.el")
+
+(declare-function setup-bt 'realgud-bt-helper)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-bt)
+)
+
+
+(setq temp-bt
+ (setup-bt "pdb"
+ "->0 gcd(a=3, b=5) called from file '/test/gcd.py' at line 28
+##1 <module> execfile() file '/test/gcd.py' at line 41
+"))
+
+(with-current-buffer temp-bt
+ (switch-to-buffer temp-bt)
+ (goto-char (point-min))
+ (dolist (pair
+ '(
+ ("->" . realgud-backtrace-number )
+ ("gc" . font-lock-function-name-face )
+ ("(" . font-lock-variable-name-face )
+ ("/test" . realgud-file-name)
+ ("2" . realgud-line-number)
+ ("##" . realgud-backtrace-number)
+ ("/test" . realgud-file-name)
+ ("4" . realgud-line-number)
+ ))
+ (search-forward (car pair))
+ (assert-eql (cdr pair)
+ (get-text-property (point) 'face))
+ )
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-bt-rdebug.el
b/packages/realgud/test/test-bt-rdebug.el
new file mode 100644
index 0000000..f3c4d25
--- /dev/null
+++ b/packages/realgud/test/test-bt-rdebug.el
@@ -0,0 +1,47 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./bt-helper.el")
+(load-file "../realgud/debugger/rdebug/init.el")
+
+(declare-function setup-bt 'realgud-bt-helper)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-bt)
+)
+
+(setq temp-bt
+ (setup-bt "rdebug"
+ "--> #0 Object.gcd(a#Fixnum, b#Fixnum)
+ at line /test/gcd.rb:6
+ #1 at line /test/gcd.rb:19
+"))
+
+(with-current-buffer temp-bt
+ (switch-to-buffer temp-bt)
+ (goto-char (point-min))
+ (dolist (pair
+ '(
+ ("#" . realgud-backtrace-number )
+ ("Objec" . font-lock-constant-face )
+ ("gc" . font-lock-function-name-face )
+ ("(" . font-lock-variable-name-face )
+ ("Fixnu" . font-lock-constant-face )
+ ("/test" . realgud-file-name)
+ (":" . realgud-line-number)
+ ("#" . realgud-backtrace-number)
+ ("/test" . realgud-file-name)
+ (":" . realgud-line-number)
+ ))
+ (search-forward (car pair))
+ (assert-equal (cdr pair)
+ (get-text-property (point) 'face))
+ )
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-bt-trepan.el
b/packages/realgud/test/test-bt-trepan.el
new file mode 100644
index 0000000..0bc5e6e
--- /dev/null
+++ b/packages/realgud/test/test-bt-trepan.el
@@ -0,0 +1,49 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./bt-helper.el")
+(load-file "../realgud/debugger/trepan/init.el")
+
+(declare-function setup-bt 'realgud-bt-helper)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-bt)
+)
+
+(setq temp-bt
+ (setup-bt "trepan"
+ "--> #0 METHOD Object#gcd(a, b) in file /test/gcd.rb at line 4
+ #1 TOP Object#<top /gcd.rb> in file /test/gcd.rb
+ at line 19
+"))
+
+(with-current-buffer temp-bt
+ (switch-to-buffer temp-bt)
+ (goto-char (point-min))
+ (dolist (pair
+ '(
+ ("#" . realgud-backtrace-number )
+ ("METHO" . font-lock-keyword-face )
+ ("Objec" . font-lock-constant-face )
+ ("#" . font-lock-function-name-face )
+ ("(" . font-lock-variable-name-face )
+ ("/test" . realgud-file-name)
+ ("line " . realgud-line-number)
+ ("#" . realgud-backtrace-number)
+ ("Objec" . font-lock-constant-face )
+ ("<top" . font-lock-variable-name-face)
+ ("/test" . realgud-file-name)
+ ("line " . realgud-line-number)
+ ))
+ (search-forward (car pair))
+ (assert-equal (cdr pair)
+ (get-text-property (point) 'face))
+ )
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-bt-trepan2.el
b/packages/realgud/test/test-bt-trepan2.el
new file mode 100644
index 0000000..d3d3d0f
--- /dev/null
+++ b/packages/realgud/test/test-bt-trepan2.el
@@ -0,0 +1,43 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./bt-helper.el")
+(load-file "../realgud/debugger/trepan2/init.el")
+
+(declare-function setup-bt 'realgud-bt-helper)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-bt)
+)
+
+(setq temp-bt
+ (setup-bt "trepan2"
+ "->0 gcd(a=3, b=5) called from file '/test/gcd.py' at line 28
+##1 <module> execfile() file '/test/gcd.py' at line 41
+"))
+
+(with-current-buffer temp-bt
+ (switch-to-buffer temp-bt)
+ (goto-char (point-min))
+ (dolist (pair
+ '(
+ ("->" . realgud-backtrace-number )
+ ("gc" . font-lock-function-name-face )
+ ("(" . font-lock-variable-name-face )
+ ("/test" . realgud-file-name)
+ ("2" . realgud-line-number)
+ ("##" . realgud-backtrace-number)
+ ("/test" . realgud-file-name)
+ ("4" . realgud-line-number)
+ ))
+ (search-forward (car pair))
+ (assert-equal (cdr pair)
+ (get-text-property (point) 'face))
+ )
+ )
+(end-tests)
diff --git a/packages/realgud/test/test-bt-trepan3k.el
b/packages/realgud/test/test-bt-trepan3k.el
new file mode 100644
index 0000000..d3d3d0f
--- /dev/null
+++ b/packages/realgud/test/test-bt-trepan3k.el
@@ -0,0 +1,43 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./bt-helper.el")
+(load-file "../realgud/debugger/trepan2/init.el")
+
+(declare-function setup-bt 'realgud-bt-helper)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-bt)
+)
+
+(setq temp-bt
+ (setup-bt "trepan2"
+ "->0 gcd(a=3, b=5) called from file '/test/gcd.py' at line 28
+##1 <module> execfile() file '/test/gcd.py' at line 41
+"))
+
+(with-current-buffer temp-bt
+ (switch-to-buffer temp-bt)
+ (goto-char (point-min))
+ (dolist (pair
+ '(
+ ("->" . realgud-backtrace-number )
+ ("gc" . font-lock-function-name-face )
+ ("(" . font-lock-variable-name-face )
+ ("/test" . realgud-file-name)
+ ("2" . realgud-line-number)
+ ("##" . realgud-backtrace-number)
+ ("/test" . realgud-file-name)
+ ("4" . realgud-line-number)
+ ))
+ (search-forward (car pair))
+ (assert-equal (cdr pair)
+ (get-text-property (point) 'face))
+ )
+ )
+(end-tests)
diff --git a/packages/realgud/test/test-bt-zshdb.el
b/packages/realgud/test/test-bt-zshdb.el
new file mode 100644
index 0000000..fdbc2e7
--- /dev/null
+++ b/packages/realgud/test/test-bt-zshdb.el
@@ -0,0 +1,38 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./bt-helper.el")
+(load-file "../realgud/debugger/zshdb/init.el")
+
+(declare-function setup-bt 'realgud-bt-helper)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-bt)
+)
+
+(setq temp-bt
+ (setup-bt "zshdb"
+ "->0 in file `/test/autogen.sh' at line 2
+##1 /test/autogen.sh called from file `/usr/local/bin/zshdb' at line 121
+"))
+(with-current-buffer temp-bt
+ (switch-to-buffer temp-bt)
+ (goto-char (point-min))
+ (dolist (pair
+ '(
+ ("->" . realgud-backtrace-number )
+ ("/test" . realgud-file-name)
+ ("line " . realgud-line-number)
+ ))
+ (search-forward (car pair))
+ (assert-equal (cdr pair)
+ (get-text-property (point) 'face))
+ )
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-buf-bt.el
b/packages/realgud/test/test-buf-bt.el
new file mode 100644
index 0000000..2ef06db
--- /dev/null
+++ b/packages/realgud/test/test-buf-bt.el
@@ -0,0 +1,27 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'load-relative)
+(require 'test-simple)
+(require 'font-lock)
+
+
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/common/buffer/backtrace.el")
+
+(declare-function realgud-get-buffer-base-name 'realgud-command)
+
+(test-simple-start)
+
+(note "realgud-buffer-backtrace")
+
+(assert-equal "abc" (realgud-get-buffer-base-name "*abc*")
+ "remove buffer stars")
+
+(assert-equal "abc" (realgud-get-buffer-base-name "abc")
+ "no buffer stars")
+
+(assert-equal "abc" (realgud-get-buffer-base-name "*abc shell*")
+ "remove buffer stars and shell")
+
+(end-tests)
diff --git a/packages/realgud/test/test-buf-cmd.el
b/packages/realgud/test/test-buf-cmd.el
new file mode 100644
index 0000000..f54ddb1
--- /dev/null
+++ b/packages/realgud/test/test-buf-cmd.el
@@ -0,0 +1,56 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/trepan/init.el")
+(declare-function realgud-cmdbuf-init 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-command-string 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-cmd-args= 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-debugger-name 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-info-srcbuf-list 'realgud-buffer-command)
+(declare-function realgud-cmdbuf-add-srcbuf 'realgud-buffer-command)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-cmdbuf)
+ (defvar realgud-pat-hash)
+ (defvar realgud-cmdbuf-info)
+)
+
+(assert-nil (realgud-cmdbuf? (current-buffer))
+ "realgud-cmdbuf? before init")
+
+(assert-equal nil (realgud-cmdbuf-command-string (current-buffer))
+ "realgud-cmdbuf-command-string - uninit")
+(setq temp-cmdbuf (generate-new-buffer "*cmdbuf-test*"))
+(assert-t (realgud-cmdbuf-init temp-cmdbuf "trepan"
+ (gethash "trepan" realgud-pat-hash))
+ "realgud-cmdbuf-init")
+
+(with-current-buffer temp-cmdbuf
+ (switch-to-buffer temp-cmdbuf)
+ (realgud-cmdbuf-info-cmd-args= '("command" "args"))
+ (assert-equal "command args"
+ (realgud-cmdbuf-command-string temp-cmdbuf))
+ (assert-equal "trepan"
+ (realgud-cmdbuf-debugger-name))
+ (assert-equal nil
+ (realgud-cmdbuf-info-srcbuf-list
+ realgud-cmdbuf-info)
+ "srcbuf-list should start out nil")
+ (realgud-cmdbuf-add-srcbuf (current-buffer) temp-cmdbuf)
+ (assert-equal (list (current-buffer))
+ (realgud-cmdbuf-info-srcbuf-list
+ realgud-cmdbuf-info)
+ "should have added one item to srcbuf-list")
+ (realgud-cmdbuf-add-srcbuf (current-buffer) temp-cmdbuf)
+ (assert-equal (list (current-buffer))
+ (realgud-cmdbuf-info-srcbuf-list
+ realgud-cmdbuf-info)
+ "Second source buffer same as first; should have added still
only one item.")
+ (switch-to-buffer nil)
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-common-helper.el
b/packages/realgud/test/test-common-helper.el
new file mode 100644
index 0000000..815fde2
--- /dev/null
+++ b/packages/realgud/test/test-common-helper.el
@@ -0,0 +1,29 @@
+(require 'test-simple)
+(load-file "../realgud/common/helper.el")
+
+(declare-function realgud-struct-field-setter 'realgud-helper)
+(declare-function realgud:debugger-name-transform 'realgud-helper)
+(declare-function __FILE__ 'load-relative)
+
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar realgud-test-info)
+)
+
+(defstruct realgud-test-info name)
+(realgud-struct-field-setter "realgud-test-info" "name")
+
+(set (make-local-variable 'realgud-test-info)
+ (make-realgud-test-info :name "foo"))
+
+(note "setter macro works")
+(assert-t (functionp 'realgud-test-info-name=))
+(assert-equal "foo" (realgud-test-info-name= "foo"))
+
+(note "realgud:debugger-name-transform")
+(assert-equal "trepan" (realgud:debugger-name-transform "trepan"))
+;; (assert-equal "realgud:gdb" (realgud:debugger-name-transform "gdb"))
+
+(end-tests)
diff --git a/packages/realgud/test/test-core.el
b/packages/realgud/test/test-core.el
new file mode 100644
index 0000000..51ddaa7
--- /dev/null
+++ b/packages/realgud/test/test-core.el
@@ -0,0 +1,96 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(eval-when-compile (defvar trepan-core))
+
+(declare-function __FILE__ 'load-relative)
+(setq trepan-core "../realgud/debugger/trepan/core.el")
+(load-file "../realgud/common/core.el")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+(declare-function realgud-parse-command-arg, 'realgud-core)
+(declare-function realgud:trepan-parse-cmd-args 'realgud:trepan)
+
+;; We use a specific language to test core. Here we use trepan.
+(load-file "../realgud/debugger/trepan/core.el")
+
+(test-simple-start)
+
+;; FIXME: Add a test of relgud-exec-shell where
+;; we have two invocation of different files that canonicalize
+;; to the same buffer. Make sure the buffers are distinct.
+;; For example: bashdb /etc/profile should not match
+;; bashdb /tmp/profile
+
+(note "realgud:expand-file-name-if-exists")
+
+(assert-equal (realgud:expand-file-name-if-exists "file-not-here")
+ "file-not-here" "no expansion when expanded file doesn't exist")
+
+(assert-equal (realgud:expand-file-name-if-exists ".")
+ (expand-file-name "."))
+
+(note "realgud-parse-...")
+
+(lexical-let ((opt-two-args '("0" "C" "e" "E" "F" "i")))
+ (assert-equal '(("-0" "a") nil)
+ (realgud-parse-command-arg '("-0" "a") '() opt-two-args)
+ "Two args found, none remain afterwards though.")
+
+ (assert-equal
+ '(("-5") ("a" "-0"))
+ (realgud-parse-command-arg '("-5" "a" "-0") '()
+ opt-two-args)
+ "One arg not found.")
+
+ (assert-equal
+ '((nil) nil)
+ (realgud-parse-command-arg '() '() opt-two-args)
+ "Degenerate case - no args"
+ )
+
+ (assert-equal
+ '(("--port" "123") ("bar"))
+ (realgud-parse-command-arg
+ '("--port" "123" "bar") '("-port") '())
+ "two mandatory args"
+ )
+
+ (assert-equal
+ '(("/usr/bin/ruby1.9" "-W") ("trepan") ("foo") nil)
+ (realgud:trepan-parse-cmd-args
+ '("/usr/bin/ruby1.9" "-W" "trepan" "foo"))
+ "Separate Ruby with its arg from debugger and its arg.")
+
+ (assert-equal
+ '(("ruby1.9" "-T3") ("trepan" "--port" "123") ("bar") nil)
+ (realgud:trepan-parse-cmd-args
+ '("ruby1.9" "-T3" "trepan" "--port" "123" "bar"))
+ "Ruby with two args and trepan with two args")
+
+ (assert-equal
+ '(nil ("trepan" "--port" "1" "--annotate=3")
+ ("foo" "a") t)
+ (realgud:trepan-parse-cmd-args
+ '("trepan" "--port" "1" "--annotate=3" "foo" "a"))
+ "trepan with annotate args")
+
+ (assert-equal
+ '(nil ("trepan" "--port" "123")
+ ("foo" "--emacs" "a") nil)
+ (realgud:trepan-parse-cmd-args
+ '("trepan" "--port" "123" "foo" "--emacs" "a"))
+ "trepan with --emacs in the wrong place")
+
+ (assert-equal
+ '(("ruby" "-I/usr/lib/ruby")
+ ("trepan" "-h" "foo" "--emacs")
+ ("baz") t)
+ (realgud:trepan-parse-cmd-args
+ '("ruby" "-I/usr/lib/ruby" "trepan" "-h" "foo"
+ "--emacs" "baz"))
+ "trepan with emacs")
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-file.el
b/packages/realgud/test/test-file.el
new file mode 100644
index 0000000..e9129d4
--- /dev/null
+++ b/packages/realgud/test/test-file.el
@@ -0,0 +1,128 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/loc.el")
+(load-file "../realgud/common/file.el")
+
+;; Note the below line number is tested so it must match what's listed
+;; below.
+(declare-function __FILE__ 'load-relative)
+
+(declare-function realgud:file-loc-from-line 'realgud-file)
+(declare-function realgud:file-line-count 'realgud-file)
+(declare-function realgud:file-column-from-string 'realgud-file)
+(declare-function realgud-loc? 'realgud-loc)
+
+(declare-function realgud-loc-line-number 'realgud-loc)
+(declare-function realgud-loc-column-number 'realgud-loc)
+(declare-function realgud-loc-filename 'realgud-loc)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar realgud-file-remap)
+ (defvar test-filename)
+ (defvar test-file-loc)
+ (defvar remap-filename)
+ (defvar old-compilation-find-file)
+)
+
+(clrhash realgud-file-remap)
+
+(setq old-compilation-find-file (symbol-function 'compilation-find-file))
+
+(setq test-filename (symbol-file 'test-simple))
+
+(note "realgud:file-line-count")
+
+(assert-nil
+ (realgud:file-line-count "not-found-file")
+ "File not found")
+
+(assert-t (integerp (realgud:file-line-count test-filename))
+ "File found")
+
+
+(note "realgud:file-loc-from-line")
+
+(fset 'compilation-find-file (lambda(mark test-filename opt)
+ (get-buffer "*scratch*")))
+
+(save-excursion
+ ;; NOTE: this calls compilation-find-file which prompts for a file
+ ;; (assert-equal
+ ;; "File named `not-found-file' not readable"
+ ;; (realgud:file-loc-from-line
+ ;; "not-found-file" 5 (make-marker))
+ ;; )
+
+ (assert-t (stringp (realgud:file-loc-from-line test-filename 5.5))
+ "invalid real line number")
+
+ (assert-t (stringp (realgud:file-loc-from-line test-filename -1))
+ "negative number")
+
+ (note "realgud:file-loc-from-line information")
+
+ (assert-t (stringp (realgud:file-loc-from-line test-filename 10001))
+ "Line number too large for file")
+
+ (setq test-file-loc (realgud:file-loc-from-line (__FILE__) 5 nil ";; Note"))
+ (assert-t (realgud-loc? test-file-loc)
+ "Ok loc creation - no cmd marker")
+
+ (assert-t (realgud-loc?
+ (realgud:file-loc-from-line test-filename 30 (make-marker)))
+ "Ok loc creation - cmd marker")
+
+ (assert-equal 5 (realgud-loc-line-number test-file-loc))
+
+ ;; FIXME: don't know why this fails in batch
+ ;; (assert-equal 0 (realgud-loc-column-number test-file-loc))
+
+ (assert-equal (__FILE__) (realgud-loc-filename test-file-loc))
+
+ (note "realgud:file-loc-from-line remapping")
+
+ (setq remap-filename " bogus remap-filename.el")
+
+ ;; (assert-equal
+ ;; (format "File named `%s' not readable" remap-filename)
+ ;; (realgud:file-loc-from-line
+ ;; remap-filename 5 (make-marker))
+ ;; )
+ )
+
+
+(puthash remap-filename test-filename realgud-file-remap)
+
+(assert-t (realgud-loc?
+ (realgud:file-loc-from-line remap-filename 30))
+ "Ok loc creation with remap - no cmd marker")
+
+;; FIXME: don't know why this fails in batch
+;; (assert-equal
+;; 18
+;; (realgud:file-column-from-string (__FILE__) 7 "__FILE__")
+;; "Should find string in file/line and get column"
+;; )
+
+(assert-nil
+ (realgud:file-column-from-string (__FILE__) 5 "__FILE__")
+ "Should not find string at this line in located file"
+ )
+
+(assert-nil
+ (realgud:file-column-from-string (concat (__FILE__) "FOO") 7 "__FILE__")
+ "Should not find file"
+ )
+
+(assert-nil
+ (realgud:file-column-from-string (__FILE__) 10000 "__FILE__")
+ "Should not find line in file at all"
+ )
+
+(fset 'compilation-find-file old-compilation-find-file)
+
+(end-tests)
diff --git a/packages/realgud/test/test-gdb-core.el
b/packages/realgud/test/test-gdb-core.el
new file mode 100644
index 0000000..dfc1a1a
--- /dev/null
+++ b/packages/realgud/test/test-gdb-core.el
@@ -0,0 +1,36 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/gdb/core.el")
+
+(declare-function realgud:gdb-parse-cmd-args 'realgud-gdb-core)
+
+(test-simple-start)
+
+(note "invoke gdb without command line arguments")
+(assert-equal '(("gdb") nil nil nil)
+ (realgud:gdb-parse-cmd-args
+ '("gdb")))
+
+(note "invoke gdb with annotate command line parameter")
+(assert-equal '(("gdb" "--annotate" "1") nil nil t)
+ (realgud:gdb-parse-cmd-args
+ '("gdb" "--annotate" "1")))
+
+(note "invoke gdb with annotate command line parameter and file")
+(assert-equal '(("gdb" "--annotate" "1") nil ("file.c") t)
+ (realgud:gdb-parse-cmd-args
+ '("gdb" "--annotate" "1" "file.c")))
+
+(note "invoke gdb with annotate command line parameter and pid")
+(assert-equal '(("gdb" "--annotate" "1" "-p") nil ("4812") t)
+ (realgud:gdb-parse-cmd-args
+ '("gdb" "--annotate" "1" "-p" "4812")))
+
+(note "invoke gdb with pid")
+(assert-equal '(("gdb" "-p") nil ("4511") nil)
+ (realgud:gdb-parse-cmd-args
+ '("gdb" "-p" "4511")))
+
+(end-tests)
diff --git a/packages/realgud/test/test-gdb.el
b/packages/realgud/test/test-gdb.el
new file mode 100644
index 0000000..cf07cec
--- /dev/null
+++ b/packages/realgud/test/test-gdb.el
@@ -0,0 +1,68 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/gdb/core.el")
+(load-file "./regexp-helper.el")
+
+(eval-when-compile
+ (defvar realgud:gdb-minibuffer-history)
+ (defvar test:realgud-gdb-executable-save)
+ (defvar test:realgud-minibuffer-history-save)
+)
+
+(declare-function realgud:gdb-suggest-invocation 'realgud:bashdb)
+(declare-function __FILE__ 'require-relative)
+
+(test-simple-start)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:realgud-gdb-executable-save (symbol-function
'realgud:gdb-executable))
+(setq test:realgud-minibuffer-history-save realgud:gdb-minibuffer-history)
+
+(defun realgud:gdb-executable (filename)
+ "Mock function for testing"
+ (cond ((equal filename "bar.sh") 7)
+ ((equal filename "foo") 8)
+ ((equal filename "baz") 8)
+ (t 3)))
+
+(defun gdb-test()
+ (note "realgud:gdb-suggest-invocation")
+ (setq realgud:gdb-minibuffer-history nil)
+ (let ((my-directory (file-name-directory (__FILE__))))
+ (save-excursion
+ (note "Test preference to buffer editing")
+ (setq default-directory
+ (concat my-directory "gdb"))
+ (find-file-literally "foo.c")
+ (assert-equal "gdb foo" (realgud:gdb-suggest-invocation)
+ "Should find file sans extension - foo")
+ (find-file-literally "baz.c")
+ (assert-equal "gdb baz" (realgud:gdb-suggest-invocation)
+ "Should find file sans extension - baz")
+ )
+ (save-excursion
+ (note "Pick up non-sans executable")
+ (setq default-directory
+ (concat my-directory "gdb/test2"))
+ ;; (assert-equal "gdb bar.sh" (realgud:gdb-suggest-invocation))
+ (setq realgud:gdb-minibuffer-history '("gdb testing"))
+ (setq default-directory
+ (concat my-directory "gdb/test2"))
+ (assert-equal "gdb testing" (realgud:gdb-suggest-invocation)
+ "After setting minibuffer history - takes precidence")
+ )
+ (setq default-directory my-directory)
+ )
+ )
+(gdb-test)
+(end-tests)
+
+;; Restore the old values.
+;; You might have to run the below if you run this interactively.
+(fset 'realgud:gdb-executable test:realgud-gdb-executable-save)
+(setq realgud:gdb-minibuffer-history test:realgud-minibuffer-history-save)
+(setq default-directory (file-name-directory (__FILE__)))
diff --git a/packages/realgud/test/test-gub-core.el
b/packages/realgud/test/test-gub-core.el
new file mode 100644
index 0000000..cab0b0b
--- /dev/null
+++ b/packages/realgud/test/test-gub-core.el
@@ -0,0 +1,22 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/gub/core.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function gub-parse-cmd-args 'realgud-gub-core)
+
+(test-simple-start)
+
+(note "form(s) involving gub.sh shell script")
+(assert-equal '("gub.sh" ("--gub=\"-I\"") ("./gcd.go" "3" "5"))
+ (gub-parse-cmd-args
+ '("gub.sh" "--gub=\"-I\"" "--" "./gcd.go" "3" "5")))
+
+(note "form(s) involving underlying tortoise interpreter")
+(assert-equal '("tortoise" ("-run" "-gub=" "-interp=SS") ("./gcd.go" "3" "5"))
+ (gub-parse-cmd-args
+ '("tortoise" "-run" "-gub=" "-interp=SS" "--" "./gcd.go" "3"
"5")))
+
+(end-tests)
diff --git a/packages/realgud/test/test-ipdb.el
b/packages/realgud/test/test-ipdb.el
new file mode 100644
index 0000000..e82e56f
--- /dev/null
+++ b/packages/realgud/test/test-ipdb.el
@@ -0,0 +1,39 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/debugger/ipdb/ipdb.el")
+
+(eval-when-compile (defvar test:run-process-save))
+
+(declare-function ipdb-parse-cmd-args 'realgud:ipdb-core)
+(declare-function realgud:ipdb 'realgud:ipdb)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:run-process-save (symbol-function 'realgud:run-process))
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuffer-histroy &optional no-reset)
+ "Fake realgud:run-process used in testing"
+ (note
+ (format "%s %s %s" debugger-name script-filename cmd-args))
+ (assert-equal "ipdb" debugger-name "debugger name gets passed")
+ (assert-equal (expand-file-name "./gcd.py") script-filename "file name
check")
+ (assert-equal '("3" "5") (cddr cmd-args) "command args listified")
+ )
+
+(note "ipdb-parse-cmd-args")
+(assert-equal (list nil '("ipdb") (list (expand-file-name "foo")) nil)
+ (ipdb-parse-cmd-args '("ipdb" "foo")))
+(assert-equal (list nil '("ipdb") (list (expand-file-name "program.py") "foo")
nil)
+ (ipdb-parse-cmd-args
+ '("ipdb" "program.py" "foo")))
+
+(realgud:ipdb "ipdb ./gcd.py 3 5")
+;; Restore the old value of realgud:run-process
+(fset 'realgud:run-process test:run-process-save)
+
+(end-tests)
diff --git a/packages/realgud/test/test-jdb.el
b/packages/realgud/test/test-jdb.el
new file mode 100644
index 0000000..881b60d
--- /dev/null
+++ b/packages/realgud/test/test-jdb.el
@@ -0,0 +1,18 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/debugger/jdb/core.el")
+(test-simple-start)
+
+(declare-function __FILE__ 'load-relative)
+(declare-function realgud:jdb-parse-cmd-args 'realgud:jdb-core)
+(declare-function realgud:jdb-dot-to-slash 'realgud:jdb-core)
+
+(assert-equal '("jdb" nil ("./TestMe.java"))
+ (realgud:jdb-parse-cmd-args '("jdb" "./TestMe.java")))
+(assert-equal "mcb/pcingola/SnpEff/main"
+ (realgud:jdb-dot-to-slash "mcb.pcingola.SnpEff.main"))
+
+(end-tests)
diff --git a/packages/realgud/test/test-lang.el
b/packages/realgud/test/test-lang.el
new file mode 100644
index 0000000..72f775c
--- /dev/null
+++ b/packages/realgud/test/test-lang.el
@@ -0,0 +1,65 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+
+(eval-when-compile
+ (defvar elisp-file)
+ (defvar elisp-buffer)
+)
+
+(set (make-local-variable 'elisp-file)
+ "../realgud/common/core.el")
+
+(load-file "../realgud/common/lang.el")
+(test-simple-start)
+
+(declare-function realgud-suggest-lang-file 'realgud-lang)
+(declare-function realgud:suggest-file-from-buffer 'realgud-lang)
+(declare-function realgud-lang-mode? 'realgud-lang)
+(declare-function __FILE__ 'load-relative)
+
+(note "realgud-lang-mode?")
+
+(assert-nil
+ (realgud-lang-mode? elisp-file "ruby")
+ "realgud-lang-mode? with Lisp file")
+
+
+(save-excursion
+ (find-file "./gcd.rb")
+ (assert-t
+ (realgud-lang-mode? "./gcd.rb" "ruby")
+ "realgud-lang-mode? with Ruby file")
+ )
+
+
+(assert-equal "gcd.rb"
+ (realgud-suggest-lang-file "ruby" "\\.rb$")
+ "realgud-suggest-lang-file"
+ )
+
+(assert-equal "default.bogus"
+ (realgud-suggest-lang-file "bogus" "\\.bogus$" "default.bogus")
+ "realgud-suggest-lang-file"
+ )
+
+(assert-t (file-exists-p (realgud-suggest-lang-file "bogus" "\\.bogus$")))
+
+(note "realgud:suggest-file-from-buffer")
+
+
+(with-current-buffer
+ (setq elisp-buffer (find-file "./test-dbgr.el"))
+ (set (make-local-variable 'major-mode)
+ 'emacs-lisp-mode)
+ (message "set major mode to %s" major-mode)
+ )
+(assert-equal (buffer-file-name elisp-buffer)
+ (realgud:suggest-file-from-buffer
+ "emacs-lisp"
+ (list elisp-buffer))
+ "realgud-lang-mode? with Lisp file")
+
+(end-tests)
diff --git a/packages/realgud/test/test-loc-regexp-gub.el
b/packages/realgud/test/test-loc-regexp-gub.el
new file mode 100644
index 0000000..e6c4746
--- /dev/null
+++ b/packages/realgud/test/test-loc-regexp-gub.el
@@ -0,0 +1,63 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./regexp-helper.el")
+(load-file "../realgud/common/regexp.el")
+(load-file "../realgud/debugger/gub/init.el")
+
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function cmdbuf-loc-match 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar dbg-name)
+ (defvar realgud-pat-hash)
+ (defvar loc-pat)
+ (defvar test-dbgr)
+ (defvar test-text)
+)
+
+;; Some setup usually done in setting up the buffer.
+;; We customize this for the debugger trepan. Others may follow.
+;; FIXME: encapsulate this.
+(setq dbg-name "gub")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+
+(setq test-text "interp/testdata/square.go:15:6")
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
+
+(note "extract file name")
+(assert-equal 0 (cmdbuf-loc-match test-text test-dbgr))
+(assert-equal "interp/testdata/square.go"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text))
+
+(assert-equal "15"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text) "extract line number")
+
+(setq test-text " interp/testdata/square.go:15:6")
+(assert-nil (numberp (cmdbuf-loc-match test-text test-dbgr))
+ "location starts with blank")
+
+
+(end-tests)
diff --git a/packages/realgud/test/test-loc-regexp-nodejs.el
b/packages/realgud/test/test-loc-regexp-nodejs.el
new file mode 100644
index 0000000..f9b647d
--- /dev/null
+++ b/packages/realgud/test/test-loc-regexp-nodejs.el
@@ -0,0 +1,115 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(load-file "./regexp-helper.el")
+(load-file "../realgud/common/regexp.el")
+(load-file "../realgud/debugger/nodejs/init.el")
+
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function cmdbuf-loc-match 'realgud-regexp-helper)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function test-simple-start 'test-simple)
+(declare-function assert-t 'test-simple)
+(declare-function assert-equal 'test-simple)
+(declare-function note 'test-simple)
+(declare-function end-tests 'test-simple)
+(declare-function realgud-loc-pat-char-offset-group 'realgud:nodejs-init)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar file-group)
+ (defvar frame-re)
+ (defvar line-group)
+ (defvar num-group)
+ (defvar col-group)
+ (defvar test-pos)
+ (defvar bt-re)
+ (defvar dbg-name)
+ (defvar realgud-pat-hash)
+ (defvar loc-pat)
+ (defvar test-dbgr)
+ (defvar test-s1)
+ (defvar realgud-pat-bt)
+ (defvar realgud:nodejs-pat-hash)
+)
+
+; Some setup usually done in setting up the buffer.
+; We customize this for the debugger trepan. Others may follow.
+; FIXME: encapsulate this.
+(setq dbg-name "nodejs")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+
+(note "debugger-backtrace")
+(setq realgud-pat-bt (gethash "debugger-backtrace"
+ realgud:nodejs-pat-hash))
+(setq test-s1
+ "#0 module.js:380:17
+#1 Module._compile module2.js:456:26
+#2 Module._extensions..js module.js:474:10
+#3 Module.load module.js:356:32
+")
+
+(setq bt-re (realgud-loc-pat-regexp realgud-pat-bt))
+(setq num-group (realgud-loc-pat-num realgud-pat-bt))
+(setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
+(setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
+(setq col-group (realgud-loc-pat-char-offset-group realgud-pat-bt))
+(assert-equal 0 (string-match bt-re test-s1))
+(assert-equal "0" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "module.js"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "380"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(assert-equal "17" (substring test-s1
+ (match-beginning col-group)
+ (match-end col-group)))
+
+(setq test-pos (match-end 0))
+(assert-equal 19 (string-match bt-re test-s1 test-pos))
+
+(setq test-s1
+ "#1 Module._compile module2.js:456:26
+#2 Module._extensions..js module.js:474:10
+#3 Module.load module.js:356:32
+")
+(assert-equal 0 (string-match bt-re test-s1))
+
+(assert-equal "1" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "module2.js"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "456"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(assert-equal "26" (substring test-s1
+ (match-beginning col-group)
+ (match-end col-group)))
+(setq test-pos (match-end 0))
+(assert-equal 36 test-pos)
+
+(end-tests)
diff --git a/packages/realgud/test/test-loc-regexp-trepan.el
b/packages/realgud/test/test-loc-regexp-trepan.el
new file mode 100644
index 0000000..d8fd898
--- /dev/null
+++ b/packages/realgud/test/test-loc-regexp-trepan.el
@@ -0,0 +1,83 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./regexp-helper.el")
+(load-file "../realgud/common/regexp.el")
+(load-file "../realgud/debugger/trepan/init.el")
+
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function cmdbuf-loc-match 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar dbg-name)
+ (defvar realgud-pat-hash)
+ (defvar loc-pat)
+ (defvar test-dbgr)
+ (defvar test-text)
+)
+
+;; Some setup usually done in setting up the buffer.
+;; We customize this for the debugger trepan. Others may follow.
+;; FIXME: encapsulate this.
+(setq dbg-name "trepan")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+(setq test-text "-- (/usr/local/bin/irb:9 @2)")
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
+
+(note "extract file name")
+(assert-equal 0 (cmdbuf-loc-match test-text test-dbgr))
+(assert-equal "/usr/local/bin/irb"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text))
+
+(assert-equal "9"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text) "extract line number")
+
+(setq test-text "-> (<internal:lib/rubygems/custom_require>:28 remapped
/usr/lib/ruby/gems/1.9.1/gems/data/custom_require.rb:28 @2)")
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "remapped location")
+
+(assert-equal 0 (cmdbuf-loc-match test-text test-dbgr))
+(assert-equal "/usr/lib/ruby/gems/1.9.1/gems/data/custom_require.rb"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text) "extract remapped file name")
+
+(assert-equal "28"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text) "extract remapped line number")
+
+(setq test-text "C> (/tmp/c-func.rb:2)")
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location for
C fn")
+
+(assert-equal 0 (cmdbuf-loc-match test-text test-dbgr))
+(assert-equal "/tmp/c-func.rb"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text) "extract file name for C fn")
+
+(assert-equal "2"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text) "extract line number for C fn")
+
+(end-tests)
diff --git a/packages/realgud/test/test-loc-regexp-trepanpl.el
b/packages/realgud/test/test-loc-regexp-trepanpl.el
new file mode 100644
index 0000000..e56325d
--- /dev/null
+++ b/packages/realgud/test/test-loc-regexp-trepanpl.el
@@ -0,0 +1,128 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(load-file "./regexp-helper.el")
+(load-file "../realgud/common/regexp.el")
+(load-file "../realgud/debugger/trepan.pl/init.el")
+
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function cmdbuf-loc-match 'realgud-regexp-helper)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function test-simple-start 'test-simple)
+(declare-function assert-t 'test-simple)
+(declare-function assert-equal 'test-simple)
+(declare-function note 'test-simple)
+(declare-function end-tests 'test-simple)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar file-group)
+ (defvar frame-re)
+ (defvar line-group)
+ (defvar num-group)
+ (defvar test-pos)
+ (defvar dbg-name)
+ (defvar realgud-pat-hash)
+ (defvar loc-pat)
+ (defvar test-dbgr)
+ (defvar test-s1)
+ (defvar realgud-pat-bt)
+ (defvar realgud:trepanpl-pat-hash)
+)
+
+; Some setup usually done in setting up the buffer.
+; We customize this for the debugger trepan. Others may follow.
+; FIXME: encapsulate this.
+(setq dbg-name "trepan.pl")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+
+(setq test-s1 "-- main::(../example/gcd.pl:18)")
+(assert-t (numberp (cmdbuf-loc-match test-s1 test-dbgr)) "basic location")
+
+(assert-equal 0 (cmdbuf-loc-match test-s1 test-dbgr))
+
+(note "extract location fields")
+(assert-equal "../example/gcd.pl"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-s1))
+
+(assert-equal "18"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-s1) "extract line number")
+
+
+(note "Test with hex location")
+(setq test-s1 "-- File::Basename::(/usr/share/perl/5.14/File/Basename.pm:284
@0x8918b70)")
+(assert-t (numberp (cmdbuf-loc-match test-s1 test-dbgr)) "basic location")
+(assert-equal 0 (cmdbuf-loc-match test-s1 test-dbgr))
+
+(assert-equal "/usr/share/perl/5.14/File/Basename.pm"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-s1))
+
+(assert-equal "284"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-s1) "extract line number")
+
+
+(note "debugger-backtrace")
+(setq realgud-pat-bt (gethash "debugger-backtrace"
+ realgud:trepanpl-pat-hash))
+(setq test-s1
+ "--> #0 @ = File::Basename::fileparse('/usr/local/bin/trepan.pl') in
+ file `/usr/share/perl/5.18.2/File/Basename.pm' at line 107
+ #1 @ = File::Basename::dirname('/usr/local/bin/trepan.pl') in
+ file `/usr/share/perl/5.18.2/File/Basename1.pm' at line 294
+ #2 file `/usr/local/bin/trepan.pl' at line 11
+")
+(setq frame-re (realgud-loc-pat-regexp realgud-pat-bt))
+(setq num-group (realgud-loc-pat-num realgud-pat-bt))
+(setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
+(setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
+(assert-equal 0 (string-match frame-re test-s1))
+(assert-equal "0" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/usr/share/perl/5.18.2/File/Basename.pm"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "107"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+
+(assert-equal 127 (string-match frame-re test-s1 test-pos))
+(assert-equal "1" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/usr/share/perl/5.18.2/File/Basename1.pm"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "294"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+(assert-equal 254 test-pos)
+
+(end-tests)
diff --git a/packages/realgud/test/test-loc.el
b/packages/realgud/test/test-loc.el
new file mode 100644
index 0000000..3a9510a
--- /dev/null
+++ b/packages/realgud/test/test-loc.el
@@ -0,0 +1,63 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/buffer/source.el")
+(load-file "../realgud/common/loc.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function make-realgud-loc 'realgud-loc)
+(declare-function realgud-loc-cmd-marker 'realgud-loc)
+(declare-function realgud-loc-line-number 'realgud-loc)
+(declare-function realgud-loc-marker 'realgud-loc)
+(declare-function realgud-loc-marker= 'realgud-loc)
+
+(test-simple-start)
+
+(save-current-buffer
+
+ ;; Below, we need to make sure current-buffer has an associated
+ ;; file with it.
+ (find-file (symbol-file 'test-simple))
+
+ (note "location field extraction")
+ (let* ((buff (current-buffer))
+ (filename (buffer-file-name buff))
+ (source-marker (point-marker))
+ (cmd-marker (point-marker))
+ (good-loc (make-realgud-loc
+ :filename filename
+ :line-number 5
+ :marker source-marker
+ :cmd-marker cmd-marker
+ ))
+ (good-loc2 (make-realgud-loc
+ :filename filename
+ :line-number 6
+ :marker source-marker
+ :cmd-marker cmd-marker
+ ))
+ ;; (good-loc3 (realgud-loc-current buff cmd-marker))
+ )
+
+ (assert-equal 5 (realgud-loc-line-number good-loc) "line-number
extraction")
+
+ (assert-equal source-marker (realgud-loc-marker good-loc)
+ "source code marker extraction")
+
+
+ (assert-equal cmd-marker (realgud-loc-cmd-marker good-loc)
+ "command process marker extraction")
+
+
+ (realgud-loc-marker= good-loc2 source-marker)
+ (assert-equal source-marker (realgud-loc-marker good-loc2)
+ "marker set")
+
+ ))
+
+(end-tests)
+
+; TODO: add test for debug-loc-goto, e.g.
+;(realgud-loc-goto (realgud-loc-new "/tmp/bashdb.diff" 8))
+;(realgud-loc-goto (realgud-loc-new "/tmp/bashdb.diff" 8) 'other-window 1)
diff --git a/packages/realgud/test/test-lochist.el
b/packages/realgud/test/test-lochist.el
new file mode 100644
index 0000000..b684339
--- /dev/null
+++ b/packages/realgud/test/test-lochist.el
@@ -0,0 +1,114 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/loc.el")
+(load-file "../realgud/common/lochist.el")
+(load-file "../realgud/common/buffer/helper.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function make-realgud-loc 'realgud-loc)
+(declare-function make-realgud-loc-his 'realgud-loc)
+(declare-function realgud-loc-hist-add 'realgud-lochist)
+(declare-function realgud-loc-hist-ring 'realgud-lochist)
+(declare-function realgud-loc-hist-item 'realgud-lochist)
+(declare-function realgud-loc-hist-position 'realgud-lochist)
+(declare-function realgud-loc-hist-index 'realgud-lochist)
+(declare-function realgud-loc-hist-newest 'realgud-lochist)
+(declare-function realgud:buffer-line-no-props 'realgud-buffer-helper)
+(declare-function make-realgud-loc-hist 'realgud-lochist)
+(declare-function ring-length 'ring)
+
+(declare-function realgud-get-cmdbuf-from-srcbuf 'realgud-buffer-helper)
+
+(test-simple-start)
+
+;;; (defun setup()
+;;; (lexical-let ((loc-hist (make-realgud-loc-hist))
+;;; (filename (buffer-file-name (current-buffer)))
+;;; (loc (realgud-loc-current)))
+;;; (realgud-loc-hist-add loc-hist loc)))
+;;; ;; (message "aa ring-index %s"
+;;; ;; (realgud-loc-hist-index loc-hist))))
+
+;;; (setup)
+
+
+;; FIXME: redo tests, so we don't have to almost duplicate and
+;; dummy realgud-loc-current.
+(defun realgud-loc-current(&optional source-buffer cmd-marker)
+ "Create a location object for the point in the current buffer.
+ If SOURCE-BUFFER is not given, take the current buffer as the
+ source buffer."
+ (interactive "")
+ (unless source-buffer
+ (setq source-buffer (current-buffer)))
+ ;;(unless (realgud-srcbuf? source-buffer)
+ ;; (error "%s is not a realgud source buffer" source-buffer))
+ (unless cmd-marker
+ (setq cmd-marker
+ (realgud-get-cmdbuf-from-srcbuf source-buffer))
+ )
+ (with-current-buffer source-buffer
+ (let ((mark (point-marker))
+ (text (realgud:buffer-line-no-props)))
+ (make-realgud-loc
+ :filename (buffer-file-name source-buffer)
+ :column-number (current-column)
+ :line-number (line-number-at-pos)
+ :source-text text
+ :marker mark
+ :cmd-marker cmd-marker
+ )
+ )))
+
+
+(let ((saved-buffer (current-buffer)))
+ ; Below, we need to make sure current-buffer has an associated
+ ; file with it.
+ (find-file (symbol-file 'test-simple))
+
+ (note "location ring initialization and fields access")
+ (let* ((loc-hist (make-realgud-loc-hist))
+ (source-buffer (current-buffer))
+ (cmd-marker (point-marker))
+ (filename (buffer-file-name (current-buffer)))
+ (loc (realgud-loc-current source-buffer cmd-marker)))
+
+ (assert-t (ring-p (realgud-loc-hist-ring loc-hist))
+ "get ring component for a new history ring")
+
+
+ (assert-equal -1 (realgud-loc-hist-position loc-hist)
+ "ring position for an empty history ring is -1")
+
+
+ (assert-nil (realgud-loc-hist-item loc-hist)
+ "get item for an empty history ring")
+
+ (realgud-loc-hist-add loc-hist loc)
+ (assert-equal loc (realgud-loc-hist-item loc-hist)
+ "add an item to an empty history ring")
+
+
+ (assert-equal 1 (ring-length
+ (realgud-loc-hist-ring loc-hist))
+ "One item in history ring")
+
+ (assert-equal 1 (realgud-loc-hist-index loc-hist)
+ "ring index in history ring is 1")
+
+ ;; (realgud-loc-hist-add loc-hist loc)
+ ;; (assert-equal 1 (ring-length
+ ;; (realgud-loc-hist-ring loc-hist) )
+ ;; "duplicate item added is ignored")
+
+
+ (assert-equal 1 (realgud-loc-hist-index loc-hist)
+ "ring index in history ring after dup ignore is still 1")
+
+ (assert-equal -1 (realgud-loc-hist-newest loc-hist) "Set to newest
position")
+
+ ))
+
+(end-tests)
diff --git a/packages/realgud/test/test-nodejs.el
b/packages/realgud/test/test-nodejs.el
new file mode 100644
index 0000000..e6ab3bb
--- /dev/null
+++ b/packages/realgud/test/test-nodejs.el
@@ -0,0 +1,37 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/nodejs/nodejs.el")
+
+(eval-when-compile (defvar test:run-process-save))
+
+(declare-function nodejs-parse-cmd-args 'realgud:nodejs)
+(declare-function nodejs 'realgud:nodejs)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:run-process-save (symbol-function 'realgud:run-process))
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuf-history &optional no-reset)
+ "Fake realgud:run-process used in testing"
+ (note
+ (format "%s %s %s" debugger-name script-filename cmd-args))
+ (assert-equal "node" debugger-name "debugger name gets passed")
+ (let ((expanded-name (expand-file-name "./gcd.js")))
+ (assert-equal expanded-name script-filename "file name check")
+ ))
+
+(note "nodejs-parse-cmd-args")
+(assert-equal (list '("node" "debug") nil '("foo"))
+ (nodejs-parse-cmd-args '("node" "debug" "foo")))
+
+;; FIXME: need to mock remove-ansi-schmutz in realgud:nodejs
+;; (realgud:nodejs "node debug ./gcd.js 3 5")
+
+;; Restore the old value of realgud:run-process
+(fset 'realgud:run-process test:run-process-save)
+
+(end-tests)
diff --git a/packages/realgud/test/test-pdb.el
b/packages/realgud/test/test-pdb.el
new file mode 100644
index 0000000..d58d5a0
--- /dev/null
+++ b/packages/realgud/test/test-pdb.el
@@ -0,0 +1,39 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/debugger/pdb/pdb.el")
+
+(eval-when-compile (defvar test:run-process-save))
+
+(declare-function pdb-parse-cmd-args 'realgud:pdb-core)
+(declare-function realgud:pdb 'realgud:pdb)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:run-process-save (symbol-function 'realgud:run-process))
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuffer-histroy &optional no-reset)
+ "Fake realgud:run-process used in testing"
+ (note
+ (format "%s %s %s" debugger-name script-filename cmd-args))
+ (assert-equal "pdb" debugger-name "debugger name gets passed")
+ (assert-equal (expand-file-name "./gcd.py") script-filename "file name
check")
+ (assert-equal '("3" "5") (cddr cmd-args) "command args listified")
+ )
+
+(note "pdb-parse-cmd-args")
+(assert-equal (list nil '("pdb") (list (expand-file-name "foo")) nil)
+ (pdb-parse-cmd-args '("pdb" "foo")))
+(assert-equal (list nil '("pdb") (list (expand-file-name "program.py") "foo")
nil)
+ (pdb-parse-cmd-args
+ '("pdb" "program.py" "foo")))
+
+(realgud:pdb "pdb ./gcd.py 3 5")
+;; Restore the old value of realgud:run-process
+(fset 'realgud:run-process test:run-process-save)
+
+(end-tests)
diff --git a/packages/realgud/test/test-perldb.el
b/packages/realgud/test/test-perldb.el
new file mode 100644
index 0000000..90b4fef
--- /dev/null
+++ b/packages/realgud/test/test-perldb.el
@@ -0,0 +1,26 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/perldb/perldb.el")
+
+(declare-function realgud:perldb-parse-cmd-args 'realgud:perldb)
+(declare-function realgud:perldb 'realgud:perldb)
+(declare-function __FILE__ 'load-relative)
+
+(declare-function realgud-perldb-parse-cmd-args 'realgud-perldb)
+(test-simple-start)
+
+(note "realgud:perldb-parse-cmd-args")
+(assert-equal (list
+ '("perl" "-W" "-d") nil
+ (list (expand-file-name"gcd.rb") "a" "b"))
+ (realgud:perldb-parse-cmd-args
+ '("perl" "-W" "-d" "gcd.rb" "a" "b")))
+(assert-equal (list
+ '("perl5.10.1" "-C" "/tmp" "-d") nil
+ (list (expand-file-name "gcd.rb")))
+ (realgud:perldb-parse-cmd-args
+ '("perl5.10.1" "-C" "/tmp" "-d" "gcd.rb")))
+
+(end-tests)
diff --git a/packages/realgud/test/test-rdebug.el
b/packages/realgud/test/test-rdebug.el
new file mode 100644
index 0000000..20a7d22
--- /dev/null
+++ b/packages/realgud/test/test-rdebug.el
@@ -0,0 +1,45 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/debugger/rdebug/rdebug.el")
+(declare-function rdebug-get-script-name 'realgud-rdebug)
+(declare-function __FILE__ 'load-relative)
+(test-simple-start)
+
+(note "rdebug-get-script-name")
+(assert-equal '("foo" nil)
+ (rdebug-get-script-name '("rdebug" "foo")))
+(assert-equal '("foo" nil)
+ (rdebug-get-script-name '("rdebug" "-m" "foo")))
+(assert-equal '("foo" t)
+ (rdebug-get-script-name
+ '("rdebug" "--emacs" "3" "foo")))
+(assert-equal '("foo" t)
+ (rdebug-get-script-name
+ '("myrdebug" "--annotate=1" "foo")))
+(assert-equal '("foo" t)
+ (rdebug-get-script-name
+ '("ruby" "rdebug" "--annotate" "1" "foo")))
+(assert-equal '("foo" nil)
+ (rdebug-get-script-name
+ '("/usr/bin/ruby19" "rdebug"
+ "--emacs-basic" "foo")))
+(assert-equal '("foo" nil)
+ (rdebug-get-script-name '("rdbg.rb" "foo")))
+(assert-equal '("rdbg.rb" nil)
+ (rdebug-get-script-name
+ '("rdebug" "rdbg.rb" "foo")))
+(assert-equal '("foo" t)
+ (rdebug-get-script-name
+ '("rdebug" "-A" "1" "foo")))
+(assert-equal '("foo" nil)
+ (rdebug-get-script-name
+ '("rdebug" "--include" "me" "-n" "foo")))
+(assert-equal '("foo" nil)
+ (rdebug-get-script-name
+ '("rdebug" "--server" "-d" "--host"
+ "localhost" "foo" "-1")))
+
+(end-tests)
diff --git a/packages/realgud/test/test-realgud.el
b/packages/realgud/test/test-realgud.el
new file mode 100644
index 0000000..2e7d09e
--- /dev/null
+++ b/packages/realgud/test/test-realgud.el
@@ -0,0 +1,31 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud.el")
+
+(declare-function realgud:loaded-features 'realgud)
+(declare-function realgud:unload-features 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar test-realgud:features)
+)
+
+(note "realgud")
+
+(note "realgud:loaded-features")
+(set (make-local-variable 'test-realgud:features) (realgud:loaded-features))
+;; (dolist (feature '(realgud-trepan
+;; realgud-core))
+;; (assert-t (not (not (member feature test-realgud:features)))) )
+
+(note "realgud-unload-features")
+(load-file "../realgud.el")
+(assert-nil (not (realgud:loaded-features)))
+(assert-nil (not (realgud:unload-features)))
+(realgud:loaded-features)
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-bashdb.el
b/packages/realgud/test/test-regexp-bashdb.el
new file mode 100644
index 0000000..00830e9
--- /dev/null
+++ b/packages/realgud/test/test-regexp-bashdb.el
@@ -0,0 +1,111 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/debugger/bashdb/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function loc-match 'realgud-helper)
+(declare-function prompt-match 'regexp-helper)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar file-group)
+ (defvar frame-re)
+ (defvar line-group)
+ (defvar num-group)
+ (defvar test-pos)
+ (defvar prompt-pat)
+ (defvar realgud:bashdb-pat-hash)
+ (defvar realgud-pat-bt)
+ (defvar test-s1)
+ (defvar test-text)
+ (defvar brkpt-del)
+ (defvar bp-del-pat)
+)
+
+(set (make-local-variable 'bp-del-pat)
+ (gethash "brkpt-del" realgud:bashdb-pat-hash))
+
+(note "bashdb prompt matching")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:bashdb-pat-hash))
+(prompt-match "bashdb<10> " "10")
+(prompt-match "bashdb<(5)> " "5" "subshell prompt %s")
+(prompt-match "bashdb<<1>> " "1" "nested debug prompt %s")
+
+(note "debugger-backtrace")
+(setq realgud-pat-bt (gethash "debugger-backtrace"
+ realgud:bashdb-pat-hash))
+(setq test-s1
+ "->0 in file `/etc/apparmor/functions' at line 24
+##1 source(\"/etc/apparmor/functions\") called from file
`/etc/init.d/apparmor' at line 35
+##2 source(\"/etc/init.d/apparmor\") called from file `/usr/local/bin/bashdb'
at line 140
+##3 main() called from file `/bin/bashdb' at line 0
+")
+(setq frame-re (realgud-loc-pat-regexp realgud-pat-bt))
+(setq num-group (realgud-loc-pat-num realgud-pat-bt))
+(setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
+(setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
+(assert-equal 0 (string-match frame-re test-s1))
+(assert-equal "0" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/etc/apparmor/functions"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "24"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+
+(assert-equal 49 (string-match frame-re test-s1 test-pos))
+(assert-equal "1" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/etc/init.d/apparmor"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "35"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+(assert-equal 138 (string-match frame-re test-s1 test-pos))
+(assert-equal "2" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/usr/local/bin/bashdb"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "140"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+(assert-equal 226 (string-match frame-re test-s1 test-pos))
+(assert-equal "3" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/bin/bashdb"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+
+(note "breakpoint delete matching")
+(setq test-text "Removed 1 breakpoint(s).\n")
+(assert-t (numberp (loc-match test-text bp-del-pat)) "breakpoint delete
matching")
+
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-gdb.el
b/packages/realgud/test/test-regexp-gdb.el
new file mode 100644
index 0000000..fcf8fa9
--- /dev/null
+++ b/packages/realgud/test/test-regexp-gdb.el
@@ -0,0 +1,111 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/gdb/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar dbg-name) (defvar realgud-pat-hash) (defvar realgud-bt-pat)
+ (defvar loc-pat) (defvar prompt-pat) (defvar test-s1)
+ (defvar file-group) (defvar line-group) (defvar test-pos)
+ (defvar test-dbgr) (defvar test-text) (defvar realgud-bt-re)
+)
+
+; Some setup usually done in setting up the buffer.
+; We customize this for this debugger.
+; FIXME: encapsulate this.
+(setq dbg-name "gdb")
+
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+;; FIXME: we get a void variable somewhere in here when running
+;; even though we define it in lexical-let. Dunno why.
+;; setq however will workaround this.
+(setq test-text "/home/rocky/c/ctest.c:80:2000:beg:0x8048748>")
+(note "traceback location matching")
+
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
+(assert-equal "/home/rocky/c/ctest.c"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text) "extract file name")
+(assert-equal "80"
+ (match-string (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text) "extract line number")
+(note "debugger-backtrace")
+(setq realgud-bt-pat (gethash "debugger-backtrace"
+ realgud:gdb-pat-hash))
+(setq test-s1
+ "#0 main (argc=2, argv=0xbffff564, envp=0xbffff570) at main.c:935
+#1 0xb7e9f4a5 in *__GI___strdup (s=0xbffff760 \"/tmp/remake/remake\") at
strdup.c:42
+#2 0x080593ac in main (argc=2, argv=0xbffff5a4, envp=0xbffff5b0)
+ at main.c:952
+#46 0xb7f51b87 in vm_call_cfunc (th=0x804d188, reg_cfp=0xb7ba9e88, num=0,
+ recv=157798080, blockptr=0x0, me=0x80d12a0) at vm_insnhelper.c:410
+")
+(setq realgud-bt-re (realgud-loc-pat-regexp realgud-bt-pat))
+(setq file-group (realgud-loc-pat-file-group realgud-bt-pat))
+(setq line-group (realgud-loc-pat-line-group realgud-bt-pat))
+(assert-equal 0 (string-match realgud-bt-re test-s1))
+(assert-equal "main.c"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "935"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(setq test-pos (match-end 0))
+(assert-equal 65 test-pos)
+(assert-equal 65 (string-match realgud-bt-re test-s1 test-pos))
+(assert-equal "strdup.c"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "42"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(setq test-pos (match-end 0))
+(assert-equal 149 test-pos)
+(assert-equal 149 (string-match realgud-bt-re test-s1 test-pos))
+(assert-equal "main.c"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "952"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(setq test-pos (match-end 0))
+(assert-equal 233 test-pos)
+(assert-equal 233 (string-match realgud-bt-re test-s1 test-pos))
+(assert-equal "vm_insnhelper.c"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "410"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(note "prompt")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:gdb-pat-hash))
+(prompt-match "(gdb) ")
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-gub.el
b/packages/realgud/test/test-regexp-gub.el
new file mode 100644
index 0000000..0240a05
--- /dev/null
+++ b/packages/realgud/test/test-regexp-gub.el
@@ -0,0 +1,65 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/gub/init.el")
+(load-file "./regexp-helper.el")
+
+(test-simple-start)
+
+(declare-function __FILE__ 'load-relative)
+
+(eval-when-compile
+ (defvar dbg-name)
+ (defvar realgud:gub-pat-hash)
+ (defvar panic-tb)
+ (defvar test-tb)
+ (defvar prompt-pat)
+ (defvar test-dbgr)
+ (defvar test-text)
+)
+
+; Some setup usually done in setting up the buffer.
+; We customize this for this debugger.
+; FIXME: encapsulate this.
+(setq dbg-name "gub")
+
+(note "gub prompt")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:gub-pat-hash))
+(prompt-match "gub[0]: ")
+(prompt-match "gub[20]: ")
+(prompt-match "address@hidden: ")
+
+(setup-regexp-vars realgud:gub-pat-hash)
+(set (make-local-variable 'test-tb)
+ (gethash "lang-backtrace" realgud:gub-pat-hash))
+
+(note "go lang traceback")
+(setq test-text "/usr/local/go/src/pkg/runtime/panic.c:482 (0x805c956)")
+
+(assert-t (numberp (tb-loc-match test-text)) "go traceback location")
+(assert-equal "/usr/local/go/src/pkg/runtime/panic.c"
+ (match-string (realgud-loc-pat-file-group test-tb)
+ test-text) "extract traceback file name")
+(assert-equal "482"
+ (match-string (realgud-loc-pat-line-group test-tb)
+ test-text) "extract traceback line number")
+
+(note "panic traceback")
+(setq test-text "
/tmp/github.com/rocky/ssa-interp/eval/selectorexpr.go:18 +0x9f")
+
+(set (make-local-variable 'panic-tb)
+ (gethash "panic-backtrace" realgud:gub-pat-hash))
+
+(assert-t (numberp (string-match (realgud-loc-pat-regexp panic-tb) test-text))
+ "go panic location")
+(assert-equal "/tmp/github.com/rocky/ssa-interp/eval/selectorexpr.go"
+ (match-string (realgud-loc-pat-file-group test-tb)
+ test-text) "extract panic traceback file name")
+(assert-equal "18"
+ (match-string (realgud-loc-pat-line-group test-tb)
+ test-text) "extract panic traceback line number")
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-ipdb.el
b/packages/realgud/test/test-regexp-ipdb.el
new file mode 100644
index 0000000..a9a74cc
--- /dev/null
+++ b/packages/realgud/test/test-regexp-ipdb.el
@@ -0,0 +1,108 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/ipdb/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function loc-match 'realgud-helper)
+(declare-function prompt-match 'regexp-helper)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar loc-pat) (defvar prompt-pat) (defvar realgud:ipdb-pat-hash)
+ (defvar tb-pat) (defvar test-text) (defvar prompt-str)
+ (defvar bps-pat)
+)
+
+(set (make-local-variable 'bps-pat)
+ (gethash "brkpt-set" realgud:ipdb-pat-hash))
+
+(set (make-local-variable 'loc-pat)
+ (gethash "loc" realgud:ipdb-pat-hash))
+
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:ipdb-pat-hash))
+
+(set (make-local-variable 'tb-pat)
+ (gethash "lang-backtrace" realgud:ipdb-pat-hash))
+
+;; FIXME: we get a void variable somewhere in here when running
+;; even though we define it in lexical-let. Dunno why.
+;; setq however will workaround this.
+(setq test-text
+ " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
+(note "traceback location matching")
+
+(assert-t (numberp (loc-match test-text tb-pat)) "basic traceback location")
+
+(assert-equal "/usr/lib/python2.6/code.py"
+ (match-string (realgud-loc-pat-file-group tb-pat)
+ test-text))
+
+(setq test-text
+ " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
+(loc-match test-text tb-pat)
+(assert-equal "281"
+ (match-string (realgud-loc-pat-line-group tb-pat)
+ test-text) "extract line number")
+
+(note "breakpoint location matching")
+
+(setq test-text "Breakpoint 1 at /src/git/code/gcd.py:13")
+(assert-t (numberp (loc-match test-text bps-pat))
+ "basic breakpoint location")
+
+(assert-equal "/src/git/code/gcd.py"
+ (match-string (realgud-loc-pat-file-group
+ bps-pat)
+ test-text)
+ "extract breakpoint file name")
+
+
+(assert-equal "13"
+ (match-string (realgud-loc-pat-line-group
+ bps-pat)
+ test-text) "extract breakpoint line number")
+
+;; (set test-text "(c:\\working\\python\\helloworld.py:30): <module>")
+;;
+;; (assert-t (numberp (loc-match test-text loc-pat)) "MS DOS position
location")
+;; ;;
+;; (assert-equal "c:\\working\\python\\helloworld.py"
+;; (match-string (realgud-loc-pat-file-group loc-pat)
+;; test-text)
+;; (format "Failing file group is %s"
+;; (realgud-loc-pat-file-group tb-pat))
+;; "extract file name")
+;; (assert-equal "30"
+;; (match-string (realgud-loc-pat-line-group loc-pat)
+;; test-text) "extract line number")
+
+(setq test-text "> /usr/bin/ipython(24)<module>")
+(assert-t (numberp (loc-match test-text loc-pat)) "position location")
+(assert-equal "/usr/bin/ipython"
+ (match-string (realgud-loc-pat-file-group loc-pat)
+ test-text)
+ (format "Failing file group is %s"
+ (realgud-loc-pat-file-group tb-pat)))
+(assert-equal "24"
+ (match-string (realgud-loc-pat-line-group
+ loc-pat)
+ test-text)
+ "extract line number")
+
+
+(note "prompt matching")
+(set (make-local-variable 'prompt-str) "ipdb> ")
+(prompt-match prompt-str nil "debugger prompt: %s")
+(setq prompt-str "ipdb")
+(assert-nil (numberp (loc-match prompt-str prompt-pat))
+ (format "%s %s" "invalid debugger prompt"
+ prompt-str))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-jdb.el
b/packages/realgud/test/test-regexp-jdb.el
new file mode 100644
index 0000000..efac100
--- /dev/null
+++ b/packages/realgud/test/test-regexp-jdb.el
@@ -0,0 +1,78 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/jdb/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function prompt-match 'regexp-helper)
+
+(eval-when-compile
+ (defvar dbg-name) (defvar realgud-pat-hash) (defvar loc-pat)
+ (defvar test-dbgr) (defvar test-text) (defvar prompt-pat)
+ (defvar realgud:jdb-pat-hash)
+)
+
+(test-simple-start)
+
+(note "jdb prompt matching")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:jdb-pat-hash))
+(prompt-match "main[1] " "1" "most common main prompt")
+(prompt-match "main[2] " "2" "main prompt up a level")
+(prompt-match "> " nil "no loc prompt")
+
+
+; Some setup usually done in setting up the buffer.
+; We customize this for this debugger.
+; FIXME: encapsulate this.
+(setq dbg-name "jdb")
+
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+;; FIXME: we get a void variable somewhere in here when running
+;; even though we define it in lexical-let. Dunno why.
+;; setq however will workaround this.
+(let ((text "Breakpoint hit: \"thread=main\", TestMe.main(), line=7 bci=0"))
+
+ (note "traceback location matching")
+
+ (assert-t (numberp (cmdbuf-loc-match text test-dbgr)) "breakpoint location")
+ (assert-equal "7"
+ (match-string (realgud-cmdbuf-info-line-group test-dbgr)
+ text) "extract line number from breakpoint"))
+
+(let ((text "Step completed: \"thread=main\", TestMe.main(), line=71 bci=0"))
+ (assert-t (numberp (cmdbuf-loc-match text test-dbgr)) "breakpoint location")
+ (assert-equal "71"
+ (match-string (realgud-cmdbuf-info-line-group test-dbgr)
+ text) "extract line number from step"))
+
+;; (note "debugger-backtrace")
+;; (setq realgud-bt-pat (gethash "debugger-backtrace"
+;; realgud:jdb-pat-hash))
+;; (setq s1
+;; " [1] java.lang.Class.getDeclaredMethods0 (native method)
+;; [2] java.lang.Class.privateGetDeclaredMethods (Class.java:2,570)
+;; [3] java.lang.Class.getMethod0 (Class.java:2,813)
+;; [4] java.lang.Class.getMethod (Class.java:1,663)
+;; [5] sun.launcher.LauncherHelper.getMainMethod (LauncherHelper.java:494)
+;; [6] sun.launcher.LauncherHelper.checkAndLoadMain (LauncherHelper.java:486)
+;; ")
+;; (setq realgud-bt-re (realgud-loc-pat-regexp realgud-bt-pat))
+;; (setq file-group (realgud-loc-pat-file-group realgud-bt-pat))
+;; (setq line-group (realgud-loc-pat-line-group realgud-bt-pat))
+;; (assert-equal 0 (string-match realgud-bt-re s1))
+;; (assert-equal "570"
+;; (substring s1
+;; (match-beginning line-group)
+;; (match-end line-group)))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-nodejs.el
b/packages/realgud/test/test-regexp-nodejs.el
new file mode 100644
index 0000000..c4ea10d
--- /dev/null
+++ b/packages/realgud/test/test-regexp-nodejs.el
@@ -0,0 +1,74 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/nodejs/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function cmdbuf-loc-match 'realgud-regexp)
+(declare-function loc-match 'realgud-helper)
+(declare-function prompt-match 'regexp-helper)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar dbg-name)
+ (defvar loc-pat)
+ (defvar bt-pat)
+ (defvar prompt-pat)
+ (defvar realgud:nodejs-pat-hash)
+ (defvar realgud-pat-hash)
+ (defvar test-dbgr)
+ (defvar test-text)
+ (defvar test-s1)
+)
+
+(note "nodejs prompt matching")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:nodejs-pat-hash))
+(prompt-match "debug> ")
+(prompt-match "[1G[0Jdebug> [8G[1G[0Kconnecting... ok")
+
+(note "nodejs location matching")
+(setq dbg-name "nodejs")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+(setq test-text "break in test/fixtures/break-in-module/main.js:1\n")
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
+
+(string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
+(assert-equal "test/fixtures/break-in-module/main.js"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text) "extract file name")
+
+(string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
+(assert-equal "1"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text) "extract line number")
+
+(note "debugger-backtrace")
+(setq test-text
+ "#0 module.js:380:17
+")
+
+(set (make-local-variable
+ 'bt-pat)
+ (gethash "debugger-backtrace" realgud:nodejs-pat-hash))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-pdb.el
b/packages/realgud/test/test-regexp-pdb.el
new file mode 100644
index 0000000..dfb72af
--- /dev/null
+++ b/packages/realgud/test/test-regexp-pdb.el
@@ -0,0 +1,107 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/pdb/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function prompt-match 'regexp-helper)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar loc-pat) (defvar prompt-pat) (defvar realgud:pdb-pat-hash)
+ (defvar tb-pat) (defvar test-text) (defvar prompt-str)
+ (defvar bps-pat)
+)
+
+(set (make-local-variable 'bps-pat)
+ (gethash "brkpt-set" realgud:pdb-pat-hash))
+
+(set (make-local-variable 'loc-pat)
+ (gethash "loc" realgud:pdb-pat-hash))
+
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:pdb-pat-hash))
+
+(set (make-local-variable 'tb-pat)
+ (gethash "lang-backtrace" realgud:pdb-pat-hash))
+
+;; FIXME: we get a void variable somewhere in here when running
+;; even though we define it in lexical-let. Dunno why.
+;; setq however will workaround this.
+(setq test-text
+ " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
+(note "traceback location matching")
+
+(assert-t (numberp (loc-match test-text tb-pat)) "basic traceback location")
+
+(assert-equal "/usr/lib/python2.6/code.py"
+ (match-string (realgud-loc-pat-file-group tb-pat)
+ test-text))
+
+(setq test-text
+ " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
+(loc-match test-text tb-pat)
+(assert-equal "281"
+ (match-string (realgud-loc-pat-line-group tb-pat)
+ test-text) "extract line number")
+
+(note "breakpoint location matching")
+
+(setq test-text "Breakpoint 1 at /src/git/code/gcd.py:13")
+(assert-t (numberp (loc-match test-text bps-pat))
+ "basic breakpoint location")
+
+(assert-equal "/src/git/code/gcd.py"
+ (match-string (realgud-loc-pat-file-group
+ bps-pat)
+ test-text)
+ "extract breakpoint file name")
+
+
+(assert-equal "13"
+ (match-string (realgud-loc-pat-line-group
+ bps-pat)
+ test-text) "extract breakpoint line number")
+
+;; (set test-text "(c:\\working\\python\\helloworld.py:30): <module>")
+;;
+;; (assert-t (numberp (loc-match test-text loc-pat)) "MS DOS position
location")
+;; ;;
+;; (assert-equal "c:\\working\\python\\helloworld.py"
+;; (match-string (realgud-loc-pat-file-group loc-pat)
+;; test-text)
+;; (format "Failing file group is %s"
+;; (realgud-loc-pat-file-group tb-pat))
+;; "extract file name")
+;; (assert-equal "30"
+;; (match-string (realgud-loc-pat-line-group loc-pat)
+;; test-text) "extract line number")
+
+(setq test-text "> /usr/bin/ipython(24)<module>")
+(assert-t (numberp (loc-match test-text loc-pat)) "position location")
+(assert-equal "/usr/bin/ipython"
+ (match-string (realgud-loc-pat-file-group loc-pat)
+ test-text)
+ (format "Failing file group is %s"
+ (realgud-loc-pat-file-group tb-pat)))
+(assert-equal "24"
+ (match-string (realgud-loc-pat-line-group
+ loc-pat)
+ test-text)
+ "extract line number")
+
+
+(note "prompt matching")
+(set (make-local-variable 'prompt-str) "(Pdb) ")
+(prompt-match prompt-str nil "debugger prompt: %s")
+(setq prompt-str "((Pdb)) ")
+(prompt-match prompt-str nil "nested debugger prompt: %s")
+(setq prompt-str "Pdb) ")
+(assert-nil (numberp (loc-match prompt-str prompt-pat))
+ (format "%s %s" "invalid debugger prompt"
+ prompt-str))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-perldb.el
b/packages/realgud/test/test-regexp-perldb.el
new file mode 100644
index 0000000..71ac0b6
--- /dev/null
+++ b/packages/realgud/test/test-regexp-perldb.el
@@ -0,0 +1,207 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/lang/perl.el")
+(load-file "../realgud/debugger/perldb/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function prompt-match 'regexp-helper)
+(declare-function cmdbuf-loc-match 'realgud-regexp)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar dbg-name)
+ (defvar realgud:perldb-pat-hash)
+ (defvar realgud-pat-hash)
+ (defvar panic-tb)
+ (defvar loc-pat)
+ (defvar test-pos)
+ (defvar prompt-pat)
+ (defvar test-dbgr)
+ (defvar carp-bt-re)
+ (defvar file-group)
+ (defvar line-group)
+ (defvar test-text)
+ (defvar lang-bt-pat)
+ (defvar lang-bt-re)
+ (defvar realgud-bt-pat)
+ (defvar realgud-bt-re)
+ (defvar test-s1)
+ (defvar realgud-perl-ignore-file-re)
+)
+
+; Some setup usually done in setting up the buffer.
+; We customize this for this debugger.
+; FIXME: encapsulate this.
+(setq dbg-name "perldb")
+(set (make-local-variable 'loc-pat)
+ (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:perldb-pat-hash))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :alt-line-group (realgud-loc-pat-alt-line-group loc-pat)
+ :alt-file-group (realgud-loc-pat-alt-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)
+ :text-group (realgud-loc-pat-text-group loc-pat)
+ ))
+
+(note "prompt")
+(prompt-match " DB<2> " "2")
+(prompt-match "[pid=6489->6502] DB<1> " "1")
+
+(setq test-text "((eval 1006)[../example/eval.pl:5])")
+(assert-equal 1 (string-match realgud:perldb-loc-eval-regexp
+ test-text)
+ "perldb eval loc matching")
+
+(assert-equal "../example/eval.pl"
+ (match-string (realgud-cmdbuf-info-alt-file-group test-dbgr)
+ test-text)
+ "extract file name when we have source text")
+
+(assert-equal "5"
+ (match-string (realgud-cmdbuf-info-alt-line-group test-dbgr)
+ test-text))
+
+(assert-equal 0 (string-match realgud-perl-ignore-file-re
+ "(eval 1006)[../example/eval.pl:5]")
+ "perldb file ignore matching")
+
+(setq test-text "main::(/usr/bin/latex2html:102):\n")
+
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
+(assert-equal "/usr/bin/latex2html"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text)
+ "extract file name")
+
+(setq test-text
"File::Basename::dirname(/usr/share/perl/5.16.0/File/Basename.pm:284): my $path
= shift;
+")
+
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr))
+ "location with source")
+(assert-equal "/usr/share/perl/5.16.0/File/Basename.pm"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text)
+ "extract file name when we have source text")
+(assert-equal "284"
+ (match-string (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text)
+ "extract line number when we have source text")
+(assert-equal "my $path = shift;"
+ (match-string (realgud-cmdbuf-info-text-group test-dbgr)
+ test-text)
+ "extract source text")
+
+(setq test-text "main::((eval 6)[eval.pl:5]:2): $x = 2;")
+
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "eval location")
+
+(assert-equal "eval.pl"
+ (match-string (realgud-cmdbuf-info-alt-file-group test-dbgr)
+ test-text)
+ "extract eval file name")
+
+(assert-equal "5"
+ (match-string (realgud-cmdbuf-info-alt-line-group test-dbgr)
+ test-text) "extract line number")
+
+(note "location for with CODE in it")
+(setq test-text "main::CODE(0x9407ac8)(l2hconf.pm:6):\n")
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)))
+(assert-equal "l2hconf.pm"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text))
+(assert-equal "6"
+ (match-string (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text))
+
+(note "debugger-backtrace")
+(setq realgud-bt-pat (gethash "debugger-backtrace"
+ realgud:perldb-pat-hash))
+(setq test-s1
+ "$ = main::top_navigation_panel called from file `./latex2html' line 7400
+p")
+(setq realgud-bt-re (realgud-loc-pat-regexp realgud-bt-pat))
+(setq file-group (realgud-loc-pat-file-group realgud-bt-pat))
+(setq line-group (realgud-loc-pat-line-group realgud-bt-pat))
+(assert-equal 30 (string-match realgud-bt-re test-s1))
+(assert-equal "./latex2html"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "7400"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(note "debugger-errmsg")
+(setq realgud-bt-pat (gethash "perl-errmsg"
+ realgud:perldb-pat-hash))
+(setq test-s1
+ "Use of uninitialized value $lines[0] in join or string at
bin/../lib/LineCache.pm line 548.")
+(setq realgud-bt-re (realgud-loc-pat-regexp realgud-bt-pat))
+(setq file-group (realgud-loc-pat-file-group realgud-bt-pat))
+(setq line-group (realgud-loc-pat-line-group realgud-bt-pat))
+(assert-equal 54 (string-match realgud-bt-re test-s1))
+(assert-equal "bin/../lib/LineCache.pm"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "548"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(note "carp-backtrace")
+(setq test-s1
+ " at /tmp/foo.pl line 7
+ main::__ANON__('Illegal division by zero at /tmp/foo.pl line 4.\x{a}')
called at foo2.pl line 5
+ main::foo(3) called at foo3.pl line 8
+")
+(setq lang-bt-pat (gethash "lang-backtrace"
+ realgud:perldb-pat-hash))
+(setq carp-bt-re (realgud-loc-pat-regexp lang-bt-pat))
+(setq file-group (realgud-loc-pat-file-group lang-bt-pat))
+(setq line-group (realgud-loc-pat-line-group lang-bt-pat))
+(assert-equal 0 (string-match carp-bt-re test-s1))
+(assert-equal "/tmp/foo.pl"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "7"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+
+(assert-equal 22 (string-match carp-bt-re test-s1 test-pos))
+(assert-equal "foo2.pl"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "5"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(setq test-pos (match-end 0))
+(assert-equal 119 (string-match carp-bt-re test-s1 test-pos))
+(assert-equal "foo3.pl"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "8"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-rdebug.el
b/packages/realgud/test/test-regexp-rdebug.el
new file mode 100644
index 0000000..26477b7
--- /dev/null
+++ b/packages/realgud/test/test-regexp-rdebug.el
@@ -0,0 +1,44 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/rdebug/init.el")
+(load-file "./regexp-helper.el")
+
+(test-simple-start)
+
+(setup-regexp-vars realgud-rdebug-pat-hash)
+(setq rails-bt (gethash "rails-backtrace" realgud-rdebug-pat-hash))
+
+;; FIXME: we get a void variable somewhere in here when running
+;; even though we define it in lexical-let. Dunno why.
+;; setq however will workaround this.
+(setq text " from /usr/local/bin/irb:12:in `<main>'")
+(note "traceback location matching")
+(lexical-let ((text " from /usr/local/bin/irb:12:in `<main>'"))
+ (assert-t (numberp (loc-match text helper-tb)) "basic traceback location")
+ (assert-equal "/usr/local/bin/irb"
+ (match-string (realgud-loc-pat-file-group helper-tb)
+ text)
+ "extract traceback file name")
+ (assert-equal "12"
+ (match-string (realgud-loc-pat-line-group helper-tb)
+ text) "extract traceback line number")
+ )
+
+(lexical-let ((text "Breakpoint 1 file /usr/bin/irb, line 10\n"))
+ (assert-t (numberp (loc-match text helper-bps)) "basic breakpoint location")
+ (assert-equal "/usr/bin/irb"
+ (match-string (realgud-loc-pat-file-group helper-bps)
+ text) "extract breakpoint file name")
+ (assert-equal "10"
+ (match-string (realgud-loc-pat-line-group helper-bps)
+ text) "extract breakpoint line number")
+ )
+
+(note "prompt")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud-rdebug-pat-hash))
+(prompt-match "(rdb:1) ")
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-remake.el
b/packages/realgud/test/test-regexp-remake.el
new file mode 100644
index 0000000..1a3390c
--- /dev/null
+++ b/packages/realgud/test/test-regexp-remake.el
@@ -0,0 +1,62 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/remake/init.el")
+(load-file "./regexp-helper.el")
+
+(test-simple-start)
+
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:remake-pat-hash))
+(set (make-local-variable 'frame-pat)
+ (gethash "debugger-backtrace" realgud:remake-pat-hash))
+
+(note "remake prompt")
+(prompt-match "remake<10> " "10")
+(prompt-match "remake<<1>> " "1" "recursive remake %s")
+
+(note "remake debugger-backtrace")
+(setq s1
+ "=>#0 Makefile.in at /tmp/Makefile:216
+ #1 Makefile at /tmp/Makefile:230
+")
+
+(set (make-local-variable 'frame-re)
+ (realgud-loc-pat-regexp frame-pat))
+(set (make-local-variable 'num-group)
+ (realgud-loc-pat-num frame-pat))
+(set (make-local-variable 'file-group)
+ (realgud-loc-pat-file-group frame-pat))
+(set (make-local-variable 'line-group)
+ (realgud-loc-pat-line-group frame-pat))
+
+(assert-equal 0 (string-match frame-re s1))
+(assert-equal "0" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/tmp/Makefile"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "216"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(set (make-local-variable 'pos)
+ (match-end 0))
+
+(assert-equal 39 (string-match frame-re s1 pos))
+(assert-equal "1" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/tmp/Makefile"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "230"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-ruby.el
b/packages/realgud/test/test-regexp-ruby.el
new file mode 100644
index 0000000..d15ab9c
--- /dev/null
+++ b/packages/realgud/test/test-regexp-ruby.el
@@ -0,0 +1,41 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+;; Don't have a pat-hash for ruby, so we need something that pulls in
+;; Ruby.
+(load-file "./regexp-helper.el")
+(load-file "../realgud/debugger/rdebug/init.el")
+
+(test-simple-start)
+
+(setq bt (gethash "rails-backtrace" realgud-rdebug-pat-hash))
+
+;; FIXME: we get a void variable somewhere in here when running
+;; even though we define it in lexical-let. Dunno why.
+;; setq however will workaround this.
+(setq text "/tmp/rails-2.3.5/lib/tasks/databases.rake:360")
+
+(lexical-let ((text "/tmp/rails-2.3.5/lib/tasks/databases.rake:360"))
+
+ (assert-t (numberp (loc-match text bt)) "basic traceback location")
+ (assert-equal "/tmp/rails-2.3.5/lib/tasks/databases.rake"
+ (match-string (realgud-loc-pat-file-group bt)
+ text) "extract traceback file name")
+ (assert-equal "360"
+ (match-string (realgud-loc-pat-line-group bt)
+ text) "extract traceback line number")
+ )
+
+(let ((text
+ "/tmp/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'"))
+
+ (assert-t (numberp (loc-match text bt)) "traceback location with in")
+ (assert-equal "/tmp/gems/rake-0.8.7/lib/rake.rb"
+ (match-string (realgud-loc-pat-file-group bt)
+ text) "extract traceback file name 2")
+ (assert-equal "597"
+ (match-string (realgud-loc-pat-line-group bt)
+ text) "extract breakpoint line number 2")
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-trepan.el
b/packages/realgud/test/test-regexp-trepan.el
new file mode 100644
index 0000000..bff0331
--- /dev/null
+++ b/packages/realgud/test/test-regexp-trepan.el
@@ -0,0 +1,124 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/trepan/init.el")
+(load-file "./regexp-helper.el")
+
+(test-simple-start)
+
+(set (make-local-variable 'bps-pat)
+ (gethash "brkpt-set" realgud:trepan-pat-hash))
+(set (make-local-variable 'dbg-bt-pat)
+ (gethash "debugger-backtrace" realgud:trepan-pat-hash))
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:trepan-pat-hash))
+(set (make-local-variable 'lang-bt-pat)
+ (gethash "lang-backtrace" realgud:trepan-pat-hash))
+(set (make-local-variable 'ctrl-pat)
+ (gethash "control-frame" realgud:trepan-pat-hash))
+
+;; FIXME: we get a void variable somewhere in here when running
+;; even though we define it in lexical-let. Dunno why.
+;; setq however will workaround this.
+(set (make-local-variable 'text)
+ " from /usr/local/bin/irb:12:in `<main>'")
+
+(note "traceback location matching")
+
+(setq text " from /usr/local/bin/irb:12:in `<main>'")
+
+(assert-t (numberp (loc-match text lang-bt-pat))
+ "basic traceback location")
+(assert-equal "/usr/local/bin/irb"
+ (match-string (realgud-loc-pat-file-group lang-bt-pat) text)
+ "extract traceback file name")
+
+(assert-equal "12"
+ (match-string (realgud-loc-pat-line-group
+ lang-bt-pat) text)
+ "extract traceback line number")
+
+(note "debugger-backtrace")
+(set (make-local-variable 's1)
+ "--> #0 METHOD Object#require(path) in file <internal:lib/require> at
line 28
+ #1 TOP Object#<top /tmp/linecache.rb> in file /tmp/linecache.rb
+")
+
+(set (make-local-variable 'frame-re)
+ (realgud-loc-pat-regexp dbg-bt-pat))
+(set (make-local-variable 'num-group)
+ (realgud-loc-pat-num dbg-bt-pat))
+(set (make-local-variable 'file-group)
+ (realgud-loc-pat-file-group dbg-bt-pat))
+(set (make-local-variable 'line-group)
+ (realgud-loc-pat-line-group dbg-bt-pat))
+
+(assert-equal 0 (string-match frame-re s1))
+(assert-equal "0" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "<internal:lib/require>"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "28"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq pos (match-end 0))
+
+(assert-equal 77 (string-match frame-re s1 pos))
+(assert-equal "1" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/tmp/linecache.rb"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+
+(note "prompt")
+(prompt-match "(trepan): ")
+(prompt-match "((trepan)): " nil "nested debugger prompt: %s")
+(prompt-match "((address@hidden)): " "@55" "nested debugger prompt with addr:
%s")
+(prompt-match "((address@hidden)): " "@main"
+ "nested debugger prompt with method: %s")
+(setq prompt-str "trepan:")
+(assert-nil (loc-match prompt-str prompt-pat)
+ (format "invalid prompt %s" prompt-str))
+
+
+(note "control-frame")
+(assert-equal 0 (loc-match
+ "c:0026 p:0181 s:0136 b:0136 l:000135 d:000135 METHOD
/trepan-0.0.1/app/frame.rb:132 "
+ ctrl-pat)
+ )
+(assert-equal 0 (loc-match
+ "c:0030 p:0041 s:0144 b:0144 l:00226c d:00226c METHOD
/gems/trepan-0.0.1/processor/eval.rb:15 "
+ ctrl-pat)
+ )
+(assert-equal 0 (loc-match
+ "c:0015 p:0139 s:0070 b:0070 l:000063 d:000069 BLOCK
/gems/app/core.rb:121"
+ ctrl-pat)
+ )
+
+(setq text "Breakpoint 1 set at VM offset 2 of instruction sequence \"<top
/usr/local/bin/irb>\",
+ line 9 in file /usr/local/bin/irb.
+")
+
+
+(assert-t (numberp (loc-match text bps-pat))
+ "basic breakpoint location")
+
+
+(assert-equal "/usr/local/bin/irb"
+ (match-string (realgud-loc-pat-file-group
+ bps-pat) text)
+ "extract breakpoint file name")
+
+(assert-equal "9"
+ (match-string (realgud-loc-pat-line-group
+ bps-pat) text)
+ "extract breakpoint line number")
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-trepan2.el
b/packages/realgud/test/test-regexp-trepan2.el
new file mode 100644
index 0000000..15ed531
--- /dev/null
+++ b/packages/realgud/test/test-regexp-trepan2.el
@@ -0,0 +1,167 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./regexp-helper.el")
+(load-file "../realgud/debugger/trepan2/init.el")
+
+(declare-function loc-match 'realgud-helper)
+(declare-function prompt-match 'regexp-helper)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+(declare-function setup-regexp-vars 'regexp-helper)
+(declare-function realgud-loc-pat-text-group 'realgud-trepan2-init)
+
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar file-group)
+ (defvar frame-re)
+ (defvar line-group)
+ (defvar num-group)
+ (defvar test-pos)
+ (defvar test-s1)
+ (defvar helper-tb)
+ (defvar helper-bps)
+ (defvar prompt-pat)
+ (defvar realgud-pat-bt)
+ (defvar helper-loc)
+ (defvar realgud:trepan2-pat-hash)
+ (defvar trepan2-text)
+)
+
+(note "prompt matching")
+
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:trepan2-pat-hash))
+
+(prompt-match "(trepan2) ")
+
+(setup-regexp-vars realgud:trepan2-pat-hash)
+
+(note "debugger-backtrace")
+(setq realgud-pat-bt (gethash "debugger-backtrace"
+ realgud:trepan2-pat-hash))
+(setq test-s1
+ "##0 gcd(a=3, b=5) called from file '/tmp/test/gcd.py' at line 31
+->1 <module> exec()
+ '/tmp/test/gcd2.py' at line 41
+")
+(setq frame-re (realgud-loc-pat-regexp realgud-pat-bt))
+(setq num-group (realgud-loc-pat-num realgud-pat-bt))
+(setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
+(setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
+(assert-equal 0 (string-match frame-re test-s1))
+(assert-equal "0" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/tmp/test/gcd.py"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "31"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+
+(assert-equal 64 (string-match frame-re test-s1 test-pos))
+(assert-equal "1" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/tmp/test/gcd2.py"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "41"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+(assert-equal 120 test-pos)
+
+(setq helper-tb (gethash "lang-backtrace" realgud:trepan2-pat-hash))
+
+(note "traceback location matching")
+(setq test-s1
+ " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
+
+(assert-t (numberp (loc-match test-s1 helper-tb))
+ "basic traceback location")
+
+(assert-equal "/usr/lib/python2.6/code.py"
+ (match-string (realgud-loc-pat-file-group helper-tb)
+ test-s1)
+ (format "extract file - failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "281"
+ (match-string (realgud-loc-pat-line-group helper-tb)
+ test-s1) "extract line number")
+
+(note "breakpoint location matching")
+
+(setq test-s1
+ "Breakpoint 1 set at line 13 of file /src/git/code/gcd.py")
+
+(assert-t (numberp (loc-match test-s1 helper-bps))
+ "basic breakpoint location")
+(assert-equal "/src/git/code/gcd.py"
+ (match-string (realgud-loc-pat-file-group helper-bps)
+ test-s1) "extract breakpoint file name")
+(assert-equal "13"
+ (match-string (realgud-loc-pat-line-group helper-bps)
+ test-s1)
+ "extract breakpoint line number")
+(setq test-s1 "(c:\\working\\python\\helloworld.py:30): <module>")
+(assert-t (numberp (loc-match test-s1 helper-loc))
+ "MS DOS position location")
+(assert-equal "c:\\working\\python\\helloworld.py"
+ (match-string (realgud-loc-pat-file-group helper-loc)
+ test-s1)
+ (format "extract file - Failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "30"
+ (match-string (realgud-loc-pat-line-group helper-loc)
+ test-s1) "extract line number")
+
+(setq test-s1 "(/usr/bin/ipython:24 @31): <module>")
+(assert-t (numberp (loc-match test-s1 helper-loc))
+ "position location")
+(assert-equal "/usr/bin/ipython"
+ (match-string (realgud-loc-pat-file-group helper-loc)
+ test-s1)
+ (format "extract-file - failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "24"
+ (match-string (realgud-loc-pat-line-group helper-loc)
+ test-s1)
+ "extract line number")
+
+(setq test-s1
+ "(/tmp/eval_stringzDKTfr.py:1 remapped <string>): <module>")
+(assert-t (numberp (loc-match test-s1 helper-loc)) "position location")
+(assert-equal "/tmp/eval_stringzDKTfr.py"
+ (match-string (realgud-loc-pat-file-group helper-loc)
+ test-s1)
+ (format "extract-file name - failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "1"
+ (match-string (realgud-loc-pat-line-group helper-loc)
+ test-s1) "extract line number")
+
+(note "source text")
+
+(setq test-s1
+ "(/usr/local/bin/trepan2:4): <module>\n-- 4 [34mimport[39;49;00m
[39;49;00m[04m[36msys[39;49;00m\n(trepan2) ")
+(assert-t (numberp (loc-match test-s1 helper-loc)) "source location")
+(assert-equal
+ "[34mimport[39;49;00m [39;49;00m[04m[36msys[39;49;00m"
+ (match-string (realgud-loc-pat-text-group helper-loc)
+ test-s1) "extract source text")
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-trepan3k.el
b/packages/realgud/test/test-regexp-trepan3k.el
new file mode 100644
index 0000000..1c60d52
--- /dev/null
+++ b/packages/realgud/test/test-regexp-trepan3k.el
@@ -0,0 +1,167 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "./regexp-helper.el")
+(load-file "../realgud/debugger/trepan3k/init.el")
+
+(declare-function loc-match 'realgud-helper)
+(declare-function prompt-match 'regexp-helper)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+(declare-function setup-regexp-vars 'regexp-helper)
+(declare-function realgud-loc-pat-text-group 'realgud-trepan3k-init)
+
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar file-group)
+ (defvar frame-re)
+ (defvar line-group)
+ (defvar num-group)
+ (defvar test-pos)
+ (defvar test-s1)
+ (defvar helper-tb)
+ (defvar helper-bps)
+ (defvar prompt-pat)
+ (defvar realgud-pat-bt)
+ (defvar helper-loc)
+ (defvar realgud:trepan3k-pat-hash)
+ (defvar trepan3k-text)
+)
+
+(note "prompt matching")
+
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:trepan3k-pat-hash))
+
+(prompt-match "(trepan3k) ")
+
+(setup-regexp-vars realgud:trepan3k-pat-hash)
+
+(note "debugger-backtrace")
+(setq realgud-pat-bt (gethash "debugger-backtrace"
+ realgud:trepan3k-pat-hash))
+(setq test-s1
+ "##0 gcd(a=3, b=5) called from file '/tmp/test/gcd.py' at line 31
+->1 <module> exec()
+ '/tmp/test/gcd2.py' at line 41
+")
+(setq frame-re (realgud-loc-pat-regexp realgud-pat-bt))
+(setq num-group (realgud-loc-pat-num realgud-pat-bt))
+(setq file-group (realgud-loc-pat-file-group realgud-pat-bt))
+(setq line-group (realgud-loc-pat-line-group realgud-pat-bt))
+(assert-equal 0 (string-match frame-re test-s1))
+(assert-equal "0" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/tmp/test/gcd.py"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "31"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+
+(assert-equal 64 (string-match frame-re test-s1 test-pos))
+(assert-equal "1" (substring test-s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/tmp/test/gcd2.py"
+ (substring test-s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "41"
+ (substring test-s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq test-pos (match-end 0))
+(assert-equal 120 test-pos)
+
+(setq helper-tb (gethash "lang-backtrace" realgud:trepan3k-pat-hash))
+
+(note "traceback location matching")
+(setq test-s1
+ " File \"/usr/lib/python2.6/code.py\", line 281, in raw_input")
+
+(assert-t (numberp (loc-match test-s1 helper-tb))
+ "basic traceback location")
+
+(assert-equal "/usr/lib/python2.6/code.py"
+ (match-string (realgud-loc-pat-file-group helper-tb)
+ test-s1)
+ (format "extract file - failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "281"
+ (match-string (realgud-loc-pat-line-group helper-tb)
+ test-s1) "extract line number")
+
+(note "breakpoint location matching")
+
+(setq test-s1
+ "Breakpoint 1 set at line 13 of file /src/git/code/gcd.py")
+
+(assert-t (numberp (loc-match test-s1 helper-bps))
+ "basic breakpoint location")
+(assert-equal "/src/git/code/gcd.py"
+ (match-string (realgud-loc-pat-file-group helper-bps)
+ test-s1) "extract breakpoint file name")
+(assert-equal "13"
+ (match-string (realgud-loc-pat-line-group helper-bps)
+ test-s1)
+ "extract breakpoint line number")
+(setq test-s1 "(c:\\working\\python\\helloworld.py:30): <module>")
+(assert-t (numberp (loc-match test-s1 helper-loc))
+ "MS DOS position location")
+(assert-equal "c:\\working\\python\\helloworld.py"
+ (match-string (realgud-loc-pat-file-group helper-loc)
+ test-s1)
+ (format "extract file - Failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "30"
+ (match-string (realgud-loc-pat-line-group helper-loc)
+ test-s1) "extract line number")
+
+(setq test-s1 "(/usr/bin/ipython:24): <module>")
+(assert-t (numberp (loc-match test-s1 helper-loc))
+ "position location")
+(assert-equal "/usr/bin/ipython"
+ (match-string (realgud-loc-pat-file-group helper-loc)
+ test-s1)
+ (format "extract-file - failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "24"
+ (match-string (realgud-loc-pat-line-group helper-loc)
+ test-s1)
+ "extract line number")
+
+(setq test-s1
+ "(/tmp/eval_stringzDKTfr.py:1 remapped <string>): <module>")
+(assert-t (numberp (loc-match test-s1 helper-loc)) "position location")
+(assert-equal "/tmp/eval_stringzDKTfr.py"
+ (match-string (realgud-loc-pat-file-group helper-loc)
+ test-s1)
+ (format "extract-file name - failing file group is %s"
+ (realgud-loc-pat-file-group helper-tb)))
+(assert-equal "1"
+ (match-string (realgud-loc-pat-line-group helper-loc)
+ test-s1) "extract line number")
+
+(note "source text")
+
+(setq test-s1
+ "(/usr/local/bin/trepan3k:4): <module>\n-- 4 [34mimport[39;49;00m
[39;49;00m[04m[36msys[39;49;00m\n(trepan3k) ")
+(assert-t (numberp (loc-match test-s1 helper-loc)) "source location")
+(assert-equal
+ "[34mimport[39;49;00m [39;49;00m[04m[36msys[39;49;00m"
+ (match-string (realgud-loc-pat-text-group helper-loc)
+ test-s1) "extract source text")
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-trepanjs.el
b/packages/realgud/test/test-regexp-trepanjs.el
new file mode 100644
index 0000000..d26102d
--- /dev/null
+++ b/packages/realgud/test/test-regexp-trepanjs.el
@@ -0,0 +1,94 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/trepanjs/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
+(declare-function cmdbuf-loc-match 'realgud-regexp)
+(declare-function loc-match 'realgud-helper)
+(declare-function prompt-match 'regexp-helper)
+(declare-function realgud-loc-pat-num 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+(declare-function setup-regexp-vars 'regexp-helper)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar dbg-name)
+ (defvar loc-pat)
+ (defvar bt-pat)
+ (defvar prompt-pat)
+ (defvar realgud:trepanjs-pat-hash)
+ (defvar realgud-pat-hash)
+ (defvar helper-bps)
+ (defvar test-dbgr)
+ (defvar test-text)
+ (defvar test-s1)
+)
+
+(setup-regexp-vars realgud:trepanjs-pat-hash)
+
+(note "trepanjs prompt matching")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:trepanjs-pat-hash))
+(prompt-match "(trepanjs) ")
+(prompt-match "[1G[0J(trepanjs) [8G[1G[0Kconnecting... ok")
+
+(note "trepanjs location matching")
+(setq dbg-name "trepanjs")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+(setq test-text "break in test/fixtures/break-in-module/main.js at line
1:23\n")
+(assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
+
+(string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
+(assert-equal "test/fixtures/break-in-module/main.js"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ test-text) "extract file name")
+
+(string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
+(assert-equal "1"
+ (match-string
+ (realgud-cmdbuf-info-line-group test-dbgr)
+ test-text) "extract line number")
+
+(note "breakpoint location matching")
+
+(setq test-text
+ "Breakpoint 2 set in file /tmp/gcd.js, line 2.
+")
+
+(assert-t (numberp (loc-match test-text helper-bps))
+ "basic breakpoint location")
+(assert-equal "/tmp/gcd.js"
+ (match-string (realgud-loc-pat-file-group helper-bps)
+ test-text) "extract breakpoint file name")
+(assert-equal "2"
+ (match-string (realgud-loc-pat-line-group helper-bps)
+ test-text)
+ "extract breakpoint line number")
+
+(note "debugger-backtrace")
+(setq test-text
+ "##1 in file /tmp/test/gcd.js at line 2:12"
+)
+
+(set (make-local-variable
+ 'bt-pat)
+ (gethash "debugger-backtrace" realgud:trepanjs-pat-hash))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-trepanpl.el
b/packages/realgud/test/test-regexp-trepanpl.el
new file mode 100644
index 0000000..694dc1d
--- /dev/null
+++ b/packages/realgud/test/test-regexp-trepanpl.el
@@ -0,0 +1,89 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/debugger/trepan.pl/init.el")
+(load-file "./regexp-helper.el")
+
+(eval-when-compile
+ (defvar realgud:trepanpl-pat-hash)
+ (defvar prompt-str)
+ (defvar test-dbgr)
+ (defvar carp-bt-re)
+ (defvar file-group)
+ (defvar line-group)
+ (defvar test-text)
+ (defvar dbg-bt-pat)
+ (defvar bps-pat)
+ (defvar realgud-bt-pat)
+ (defvar realgud-perl-ignnore-file-re)
+)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(set (make-local-variable 'helper-bps)
+ (gethash "brkpt-set" realgud:trepanpl-pat-hash))
+(set (make-local-variable 'prompt)
+ (gethash "prompt" realgud:trepanpl-pat-hash))
+(set (make-local-variable 'helper-tb)
+ (gethash "lang-backtrace" realgud:trepanpl-pat-hash))
+
+
+(note "prompt matching")
+(set (make-local-variable 'prompt-pat)
+ (gethash "prompt" realgud:trepanpl-pat-hash))
+(prompt-match "(trepanpl): ")
+(prompt-match "((trepanpl)): " nil "nested debugger prompt: %s")
+(setq prompt-str "trepanpl:")
+(assert-nil (loc-match prompt-str prompt-pat)
+ (format "invalid prompt %s" prompt-str))
+
+(setq test-text "Breakpoint 2 set in /tmp/File/Basename.pm at line 215")
+
+(assert-t (numberp (bp-loc-match test-text))
+ "basic breakpoint location")
+(assert-equal "/tmp/File/Basename.pm"
+ (match-string (realgud-loc-pat-file-group helper-bps)
+ test-text)
+ "extract breakpoint file name"
+ )
+(assert-equal "215"
+ (match-string (realgud-loc-pat-line-group helper-bps)
+ test-text)
+ "extract breakpoint line number"
+ )
+
+(setq test-text "Breakpoint 1 set in (eval 1177)[/Eval.pm:94] at line 5")
+(assert-t (numberp (bp-loc-match test-text)) "eval breakpoint location")
+(setq bps-pat
+ (gethash "brkpt-set" realgud:trepanpl-pat-hash))
+(setq dbg-bt-pat
+ (gethash "debugger-backtrace" realgud:trepanpl-pat-hash))
+(setq prompt-pat
+ (gethash "prompt" realgud:trepanpl-pat-hash))
+(setq lang-bt-pat
+ (gethash "lang-backtrace" realgud:trepanpl-pat-hash))
+
+(note "prompt")
+(prompt-match "(trepanpl): ")
+(prompt-match "((trepanpl)): " nil "nested debugger prompt: %s")
+
+(setq test-text "Breakpoint 1 set in /tmp/gcd.pl at line 9")
+
+(assert-t (numberp (loc-match test-text bps-pat))
+ "basic breakpoint location")
+
+
+(assert-equal "/tmp/gcd.pl"
+ (match-string (realgud-loc-pat-file-group
+ bps-pat) test-text)
+ "extract breakpoint file name")
+
+(assert-equal "9"
+ (match-string (realgud-loc-pat-line-group
+ bps-pat) test-text)
+ "extract breakpoint line number")
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp-zshdb.el
b/packages/realgud/test/test-regexp-zshdb.el
new file mode 100644
index 0000000..c9ff95a
--- /dev/null
+++ b/packages/realgud/test/test-regexp-zshdb.el
@@ -0,0 +1,70 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/zshdb/init.el")
+(load-file "./regexp-helper.el")
+
+(test-simple-start)
+
+(setq prompt-pat (gethash "prompt" realgud:zshdb-pat-hash))
+(setq frame-pat (gethash "debugger-backtrace" realgud:zshdb-pat-hash))
+
+(note "zshdb prompt matching")
+(prompt-match "zshdb<10> " "10")
+(prompt-match "zshdb<(5)> " "5" "subshell prompt %s")
+(prompt-match "zshdb<<1>> " "1" "nested debug prompt %s")
+
+(note "zshdb frame matching")
+
+(note "debugger-backtrace")
+(setq s1
+ "->0 in file `/etc/apparmor/functions' at line 24
+##1 /etc/apparmor/functions called from file `/etc/init.d/apparmor' at line 35
+##2 /etc/init.d/apparmor called from file `/usr/local/bin/zshdb' at line 129
+")
+(setq frame-re (realgud-loc-pat-regexp frame-pat))
+(setq num-group (realgud-loc-pat-num frame-pat))
+(setq file-group (realgud-loc-pat-file-group frame-pat))
+(setq line-group (realgud-loc-pat-line-group frame-pat))
+(assert-equal 0 (string-match frame-re s1))
+(assert-equal "0" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/etc/apparmor/functions"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "24"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq pos (match-end 0))
+
+(assert-equal 49 (string-match frame-re s1 pos))
+(assert-equal "1" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/etc/init.d/apparmor"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "35"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+(setq pos (match-end 0))
+(assert-equal 128 (string-match frame-re s1 pos))
+(assert-equal "2" (substring s1
+ (match-beginning num-group)
+ (match-end num-group)))
+(assert-equal "/usr/local/bin/zshdb"
+ (substring s1
+ (match-beginning file-group)
+ (match-end file-group)))
+(assert-equal "129"
+ (substring s1
+ (match-beginning line-group)
+ (match-end line-group)))
+
+(end-tests)
diff --git a/packages/realgud/test/test-regexp.el
b/packages/realgud/test/test-regexp.el
new file mode 100644
index 0000000..da9a81a
--- /dev/null
+++ b/packages/realgud/test/test-regexp.el
@@ -0,0 +1,77 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'load-relative)
+(require 'test-simple)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/trepan/init.el")
+(load-file "./regexp-helper.el")
+
+(declare-function cmdbuf-loc-match 'realgud-regexp)
+(declare-function make-realgud-cmdbuf-info 'realgud-regexp)
+(declare-function realgud-cmdbuf-info 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-file-group 'realgud-regexp)
+(declare-function realgud-cmdbuf-info-line-group 'realgud-regexp)
+(declare-function realgud-loc-pat-file-group 'realgud-regexp)
+(declare-function realgud-loc-pat-line-group 'realgud-regexp)
+(declare-function realgud-loc-pat-regexp 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar dbg-name)
+ (defvar realgud-pat-hash)
+ (defvar loc-pat)
+ (defvar test-dbgr)
+)
+
+; Some setup usually done in setting up the buffer.
+; We customize this for the debugger trepan. Others may follow.
+; FIXME: encapsulate this.
+(setq dbg-name "trepan")
+(setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
+
+(setq test-dbgr (make-realgud-cmdbuf-info
+ :debugger-name dbg-name
+ :loc-regexp (realgud-loc-pat-regexp loc-pat)
+ :file-group (realgud-loc-pat-file-group loc-pat)
+ :line-group (realgud-loc-pat-line-group loc-pat)))
+
+
+(lexical-let ((text ".. (./dbgr.rb:73)")
+ (text2 "C> ((eval):1 via /tmp/eval2.rb:2)")
+ (text3 "-- (<internal:prelude>:28 remapped prelude.rb:28)")
+ (text4 "--
(/src/external-vcs/dbgrr/processor/command/info_subcmd/registers_subcmd/dfp.rb:2)\nrequire_relative
%w(.. .. base subsubcmd)\n")
+ )
+
+ (assert-t (numberp (cmdbuf-loc-match text test-dbgr)) "basic location")
+ (assert-equal "./dbgr.rb"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ text) "extract file name")
+ (assert-equal "73"
+ (match-string (realgud-cmdbuf-info-line-group test-dbgr)
+ text) "extract line number")
+ (assert-t (numberp (cmdbuf-loc-match text4 test-dbgr)) "more complex
location")
+
+
+ ;; Now try 'via'
+ (assert-t (numberp (cmdbuf-loc-match text2 test-dbgr)) "basic 'via'
location")
+ (assert-equal "/tmp/eval2.rb"
+ (match-string (realgud-cmdbuf-info-file-group test-dbgr)
+ text2)
+ "extract via file name")
+ (assert-equal "2" (match-string (realgud-cmdbuf-info-line-group test-dbgr)
+ text2)
+ "extract via line number")
+
+ ;; Now try remap
+ (assert-t (numberp (cmdbuf-loc-match text3 test-dbgr)) "basic 'via'
location")
+
+ ;;
+ (setq text "--> #0 METHOD Object#square(x) in file ./trepan.rb at line 73")
+ (assert-nil (numberp (cmdbuf-loc-match text test-dbgr)) "unmatched location")
+
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-remake-core.el
b/packages/realgud/test/test-remake-core.el
new file mode 100644
index 0000000..1f76d22
--- /dev/null
+++ b/packages/realgud/test/test-remake-core.el
@@ -0,0 +1,38 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/remake/core.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function remake-parse-cmd-args 'realgud-remake-core)
+(declare-function remake-suggest-Makefile 'realgud-remake-core)
+(declare-function remake-suggest-file-priority 'realgud-remake-core)
+
+(test-simple-start)
+
+(assert-equal (list "remake" (expand-file-name "Makefile")
+ (list "-X" "-f" (expand-file-name "Makefile")))
+ (remake-parse-cmd-args
+ '("remake" "-X" "-f" "Makefile"))
+ "remake-parse-cmd-args")
+
+(assert-equal "Makefile" (remake-suggest-Makefile) "remake-suggest-Makefile")
+
+(assert-equal 2 (remake-suggest-file-priority "foo")
+ "remake-file-suggest-priority")
+(let ((buffer (get-file-buffer "Makefile.am")))
+ (if buffer (kill-buffer buffer))
+ (assert-equal 2 (remake-suggest-file-priority "Makefile.am"))
+ (setq buffer (find-file-noselect "Makefile.am"))
+ (assert-equal 5 (remake-suggest-file-priority "Makefile.am"))
+ (kill-buffer buffer)
+ (setq buffer (get-file-buffer "Makefile"))
+ (if buffer (kill-buffer buffer))
+ (assert-equal 6 (remake-suggest-file-priority "Makefile"))
+ (setq buffer (find-file-noselect "Makefile"))
+ (assert-equal 8 (remake-suggest-file-priority "Makefile"))
+ (kill-buffer buffer)
+ )
+
+(end-tests)
diff --git a/packages/realgud/test/test-remake.el
b/packages/realgud/test/test-remake.el
new file mode 100644
index 0000000..f441932
--- /dev/null
+++ b/packages/realgud/test/test-remake.el
@@ -0,0 +1,37 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/core.el") ;; for realgud-exec-shell
+(load-file "../realgud/debugger/remake/remake.el")
+
+(eval-when-compile (defvar my-buf))
+
+(declare-function realgud:remake 'realgud:remake)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(defun realgud-exec-shell (debugger-name script-filename program
+ &optional no-reset &rest args)
+ "Mock for realgud-exec-shell. We copy the part of the real realgud-exec-shell
+file-name-directory that was failing"
+ (let ((cmdproc-buffer (get-buffer-create "foo"))
+ (starting-directory
+ (or (file-name-directory script-filename)
+ default-directory "./")))
+ (start-process "my-process" cmdproc-buffer "sleep" "10000")
+ cmdproc-buffer
+ )
+ )
+
+(note "can deal with no Makefile name")
+;; If realgud:remake is successful we switch buffers
+(setq my-buf (current-buffer))
+;; FIXME:
+;; (realgud:remake "remake --debugger")
+;; (assert-t (not (eq (current-buffer) my-buf)))
+;; (delete-process "foo")
+;; (switch-to-buffer my-buf)
+
+(end-tests)
diff --git a/packages/realgud/test/test-send.el
b/packages/realgud/test/test-send.el
new file mode 100644
index 0000000..580cfd5
--- /dev/null
+++ b/packages/realgud/test/test-send.el
@@ -0,0 +1,61 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+
+(load-file "../realgud/common/send.el")
+(load-file "../realgud/common/regexp.el")
+(load-file "../realgud/debugger/trepan/init.el")
+
+(declare-function realgud-srcbuf-init 'realgud-buffer-source)
+(test-simple-start)
+
+(eval-when-compile
+ (defvar temp-cmdbuf nil)
+ (defvar realgud-pat-hash)
+ (defvar file-name)
+)
+
+(defun setup ()
+ (setq temp-cmdbuf (generate-new-buffer "*cmdbuf-test*"))
+ (realgud-cmdbuf-init temp-cmdbuf "trepan" (gethash "trepan"
realgud-pat-hash))
+ (realgud-srcbuf-init (current-buffer) temp-cmdbuf)
+)
+
+(defun tear-down()
+ (kill-buffer temp-cmdbuf)
+)
+
+(dolist (str '("abc" "100%" "I feel %% today"))
+ (assert-equal str (realgud-expand-format str "format no expand characters")))
+
+
+(assert-equal "line 5" (realgud-expand-format "line %p" 5)
+ "format %l - with arg")
+(assert-equal "line " (realgud-expand-format "line %p")
+ "format %l - without arg")
+
+(assert-equal "hi, rocky!"
+ (realgud-expand-format "h%s!" "i, rocky")
+ "format %s")
+
+(setup)
+;; Current buffer is now set up as a source buffer
+(setq file-name (buffer-file-name))
+(note "File formatting")
+(if (and file-name (realgud-get-srcbuf (current-buffer)))
+ (dolist
+ (pair
+ (list
+ (cons "%d" (file-name-directory file-name))
+ (cons "%x" file-name)
+ (cons "%X" (expand-file-name file-name))
+ (cons "%f" "test-send.el")
+ (cons "%F" "test-send")))
+ (assert-equal (cdr pair) (realgud-expand-format (car pair)))))
+(tear-down)
+
+
+(assert-raises error (realgud-command "testing"))
+
+(end-tests)
diff --git a/packages/realgud/test/test-shortkey.el
b/packages/realgud/test/test-shortkey.el
new file mode 100644
index 0000000..5f599d9
--- /dev/null
+++ b/packages/realgud/test/test-shortkey.el
@@ -0,0 +1,40 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+(load-file "../realgud/common/shortkey.el")
+(load-file "../realgud/common/buffer/command.el")
+(declare-function realgud-cmdbuf-init 'realgud-buffer-command)
+(declare-function realgud-shortkey-mode-setup 'realgud-shortkey)
+(declare-function realgud-get-short-key-mode-map 'realgud-shortkey)
+
+(eval-when-compile
+ (defvar temp-cmdbuf)
+ (defvar debugger-name)
+ (defvar realgud-pat-hash)
+ (defvar test-keymap)
+ (defvar nodejs-short-key-mode-map)
+)
+
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(note "realgud-shortkey")
+(assert-raises error (realgud-shortkey-mode-setup))
+(assert-nil (realgud-get-short-key-mode-map (current-buffer)))
+
+(note "realgud-get-short-key-mode-map")
+
+(setq temp-cmdbuf (generate-new-buffer "*cmdbuf-test*"))
+(setq debugger-name "nodejs")
+(load-file "../realgud/debugger/nodejs/nodejs.el")
+(realgud-cmdbuf-init temp-cmdbuf debugger-name
+ (gethash debugger-name realgud-pat-hash))
+(setq test-keymap (realgud-get-short-key-mode-map temp-cmdbuf))
+(assert-t (keymapp test-keymap)
+ "realgud-get-short-key-mode-map returns keymap")
+(assert-equal test-keymap nodejs-short-key-mode-map
+ "realgud-get-short-key-mode-map returns nodejs-short-key-mode-map")
+(end-tests)
diff --git a/packages/realgud/test/test-srcbuf.el
b/packages/realgud/test/test-srcbuf.el
new file mode 100644
index 0000000..a910c42
--- /dev/null
+++ b/packages/realgud/test/test-srcbuf.el
@@ -0,0 +1,72 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/buffer/source.el")
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/trepan/init.el")
+(load-file "../realgud/debugger/trepan/track-mode.el")
+
+(declare-function realgud-cmdbuf-init 'realgud-buffer-command)
+(declare-function realgud-srcbuf-init 'realgud-buffer-source)
+(declare-function __FILE__ 'load-relative)
+
+(declare-function realgud-srcbuf? 'realgud-buffer-source)
+(declare-function realgud-srcbuf-loc-p 'realgud-loc)
+(declare-function realgud-srcbuf-info-debugger-name 'realgud-loc)
+(declare-function realgud-srcbuf-info-cmdproc 'realgud-track)
+(declare-function realgud-srcbuf-init-or-update 'realgud-track)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar realgud-pat-hash)
+ (defvar realgud-srcbuf-info)
+ (defvar temp-srcbuf)
+ (defvar test-filename)
+)
+
+(defvar temp-cmdbuf nil)
+(defun tear-down()
+ (kill-buffer temp-cmdbuf)
+ (kill-buffer temp-srcbuf)
+)
+
+(defun setup ()
+ (setq temp-cmdbuf (generate-new-buffer "*cmdbuf-test*"))
+ (realgud-cmdbuf-init temp-cmdbuf "trepan" (gethash "trepan"
realgud-pat-hash))
+ (setq temp-srcbuf (find-file-noselect "./gcd.rb"))
+)
+
+(assert-nil (realgud-srcbuf? (current-buffer)) "realgud-srcbuf? before init")
+(setq realgud-srcbuf-info nil)
+(assert-nil (realgud-srcbuf? (current-buffer))
+ "realgud-srcbuf? before init - but nil")
+
+(note "realgud-srcbuf-init")
+(setup)
+(realgud-srcbuf-init temp-srcbuf temp-cmdbuf)
+
+(assert-t (realgud-srcbuf? temp-srcbuf)
+ "realgud-srcbuf? after init")
+
+(assert-equal temp-cmdbuf
+ (with-current-buffer temp-srcbuf
+ (realgud-srcbuf-info-cmdproc realgud-srcbuf-info)))
+
+(realgud-srcbuf-init-or-update temp-srcbuf temp-cmdbuf)
+(assert-equal temp-cmdbuf
+ (with-current-buffer temp-srcbuf
+ (realgud-srcbuf-info-cmdproc realgud-srcbuf-info))
+ "realgud-srcbuf-init-or-update - update")
+
+(kill-buffer temp-srcbuf)
+(setq temp-srcbuf (find-file-noselect "./gcd.rb"))
+(realgud-srcbuf-init-or-update temp-srcbuf temp-cmdbuf)
+(assert-equal temp-cmdbuf
+ (with-current-buffer temp-srcbuf
+ (realgud-srcbuf-info-cmdproc realgud-srcbuf-info))
+ "realgud-srcbuf-init-or-update - init")
+(tear-down)
+
+(end-tests)
diff --git a/packages/realgud/test/test-track-mode.el
b/packages/realgud/test/test-track-mode.el
new file mode 100644
index 0000000..7128e6d
--- /dev/null
+++ b/packages/realgud/test/test-track-mode.el
@@ -0,0 +1,66 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'comint)
+(load-file "../realgud/debugger/trepan/trepan.el")
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/common/track-mode.el")
+(load-file "../realgud/common/backtrace-mode.el")
+
+(declare-function realgud-cmdbuf-init 'realgud-buffer-command)
+(declare-function realgud-srcbuf-init 'realgud-buffer-source)
+(declare-function __FILE__ 'load-relative)
+
+(test-simple-start)
+
+(defvar realgud-pat-hash)
+(defvar temp-cmdbuf nil)
+
+(declare-function trepan-track-mode 'realgud:trepan)
+(declare-function realgud-track-mode-vars 'realgud-track-mode)
+(declare-function realgud-backtrace-mode 'realgud-backtrace-mode)
+
+(defun setup ()
+ (setq temp-cmdbuf (generate-new-buffer "*cmdbuf-test*"))
+ ;; (start-process "test-track-mode" temp-cmdbuf nil)
+ (start-process "test-track-mode" temp-cmdbuf "/bin/sh")
+
+ (realgud-cmdbuf-init temp-cmdbuf "trepan" (gethash "trepan"
realgud-pat-hash))
+ (with-current-buffer temp-cmdbuf
+ (comint-mode)
+ (trepan-track-mode 't))
+ (realgud-srcbuf-init (current-buffer) temp-cmdbuf)
+)
+
+(defun tear-down()
+ (kill-buffer temp-cmdbuf)
+)
+
+(setup)
+
+;; Current buffer is now set up as a source buffer
+
+(with-current-buffer temp-cmdbuf
+ (switch-to-buffer temp-cmdbuf)
+ (dolist (fn '(realgud-track-hist-newest
+ realgud-track-hist-newer
+ realgud-track-hist-older
+ realgud-track-hist-oldest))
+ (assert-nil (null (where-is-internal fn))
+ (format "track-functions-mapped-to-keys %s" fn))
+ )
+ (switch-to-buffer nil)
+ )
+
+(note "track-mode-vars")
+(makunbound 'foo-track-mode)
+(makunbound 'foo-track-mode-map)
+(realgud-track-mode-vars "foo")
+(dolist (var '("foo-track-mode-map" "foo-track-mode"))
+ (let ((var-sym (intern var)))
+ (assert-t (boundp var-sym))
+ (assert-t (stringp (get var-sym 'variable-documentation)))
+ ))
+
+(end-tests)
diff --git a/packages/realgud/test/test-track.el
b/packages/realgud/test/test-track.el
new file mode 100644
index 0000000..d0bb147
--- /dev/null
+++ b/packages/realgud/test/test-track.el
@@ -0,0 +1,119 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/track.el")
+(load-file "../realgud/common/core.el")
+(load-file "../realgud/common/loc.el")
+(load-file "../realgud/debugger/trepan/core.el")
+(load-file "../realgud/debugger/trepan/init.el")
+
+(declare-function __FILE__ 'load-relative)
+(declare-function realgud-cmdbuf-init 'realgud-buffer-command)
+(declare-function realgud-loc-filename 'realgud-loc)
+(declare-function realgud-loc-p 'realgud-loc)
+(declare-function realgud-loc-line-number 'realgud-loc)
+(declare-function realgud:track-from-region 'realgud-track)
+(declare-function realgud-track-loc 'realgud-track)
+(declare-function realgud-track-loc-remaining 'realgud-track)
+(declare-function realgud-track-selected-frame 'realgud-track)
+(declare-function realgud-track-termination? 'realgud-track)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar debugger-output)
+ (defvar line-number)
+ (defvar realgud-pat-hash)
+ (defvar test-filename)
+)
+
+;; Some setup usually done in setting up the buffer.
+;; We customize this for the debugger trepan. Others may follow.
+;; FIXME: encapsulate this.
+(makunbound 'realgud-cmdbuf-info)
+
+;; FIXME/WARNING the below is customized for trepan
+(realgud-cmdbuf-init (current-buffer) "trepan"
+ (gethash "trepan" realgud-pat-hash))
+
+(setq test-filename (symbol-file 'test-simple))
+(setq line-number 7)
+(setq debugger-output (format "-> (%s:%d)\nrequire 'foo'\n(trepan):\n"
+ test-filename line-number))
+(lexical-let ((loc (realgud-track-loc debugger-output nil)))
+ (assert-t (realgud-loc-p loc) "loc extracted")
+ (assert-equal "(trepan):\n"
+ (realgud-track-loc-remaining debugger-output)
+ "loc-remaining")
+ (assert-equal test-filename (realgud-loc-filename loc)
+ "loc filename extracted")
+ (assert-equal line-number (realgud-loc-line-number loc)
+ "loc line-number extracted")
+ )
+
+(note "realgud-track-selected-frame")
+(setq debugger-output "up
+--> #1 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/irb at line 9
+ (/usr/local/bin/irb:9 @11)
+require irb'
+")
+(assert-equal 1 (realgud-track-selected-frame debugger-output))
+
+(setq debugger-output "
+--> #0 TOP Object#<top /usr/local/bin/irb> in file /usr/local/bin/irb at line 9
+ (/usr/local/bin/irb:9 @11)
+require irb'
+")
+(assert-equal 0 (realgud-track-selected-frame debugger-output))
+
+(setq debugger-output "
+<- (<internal:lib/rubygems/custom_require>:38 remapped
/usr/local/lib/ruby/gems/1.9.1/gems/trepanning-0.1.3.dev/data/custom_require.rb:38
@16)
+R=> false
+end
+")
+(assert-nil (realgud-track-selected-frame debugger-output))
+
+
+(note "realgud-track-termination?")
+(setq debugger-output "-- (/usr/local/bin/irb:9 @2)
+require 'irb'
+")
+(assert-nil (realgud-track-termination? debugger-output))
+(setq debugger-output "Really quit? (N/y) y
+trepan: That's all, folks...
+")
+(assert-t (realgud-track-termination? debugger-output))
+
+
+;; (setq debugger-bp-output (format "Breakpoint %d set at line %d\n\tin file
%s.\n"
+;; bp-num line-number test-filename))
+;; (setq bp-loc (realgud-track-bp-loc debugger-bp-output nil))
+;; (setq bp-num 2)
+
+;; (specify "bp-loc extracted"
+;; (message "output: %s" debugger-bp-output)
+;; (message "bp-loc: %s" bp-loc)
+;; (message "bp-num: %d" bp-num)
+;; (assert-t (realgud-loc-p bp-loc))
+;; (assert-equal bp-num (realgud-loc-num bp-loc)))
+
+;; (specify "realgud-track-divert-prompt"
+;; (realgud-cmdbuf-info-divert-output?= 't)
+;; (setq realgud-track-divert-string "")
+;; (setq text
+;; "--> #0 TOP Object#<top /usr/local/bin/irb> in file
/usr/local/bin/irb at line 9\n(trepan): ")
+;; (setq realgud-last-output-start (point-max))
+;; (realgud-track-divert-prompt text (current-buffer) (point-max))
+;; (assert-equal "--> #0 TOP Object#<top /usr/local/bin/irb> in file
/usr/local/bin/irb at line 9\n"
+;; realgud-track-divert-string)
+;; (assert-equal nil (realgud-sget 'cmdbuf-info 'divert-output?))
+;; )
+
+(makunbound 'realgud-cmdbuf-info)
+(assert-raises error
+ (realgud:track-from-region (point-min)
+ (point-max))
+ "invalid cmdbuf")
+
+(end-tests)
diff --git a/packages/realgud/test/test-trepan2.el
b/packages/realgud/test/test-trepan2.el
new file mode 100644
index 0000000..6197357
--- /dev/null
+++ b/packages/realgud/test/test-trepan2.el
@@ -0,0 +1,45 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/trepan2/trepan2.el")
+(load-file "../realgud/debugger/trepan2/core.el")
+(load-file "../realgud.el")
+
+(declare-function trepan2-parse-cmd-args 'realgud:trepan2)
+(declare-function realgud:trepan2-find-file 'realgud:trepan2-core)
+(declare-function __FILE__ 'load-relative)
+
+
+(test-simple-start)
+
+(note "trepan2-parse-cmd-args")
+
+(assert-equal '(nil ("trepan2") ("foo") nil)
+ (trepan2-parse-cmd-args '("trepan2" "foo")))
+(assert-equal '(nil ("trepan2" "-n") ("foo") nil)
+ (trepan2-parse-cmd-args '("trepan2" "-n" "foo")))
+(assert-equal '(("/usr/bin/python") ("trepan2" "--different")
+ ("foo") nil)
+ (trepan2-parse-cmd-args
+ '("/usr/bin/python" "trepan2"
+ "--different" "foo")))
+(assert-equal '(nil ("program.py") ("foo") nil)
+ (trepan2-parse-cmd-args '("program.py" "foo")))
+(assert-equal '(nil ("trepan2") ("program.py" "foo") nil)
+ (trepan2-parse-cmd-args
+ '("trepan2" "program.py" "foo")))
+
+(note "realgud:trepan2-find-file")
+(assert-nil (realgud:trepan2-find-file "<string>")
+ "Should ignore psuedo file")
+
+(eval-when-compile
+ (defvar test-python-file))
+
+(set (make-local-variable 'test-python-file)
+ (concat (file-name-directory (__FILE__)) "gcd.py"))
+(assert-equal test-python-file (realgud:trepan2-find-file test-python-file)
+ "Should ignore psuedo file")
+
+(end-tests)
diff --git a/packages/realgud/test/test-trepan3k.el
b/packages/realgud/test/test-trepan3k.el
new file mode 100644
index 0000000..758ad86
--- /dev/null
+++ b/packages/realgud/test/test-trepan3k.el
@@ -0,0 +1,37 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/trepan3k/trepan3k.el")
+(declare-function trepan3k-parse-cmd-args 'realgud:trepan3k)
+(declare-function __FILE__ 'require-relative)
+
+(test-simple-start)
+
+(note "trepan3k-parse-cmd-args")
+
+(assert-equal '(nil ("trepan3k") ("foo") nil)
+ (trepan3k-parse-cmd-args '("trepan3k" "foo")))
+(assert-equal '(nil ("trepan3k" "-n") ("foo") nil)
+ (trepan3k-parse-cmd-args '("trepan3k" "-n" "foo")))
+(assert-equal '(nil ("trepan3k" "--annotate=1") ("foo") t)
+ (trepan3k-parse-cmd-args
+ '("trepan3k" "--annotate=1" "foo")))
+(assert-equal '(nil ("mytrepan3k" "--annotate=1") ("foo") t)
+ (trepan3k-parse-cmd-args
+ '("mytrepan3k" "--annotate=1" "foo")))
+(assert-equal '(("python") ("trepan3k" "--annotate") ("1" "foo") t)
+ (trepan3k-parse-cmd-args
+ '("python" "trepan3k" "--annotate" "1" "foo")))
+(assert-equal '(("/usr/bin/python") ("trepan3k" "--different")
+ ("foo") nil)
+ (trepan3k-parse-cmd-args
+ '("/usr/bin/python" "trepan3k"
+ "--different" "foo")))
+(assert-equal '(nil ("program.py") ("foo") nil)
+ (trepan3k-parse-cmd-args '("program.py" "foo")))
+(assert-equal '(nil ("trepan3k") ("program.py" "foo") nil)
+ (trepan3k-parse-cmd-args
+ '("trepan3k" "program.py" "foo")))
+
+(end-tests)
diff --git a/packages/realgud/test/test-trepanpl.el
b/packages/realgud/test/test-trepanpl.el
new file mode 100644
index 0000000..6b5c807
--- /dev/null
+++ b/packages/realgud/test/test-trepanpl.el
@@ -0,0 +1,50 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/common/buffer/command.el")
+(load-file "../realgud/debugger/trepan.pl/trepanpl.el")
+
+(eval-when-compile (defvar test:run-process-save))
+
+(declare-function realgud:trepanpl-parse-cmd-args 'realgud:trepanpl)
+(declare-function realgud:trepan.pl 'realgud:trepanpl)
+(declare-function __FILE__ 'require-relative)
+
+(test-simple-start)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:run-process-save (symbol-function 'realgud:run-process))
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuf-history
+ &optional no-reset)
+ "Fake realgud:run-process used in testing"
+ (note
+ (format "%s %s %s" debugger-name script-filename cmd-args))
+ (assert-equal "trepan.pl" debugger-name "debugger name gets passed")
+ (let ((expanded-name (expand-file-name "./gcd.pl")))
+ (assert-equal expanded-name script-filename "file name check")
+ (assert-equal (list "-I" (expand-file-name ".") expanded-name "3" "5")
+ (cdr cmd-args) "command args listified")
+ )
+ nil ;; Make sure trepanpl doesn't try to do anything with cmdbuf
+ )
+
+(note "realgud:trepanpl-parse-cmd-args")
+(assert-equal (list nil '("trepan.pl") '("foo"))
+ (realgud:trepanpl-parse-cmd-args '("trepan.pl" "foo")))
+(assert-equal (list '("perl5.8") '("trepan.pl") '("foo"))
+ (realgud:trepanpl-parse-cmd-args '("perl5.8" "trepan.pl" "foo")))
+(assert-equal (list nil '("trepan.pl") '("program.pl" "foo"))
+ (realgud:trepanpl-parse-cmd-args
+ '("trepan.pl" "program.pl" "foo")))
+(assert-equal (list nil '("trepan.pl") (list (expand-file-name "gcd.pl")
"foo"))
+ (realgud:trepanpl-parse-cmd-args
+ '("trepan.pl" "gcd.pl" "foo")))
+
+(realgud:trepan.pl "trepanpl -I . ./gcd.pl 3 5")
+
+;; Restore the old value of realgud:run-process
+(fset 'realgud:run-process test:run-process-save)
+
+(end-tests)
diff --git a/packages/realgud/test/test-utils.el
b/packages/realgud/test/test-utils.el
new file mode 100644
index 0000000..47d9958
--- /dev/null
+++ b/packages/realgud/test/test-utils.el
@@ -0,0 +1,49 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'comint)
+(require 'eshell)
+(require 'shell)
+
+(load-file "../realgud/common/utils.el")
+
+(declare-function realgud:flatten 'realgud-utils)
+(declare-function realgud:strip 'realgud-regexp)
+(declare-function __FILE__ 'load-relative)
+(declare-function realgud:canonic-major-mode 'realgud-utils)
+
+(test-simple-start)
+
+(eval-when-compile
+ (defvar test-realgud:features)
+)
+
+(note "realgud:strip")
+(assert-equal "abc" (realgud:strip "abc"))
+(assert-equal "def" (realgud:strip "\n def\t "))
+
+(note "realgud:flatten")
+(assert-equal '(abc) (realgud:flatten '(abc)))
+(assert-equal '(abc def h i j) (realgud:flatten '(abc (def (h) i) j)))
+
+(note "realgud:canonic-major-mode")
+
+(assert-raises error (realgud:canonic-major-mode)
+ "Not in eshell, comint or shell-mode")
+
+(with-temp-buffer
+ (comint-mode)
+ (assert-equal 'comint (realgud:canonic-major-mode)))
+
+(with-temp-buffer
+ (eshell-mode)
+ (assert-equal 'eshell (realgud:canonic-major-mode)))
+
+;; (with-temp-buffer
+;; (start-process "bogus" (current-buffer) "sleep" "1")
+;; (shell-mode)
+;; (assert-equal 'comint (realgud:canonic-major-mode))
+;; )
+
+(end-tests)
diff --git a/packages/realgud/test/test-zshdb.el
b/packages/realgud/test/test-zshdb.el
new file mode 100644
index 0000000..86eb5e5
--- /dev/null
+++ b/packages/realgud/test/test-zshdb.el
@@ -0,0 +1,58 @@
+;; Press C-x C-e at the end of the next line to run this file test
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(load-file "../realgud/debugger/zshdb/zshdb.el")
+(load-file "../realgud/common/core.el")
+
+(declare-function realgud:expand-file-name-if-exists 'realgud-core)
+
+(eval-when-compile
+ (defvar test:run-process-save)
+ (defvar realgud:zshdb-minibuffer-history)
+ )
+
+(declare-function zshdb-parse-cmd-args 'realgud:zshdb)
+(declare-function zshdb-suggest-invocation 'realgud:zshdb)
+(declare-function realgud:zshdb 'realgud:zshdb)
+(declare-function __FILE__ 'require-relative)
+
+(test-simple-start)
+(make-local-variable 'realgud:zshdb-minibuffer-history)
+(setq realgud:zshdb-minibuffer-history nil)
+
+;; Save value realgud:run-process and change it to something we want
+(setq test:run-process-save (symbol-function 'realgud:run-process))
+(defun realgud:run-process(debugger-name script-filename cmd-args
+ minibuf-history
+ &optional no-reset)
+ "Fake realgud:run-process used in testing"
+ (note
+ (format "%s %s %s" debugger-name script-filename cmd-args))
+ (assert-equal "zshdb" debugger-name "debugger name gets passed")
+ (let ((expanded-name
+ (realgud:expand-file-name-if-exists "./gcd.sh")))
+ (assert-equal expanded-name script-filename "file name check")
+ (assert-equal (list expanded-name "3" "5")
+ (cdr cmd-args) "command args listified")
+ ))
+
+(note "zshdb-parse-cmd-args")
+(assert-equal (list nil '("zshdb")
+ (list (realgud:expand-file-name-if-exists "foo")) nil)
+ (zshdb-parse-cmd-args '("zshdb" "foo")))
+(assert-equal (list nil '("zshdb")
+ (list (realgud:expand-file-name-if-exists "program.sh")
+ "foo") nil)
+ (zshdb-parse-cmd-args
+ '("zshdb" "program.sh" "foo")))
+
+(with-current-buffer (find-file "gcd.sh")
+ (shell-script-mode)
+ (assert-matches "zshdb .*gcd.sh$" (zshdb-suggest-invocation "zshdb")))
+
+(realgud:zshdb "zshdb ./gcd.sh 3 5")
+;; Restore the old value of realgud:run-process
+(fset 'realgud:run-process test:run-process-save)
+
+(end-tests)