]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/gud.el
(gud-common-init): Use absolute file so that
[gnu-emacs] / lisp / progmodes / gud.el
index 655c74961429bfb79d4b5a7166fadd01bf48bece..f5e6218a432054224c6683ea502cc947b39681f6 100644 (file)
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; 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, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
-;; The ancestral gdb.el was by W. Schelter <wfs@rascal.ics.utexas.edu> It was
-;; later rewritten by rms.  Some ideas were due to Masanobu.  Grand
+;; The ancestral gdb.el was by W. Schelter <wfs@rascal.ics.utexas.edu>.
+;; It was later rewritten by rms.  Some ideas were due to Masanobu.  Grand
 ;; Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com> Barry
 ;; Warsaw <bwarsaw@cen.com> hacked the mode to use comint.el.  Shane Hartman
 ;; <shane@spr.com> added support for xdb (HPUX debugger).  Rick Sladkey
 (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) and jdb."
-  :group 'unix
+  :group 'processes
   :group 'tools)
 
 
@@ -104,7 +107,8 @@ If SOFT is non-nil, returns nil if the symbol doesn't already exist."
   "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 ()
@@ -138,7 +142,7 @@ Used to grey out relevant toolbar icons.")
       (comint-interrupt-subjob))))
 
 (easy-mmode-defmap gud-menu-map
-  '(([help]     "Info" . gud-goto-info)
+  '(([help]     "Info (debugger)" . gud-goto-info)
     ([tooltips] menu-item "Show GUD tooltips" gud-tooltip-mode
                   :enable (and (not emacs-basic-display)
                               (display-graphic-p)
@@ -294,6 +298,11 @@ Used to grey out relevant toolbar icons.")
 (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))
@@ -305,6 +314,8 @@ Uses `gud-<MINOR-MODE>-directories' to find the source files."
        (setq directories (cdr directories)))
       result)))
 
+(declare-function gdb-create-define-alist "gdb-ui" ())
+
 (defun gud-find-file (file)
   ;; Don't get confused by double slashes in the name that comes from GDB.
   (while (string-match "//+" file)
@@ -494,8 +505,6 @@ required by the caller."
        ((memq minor-mode '(gdbmi gdba))
        (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))
@@ -703,6 +712,9 @@ The option \"--fullname\" must be included in this value."
 (defvar gud-filter-pending-text nil
   "Non-nil means this is text that has been saved for later in `gud-filter'.")
 
+;; If in gdba mode, gdb-ui is loaded.
+(declare-function gdb-restore-windows "gdb-ui" ())
+
 ;; The old gdb command (text command mode).  The new one is in gdb-ui.el.
 ;;;###autoload
 (defun gud-gdb (command-line)
@@ -753,7 +765,6 @@ directory and source-file directory for your debugger."
   (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 'gud-gdb-mode-hook))
 
@@ -878,7 +889,7 @@ It is passed through FILTER before we look at it."
                    (string-match "^#\\([0-9]+\\) +[0-9a-fx]+ in \\([:0-9a-zA-Z_]+\\) (" e)
                    (string-match "^#\\([0-9]+\\) +\\([:0-9a-zA-Z_]+\\) (" e)))
              (if (not (string-match
-                       "at \\([-0-9a-zA-Z_.]+\\):\\([0-9]+\\)$" e))
+                       "at \\([-0-9a-zA-Z_/.]+\\):\\([0-9]+\\)$" e))
                  nil
                (setcar newlst
                        (list (nth 0 (car newlst))
@@ -890,7 +901,7 @@ It is passed through FILTER before we look at it."
            (setq newlst
                  (cons
                   (if (string-match
-                       "at \\([-0-9a-zA-Z_.]+\\):\\([0-9]+\\)$" e)
+                       "at \\([-0-9a-zA-Z_/.]+\\):\\([0-9]+\\)$" e)
                       (list name num (match-string 1 e)
                             (match-string 2 e))
                     (list name num))
@@ -1222,10 +1233,6 @@ whereby $stopformat=1 produces an output format compatible with
          (setq result (substring result 0 (match-beginning 0))))))
     (or result "")))
 
-(defvar gud-dgux-p (string-match "-dgux" system-configuration)
-  "Non-nil means to assume the interface approriate for DG/UX dbx.
-This was tested using R4.11.")
-
 ;; There are a couple of differences between DG's dbx output and normal
 ;; dbx output which make it nontrivial to integrate this into the
 ;; standard dbx-marker-filter (mainly, there are a different number of
@@ -1284,9 +1291,6 @@ and source-file directory for your debugger."
    (gud-irix-p
     (gud-common-init command-line 'gud-dbx-massage-args
                     'gud-irixdbx-marker-filter))
-   (gud-dgux-p
-    (gud-common-init command-line 'gud-dbx-massage-args
-                    'gud-dguxdbx-marker-filter))
    (t
     (gud-common-init command-line 'gud-dbx-massage-args
                     'gud-dbx-marker-filter)))
@@ -2296,7 +2300,6 @@ gud, see `gud-mode'."
   (gud-def gud-run    "run"           nil    "Run the program.") ;if VM start using jdb
   (gud-def gud-print  "print %e"  "\C-p" "Evaluate Java expression at point.")
 
-
   (setq comint-prompt-regexp "^> \\|^[^ ]+\\[[0-9]+\\] ")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'jdb-mode-hook)
@@ -2442,9 +2445,6 @@ comint mode, which see."
   :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.
@@ -2500,7 +2500,12 @@ comint mode, which see."
       (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)
+                     ;; Tramp has already been loaded if we are here.
+                     (setq file (tramp-file-name-localname
+                                 (tramp-dissect-file-name 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.
@@ -2591,6 +2596,8 @@ It is saved for when this flag is not set.")
 (defvar gud-overlay-arrow-position nil)
 (add-to-list 'overlay-arrow-variable-list 'gud-overlay-arrow-position)
 
+(declare-function gdb-reset "gdb-ui" ())
+
 (defun gud-sentinel (proc msg)
   (cond ((null (buffer-name (process-buffer proc)))
         ;; buffer killed
@@ -2660,6 +2667,11 @@ Obeying it means displaying in another window the specified file and line."
     (setq gud-last-last-frame gud-last-frame
          gud-last-frame nil)))
 
+(declare-function global-hl-line-highlight  "hl-line" ())
+(declare-function hl-line-highlight         "hl-line" ())
+(declare-function gdb-display-source-buffer "gdb-ui"  (buffer))
+(declare-function gdb-display-buffer "gdb-ui" (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.
 ;; Put the overlay-arrow on the line LINE in that buffer.
@@ -2675,10 +2687,10 @@ Obeying it means displaying in another window the specified file and line."
         (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))
+                             (or (if (get-buffer-window buffer 'visible)
+                                     (display-buffer buffer nil 'visible))
                                  (unless (gdb-display-source-buffer buffer)
-                                   (gdb-display-buffer buffer nil))))
+                                   (gdb-display-buffer buffer nil 'visible))))
                          (display-buffer buffer))))
         (pos))
     (if buffer
@@ -2849,7 +2861,7 @@ Obeying it means displaying in another window the specified file and line."
            (set-marker-insertion-type gud-delete-prompt-marker t))
          (unless (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
                      'jdb)
-             (insert (concat  expr " = "))))))
+           (insert (concat  expr " = "))))))
     expr))
 
 ;; The next eight functions are hacked from gdbsrc.el by
@@ -2992,6 +3004,12 @@ Link exprs of the form:
        (t nil)))
      (t nil))))
 
+
+(declare-function c-langelem-sym "cc-defs" (langelem))
+(declare-function c-langelem-pos "cc-defs" (langelem))
+(declare-function syntax-symbol  "gud"     (x))
+(declare-function syntax-point   "gud"     (x))
+
 (defun gud-find-class (f line)
   "Find fully qualified class in file F at line LINE.
 This function uses the `gud-jdb-classpath' (and optional
@@ -3253,6 +3271,9 @@ Treats actions as defuns."
        (kill-local-variable 'gdb-define-alist)
        (remove-hook 'after-save-hook 'gdb-create-define-alist t))))
 
+(define-obsolete-variable-alias 'tooltip-gud-modes
+                                'gud-tooltip-modes "22.1")
+
 (defcustom gud-tooltip-modes '(gud-mode c-mode c++-mode fortran-mode
                                        python-mode)
   "List of modes for which to enable GUD tooltips."
@@ -3260,6 +3281,9 @@ Treats actions as defuns."
   :group 'gud
   :group 'tooltip)
 
+(define-obsolete-variable-alias 'tooltip-gud-display
+                                'gud-tooltip-display "22.1")
+
 (defcustom gud-tooltip-display
   '((eq (tooltip-event-buffer gud-tooltip-event)
        (marker-buffer gud-overlay-arrow-position)))
@@ -3277,11 +3301,6 @@ only tooltips in the buffer containing the overlay arrow."
   :group 'gud
   :group 'tooltip)
 
-(define-obsolete-variable-alias 'tooltip-gud-modes
-                                'gud-tooltip-modes "22.1")
-(define-obsolete-variable-alias 'tooltip-gud-display
-                                'gud-tooltip-display "22.1")
-
 ;;; Reacting on mouse movements
 
 (defun gud-tooltip-change-major-mode ()
@@ -3322,6 +3341,10 @@ ACTIVATEP non-nil means activate mouse motion events."
       (kill-local-variable 'gud-tooltip-mouse-motions-active)
       (kill-local-variable 'track-mouse))))
 
+(defvar tooltip-last-mouse-motion-event)
+(declare-function tooltip-hide "tooltip" (&optional ignored-arg))
+(declare-function tooltip-start-delayed-tip "tooltip" ())
+
 (defun gud-tooltip-mouse-motion (event)
   "Command handler for mouse movement events in `global-map'."
   (interactive "e")
@@ -3356,6 +3379,9 @@ With arg, dereference expr if ARG is positive, otherwise do not derereference."
 
 (define-obsolete-function-alias 'tooltip-gud-toggle-dereference
                                 'gud-tooltip-dereference "22.1")
+(defvar tooltip-use-echo-area)
+(declare-function tooltip-show "tooltip" (text &optional use-echo-area))
+(declare-function tooltip-strip-prompt "tooltip" (process output))
 
 ; This will only display data that comes in one chunk.
 ; Larger arrays (say 400 elements) are displayed in
@@ -3377,6 +3403,10 @@ With arg, dereference expr if ARG is positive, otherwise do not derereference."
        ((xdb pdb) (concat "p " expr))
        (sdb (concat expr "/"))))
 
+(declare-function gdb-enqueue-input "gdb-ui" (item))
+(declare-function tooltip-expr-to-print "tooltip" (event))
+(declare-function tooltip-event-buffer "tooltip" (event))
+
 (defun gud-tooltip-tips (event)
   "Show tip for identifier or selection under the mouse.
 The mouse must either point at an identifier or inside a selected
@@ -3401,10 +3431,7 @@ This function must return nil if it doesn't handle EVENT."
          (if (and (eq gud-minor-mode 'gdba)
                   (not gdb-active-process))
              (progn
-               (with-current-buffer
-                   (window-buffer (let ((mouse (mouse-position)))
-                                    (window-at (cadr mouse)
-                                               (cddr mouse))))
+               (with-current-buffer (tooltip-event-buffer event)
                  (let ((define-elt (assoc expr gdb-define-alist)))
                    (unless (null define-elt)
                      (tooltip-show
@@ -3435,5 +3462,5 @@ so they have been disabled."))
 
 (provide 'gud)
 
-;;; arch-tag: 6d990948-df65-461a-be39-1c7fb83ac4c4
+;; arch-tag: 6d990948-df65-461a-be39-1c7fb83ac4c4
 ;;; gud.el ends here