]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/gud.el
Updated to IDLWAVE v5.7 (see idlwave.org), and variable cleanup
[gnu-emacs] / lisp / progmodes / gud.el
index 5c81ba7f6f97e1128b0fac0a298220a483bb9dac..fd8bfeb5d725fbe56b6e4954c7e768309e07ef61 100644 (file)
@@ -4,7 +4,7 @@
 ;; Maintainer: FSF
 ;; Keywords: unix, tools
 
-;; Copyright (C) 1992,93,94,95,96,1998,2000,02,03,04 Free Software Foundation, Inc.
+;; Copyright (C) 1992,93,94,95,96,1998,2000,02,03,04,05 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
 
 ;;; 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 Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com>
-;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>,
-;; who also hacked the mode to use comint.el.  Shane Hartman <shane@spr.com>
-;; added support for xdb (HPUX debugger).  Rick Sladkey <jrs@world.std.com>
-;; wrote the GDB command completion code.  Dave Love <d.love@dl.ac.uk>
-;; added the IRIX kluge, re-implemented the Mips-ish variant and added
-;; a menu. Brian D. Carlstrom <bdc@ai.mit.edu> combined the IRIX kluge with
-;; the gud-xdb-directories hack producing gud-dbx-directories.  Derek L. Davies
-;; <ddavies@world.std.com> added support for jdb (Java debugger.)
+;; 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
+;; <jrs@world.std.com> wrote the GDB command completion code.  Dave Love
+;; <d.love@dl.ac.uk> added the IRIX kluge, re-implemented the Mips-ish variant
+;; and added a menu. Brian D. Carlstrom <bdc@ai.mit.edu> combined the IRIX
+;; kluge with the gud-xdb-directories hack producing gud-dbx-directories.
+;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java
+;; debugger.)
 
 ;;; Code:
 
@@ -107,11 +107,10 @@ Used to grey out relevant togolbar icons.")
                (setq same-window-regexps nil)
                (throw 'info-found nil))))
        nil 0)
-      (require 'info)
       (select-frame (make-frame)))
     (if (memq gud-minor-mode '(gdbmi gdba))
-       (Info-goto-node "(emacs)GDB Graphical Interface")
-      (Info-goto-node "(emacs)Debuggers"))))
+       (info "(emacs)GDB Graphical Interface")
+      (info "(emacs)Debuggers"))))
 
 (easy-mmode-defmap gud-menu-map
   '(([help]     "Info" . gud-goto-info)
@@ -141,6 +140,9 @@ Used to grey out relevant togolbar icons.")
                  :enable (and (not gud-running)
                               (memq gud-minor-mode
                                     '(gdbmi gdba gdb dbx xdb jdb pdb bashdb))))
+    ([print*]  menu-item "Print Dereference" gud-pstar
+                     :enable (and (not gud-running)
+                                 (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
@@ -184,18 +186,19 @@ Used to grey out relevant togolbar icons.")
        (dolist (x '((gud-break . "gud-break")
                     (gud-remove . "gud-remove")
                     (gud-print . "gud-print")
+                    (gud-pstar . "gud-pstar")
                     (gud-watch . "gud-watch")
-                    (gud-run . "gud-run")
-                    (gud-until . "gud-until")
                     (gud-cont . "gud-cont")
+                    (gud-until . "gud-until")
+                    (gud-finish . "gud-finish")
+                    (gud-run . "gud-run")
                     ;; gud-s, gud-si etc. instead of gud-step,
                     ;; gud-stepi, to avoid file-name clashes on DOS
                     ;; 8+3 filesystems.
-                    (gud-step . "gud-s")
                     (gud-next . "gud-n")
-                    (gud-finish . "gud-finish")
-                    (gud-stepi . "gud-si")
+                    (gud-step . "gud-s")
                     (gud-nexti . "gud-ni")
+                    (gud-stepi . "gud-si")
                     (gud-up . "gud-up")
                     (gud-down . "gud-down")
                     (gud-goto-info . "info"))
@@ -343,13 +346,13 @@ t means that there is no stack, and we are in display-file mode.")
 
 (defvar gud-speedbar-menu-items
   ;; Note to self.  Add expand, and turn off items when not available.
-  '(["Jump to stack frame" speedbar-edit-line 
+  '(["Jump to stack frame" speedbar-edit-line
      (with-current-buffer gud-comint-buffer
        (not (memq gud-minor-mode '(gdbmi gdba))))]
-    ["Edit value" speedbar-edit-line 
+    ["Edit value" speedbar-edit-line
      (with-current-buffer gud-comint-buffer
        (not (memq gud-minor-mode '(gdbmi gdba))))]
-    ["Delete expression" gdb-var-delete 
+    ["Delete expression" gdb-var-delete
      (with-current-buffer gud-comint-buffer
        (not (memq gud-minor-mode '(gdbmi gdba))))])
   "Additional menu items to add to the speedbar frame.")
@@ -494,18 +497,24 @@ off the specialized speedbar mode."
     ;; Check for annotations and change gud-minor-mode to 'gdba if
     ;; they are found.
     (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc)
-      (when (string-equal (match-string 1 gud-marker-acc) "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.
-       output (concat output
-                     (substring gud-marker-acc 0 (match-beginning 0)))
-
-       ;; Set the accumulator to the remaining text.
-       gud-marker-acc (substring gud-marker-acc (match-end 0))))
+      (let ((match (match-string 1 gud-marker-acc)))
+       (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.
+        output (concat output
+                       (substring gud-marker-acc 0 (match-beginning 0)))
+        
+        ;; Set the accumulator to the remaining text.
+        
+        gud-marker-acc (substring gud-marker-acc (match-end 0)))
+       (if (string-equal match "error-begin")
+           (put-text-property 0 (length gud-marker-acc)
+                              'face font-lock-warning-face
+                              gud-marker-acc))))
 
     ;; Does the remaining text look like it might end with the
     ;; beginning of another marker?  If it does, then keep it in
@@ -581,6 +590,8 @@ and source-file directory for your debugger."
   (gud-def gud-up     "up %p"        "<" "Up N stack frames (numeric arg).")
   (gud-def gud-down   "down %p"      ">" "Down N stack frames (numeric arg).")
   (gud-def gud-print  "print %e"     "\C-p" "Evaluate C expression at point.")
+  (gud-def gud-pstar  "print* %e"    nil
+          "Evaluate C dereferenced pointer expression at point.")
   (gud-def gud-until  "until %l"     "\C-u" "Continue to current line.")
   (gud-def gud-run    "run"         nil    "Run the program.")
 
@@ -1215,7 +1226,7 @@ containing the executable being debugged."
 The directory containing FILE becomes the initial working directory
 and source-file directory for your debugger.
 
-You can set the variable 'gud-xdb-directories' to a list of program source
+You can set the variable `gud-xdb-directories' to a list of program source
 directories if your program contains sources from more than one directory."
   (interactive (list (gud-query-cmdline 'xdb)))
 
@@ -2523,16 +2534,12 @@ It is saved for when this flag is not set.")
            ;; This must be outside of the save-excursion
            ;; in case the source file is our current buffer.
            (if process-window
-               (save-selected-window
-                 (select-window process-window)
+               (with-selected-window process-window
                  (gud-display-frame))
              ;; We have to be in the proper buffer, (process-buffer proc),
              ;; but not in a save-excursion, because that would restore point.
-             (let ((old-buf (current-buffer)))
-               (set-buffer (process-buffer proc))
-               (unwind-protect
-                   (gud-display-frame)
-                 (set-buffer old-buf)))))
+             (with-current-buffer (process-buffer proc)
+               (gud-display-frame))))
 
          ;; If we deferred text that arrived during this processing,
          ;; handle it now.
@@ -3134,8 +3141,6 @@ only tooltips in the buffer containing the overlay arrow."
                                 'gud-tooltip-modes "22.1")
 (define-obsolete-variable-alias 'tooltip-gud-display
                                 'gud-tooltip-display "22.1")
-(define-obsolete-variable-alias 'tooltip-use-echo-area
-                                'gud-tooltip-echo-area "22.1")
 
 ;;; Reacting on mouse movements
 
@@ -3192,7 +3197,7 @@ For C this would dereference a pointer expression.")
   "The mouse movement event that led to a tooltip display.
 This event can be examined by forms in GUD-TOOLTIP-DISPLAY.")
 
-(defun gud-tooltip-toggle-dereference ()
+(defun toggle-gud-tooltip-dereference ()
   "Toggle whether tooltips should show `* expr' or `expr'."
   (interactive)
   (setq gud-tooltip-dereference (not gud-tooltip-dereference))
@@ -3201,7 +3206,7 @@ This event can be examined by forms in GUD-TOOLTIP-DISPLAY.")
             (if gud-tooltip-dereference "on" "off"))))
 
 (define-obsolete-function-alias 'tooltip-gud-toggle-dereference
-                                'gud-tooltip-toggle-dereference "22.1")
+                                'toggle-gud-tooltip-dereference "22.1")
 
 (define-minor-mode gud-tooltip-mode
   "Toggle the display of GUD tooltips."
@@ -3215,7 +3220,7 @@ This event can be examined by forms in GUD-TOOLTIP-DISPLAY.")
        (add-hook 'tooltip-hook 'gud-tooltip-tips)
        (define-key global-map [mouse-movement] 'gud-tooltip-mouse-motion))
     (unless tooltip-mode (remove-hook 'pre-command-hook 'tooltip-hide)
-    (remove-hook 'change-major-mode-hook 'tooltip-change-major-mode)
+    (remove-hook 'change-major-mode-hook 'gud-tooltip-change-major-mode)
     (remove-hook 'tooltip-hook 'gud-tooltip-tips)
     (define-key global-map [mouse-movement] 'ignore)))
   (gud-tooltip-activate-mouse-motions-if-enabled)
@@ -3237,7 +3242,7 @@ This event can be examined by forms in GUD-TOOLTIP-DISPLAY.")
 
 ; This will only display data that comes in one chunk.
 ; Larger arrays (say 400 elements) are displayed in
-; the tootip incompletely and spill over into the gud buffer.
+; the tooltip incompletely and spill over into the gud buffer.
 ; Switching the process-filter creates timing problems and
 ; it may be difficult to do better. Using annotations as in
 ; gdb-ui.el gets round this problem.
@@ -3245,7 +3250,7 @@ This event can be examined by forms in GUD-TOOLTIP-DISPLAY.")
   "Process debugger output and show it in a tooltip window."
   (set-process-filter process gud-tooltip-original-filter)
   (tooltip-show (tooltip-strip-prompt process output)
-               gud-tooltip-echo-area))
+               (or gud-tooltip-echo-area tooltip-use-echo-area)))
 
 (defun gud-tooltip-print-command (expr)
   "Return a suitable command to print the expression EXPR.
@@ -3253,11 +3258,11 @@ If GUD-TOOLTIP-DEREFERENCE is t, also prepend a `*' to EXPR."
   (when gud-tooltip-dereference
     (setq expr (concat "*" expr)))
   (case gud-minor-mode
-    ((gdb gdba) (concat "server print " expr))
-    ((dbx gdbmi) (concat "print " expr))
-    (xdb (concat "p " expr))
-    (sdb (concat expr "/"))
-    (perldb expr)))
+       (gdba (concat "server print " expr))
+       ((dbx gdbmi) (concat "print " expr))
+       (xdb (concat "p " expr))
+       (sdb (concat expr "/"))
+       (perldb expr)))
 
 (defun gud-tooltip-tips (event)
   "Show tip for identifier or selection under the mouse.
@@ -3290,9 +3295,15 @@ This function must return nil if it doesn't handle EVENT."
                                                (cddr mouse))))
                  (let ((define-elt (assoc expr gdb-define-alist)))
                    (unless (null define-elt)
-                     (tooltip-show (cdr define-elt))
+                     (tooltip-show
+                      (cdr define-elt)
+                      (or gud-tooltip-echo-area tooltip-use-echo-area))
                      expr))))
            (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\
+so they have been disabled."))
              (unless (null cmd) ; CMD can be nil if unknown debugger
                (if (memq gud-minor-mode '(gdba gdbmi))
                      (if gdb-macro-info