;;; gud.el --- Grand Unified Debugger mode for running GDB and other debuggers
-;; Copyright (C) 1992-1996, 1998, 2000-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1996, 1998, 2000-2013 Free Software Foundation,
+;; Inc.
;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
;; Maintainer: FSF
;;; Code:
-(eval-when-compile (require 'cl)) ; for case macro
-
(require 'comint)
(defvar gdb-active-process)
([run] menu-item "Run" gud-run
:enable (not gud-running)
:visible (memq gud-minor-mode '(gdbmi gdb dbx jdb)))
- ([go] menu-item (if gdb-active-process "Continue" "Run") gud-go
+ ([go] menu-item (if (bound-and-true-p gdb-active-process)
+ "Continue" "Run") gud-go
:visible (and (eq gud-minor-mode 'gdbmi)
(gdb-show-run-p)))
([stop] menu-item "Stop" gud-stop-subjob
'(gdbmi gdb dbx xdb jdb pdb)))
([pp] menu-item "Print S-expression" gud-pp
:enable (and (not gud-running)
- gdb-active-process)
+ (bound-and-true-p gdb-active-process))
:visible (and (string-equal
(buffer-local-value
'gud-target-name gud-comint-buffer) "emacs")
nil 'gdb-edit-value)
nil
(if gdb-show-changed-values
- (or parent (case status
- (changed 'font-lock-warning-face)
- (out-of-scope 'shadow)
- (t t)))
+ (or parent (pcase status
+ (`changed 'font-lock-warning-face)
+ (`out-of-scope 'shadow)
+ (_ t)))
t)
depth)
(if (eq status 'out-of-scope) (setq parent 'shadow))
nil 'gdb-edit-value)
nil
(if gdb-show-changed-values
- (or parent (case status
- (changed 'font-lock-warning-face)
- (out-of-scope 'shadow)
- (t t)))
+ (or parent (pcase status
+ (`changed 'font-lock-warning-face)
+ (`out-of-scope 'shadow)
+ (_ t)))
t)
depth)
(speedbar-make-tag-line
(declare-function global-hl-line-highlight "hl-line" ())
(declare-function hl-line-highlight "hl-line" ())
(declare-function gdb-display-source-buffer "gdb-mi" (buffer))
-(declare-function gdb-display-buffer "gdb-mi" (buf dedicated &optional size))
;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
;; and that its line LINE is visible.
(gud-find-file true-file)))
(window (and buffer
(or (get-buffer-window buffer)
- (if (eq gud-minor-mode 'gdbmi)
- (or (if (get-buffer-window buffer 'visible)
- (display-buffer buffer nil 'visible))
- (unless (gdb-display-source-buffer buffer)
- (gdb-display-buffer buffer nil 'visible))))
(display-buffer buffer))))
(pos))
- (if buffer
- (progn
- (with-current-buffer buffer
- (unless (or (verify-visited-file-modtime buffer) gud-keep-buffer)
- (if (yes-or-no-p
- (format "File %s changed on disk. Reread from disk? "
- (buffer-name)))
- (revert-buffer t t)
- (setq gud-keep-buffer t)))
- (save-restriction
- (widen)
- (goto-char (point-min))
- (forward-line (1- line))
- (setq pos (point))
- (or gud-overlay-arrow-position
- (setq gud-overlay-arrow-position (make-marker)))
- (set-marker gud-overlay-arrow-position (point) (current-buffer))
- ;; If they turned on hl-line, move the hl-line highlight to
- ;; the arrow's line.
- (when (featurep 'hl-line)
- (cond
- (global-hl-line-mode
- (global-hl-line-highlight))
- ((and hl-line-mode hl-line-sticky-flag)
- (hl-line-highlight)))))
- (cond ((or (< pos (point-min)) (> pos (point-max)))
- (widen)
- (goto-char pos))))
- (when window
- (set-window-point window gud-overlay-arrow-position)
- (if (eq gud-minor-mode 'gdbmi)
- (setq gdb-source-window window)))))))
+ (when buffer
+ (with-current-buffer buffer
+ (unless (or (verify-visited-file-modtime buffer) gud-keep-buffer)
+ (if (yes-or-no-p
+ (format "File %s changed on disk. Reread from disk? "
+ (buffer-name)))
+ (revert-buffer t t)
+ (setq gud-keep-buffer t)))
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (forward-line (1- line))
+ (setq pos (point))
+ (or gud-overlay-arrow-position
+ (setq gud-overlay-arrow-position (make-marker)))
+ (set-marker gud-overlay-arrow-position (point) (current-buffer))
+ ;; If they turned on hl-line, move the hl-line highlight to
+ ;; the arrow's line.
+ (when (featurep 'hl-line)
+ (cond
+ (global-hl-line-mode
+ (global-hl-line-highlight))
+ ((and hl-line-mode hl-line-sticky-flag)
+ (hl-line-highlight)))))
+ (cond ((or (< pos (point-min)) (> pos (point-max)))
+ (widen)
+ (goto-char pos))))
+ (when window
+ (set-window-point window gud-overlay-arrow-position)
+ (if (eq gud-minor-mode 'gdbmi)
+ (setq gdb-source-window window))))))
;; The gud-call function must do the right thing whether its invoking
;; keystroke is from the GUD buffer itself (via major-mode binding)
(defun gud-tooltip-print-command (expr)
"Return a suitable command to print the expression EXPR."
- (case gud-minor-mode
- (gdbmi (concat "-data-evaluate-expression " expr))
- (dbx (concat "print " expr))
- ((xdb pdb) (concat "p " expr))
- (sdb (concat expr "/"))))
+ (pcase gud-minor-mode
+ (`gdbmi (concat "-data-evaluate-expression \"" expr "\""))
+ (`dbx (concat "print " expr))
+ ((or `xdb `pdb) (concat "p " expr))
+ (`sdb (concat expr "/"))))
(declare-function gdb-input "gdb-mi" (command handler))
(declare-function tooltip-expr-to-print "tooltip" (event))
(let ((cmd (gud-tooltip-print-command expr)))
(when (and gud-tooltip-mode (eq gud-minor-mode 'gdb))
(gud-tooltip-mode -1)
- (message-box "Using GUD tooltips in this mode is unsafe\n\
+ ;; The blank before the newline is for MS-Windows,
+ ;; whose emulation of message box removes newlines and
+ ;; displays a single long line.
+ (message-box "Using GUD tooltips in this mode is unsafe \n\
so they have been disabled."))
(unless (null cmd) ; CMD can be nil if unknown debugger
(if (eq gud-minor-mode 'gdbmi)