unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RFC: a minor mode that uses GDB like CLI commands
@ 2005-03-18 18:58 Dan Nicolaescu
  2005-03-19  1:28 ` Miles Bader
  2005-03-19 12:32 ` Juri Linkov
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Nicolaescu @ 2005-03-18 18:58 UTC (permalink / 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
  ;; ======================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-03-21  2:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-18 18:58 RFC: a minor mode that uses GDB like CLI commands Dan Nicolaescu
2005-03-19  1:28 ` Miles Bader
2005-03-19 12:32 ` Juri Linkov
2005-03-21  2:55   ` Nick Roberts
2005-03-21  2:11     ` David Kastrup

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).