       (puthash "stack"       'rdebug--setup-stack-buffer                 map)
       (puthash "variables"   'rdebug--setup-variables-buffer             map)
       (puthash "display"     'rdebug--setup-display-buffer               map)
+      (puthash "output"      'rdebug--setup-output-buffer                map)
       (puthash "help"        'rdebug--setup-secondary-window-help-buffer map)
       map)))
 
 (defun rdebug-process-annotation (name contents)
   (rdebug-debug-enter "rdebug-process-annotation"
+  ;; Ruby-debug uses the name "starting" for process output (just like
+  ;; GDB). However, it's better to present the buffer as "output" to
+  ;; the user.
+  (if (string= name "starting")
+      (setq name "output"))
   (let ((buf (get-buffer-create (format "*rdebug-%s-%s*" name gud-target-name)))
         ;; Buffer local, doesn't survive the buffer change.
         (comint-buffer gud-comint-buffer))


(defun rdebug-process-sentinel (process event)
  "Restore the original window configuration when the debugger process exits."
  (gud-sentinel process event)
  (rdebug-debug-enter "rdebug-process-sentinel"
    (rdebug-debug-message "status=%S event=%S state=%S"
                          (process-status process)
                          event
                          rdebug-window-configuration-state)
    ;; When the debugger process exited, when the comint buffer has no
    ;; buffer process (nil). When the debugger processes is replaced
    ;; with another process we should not restore the window

    (gud-call (format "undisplay %s" number))
    (gud-call (format "display %s" expr))))

;; -- output

(defvar rdebug-output-mode-map
  (let ((map (make-sparse-keymap)))
    (suppress-keymap map)
    (rdebug-secondary-buffer-populate-map map)
    map))

(defun rdebug-output-mode ()
  "Major mode for rdebug output window.

\\{rdebug-output-mode}"
  (interactive)
  (kill-all-local-variables)
  (setq major-mode 'rdebug-output-mode)
  (setq mode-name "RDEBUG Output")
  (setq buffer-read-only t)
  (set (make-local-variable 'rdebug-secondary-buffer) t)
  (use-local-map rdebug-output-mode-map)
  (run-mode-hooks 'rdebug-output-mode-hook))

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

;; -- help

