-;;; gud.el --- Grand Unified Debugger mode for gdb, sdb, dbx, or xdb
-;;; under Emacs
+;;; gud.el --- Grand Unified Debugger mode for gdb, sdb, dbx, or xdb under Emacs
;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
;; Maintainer: FSF
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
"Major mode for interacting with an inferior debugger process.
You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx,
-or M-x xdb. Each entry point finishes by executing a hook; `gdb-mode-hook',
-`sdb-mode-hook', `dbx-mode-hook' or `xdb-mode-hook' respectively.
+M-x perldb, or M-x xdb. Each entry point finishes by executing a
+hook; `gdb-mode-hook', `sdb-mode-hook', `dbx-mode-hook',
+`perldb-mode-hook', or `xdb-mode-hook' respectively.
After startup, the following commands are available in both the GUD
interaction buffer and any source buffer GUD visits due to a breakpoint stop
;; save it for later.
(setq gud-filter-pending-text
(concat (or gud-filter-pending-text "") string))
- (save-excursion
- ;; If we have to ask a question during the processing,
- ;; defer any additional text that comes from the debugger
- ;; during that time.
- (let ((gud-filter-defer-flag t))
- ;; Process now any text we previously saved up.
- (if gud-filter-pending-text
- (setq string (concat gud-filter-pending-text string)
- gud-filter-pending-text nil))
+
+ ;; If we have to ask a question during the processing,
+ ;; defer any additional text that comes from the debugger
+ ;; during that time.
+ (let ((gud-filter-defer-flag t))
+ ;; Process now any text we previously saved up.
+ (if gud-filter-pending-text
+ (setq string (concat gud-filter-pending-text string)
+ gud-filter-pending-text nil))
+ (save-excursion
(set-buffer (process-buffer proc))
;; If we have been so requested, delete the debugger prompt.
(if (marker-buffer gud-delete-prompt-marker)
(setq process-window
(and gud-last-frame
(>= (point) (process-mark proc))
- (get-buffer-window (current-buffer)))))
- (if process-window
- (save-selected-window
- (select-window process-window)
- (gud-display-frame)))
-
- ;; Let the comint filter do the actual insertion.
- ;; That lets us inherit various comint features.
- (comint-output-filter proc output)
-
- ;; If we deferred text that arrived during this processing,
- ;; handle it now.
- (if gud-filter-pending-text
- (gud-filter proc "")))))))
+ (get-buffer-window (current-buffer))))
+
+ ;; Let the comint filter do the actual insertion.
+ ;; That lets us inherit various comint features.
+ (comint-output-filter proc output)))
+
+ ;; Put the arrow on the source line.
+ ;; This must be outside of the save-excursion
+ ;; in case the source file is our current buffer.
+ (if process-window
+ (save-selected-window
+ (select-window process-window)
+ (gud-display-frame))
+ ;; We have to be in the proper buffer, (process-buffer proc),
+ ;; but not in a save-excursion, because that would restore point.
+ (let ((old-buf (current-buffer)))
+ (set-buffer (process-buffer proc))
+ (unwind-protect
+ (gud-display-frame)
+ (set-buffer old-buf))))
+
+ ;; If we deferred text that arrived during this processing,
+ ;; handle it now.
+ (if gud-filter-pending-text
+ (gud-filter proc ""))))))
(defun gud-sentinel (proc msg)
(cond ((null (buffer-name (process-buffer proc)))
(defun gud-display-line (true-file line)
(let* ((last-nonmenu-event t) ; Prevent use of dialog box for questions.
- (buffer (gud-find-file true-file))
+ (buffer
+ (save-excursion
+ (or (eq (current-buffer) gud-comint-buffer)
+ (set-buffer gud-comint-buffer))
+ (gud-find-file true-file)))
(window (display-buffer buffer))
(pos))
-;;; (if (equal buffer (current-buffer))
-;;; nil
-;;; (setq buffer-read-only nil))
(save-excursion
-;;; (setq buffer-read-only t)
(set-buffer buffer)
(save-restriction
(widen)