(defvar gdb-macro-info)
(defvar gdb-server-prefix)
(defvar gdb-show-changed-values)
+(defvar gdb-source-window)
(defvar gdb-var-list)
(defvar gdb-speedbar-auto-raise)
+(defvar gud-tooltip-mode)
+(defvar hl-line-mode)
+(defvar hl-line-sticky-flag)
(defvar tool-bar-map)
+
;; ======================================================================
;; GUD commands must be visible in C buffers visited by GUD
(defgroup gud nil
"Grand Unified Debugger mode for gdb and other debuggers under Emacs.
Supported debuggers include gdb, sdb, dbx, xdb, perldb, pdb (Python), jdb."
- :group 'unix
+ :group 'processes
:group 'tools)
"Non-nil if debugged program is running.
Used to grey out relevant toolbar icons.")
+(defvar gdb-ready nil)
+
+(defvar gud-target-name "--unknown--"
+ "The apparent name of the program being debugged in a gud buffer.")
+
;; Use existing Info buffer, if possible.
(defun gud-goto-info ()
"Go to relevant Emacs info node."
([menu-bar run] menu-item
,(propertize "run" 'face 'font-lock-doc-face) gud-run
:visible (memq gud-minor-mode '(gdbmi gdb dbx jdb)))
- ([menu-bar go] menu-item
+ ([menu-bar go] menu-item
,(propertize " go " 'face 'font-lock-doc-face) gud-go
:visible (and (not gud-running)
(eq gud-minor-mode 'gdba)))
(defun gud-file-name (f)
"Transform a relative file name to an absolute file name.
Uses `gud-<MINOR-MODE>-directories' to find the source files."
+ ;; When `default-directory' is a remote file name, prepend its
+ ;; remote part to f, which is the local file name. Fortunately,
+ ;; `file-remote-p' returns exactly this remote file name part (or
+ ;; nil otherwise).
+ (setq f (concat (or (file-remote-p default-directory) "") f))
(if (file-exists-p f) (expand-file-name f)
(let ((directories (gud-val 'directories))
(result nil))
;; History of argument lists passed to gdb.
(defvar gud-gdb-history nil)
-(defcustom gud-gdb-command-name "gdb --annotate=3"
- "Default command to execute an executable under the GDB debugger."
+(defcustom gud-gud-gdb-command-name "gdb --fullname"
+ "Default command to run an executable under GDB in text command mode.
+The option \"--fullname\" must be included in this value."
:type 'string
:group 'gud)
(while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc)
(let ((match (match-string 1 gud-marker-acc)))
- ;; Pick up stopped annotation if attaching to process.
- (if (string-equal match "stopped") (setq gdb-active-process t))
-
- ;; Using annotations, switch to gud-gdba-marker-filter.
- (when (string-equal match "prompt")
- (require 'gdb-ui)
- (gdb-prompt nil))
-
(setq
;; Append any text before the marker to the output we're going
;; to return - we don't include the marker in this text.
;; Set the accumulator to the remaining text.
- gud-marker-acc (substring gud-marker-acc (match-end 0)))
-
- ;; Pick up any errors that occur before first prompt annotation.
- (if (string-equal match "error-begin")
- (put-text-property 0 (length gud-marker-acc)
- 'face font-lock-warning-face
- gud-marker-acc))))
+ gud-marker-acc (substring gud-marker-acc (match-end 0)))))
;; Does the remaining text look like it might end with the
;; beginning of another marker? If it does, then keep it in
(defvar gud-filter-pending-text nil
"Non-nil means this is text that has been saved for later in `gud-filter'.")
+;; The old gdb command. The new one is in gdb-ui.el.
;;;###autoload
-(defun gdb (command-line)
+(defun gud-gdb (command-line)
"Run gdb on program FILE in buffer *gud-FILE*.
The directory containing FILE becomes the initial working
directory and source-file directory for your debugger. By
`gud-gdb-command-name' for all future sessions. You need to use
text command mode to debug multiple programs within one Emacs
session."
- (interactive (list (gud-query-cmdline 'gdb)))
+ (interactive (list (gud-query-cmdline 'gud-gdb)))
+
+ (require 'gdb-ui)
(when (and gud-comint-buffer
(buffer-name gud-comint-buffer)
(error
"Multiple debugging requires restarting in text command mode"))
- (gud-common-init command-line nil 'gud-gdb-marker-filter)
- (set (make-local-variable 'gud-minor-mode) 'gdb)
+ (gud-common-init command-line nil 'gud-gdba-marker-filter)
+ (set (make-local-variable 'gud-minor-mode) 'gdba)
(gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.")
(gud-def gud-tbreak "tbreak %f:%l" "\C-t"
(setq comint-prompt-regexp "^(.*gdb[+]?) *")
(setq paragraph-start comint-prompt-regexp)
(setq gdb-first-prompt t)
+ (setq gud-running nil)
+ (setq gdb-ready nil)
(setq gud-filter-pending-text nil)
- (run-hooks 'gdb-mode-hook))
+ (run-hooks 'gud-gdb-mode-hook))
;; One of the nice features of GDB is its impressive support for
;; context-sensitive command completion. We preserve that feature
(gud-common-init command-line nil 'gud-pdb-marker-filter)
(set (make-local-variable 'gud-minor-mode) 'pdb)
- (gud-def gud-break "break %l" "\C-b" "Set breakpoint at current line.")
+ (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.")
(gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line")
(gud-def gud-step "step" "\C-s" "Step one source line with display.")
(gud-def gud-next "next" "\C-n" "Step one line (skip functions).")
:group 'gud
:type 'boolean)
-(defvar gud-target-name "--unknown--"
- "The apparent name of the program being debugged in a gud buffer.")
-
;; Perform initializations common to all debuggers.
;; The first arg is the specified command line,
;; which starts with the program to debug.
;; for local variables in the debugger buffer.
(defun gud-common-init (command-line massage-args marker-filter
&optional find-file)
- (let* ((words (string->strings command-line))
+ (let* ((words (split-string-and-unquote command-line))
(program (car words))
(dir default-directory)
;; Extract the file name from WORDS
(while (and w (not (eq (car w) t)))
(setq w (cdr w)))
(if w
- (setcar w file)))
+ (setcar w
+ (if (file-remote-p default-directory)
+ (setq file (file-name-nondirectory file))
+ file))))
(apply 'make-comint (concat "gud" filepart) program nil
(if massage-args (funcall massage-args file args) args))
;; Since comint clobbered the mode, we don't set it until now.
(and file-word (file-name-nondirectory file))))
(set (make-local-variable 'gud-marker-filter) marker-filter)
(if find-file (set (make-local-variable 'gud-find-file) find-file))
- (setq gud-running nil)
(setq gud-last-last-frame nil)
(set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
;; process-buffer is current-buffer
(unwind-protect
(progn
- ;; Write something in *compilation* and hack its mode line,
+ ;; Write something in the GUD buffer and hack its mode line,
(set-buffer (process-buffer proc))
;; Fix the mode line.
(setq mode-line-process
(buffer
(with-current-buffer gud-comint-buffer
(gud-find-file true-file)))
- (window (and buffer (or (get-buffer-window buffer)
- (if (memq gud-minor-mode '(gdbmi gdba))
- (unless (gdb-display-source-buffer buffer)
- (gdb-display-buffer buffer nil)))
- (display-buffer buffer))))
+ (window (and buffer
+ (or (get-buffer-window buffer)
+ (if (memq gud-minor-mode '(gdbmi gdba))
+ (or (if (get-buffer-window buffer 0)
+ (display-buffer buffer nil 0))
+ (unless (gdb-display-source-buffer buffer)
+ (gdb-display-buffer buffer nil))))
+ (display-buffer buffer))))
(pos))
(if buffer
(progn
'syntax-table (eval-when-compile
(string-to-syntax "> b")))
;; Make sure that rehighlighting the previous line won't erase our
- ;; syntax-table property.
+ ;; syntax-table property.
(put-text-property (1- (match-beginning 0)) (match-end 0)
'font-lock-multiline t)
nil)))))
(defun gud-tooltip-dereference (&optional arg)
"Toggle whether tooltips should show `* expr' or `expr'.
-With arg, dereference expr iff arg is positive."
+With arg, dereference expr if ARG is positive, otherwise do not derereference."
(interactive "P")
(setq gud-tooltip-dereference
(if (null arg)