From: Dan Nicolaescu <dann@ics.uci.edu>
Subject: RFC: a minor mode that uses GDB like CLI commands
Date: Fri, 18 Mar 2005 10:58:55 -0800 [thread overview]
Message-ID: <200503181858.j2IIwvAH010170@scanner2.ics.uci.edu> (raw)
The key bindings for controlling GDB when viewing a source file are
not very easy to type: C-x C-a C-n, C-x C-a C-p, etc. I usually prefer
to use GDB from the command line for this reason, the CLI interface
implies less typing.
It would be nice to have a minor mode so that one would be able to use
GDB CLI like commands ("c", "n", etc.). When turned on such a mode
changes the source code buffer to be read-only and some keys act as
GDB commands.
A proof of concept for such a mode is attached. It should turn on the
new mode by default. To turn it off type C-x C-q.
Being just a proof of concept some things are kind of rough:
- better function names would be desirable
- the mode is turned on a per file basis, it would probably be more
interesting to turn it on/off simultaneously for all the files
belonging to a GDB session
- handling of saving/restoring buffer-read-only (and maybe some other
related stuff)
- more/better key bindings are needed
- documentation
- I only tried this with GDB, I don't know if it works use it with
any other debugger
Comments, suggestions, etc. are welcome.
Thanks
--dan
*** gud.el 03 Feb 2005 20:05:35 -0800 1.29
--- gud.el 17 Mar 2005 11:45:37 -0800
***************
*** 199,204 ****
--- 199,241 ----
(setq directories (cdr directories)))
result)))
+ (defcustom gdb-turn-on-src-cmd-mode t
+ "It true turn on gdb-src-cmd-minor-mode."
+ :type 'string
+ :group 'gud)
+
+ (defvar gdb-src-cmd-minor-mode-map
+ (let ((map (make-sparse-keymap)))
+
+ (define-key map "n" 'gud-next)
+ (define-key map "c" 'gud-cont)
+ (define-key map "s" 'gud-step)
+ (define-key map "f" 'gud-finish)
+ (define-key map "r" 'gud-run)
+ (define-key map "d" 'gud-down)
+ (define-key map "u" 'gud-up)
+
+ (define-key map "\C-x\C-q" (lambda () (interactive)
+ (gdb-src-cmd-minor-mode nil)))
+ map))
+
+ (defvar gdb-src-cmd-minor-mode-old-buffer-read-only nil)
+ (make-variable-buffer-local 'gdb-src-cmd-minor-mode-old-buffer-read-only)
+
+
+ (define-minor-mode gdb-src-cmd-minor-mode
+ "Minor mode of `gud-minor-mode'.
+ In this mode some keys run gdb commands.
+ The keys used are the similar to the gdb CLI."
+ nil " G " gdb-src-cmd-minor-mode-map
+ ;; Fixme: only turn on if gud-minor-mode is true.
+ (if gdb-src-cmd-minor-mode
+ (setq
+ ;; save buffer-read-only state, some
+ gdb-src-cmd-minor-mode-old-buffer-read-only buffer-read-only
+ buffer-read-only t)
+ (setq buffer-read-only gdb-src-cmd-minor-mode-old-buffer-read-only)))
+
(defun gud-find-file (file)
;; Don't get confused by double slashes in the name that comes from GDB.
(while (string-match "//+" file)
***************
*** 212,218 ****
(with-current-buffer buf
(set (make-local-variable 'gud-minor-mode) minor-mode)
(set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
! (make-local-variable 'gud-keep-buffer))
buf)))
\f
;; ======================================================================
--- 249,256 ----
(with-current-buffer buf
(set (make-local-variable 'gud-minor-mode) minor-mode)
(set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
! (make-local-variable 'gud-keep-buffer)
! (when gdb-turn-on-src-cmd-mode (gdb-src-cmd-minor-mode 1)))
buf)))
\f
;; ======================================================================
next reply other threads:[~2005-03-18 18:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-18 18:58 Dan Nicolaescu [this message]
2005-03-19 1:28 ` RFC: a minor mode that uses GDB like CLI commands Miles Bader
2005-03-19 12:32 ` Juri Linkov
2005-03-21 2:55 ` Nick Roberts
2005-03-21 2:11 ` David Kastrup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200503181858.j2IIwvAH010170@scanner2.ics.uci.edu \
--to=dann@ics.uci.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).