     (define-key map [menu-bar debugger view breakpoints]
       (rdebug-menu-item common-map
                         "Breakpoints" 'rdebug-display-breakpoints-buffer))
+
+    (define-key map [menu-bar debugger view source]
+      (rdebug-menu-item common-map
+                        "Source" 'rdebug-display-source-buffer))
     menu))
 
 

;; that window.


(defun rdebug-pick-source-window-categorize-window (win)
  "Return how suiteable this window is to display the source buffer.
The higher score the better."
  (let ((buffer (window-buffer win)))

          (t
           2))))

(defun rdebug-frame-source-buffer (frame)
  "Return the buffer corresponding to guds frame, or nil"
  (and frame
       gud-comint-buffer
       (save-current-buffer
         (set-buffer gud-comint-buffer)
         (gud-find-file (car frame)))))


(defun rdebug-current-source-buffer ()
  "Return the latest source buffer, or nil"
  (or (rdebug-frame-source-buffer gud-last-frame)
      (rdebug-frame-source-buffer gud-last-last-frame)))


(defun rdebug-display-source-buffer ()
  "Display the current source buffer."
  (interactive)
  (let ((buffer (rdebug-current-source-buffer))
        (last-buffer (rdebug-frame-source-buffer gud-last-last-frame)))
    (if buffer
        (let ((window
               (or
                ;; Buffer is already visible, re-use the window.
                (get-buffer-window buffer)
                ;; Re-use the last window
                (and last-buffer
                     (get-buffer-window last-buffer))
                ;; Find a non-rdebug window.
                (let ((candidate nil)
                      (candidate-score -1))
                  (dolist (win (window-list (selected-frame)))
                    (let ((score
                           (rdebug-display-source-window-categorize win)))
                      (if (> score candidate-score)
                          (progn
                            (setq candidate       win)
                            (setq candidate-score score)))))
                  candidate))))
          (select-window window)
          (switch-to-buffer buffer)))))


(defun rdebug-pick-source-window ()
  "Display the source file, but do not switch window."
  (save-selected-window
    (rdebug-display-source-buffer)))


(defun rdebug-display-source-buffer-resync ()
  "Resync output and display the source buffer."
  (interactive)
  (call-interactively 'gud-source-resync)
  (rdebug-display-source-buffer))


;; -------------------------------------------------------------------
