[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: a minor mode that uses GDB like CLI commands

From: Dan Nicolaescu
Subject: RFC: a minor mode that uses GDB like CLI commands
Date: Fri, 18 Mar 2005 10:58:55 -0800

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. 


*** 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)))
+ (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))
  ;; ======================================================================
--- 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)))
  ;; ======================================================================

reply via email to

[Prev in Thread] Current Thread [Next in Thread]