all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* gdb-ui
@ 2006-03-08  8:27 Nick Roberts
  2006-03-08 10:05 ` gdb-ui Kim F. Storm
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Roberts @ 2006-03-08  8:27 UTC (permalink / raw)



I'm aware gdb-ui can get into a confused state because Emacs has no way of
knowing if input is going to gdb or the program being debugged. The code on
which it is based (gdba.el) avoided the problem by always using a separate
buffer for program input.

The problem occurs with gdb-send which sends input immediately if execution
hasn't stopped:

(defun gdb-send (proc string)
  "A comint send filter for gdb.
This filter may simply queue input for a later time."
  (with-current-buffer gud-comint-buffer
    (let ((inhibit-read-only t))
      (remove-text-properties (point-min) (point-max) '(face))))
  (let ((item (concat string "\n")))
    (if gud-running
        ^^^^^^^^^^^
      (progn
	(if gdb-enable-debug (push (cons 'send item) gdb-debug-ring))
	(process-send-string proc item))
      (gdb-enqueue-input item))))


I attach a patch that deals with this problem by making the user decide if
input is for GDB or the inferior (<return> queues the input (for GDB),
<C-return> sends it immediately (for the program being debugged)).  Its not
attractive but I think it is necessary if the GUD buffer is used for input to
both.

Does anybody use gdb-ui and encounter this problem?  If so, do you consider
that this problem justifies such a change?

-- 
Nick                                           http://www.inet.net.nz/~nickrob


*** /home/nickrob/emacs/lisp/progmodes/gdb-ui.el	2006-03-07 23:17:32.000000000 +1300
--- /home/nickrob/emacs/lisp/progmodes/mygdb-ui.el	2006-03-08 19:04:12.605909128 +1300
*************** With arg, use separate IO iff arg is pos
*** 439,444 ****
--- 439,445 ----
  			(gdb-find-watch-expression) "%e")) arg)
  	   nil   "Print the emacs s-expression.")
  
+   (define-key gud-mode-map [C-return] 'gdb-input)
    (define-key gud-minor-mode-map [left-margin mouse-1]
      'gdb-mouse-set-clear-breakpoint)
    (define-key gud-minor-mode-map [left-fringe mouse-1]
*************** With arg, use separate IO iff arg is pos
*** 464,470 ****
    (define-key gud-minor-mode-map [left-fringe mouse-3]
      'gdb-mouse-toggle-breakpoint-fringe)
  
!   (setq comint-input-sender 'gdb-send)
  
    ;; (re-)initialize
    (setq gdb-frame-address (if gdb-show-main "main" nil))
--- 465,471 ----
    (define-key gud-minor-mode-map [left-fringe mouse-3]
      'gdb-mouse-toggle-breakpoint-fringe)
  
!   (setq comint-input-sender 'gdb-send-gdb)
  
    ;; (re-)initialize
    (setq gdb-frame-address (if gdb-show-main "main" nil))
*************** The key should be one of the cars in `gd
*** 1020,1038 ****
  ;; These lists are consumed tail first.
  ;;
  
! (defun gdb-send (proc string)
    "A comint send filter for gdb.
  This filter may simply queue input for a later time."
    (with-current-buffer gud-comint-buffer
      (let ((inhibit-read-only t))
        (remove-text-properties (point-min) (point-max) '(face))))
    (let ((item (concat string "\n")))
!     (if gud-running
!       (progn
! 	(if gdb-enable-debug (push (cons 'send item) gdb-debug-ring))
! 	(process-send-string proc item))
        (gdb-enqueue-input item))))
  
  ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
  ;; is a query, or other non-top-level prompt.
  
--- 1021,1053 ----
  ;; These lists are consumed tail first.
  ;;
  
! (defun gdb-send-gdb (proc string)
    "A comint send filter for gdb.
  This filter may simply queue input for a later time."
    (with-current-buffer gud-comint-buffer
      (let ((inhibit-read-only t))
        (remove-text-properties (point-min) (point-max) '(face))))
    (let ((item (concat string "\n")))
!     (progn
!       (if gdb-enable-debug (push (cons 'send-item item) gdb-debug-ring))
        (gdb-enqueue-input item))))
  
+ (defun gdb-send-inferior (proc string)
+   "A comint send filter for gdb.
+ This filter sends input immediately."
+   (with-current-buffer gud-comint-buffer
+     (let ((inhibit-read-only t))
+       (remove-text-properties (point-min) (point-max) '(face))))
+   (let ((item (concat string "\n")))
+     (if gdb-enable-debug (push (cons 'send item) gdb-debug-ring))
+     (process-send-string proc item)))
+ 
+ (defun gdb-input ()
+   "Send input to program being debugged."
+   (interactive)
+   (let ((comint-input-sender 'gdb-send-inferior))
+     (comint-send-input)))
+ 
  ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
  ;; is a query, or other non-top-level prompt.
  

Diff finished.  Wed Mar  8 19:04:19 2006

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

end of thread, other threads:[~2006-03-09  8:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-08  8:27 gdb-ui Nick Roberts
2006-03-08 10:05 ` gdb-ui Kim F. Storm
2006-03-08 12:15   ` gdb-ui Markus Gritsch
2006-03-08 13:08     ` gdb-ui Kim F. Storm
2006-03-08 19:24   ` gdb-ui Nick Roberts
2006-03-08 20:27     ` gdb-ui Kim F. Storm
2006-03-08 21:23       ` gdb-ui Nick Roberts
2006-03-09  8:20         ` gdb-ui Kim F. Storm

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.