(eval-when-compile (require 'cl)) ; for case macro
(require 'comint)
-(require 'font-lock)
(defvar gdb-active-process)
(defvar gdb-define-alist)
(defvar gdb-macro-info)
(defvar gdb-server-prefix)
(defvar gdb-show-changed-values)
-(defvar gdb-var-changed)
+(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)
:enable (and (not gud-running)
(memq gud-minor-mode
'(gdbmi gdba gdb dbx xdb jdb pdb bashdb))))
- ([pp] menu-item "Print the emacs s-expression" gud-pp
+ ([pp] menu-item "Print S-expression" gud-pp
:enable (and (not gud-running)
gdb-active-process)
:visible (and (string-equal
(gud-run . "gud/run")
(gud-go . "gud/go")
(gud-stop-subjob . "gud/stop")
- ;; gud-s, gud-si etc. instead of gud-step,
- ;; gud-stepi, to avoid file-name clashes on DOS
- ;; 8+3 filesystems.
(gud-cont . "gud/cont")
(gud-until . "gud/until")
(gud-next . "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
(defun gud-speedbar-item-info ()
"Display the data type of the watch expression element."
(let ((var (nth (- (line-number-at-pos (point)) 2) gdb-var-list)))
- (if (nth 4 var)
- (speedbar-message "%s" (nth 3 var)))))
+ (if (nth 6 var)
+ (speedbar-message "%s: %s" (nth 6 var) (nth 3 var))
+ (speedbar-message "%s" (nth 3 var)))))
(defun gud-install-speedbar-variables ()
"Install those variables used by speedbar to enhance gud/gdb."
gud-speedbar-key-map
gud-expansion-speedbar-buttons))
- (add-to-list
+ (add-to-list
'speedbar-mode-functions-list
'("GUD" (speedbar-item-info . gud-speedbar-item-info)
(speedbar-line-directory . ignore))))
(defvar gud-speedbar-menu-items
'(["Jump to stack frame" speedbar-edit-line
- :visible (with-current-buffer gud-comint-buffer
- (not (memq gud-minor-mode '(gdbmi gdba))))]
+ :visible (not (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ '(gdbmi gdba)))]
["Edit value" speedbar-edit-line
- :visible (with-current-buffer gud-comint-buffer
- (memq gud-minor-mode '(gdbmi gdba)))]
+ :visible (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ '(gdbmi gdba))]
["Delete expression" gdb-var-delete
- (with-current-buffer gud-comint-buffer
- (memq gud-minor-mode '(gdbmi gdba)))]
+ :visible (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ '(gdbmi gdba))]
["Auto raise frame" gdb-speedbar-auto-raise
:style toggle :selected gdb-speedbar-auto-raise
- :visible (with-current-buffer gud-comint-buffer
- (memq gud-minor-mode '(gdbmi gdba)))])
+ :visible (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ '(gdbmi gdba))])
"Additional menu items to add to the speedbar frame.")
;; Make sure our special speedbar mode is loaded
(p (window-point window)))
(cond
((memq minor-mode '(gdbmi gdba))
- (when (or gdb-var-changed
+ (when (or gdb-force-update
(not (save-excursion
(goto-char (point-min))
- (let ((case-fold-search t))
- (looking-at "Watch Expressions:")))))
+ (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))
+ (let ((var-list gdb-var-list) parent)
(while var-list
- (let* (char (depth 0) (start 0)
- (var (car var-list)) (varnum (nth 1 var)))
+ (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 \\*$" (nth 3 var))))
- (speedbar-make-tag-line 'bracket ?? nil nil
- (concat (car var) "\t" (nth 4 var))
- 'gdb-edit-value
- nil
- (if (and (nth 5 var)
- gdb-show-changed-values)
- 'font-lock-warning-face
- nil) depth)
- (if (and (cadr var-list)
+ (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 "\\.")
- (cadr (cadr var-list))))
+ (car (nth 1 var-list))))
(setq char ?-)
(setq char ?+))
- (if (string-match "\\*$" (nth 3 var))
- (speedbar-make-tag-line 'bracket char
- 'gdb-speedbar-expand-node varnum
- (concat (car var) "\t"
- (nth 3 var)"\t"
- (nth 4 var))
- 'gdb-edit-value nil
- (if (and (nth 5 var)
- gdb-show-changed-values)
- 'font-lock-warning-face
- nil) depth)
- (speedbar-make-tag-line 'bracket char
- 'gdb-speedbar-expand-node varnum
- (concat (car var) "\t" (nth 3 var))
- nil nil nil depth))))
+ (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-var-changed nil)))
- (t (if (and (save-excursion
- (goto-char (point-min))
- (looking-at "Current Stack:"))
- (equal gud-last-last-frame gud-last-speedbar-stackframe))
- nil
+ (setq gdb-force-update nil)))
+ (t (unless (and (save-excursion
+ (goto-char (point-min))
+ (looking-at "Current Stack:"))
+ (equal gud-last-last-frame gud-last-speedbar-stackframe))
(let ((gud-frame-list
(cond ((eq minor-mode 'gdb)
(gud-gdb-get-stackframe buffer))
(if (and gud-comint-buffer
(buffer-name gud-comint-buffer)
+ (get-buffer-process gud-comint-buffer)
(with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)))
(error "Multiple debugging is only supported with \"gdb --fullname\""))
-
+
(gud-common-init command-line nil 'gud-gdb-marker-filter)
(set (make-local-variable 'gud-minor-mode) 'gdb)
;; The completion list is constructed by the process filter.
(defvar gud-gdb-fetched-lines)
-(defvar gud-comint-buffer nil)
-
-(defun gud-gdb-complete-command ()
+(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
available with older versions of GDB."
(interactive)
- (let* ((end (point))
- (command (buffer-substring (comint-line-beginning-position) end))
- (command-word
+ (if command
+ ;; Used by gud-watch in mini-buffer.
+ (setq command (concat "p " command))
+ ;; Used in GUD buffer.
+ (let ((end (point)))
+ (setq command (buffer-substring (comint-line-beginning-position) end))))
+ (let* ((command-word
;; Find the word break. This match will always succeed.
(and (string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command)
(substring command (match-beginning 2))))
(defun gud-gdb-run-command-fetch-lines (command buffer &optional skip)
"Run COMMAND, and return the list of lines it outputs.
-BUFFER is the GUD buffer in which to run the command.
+BUFFER is the current buffer which may be the GUD buffer in which to run.
SKIP is the number of chars to skip on each lines, it defaults to 0."
- (with-current-buffer buffer
- (if (save-excursion
- (goto-char (point-max))
- (forward-line 0)
- (not (looking-at comint-prompt-regexp)))
+ (with-current-buffer gud-comint-buffer
+ (if (and (eq gud-comint-buffer buffer)
+ (save-excursion
+ (goto-char (point-max))
+ (forward-line 0)
+ (not (looking-at comint-prompt-regexp))))
nil
;; Much of this copied from GDB complete, but I'm grabbing the stack
;; frame instead.
(gud-gdb-fetch-lines-string nil)
(gud-gdb-fetch-lines-break (or skip 0))
(gud-marker-filter
- `(lambda (string) (gud-gdb-fetch-lines-filter string ',gud-marker-filter))))
+ `(lambda (string)
+ (gud-gdb-fetch-lines-filter string ',gud-marker-filter))))
;; Issue the command to GDB.
(gud-basic-call command)
;; Slurp the output.
(while gud-gdb-fetch-lines-in-progress
- (accept-process-output (get-buffer-process buffer)))
+ (accept-process-output (get-buffer-process gud-comint-buffer)))
(nreverse gud-gdb-fetched-lines)))))
\f
;; print line numbers using LOCALE, inserting a comma or a
;; period at the thousands positions (how ingenious!).
- "\\(\[[0-9]+\] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \
+ "\\(\\[[0-9]+] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \
\\(([a-zA-Z0-9.$_]+:\\|line=\\)\\([0-9.,]+\\)"
gud-marker-acc)
(with-current-buffer gud-comint-buffer
(gud-find-file true-file)))
(window (and buffer (or (get-buffer-window buffer)
- (display-buffer buffer))))
+ (if (memq gud-minor-mode '(gdbmi gdba))
+ (gdb-display-source-buffer buffer))
+ (display-buffer buffer))))
(pos))
- (message "%s %s" (current-buffer) buffer)
(if buffer
(progn
(with-current-buffer buffer
(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>,
(remove-hook 'tooltip-hook 'gud-tooltip-tips)
(define-key global-map [mouse-movement] 'ignore)))
(gud-tooltip-activate-mouse-motions-if-enabled)
- (if (and
- gud-comint-buffer
- (buffer-name gud-comint-buffer); gud-comint-buffer might be killed
- (with-current-buffer gud-comint-buffer
- (memq gud-minor-mode '(gdbmi gdba))))
+ (if (and gud-comint-buffer
+ (buffer-name gud-comint-buffer); gud-comint-buffer might be killed
+ (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ '(gdbmi gdba)))
(if gud-tooltip-mode
(progn
(dolist (buffer (buffer-list))
"The mouse movement event that led to a tooltip display.
This event can be examined by forms in GUD-TOOLTIP-DISPLAY.")
-(defun gud-tooltip-dereference ()
+(defun gud-tooltip-dereference (&optional arg)
"Toggle whether tooltips should show `* expr' or `expr'.
With arg, dereference expr iff arg is positive."
(interactive "P")