]> code.delx.au - gnu-emacs/blobdiff - lisp/gud.el
(antlr-c-common-init): Undo last change.
[gnu-emacs] / lisp / gud.el
index 9e9650931dfb79d389c7a255feca6e5c89ef1505..b03f209905904088d3e263f8775bf07a62cce75d 100644 (file)
@@ -289,13 +289,13 @@ off the specialized speedbar mode."
                                  'speedbar-highlight-face
                                  (cond ((eq ff 'gud-gdb-find-file)
                                         'gud-gdb-goto-stackframe)
-                                       (t (error "Should never be here.")))
+                                       (t (error "Should never be here")))
                                  (car frames) t))
        (setq frames (cdr frames)))
 ;      (let ((selected-frame
 ;           (cond ((eq ff 'gud-gdb-find-file)
 ;                  (gud-gdb-selected-frame-info buffer))
-;                 (t (error "Should never be here."))))))
+;                 (t (error "Should never be here"))))))
       )
     (setq gud-last-speedbar-stackframe gud-last-last-frame)))
 
@@ -464,7 +464,7 @@ available with older versions of GDB."
     (and gud-gdb-complete-list
         (string-match "^Undefined command: \"complete\""
                       (car gud-gdb-complete-list))
-        (error "This version of GDB doesn't support the `complete' command."))
+        (error "This version of GDB doesn't support the `complete' command"))
     ;; Sort the list like readline.
     (setq gud-gdb-complete-list
          (sort gud-gdb-complete-list (function string-lessp)))
@@ -580,7 +580,7 @@ BUFFER is the GUD buffer in which to run the command."
     (set-buffer buffer)
     (if (save-excursion
          (goto-char (point-max))
-         (beginning-of-line)
+         (forward-line 0)
          (not (looking-at comint-prompt-regexp)))
        nil
       ;; Much of this copied from GDB complete, but I'm grabbing the stack
@@ -692,7 +692,7 @@ and source-file directory for your debugger."
           (not (and (boundp 'tags-file-name)
                     (stringp tags-file-name)
                     (file-exists-p tags-file-name))))
-      (error "The sdb support requires a valid tags table to work."))
+      (error "The sdb support requires a valid tags table to work"))
 
   (gud-common-init command-line 'gud-sdb-massage-args
                   'gud-sdb-marker-filter 'gud-sdb-find-file)
@@ -1046,14 +1046,14 @@ and source-file directory for your debugger."
     ;; Make dbx give out the source location info that we need.
     (process-send-string (get-buffer-process gud-comint-buffer)
                         "printf \"\032\032%1d:\",(int)$curline;file\n"))
-   (gud-dbx-use-stopformat-p
-    (process-send-string (get-buffer-process gud-comint-buffer)
-                        "set $stopformat=1\n"))
    (t
     (gud-def gud-up     "up %p"         "<" "Up (numeric arg) stack frames.")
     (gud-def gud-down   "down %p" ">" "Down (numeric arg) stack frames.")
     (gud-def gud-break "file \"%d%f\"\nstop at %l"
-                                 "\C-b" "Set breakpoint at current line.")))
+                                 "\C-b" "Set breakpoint at current line.")
+    (if gud-dbx-use-stopformat-p
+       (process-send-string (get-buffer-process gud-comint-buffer)
+                            "set $stopformat=1\n"))))
 
   (gud-def gud-remove "clear %l"  "\C-d" "Remove breakpoint at current line")
   (gud-def gud-step   "step %p"          "\C-s" "Step one line with display.")
@@ -1182,7 +1182,7 @@ directories if your program contains sources from more than one directory."
 ;; "-d" in inserted as the first switch, and "-emacs" is inserted where
 ;; it will be $ARGV[0] (see perl5db.pl).
 (defun gud-perldb-massage-args (file args)
-  (let* ((new-args '("-d"))
+  (let* ((new-args (list "-d"))
         (seen-e nil)
         (shift (lambda ()
                  (setq new-args (cons (car args) new-args))
@@ -1197,14 +1197,14 @@ directories if your program contains sources from more than one directory."
        ;; -e goes with the next arg, so shift one extra.
        (or (funcall shift)
            ;; -e as the last arg is an error in Perl.
-           (error "No code specified for -e."))
+           (error "No code specified for -e"))
        (setq seen-e t))
       (funcall shift))
 
-    (when (not seen-e)
+    (unless seen-e
       (if (or (not args)
              (string-match "^-" (car args)))
-         (error "Can't use stdin as the script to debug."))
+         (error "Can't use stdin as the script to debug"))
       ;; This is the program name.
       (funcall shift))
 
@@ -1212,9 +1212,9 @@ directories if your program contains sources from more than one directory."
     ;; as -e macs.
     (if (and args (equal "--" (car args)))
        (funcall shift)
-      (and seen-e (setq new-args (cons "--" new-args))))
+      (and seen-e (push "--" new-args)))
 
-    (setq new-args (cons "-emacs" new-args))
+    (push "-emacs" new-args)
     (while args
       (funcall shift))
 
@@ -1533,7 +1533,8 @@ the source code display in sync with the debugging session.")
 (defun gud-jdb-build-source-files-list (path extn)
   (apply 'nconc (mapcar (lambda (d)
                          (when (file-directory-p d)
-                           (directory-files d t extn nil)) path))))
+                           (directory-files d t extn nil)))
+                       path)))
 
 ;; Move point past whitespace.
 (defun gud-jdb-skip-whitespace ()
@@ -2020,12 +2021,17 @@ comint mode, which see."
 ;; in the selected window.
 ;;;###autoload (add-hook 'same-window-regexps "\\*gud-.*\\*\\(\\|<[0-9]+>\\)")
 
+(defcustom gud-chdir-before-run t
+  "Non-nil if GUD should `cd' to the debugged executable."
+  :group 'gud
+  :type 'boolean)
+
 ;; Perform initializations common to all debuggers.
 ;; The first arg is the specified command line,
 ;; which starts with the program to debug.
 ;; The other three args specify the values to use
 ;; for local variables in the debugger buffer.
-(defun gud-common-init (command-line massage-args marker-filter find-file)
+(defun gud-common-init (command-line massage-args marker-filter &optional find-file)
   (let* ((words (split-string command-line))
         (program (car words))
         ;; Extract the file name from WORDS
@@ -2053,6 +2059,7 @@ comint mode, which see."
     (pop-to-buffer (concat "*gud" filepart "*"))
     ;; Set default-directory to the file's directory.
     (and file-word
+        gud-chdir-before-run
         ;; Don't set default-directory if no directory was specified.
         ;; In that case, either the file is found in the current directory,
         ;; in which case this setq is a no-op,
@@ -2074,8 +2081,7 @@ comint mode, which see."
   (gud-mode)
   (make-local-variable 'gud-marker-filter)
   (setq gud-marker-filter marker-filter)
-  (make-local-variable 'gud-find-file)
-  (setq gud-find-file find-file)
+  (if find-file (set (make-local-variable 'gud-find-file) find-file))
 
   (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
   (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel)