From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: RFC: a minor mode that uses GDB like CLI commands Date: Fri, 18 Mar 2005 10:58:55 -0800 Message-ID: <200503181858.j2IIwvAH010170@scanner2.ics.uci.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1111172457 23508 80.91.229.2 (18 Mar 2005 19:00:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Mar 2005 19:00:57 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 18 20:00:57 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DCMhq-0005yI-QM for ged-emacs-devel@m.gmane.org; Fri, 18 Mar 2005 20:00:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DCMyO-0002ur-Bz for ged-emacs-devel@m.gmane.org; Fri, 18 Mar 2005 14:17:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DCMwk-0002Fx-T5 for emacs-devel@gnu.org; Fri, 18 Mar 2005 14:15:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DCMwg-0002CN-Dh for emacs-devel@gnu.org; Fri, 18 Mar 2005 14:15:43 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DCMwg-0002Bu-9H for emacs-devel@gnu.org; Fri, 18 Mar 2005 14:15:42 -0500 Original-Received: from [128.195.1.36] (helo=scanner2.ics.uci.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DCMhT-0007WX-0e for emacs-devel@gnu.org; Fri, 18 Mar 2005 13:59:59 -0500 Original-Received: from vino.ics.uci.edu (dann@vino.ics.uci.edu [128.195.11.198]) by scanner2.ics.uci.edu (8.12.10/8.12.10) with ESMTP id j2IIwvAH010170 for ; Fri, 18 Mar 2005 10:58:58 -0800 (PST) Original-To: emacs-devel@gnu.org Original-Lines: 98 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=-98.3, required 5, FM_MULTI_ODD2, J_CHICKENPOX_32, USER_IN_WHITELIST) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34741 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34741 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))) ;; ====================================================================== --- 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))) ;; ======================================================================