   "^\\ +\\([0-9]+\\) \\([yn]\\) +at +\\(.+\\):\\([0-9]+\\)$"
   "Regexp to recognize breakpoint lines in rdebug breakpoint buffers.")
 
-(defun rdebug--setup-breakpoints-buffer (buf name)
+(defun rdebug--setup-breakpoints-buffer (buf comint-buffer)
   "Detects breakpoint lines and sets up keymap and mouse navigation."
   (rdebug-debug-enter "rdebug--setup-breakpoints-buffer"
   (with-current-buffer buf
     (let ((inhibit-read-only t) (flag))
       (rdebug-breakpoints-mode)
-      (set (make-local-variable 'gud-target-name) name)
+      (set (make-local-variable 'gud-comint-buffer) comint-buffer)
       (goto-char (point-min))
       (while (not (eobp))
         (let ((b (line-beginning-position)) (e (line-end-position)))

            (goto-char (point-max))
            ;; 32 = space.
            (insert (make-string (* 4 rdebug-debug-depth) 32))
            (insert (apply #'format args)))))))


(defmacro rdebug-debug-enter (str &rest body)
  (declare (indent 1) (debug t))
  `(progn
     (rdebug-debug-message "--> %s\n" ,str)
     (setq rdebug-debug-depth (+ rdebug-debug-depth 1))
     (unwind-protect
         (progn
           ,@body)
       (setq rdebug-debug-depth (max 0 (- rdebug-debug-depth 1)))
       (rdebug-debug-message "<-- %s\n" ,str))))


;; Interface to gud.

  ;     '(gdb-variables-font-lock-keywords))
  (run-mode-hooks 'rdebug-variables-mode-hook))

(defun rdebug--setup-variables-buffer (buf comint-buffer)
  (rdebug-debug-enter "rdebug--setup-variables-buffer"
  (with-current-buffer buf
    (rdebug-variables-mode)
    (set (make-local-variable 'gud-comint-buffer) comint-buffer))))

(defun rdebug-variables-edit-mouse (&optional event)
  "Assign a value to a variable displayed in the variables buffer.
This function is intended to be bound to a mouse key"
  (interactive (list last-input-event))
  (save-excursion
    (if event (posn-set-point (event-end event)))
    (call-interactively 'rdebug-variables-edit)))

(defun rdebug-variables-edit (var value)
  "Assign a value to a variable displayed in the variables buffer."
  (interactive
   (let ((var nil)
         (value nil))
     (save-excursion
       (beginning-of-line)
       (when (looking-at "^\\(@?[a-zA-Z_0-9]+\\) *= *\\(.*\\)$")
         (setq var (match-string 1))
         (setq value (match-string 2))
         (setq value (read-from-minibuffer
                      (format "New value (%s): " var) value)))
       (list var value))))
  (gud-call (format "p %s=%s" var value)))


;; -- display (a.k.a watch window)

