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

* Re: RFC: a minor mode that uses GDB like CLI commands
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Miles Bader @ 2005-03-19  1:28 UTC (permalink / raw)
  Cc: emacs-devel

On Fri, 18 Mar 2005 10:58:55 -0800, Dan Nicolaescu <dann@ics.uci.edu> wrote:
> 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.

It's a useful idea.

How about making the keybindings automatically contingent on
`buffer-read-only', like `diff-mode' does?

Then the user could just turn on this mode by default in _all_ his
source buffers, and use the normal `toggle-read-only' binding to
toggle between gdb commands or editing -- you wouldn't need the
special binding for  `C-x C-q', just the bindings for the actual
commands (which is good for people like me that use `C-x C-q' for
something else).

-Miles
-- 
Do not taunt Happy Fun Ball.

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

* Re: RFC: a minor mode that uses GDB like CLI commands
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2005-03-19 12:32 UTC (permalink / raw)
  Cc: emacs-devel

Dan Nicolaescu <dann@ics.uci.edu> writes:
> Comments, suggestions, etc.  are welcome. 

It would be very good to make this mode to work like edebug
(automatically making the source code buffer read-only, etc.)
and to have similar keybindings:

" " - step
"n" - next
"c" - cont
"g" - go
...

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: RFC: a minor mode that uses GDB like CLI commands
  2005-03-21  2:55   ` Nick Roberts
@ 2005-03-21  2:11     ` David Kastrup
  0 siblings, 0 replies; 5+ messages in thread
From: David Kastrup @ 2005-03-21  2:11 UTC (permalink / raw)
  Cc: Juri Linkov, Dan Nicolaescu, emacs-devel

Nick Roberts <nickrob@snap.net.nz> writes:

>  > It would be very good to make this mode to work like edebug
>  > (automatically making the source code buffer read-only, etc.)
>  > and to have similar keybindings:
>  > 
>  > " " - step
>  > "n" - next
>  > "c" - cont
>  > "g" - go
>  > ...
>
> Its seems more natural to use the existing abbreviations for GDB, as Dan
> suggested:
>
> "s" - step
> "n" - next
> "c" - cont
> "r" - run
> "b" - break
> ...
>
> although there is clearly a significant overlap, in any case.

I think we should strive to make all of this as similar as possible,
so my take on it would be that we will, after the release of course,
change Edebug's bindings to match the bindings of gdb more closely, as
long as this works appropriately.  Certainly the bindings of Edebug
and Gud-mode should be identical (if the rest of the user interface is
similar), and the bindings of Gud-mode and gdb itself as close as
feasible.  I think we will meet less total opposition if we change
Edebug to match gdb more closely (where there are still discrepancies)
rather than the other way round...

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: RFC: a minor mode that uses GDB like CLI commands
  2005-03-19 12:32 ` Juri Linkov
@ 2005-03-21  2:55   ` Nick Roberts
  2005-03-21  2:11     ` David Kastrup
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Roberts @ 2005-03-21  2:55 UTC (permalink / raw)
  Cc: Dan Nicolaescu, emacs-devel

 > It would be very good to make this mode to work like edebug
 > (automatically making the source code buffer read-only, etc.)
 > and to have similar keybindings:
 > 
 > " " - step
 > "n" - next
 > "c" - cont
 > "g" - go
 > ...

Its seems more natural to use the existing abbreviations for GDB, as Dan
suggested:

"s" - step
"n" - next
"c" - cont
"r" - run
"b" - break
...

although there is clearly a significant overlap, in any case.

I think the idea of making the debugger source based is a good one and has
been tried with gdbsrc.el in XEmacs. The difficulty lies in ensuring that any
such mode does not interfere with the normal editing process. As it is
proposed, the user would need to keep track of buffers where it was turned on
and those where it was turned off. That is why I suggested to Dan that it
might be better to toggle all the buffers at once. This is not easy with the
present version of gdb-ui, but can be done using the features of GDB 6.2 that I
described in relation to turning on gud-minor-mode for existing buffers. It is
then possible to define a variable gdb-source-file-list which contains all the
source files for the current executable. This list could also be used to
toggle gdb-src-cmd-minor-mode.


Nick

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