(defvar gdb-macro-info)
(defvar gdb-server-prefix)
(defvar gdb-show-changed-values)
-(defvar gdb-force-update)
(defvar gdb-var-list)
(defvar gdb-speedbar-auto-raise)
(defvar tool-bar-map)
(defvar gud-minor-mode nil)
(put 'gud-minor-mode 'permanent-local t)
+(defvar gud-comint-buffer nil)
+
(defvar gud-keep-buffer nil)
(defun gud-symbol (sym &optional soft minor-mode)
(if (boundp sym) (symbol-value sym))))
(defvar gud-running nil
- "Non-nil if debuggee is running.
-Used to grey out relevant togolbar icons.")
+ "Non-nil if debugged program is running.
+Used to grey out relevant toolbar icons.")
;; Use existing Info buffer, if possible.
(defun gud-goto-info ()
(defun gud-stop-subjob ()
(interactive)
- (if (string-equal
- (buffer-local-value 'gud-target-name gud-comint-buffer) "emacs")
- (comint-stop-subjob)
- (comint-interrupt-subjob)))
+ (with-current-buffer gud-comint-buffer
+ (if (string-equal gud-target-name "emacs")
+ (comint-stop-subjob)
+ (comint-interrupt-subjob))))
(easy-mmode-defmap gud-menu-map
'(([help] "Info" . gud-goto-info)
:enable (and (not emacs-basic-display)
(display-graphic-p)
(fboundp 'x-show-tip))
+ :visible (memq gud-minor-mode
+ '(gdbmi gdba dbx sdb xdb pdb))
:button (:toggle . gud-tooltip-mode))
([refresh] "Refresh" . gud-refresh)
([run] menu-item "Run" gud-run
- :enable (and (not gud-running)
- (memq gud-minor-mode '(gdbmi gdb dbx jdb)))
- :visible (not (eq gud-minor-mode 'gdba)))
- ([go] menu-item "Run/Continue" gud-go
+ :enable (not gud-running)
+ :visible (and (memq gud-minor-mode '(gdbmi gdb dbx jdb))
+ (not (eq gud-minor-mode 'gdba))))
+ ([go] menu-item (if gdb-active-process "Continue" "Run") gud-go
:visible (and (not gud-running)
(eq gud-minor-mode 'gdba)))
([stop] menu-item "Stop" gud-stop-subjob
(and gud-running
(eq gud-minor-mode 'gdba))))
([until] menu-item "Continue to selection" gud-until
- :enable (and (not gud-running)
- (memq gud-minor-mode '(gdbmi gdba gdb perldb)))
- :visible (gud-tool-bar-item-visible-no-fringe))
+ :enable (not gud-running)
+ :visible (and (memq gud-minor-mode '(gdbmi gdba gdb perldb))
+ (gud-tool-bar-item-visible-no-fringe)))
([remove] menu-item "Remove Breakpoint" gud-remove
:enable (not gud-running)
:visible (gud-tool-bar-item-visible-no-fringe))
([tbreak] menu-item "Temporary Breakpoint" gud-tbreak
- :enable (memq gud-minor-mode
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode
'(gdbmi gdba gdb sdb xdb bashdb)))
([break] menu-item "Set Breakpoint" gud-break
:enable (not gud-running)
:visible (gud-tool-bar-item-visible-no-fringe))
([up] menu-item "Up Stack" gud-up
- :enable (and (not gud-running)
- (memq gud-minor-mode
- '(gdbmi gdba gdb dbx xdb jdb pdb bashdb))))
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode
+ '(gdbmi gdba gdb dbx xdb jdb pdb bashdb)))
([down] menu-item "Down Stack" gud-down
- :enable (and (not gud-running)
- (memq gud-minor-mode
- '(gdbmi gdba gdb dbx xdb jdb pdb bashdb))))
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode
+ '(gdbmi gdba gdb dbx xdb jdb pdb bashdb)))
([pp] menu-item "Print S-expression" gud-pp
:enable (and (not gud-running)
gdb-active-process)
'gud-target-name gud-comint-buffer) "emacs")
(eq gud-minor-mode 'gdba)))
([print*] menu-item "Print Dereference" gud-pstar
- :enable (and (not gud-running)
- (memq gud-minor-mode '(gdbmi gdba gdb))))
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode '(gdbmi gdba gdb)))
([print] menu-item "Print Expression" gud-print
:enable (not gud-running))
([watch] menu-item "Watch Expression" gud-watch
- :enable (and (not gud-running)
- (memq gud-minor-mode '(gdbmi gdba))))
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode '(gdbmi gdba)))
([finish] menu-item "Finish Function" gud-finish
- :enable (and (not gud-running)
- (memq gud-minor-mode
- '(gdbmi gdba gdb xdb jdb pdb bashdb))))
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode
+ '(gdbmi gdba gdb xdb jdb pdb bashdb)))
([stepi] menu-item "Step Instruction" gud-stepi
- :enable (and (not gud-running)
- (memq gud-minor-mode '(gdbmi gdba gdb dbx))))
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode '(gdbmi gdba gdb dbx)))
([nexti] menu-item "Next Instruction" gud-nexti
- :enable (and (not gud-running)
- (memq gud-minor-mode '(gdbmi gdba gdb dbx))))
+ :enable (not gud-running)
+ :visible (memq gud-minor-mode '(gdbmi gdba gdb dbx)))
([step] menu-item "Step Line" gud-step
:enable (not gud-running))
([next] menu-item "Next Line" gud-next
optional doc string DOC. Certain %-escapes in the string arguments
are interpreted specially if present. These are:
- %f name (without directory) of current source file.
- %F name (without directory or extension) of current source file.
- %d directory of current source file.
- %l number of current source line
- %e text of the C lvalue or function-call expression surrounding point.
- %a text of the hexadecimal address surrounding point
- %p prefix argument to the command (if any) as a number
+ %f -- Name (without directory) of current source file.
+ %F -- Name (without directory or extension) of current source file.
+ %d -- Directory of current source file.
+ %l -- Number of current source line.
+ %e -- Text of the C lvalue or function-call expression surrounding point.
+ %a -- Text of the hexadecimal address surrounding point.
+ %p -- Prefix argument to the command (if any) as a number.
+ %c -- Fully qualified class name derived from the expression
+ surrounding point (jdb only).
The `current' source file is the file of the current buffer (if
we're in a C file) or the source file current at the last break or
(buffer-name gud-comint-buffer))
(let* ((minor-mode (with-current-buffer buffer gud-minor-mode))
(window (get-buffer-window (current-buffer) 0))
+ (start (window-start window))
(p (window-point window)))
(cond
((memq minor-mode '(gdbmi gdba))
- (when (or gdb-force-update
- (not (save-excursion
- (goto-char (point-min))
- (let ((case-fold-search t))
- (looking-at "Watch Expressions:")))))
- (erase-buffer)
- (insert "Watch Expressions:\n")
- (if gdb-speedbar-auto-raise
- (raise-frame speedbar-frame))
- (let ((var-list gdb-var-list) parent)
- (while var-list
- (let* (char (depth 0) (start 0) (var (car var-list))
- (varnum (car var)) (expr (nth 1 var))
- (type (nth 3 var)) (value (nth 4 var))
- (status (nth 5 var)))
- (put-text-property
- 0 (length expr) 'face font-lock-variable-name-face expr)
- (put-text-property
- 0 (length type) 'face font-lock-type-face type)
- (while (string-match "\\." varnum start)
- (setq depth (1+ depth)
- start (1+ (match-beginning 0))))
- (if (eq depth 0) (setq parent nil))
- (if (or (equal (nth 2 var) "0")
- (and (equal (nth 2 var) "1")
- (string-match "char \\*$" type)))
+ (erase-buffer)
+ (insert "Watch Expressions:\n")
+ (if gdb-speedbar-auto-raise
+ (raise-frame speedbar-frame))
+ (let ((var-list gdb-var-list) parent)
+ (while var-list
+ (let* (char (depth 0) (start 0) (var (car var-list))
+ (varnum (car var)) (expr (nth 1 var))
+ (type (nth 3 var)) (value (nth 4 var))
+ (status (nth 5 var)))
+ (put-text-property
+ 0 (length expr) 'face font-lock-variable-name-face expr)
+ (put-text-property
+ 0 (length type) 'face font-lock-type-face type)
+ (while (string-match "\\." varnum start)
+ (setq depth (1+ depth)
+ start (1+ (match-beginning 0))))
+ (if (eq depth 0) (setq parent nil))
+ (if (or (equal (nth 2 var) "0")
+ (and (equal (nth 2 var) "1")
+ (string-match "char \\*$" type)))
+ (speedbar-make-tag-line
+ 'bracket ?? nil nil
+ (concat expr "\t" value)
+ (if (or parent (eq status 'out-of-scope))
+ 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)))
+ t)
+ depth)
+ (if (eq status 'out-of-scope) (setq parent 'shadow))
+ (if (and (nth 1 var-list)
+ (string-match (concat varnum "\\.")
+ (car (nth 1 var-list))))
+ (setq char ?-)
+ (setq char ?+))
+ (if (string-match "\\*$" type)
(speedbar-make-tag-line
- 'bracket ?? nil nil
- (concat expr "\t" value)
+ 'bracket char
+ 'gdb-speedbar-expand-node varnum
+ (concat expr "\t" type "\t" value)
(if (or parent (eq status 'out-of-scope))
nil 'gdb-edit-value)
nil
(t t)))
t)
depth)
- (if (eq status 'out-of-scope) (setq parent 'shadow))
- (if (and (nth 1 var-list)
- (string-match (concat varnum "\\.")
- (car (nth 1 var-list))))
- (setq char ?-)
- (setq char ?+))
- (if (string-match "\\*$" type)
- (speedbar-make-tag-line
- 'bracket char
- 'gdb-speedbar-expand-node varnum
- (concat expr "\t" type "\t" value)
- (if (or parent (eq status 'out-of-scope))
- 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)))
- t)
- depth)
- (speedbar-make-tag-line
- 'bracket char
- 'gdb-speedbar-expand-node varnum
- (concat expr "\t" type)
- nil nil
- (if (and (or parent status) gdb-show-changed-values)
- 'shadow t)
- depth))))
- (setq var-list (cdr var-list))))
- (setq gdb-force-update nil)))
+ (speedbar-make-tag-line
+ 'bracket char
+ 'gdb-speedbar-expand-node varnum
+ (concat expr "\t" type)
+ nil nil
+ (if (and (or parent status) gdb-show-changed-values)
+ 'shadow t)
+ depth))))
+ (setq var-list (cdr var-list)))))
(t (unless (and (save-excursion
(goto-char (point-min))
(looking-at "Current Stack:"))
(t (error "Should never be here")))
frame t))))
(setq gud-last-speedbar-stackframe gud-last-last-frame))))
+ (set-window-start window start)
(set-window-point window p))))
\f
;; The completion list is constructed by the process filter.
(defvar gud-gdb-fetched-lines)
-(defvar gud-comint-buffer nil)
-
(defun gud-gdb-complete-command (&optional command a b)
"Perform completion on the GDB command preceding point.
This is implemented using the GDB `complete' command which isn't
(existing-buffer (get-buffer (concat "*gud" filepart "*"))))
(pop-to-buffer (concat "*gud" filepart "*"))
(when (and existing-buffer (get-buffer-process existing-buffer))
- (error "This program is already running under gdb"))
+ (error "This program is already being debugged"))
;; Set the dir, in case the buffer already existed with a different dir.
(setq default-directory dir)
;; Set default-directory to the file's directory.
((memq (process-status proc) '(signal exit))
;; Stop displaying an arrow in a source file.
(setq gud-overlay-arrow-position nil)
- (with-current-buffer gud-comint-buffer
- (if (memq gud-minor-mode-type '(gdbmi gdba))
- (gdb-reset)
- (gud-reset)))
+ (if (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ '(gdba gdbmi))
+ (gdb-reset)
+ (gud-reset))
(let* ((obuf (current-buffer)))
;; save-excursion isn't the right thing if
;; process-buffer is current-buffer
(gud-find-file true-file)))
(window (and buffer (or (get-buffer-window buffer)
(if (memq gud-minor-mode '(gdbmi gdba))
- (gdb-display-source-buffer buffer))
+ (unless (gdb-display-source-buffer buffer)
+ (gdb-display-buffer buffer nil)))
(display-buffer buffer))))
(pos))
(if buffer
(cond ((or (< pos (point-min)) (> pos (point-max)))
(widen)
(goto-char pos))))
- (if window (set-window-point window gud-overlay-arrow-position))))))
+ (when window
+ (set-window-point window gud-overlay-arrow-position)
+ (if (memq gud-minor-mode '(gdbmi gdba))
+ (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)
(let ((insource (not (eq (current-buffer) gud-comint-buffer)))
(frame (or gud-last-frame gud-last-last-frame))
result)
- (while (and str (string-match "\\([^%]*\\)%\\([adeflpc]\\)" str))
+ (while (and str
+ (let ((case-fold-search nil))
+ (string-match "\\([^%]*\\)%\\([adefFlpc]\\)" str)))
(let ((key (string-to-char (match-string 2 str)))
subst)
(cond
(set-buffer gud-comint-buffer)
(save-restriction
(widen)
- (goto-char (process-mark proc))
- (forward-line 0)
+ (if (marker-position gud-delete-prompt-marker)
+ ;; We get here when printing an expression.
+ (goto-char gud-delete-prompt-marker)
+ (goto-char (process-mark proc))
+ (forward-line 0))
(if (looking-at comint-prompt-regexp)
(set-marker gud-delete-prompt-marker (point)))
(if (memq gud-minor-mode '(gdbmi gdba))
(defvar gud-find-expr-function 'gud-find-c-expr)
(defun gud-find-expr (&rest args)
- (apply gud-find-expr-function args))
+ (let ((expr (if (and transient-mark-mode mark-active)
+ (buffer-substring (region-beginning) (region-end))
+ (apply gud-find-expr-function args))))
+ (save-match-data
+ (if (string-match "\n" expr)
+ (error "Expression must not include a newline"))
+ (with-current-buffer gud-comint-buffer
+ (save-excursion
+ (goto-char (process-mark (get-buffer-process gud-comint-buffer)))
+ (forward-line 0)
+ (when (looking-at comint-prompt-regexp)
+ (set-marker gud-delete-prompt-marker (point))
+ (set-marker-insertion-type gud-delete-prompt-marker t))
+ (insert (concat expr " = ")))))
+ expr))
;; The next eight functions are hacked from gdbsrc.el by
;; Debby Ayers <ayers@asc.slb.com>,
(defvar gdb-script-font-lock-keywords
'(("^define\\s-+\\(\\(\\w\\|\\s_\\)+\\)" (1 font-lock-function-name-face))
("\\$\\(\\w+\\)" (1 font-lock-variable-name-face))
- ("^\\s-*\\(\\(\\w\\|\\s_\\)+\\)" (1 font-lock-keyword-face))))
+ ("^\\s-*\\(\\w\\(\\w\\|\\s_\\)*\\)" (1 font-lock-keyword-face))))
;; FIXME: The keyword "end" associated with "document"
;; should have font-lock-keyword-face (currently font-lock-doc-face).
(defvar gdb-script-font-lock-syntactic-keywords
'(("^document\\s-.*\\(\n\\)" (1 "< b"))
;; It would be best to change the \n in front, but it's more difficult.
- ("^en\\(d\\)\\>" (1 "> b"))))
+ ("^end\\>"
+ (0 (progn
+ (unless (eq (match-beginning 0) (point-min))
+ (put-text-property (1- (match-beginning 0)) (match-beginning 0)
+ 'syntax-table (eval-when-compile
+ (string-to-syntax "> b")))
+ (put-text-property (1- (match-beginning 0)) (match-end 0)
+ 'font-lock-multiline t)
+ nil))))))
(defun gdb-script-font-lock-syntactic-face (state)
(cond
(kill-local-variable 'gdb-define-alist)
(remove-hook 'after-save-hook 'gdb-create-define-alist t))))
-(defcustom gud-tooltip-modes '(gud-mode c-mode c++-mode fortran-mode)
+(defcustom gud-tooltip-modes '(gud-mode c-mode c++-mode fortran-mode
+ python-mode)
"List of modes for which to enable GUD tooltips."
:type 'sexp
:group 'gud
(defvar gud-tooltip-mouse-motions-active nil
"Locally t in a buffer if tooltip processing of mouse motion is enabled.")
+;; We don't set track-mouse globally because this is a big redisplay
+;; problem in buffers having a pre-command-hook or such installed,
+;; which does a set-buffer, like the summary buffer of Gnus. Calling
+;; set-buffer prevents redisplay optimizations, so every mouse motion
+;; would be accompanied by a full redisplay.
+
(defun gud-tooltip-activate-mouse-motions (activatep)
"Activate/deactivate mouse motion events for the current buffer.
ACTIVATEP non-nil means activate mouse motion events."
(case gud-minor-mode
(gdba (concat "server print " expr))
((dbx gdbmi) (concat "print " expr))
- (xdb (concat "p " expr))
- (sdb (concat expr "/"))
- (perldb expr)))
+ ((xdb pdb) (concat "p " expr))
+ (sdb (concat expr "/"))))
(defun gud-tooltip-tips (event)
"Show tip for identifier or selection under the mouse.
gdb-server-prefix "macro expand " expr "\n")
`(lambda () (gdb-tooltip-print-1 ,expr))))
(gdb-enqueue-input
- (list (concat cmd "\n") 'gdb-tooltip-print)))
+ (list (concat cmd "\n")
+ `(lambda () (gdb-tooltip-print ,expr)))))
(setq gud-tooltip-original-filter (process-filter process))
(set-process-filter process 'gud-tooltip-process-output)
(gud-basic-call cmd))