emacs-devel
[Top][All Lists]
Advanced

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

gdb-ui


From: Nick Roberts
Subject: gdb-ui
Date: Wed, 8 Mar 2006 21:27:18 +1300

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




reply via email to

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