     (setq gud-target-name target-name)
     (when rdebug-buffer (kill-buffer rdebug-buffer))
     (rename-buffer rdebug-buffer-name)
+
+    ;; Setup exit callback so that the original frame configuration
+    ;; can be restored.
+    (let ((process (get-buffer-process gud-comint-buffer)))
+      (if process
+          (set-process-sentinel process
+                                'rdebug-process-sentinel)))
 
     (set (make-local-variable 'gud-minor-mode) 'rdebug)
 

  (when rdebug-many-windows
    (rdebug-setup-windows)))

(defun rdebug-set-windows (&optional name)
  "Sets window used in multi-window frame and issues
rdebug-restore-windows if rdebug-many-windows is set"

  :type 'boolean
  :group 'rdebug)

(defcustom rdebug-restore-original-frame-configuration t
  "*If non-nil, the original window layout is restored when debugger exits."
  :type 'boolean
  :group 'rdebug)

(defgroup rdebugtrack nil
  "Rdebug file tracking by watching the prompt."
  :prefix "rdebugtrack"
