/[emacs]/emacs/lisp/gud.el
ViewVC logotype

Diff of /emacs/lisp/gud.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.154 by eliz, Tue Feb 5 18:04:49 2002 UTC revision 1.155 by eliz, Wed Mar 27 14:58:43 2002 UTC
# Line 4  Line 4 
4  ;; Maintainer: FSF  ;; Maintainer: FSF
5  ;; Keywords: unix, tools  ;; Keywords: unix, tools
6    
7  ;; Copyright (C) 1992, 93, 94, 95, 96, 1998, 2000 Free Software Foundation, Inc.  ;; Copyright (C) 1992,93,94,95,96,1998,2000,2002 Free Software Foundation, Inc.
8    
9  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
10    
# Line 1485  and source-file directory for your debug Line 1485  and source-file directory for your debug
1485  ;; You must not put whitespace between "-classpath" and the path to  ;; You must not put whitespace between "-classpath" and the path to
1486  ;; search for java classes even though it is required when invoking jdb  ;; search for java classes even though it is required when invoking jdb
1487  ;; from the command line.  See gud-jdb-massage-args for details.  ;; from the command line.  See gud-jdb-massage-args for details.
1488    ;; The same applies for "-sourcepath".
1489  ;;  ;;
1490  ;; Note: The following applies only if `gud-jdb-use-classpath' is nil;  ;; Note: The following applies only if `gud-jdb-use-classpath' is nil;
1491  ;; refer to the documentation of `gud-jdb-use-classpath' and  ;; refer to the documentation of `gud-jdb-use-classpath' and
1492  ;; `gud-jdb-classpath' variables for information on using the classpath  ;; `gud-jdb-classpath',`gud-jdb-sourcepath' variables for information
1493  ;; for locating java source files.  ;; on using the classpath for locating java source files.
1494  ;;  ;;
1495  ;; If any of the source files in the directories listed in  ;; If any of the source files in the directories listed in
1496  ;; gud-jdb-directories won't parse you'll have problems.  Make sure  ;; gud-jdb-directories won't parse you'll have problems.  Make sure
# Line 1551  steps): Line 1552  steps):
1552  Note that method 3 cannot be used with oldjdb (or Java 1 jdb) since  Note that method 3 cannot be used with oldjdb (or Java 1 jdb) since
1553  those debuggers do not support the classpath command. Use 1) or 2).")  those debuggers do not support the classpath command. Use 1) or 2).")
1554    
1555    (defvar gud-jdb-sourcepath nil
1556      "Directory list provided by an (optional) \"-sourcepath\" option to jdb.
1557    This list is prepended to `gud-jdb-classpath' to form the complete
1558    list of directories searched for source files.")
1559    
1560  (defvar gud-marker-acc-max-length 4000  (defvar gud-marker-acc-max-length 4000
1561    "Maximum number of debugger output characters to keep.    "Maximum number of debugger output characters to keep.
1562  This variable limits the size of `gud-marker-acc' which holds  This variable limits the size of `gud-marker-acc' which holds
# Line 1589  the source code display in sync with the Line 1595  the source code display in sync with the
1595  "Holds temporary classpath values.")  "Holds temporary classpath values.")
1596    
1597  (defun gud-jdb-build-source-files-list (path extn)  (defun gud-jdb-build-source-files-list (path extn)
1598  "Return a list of java source files.  "Return a list of java source files (absolute paths).
1599  PATH gives the directories in which to search for files with  PATH gives the directories in which to search for files with
1600  extension EXTN.  Normally EXTN is given as the regular expression  extension EXTN.  Normally EXTN is given as the regular expression
1601   \"\\.java$\" ."   \"\\.java$\" ."
# Line 1821  extension EXTN.  Normally EXTN is given Line 1827  extension EXTN.  Normally EXTN is given
1827    (if args    (if args
1828        (let (massaged-args user-error)        (let (massaged-args user-error)
1829    
1830          (while          (while (and args (not user-error))
1831              (and args            (cond
1832                   (not (string-match "-classpath\\(.+\\)" (car args)))             ((setq user-error (string-match "-classpath$" (car args))))
1833                   (not (setq user-error             ((setq user-error (string-match "-sourcepath$" (car args))))
1834                              (string-match "-classpath$" (car args)))))             ((string-match "-classpath\\(.+\\)" (car args))
1835            (setq massaged-args (append massaged-args (list (car args))))              (setq massaged-args
1836                      (append massaged-args
1837                              (list "-classpath")
1838                              (list
1839                               (setq gud-jdb-classpath-string
1840                                     (substring
1841                                      (car args)
1842                                      (match-beginning 1) (match-end 1)))))))
1843               ((string-match "-sourcepath\\(.+\\)" (car args))
1844                (setq massaged-args
1845                      (append massaged-args
1846                              (list "-sourcepath")
1847                              (list
1848                               (setq gud-jdb-sourcepath
1849                                     (substring
1850                                      (car args)
1851                                      (match-beginning 1) (match-end 1)))))))
1852               (t (setq massaged-args (append massaged-args (list (car args))))))
1853            (setq args (cdr args)))            (setq args (cdr args)))
1854    
1855          ;; By this point the current directory is all screwed up.  Maybe we          ;; By this point the current directory is all screwed up.  Maybe we
# Line 1835  extension EXTN.  Normally EXTN is given Line 1858  extension EXTN.  Normally EXTN is given
1858          (if user-error          (if user-error
1859              (progn              (progn
1860                (kill-buffer (current-buffer))                (kill-buffer (current-buffer))
1861                (error "Error: Omit whitespace between '-classpath' and its value")))                (error "Error: Omit whitespace between '-classpath or -sourcepath' and its value")))
1862            massaged-args)))
         (if args  
             (setq massaged-args  
                   (append  
                    massaged-args  
                    (list "-classpath")  
                    (list  
                     (setq gud-jdb-classpath-string  
                           (substring  
                            (car args)  
                            (match-beginning 1) (match-end 1))))  
                    (cdr args)))  
           massaged-args))))  
1863    
1864  ;; Search for an association with P, a fully qualified class name, in  ;; Search for an association with P, a fully qualified class name, in
1865  ;; gud-jdb-class-source-alist.  The asssociation gives the fully  ;; gud-jdb-class-source-alist.  The asssociation gives the fully
# Line 1879  relative to a classpath directory." Line 1890  relative to a classpath directory."
1890                        p)                        p)
1891                       "\\.") "/")                       "\\.") "/")
1892           ".java"))           ".java"))
1893         (cplist gud-jdb-classpath)         (cplist (append gud-jdb-sourcepath gud-jdb-classpath))
1894         found-file)         found-file)
1895      (while (and cplist      (while (and cplist
1896                  (not (setq found-file                  (not (setq found-file
# Line 1897  nil) Line 1908  nil)
1908    
1909  (defun gud-jdb-parse-classpath-string (string)  (defun gud-jdb-parse-classpath-string (string)
1910  "Parse the classpath list and convert each item to an absolute pathname."  "Parse the classpath list and convert each item to an absolute pathname."
1911    (mapcar 'file-truename (split-string string    (mapcar (lambda (s) (if (string-match "[/\\]$" s)
1912          (concat "[ \t\n\r,\"" path-separator "]+"))))                            (replace-match "" nil nil s) s))
1913              (mapcar 'file-truename
1914                      (split-string
1915                       string
1916                       (concat "[ \t\n\r,\"" path-separator "]+")))))
1917    
1918  ;; See comentary for other debugger's marker filters - there you will find  ;; See comentary for other debugger's marker filters - there you will find
1919  ;; important notes about STRING.  ;; important notes about STRING.
# Line 1911  nil) Line 1926  nil)
1926            string))            string))
1927    
1928    ;; Look for classpath information until gud-jdb-classpath-string is found    ;; Look for classpath information until gud-jdb-classpath-string is found
1929      ;; (interactive, multiple settings of classpath from jdb
1930      ;;  not supported/followed)
1931    (if (and gud-jdb-use-classpath    (if (and gud-jdb-use-classpath
1932             (not gud-jdb-classpath-string)             (not gud-jdb-classpath-string)
1933             (or (string-match "classpath:[ \t[]+\\([^]]+\\)" gud-marker-acc)             (or (string-match "classpath:[ \t[]+\\([^]]+\\)" gud-marker-acc)
# Line 2022  For general information about commands a Line 2039  For general information about commands a
2039  gud, see `gud-mode'."  gud, see `gud-mode'."
2040    (interactive    (interactive
2041     (list (gud-query-cmdline 'jdb)))     (list (gud-query-cmdline 'jdb)))
2042      (setq gud-jdb-classpath nil)
2043      (setq gud-jdb-sourcepath nil)
2044    
2045    ;; Set gud-jdb-classpath from the CLASSPATH environment variable,    ;; Set gud-jdb-classpath from the CLASSPATH environment variable,
2046    ;; if CLASSPATH is set.    ;; if CLASSPATH is set.
# Line 2040  gud, see `gud-mode'." Line 2059  gud, see `gud-mode'."
2059        (setq gud-jdb-classpath        (setq gud-jdb-classpath
2060              (gud-jdb-parse-classpath-string gud-jdb-classpath-string)))              (gud-jdb-parse-classpath-string gud-jdb-classpath-string)))
2061    (setq gud-jdb-classpath-string nil)   ; prepare for next    (setq gud-jdb-classpath-string nil)   ; prepare for next
2062      ;; If a -sourcepath option was provided, parse it
2063      (if gud-jdb-sourcepath
2064          (setq gud-jdb-sourcepath
2065                (gud-jdb-parse-classpath-string gud-jdb-sourcepath)))
2066    
2067    (gud-def gud-break  "stop at %c:%l" "\C-b" "Set breakpoint at current line.")    (gud-def gud-break  "stop at %c:%l" "\C-b" "Set breakpoint at current line.")
2068    (gud-def gud-remove "clear %c:%l"   "\C-d" "Remove breakpoint at current line")    (gud-def gud-remove "clear %c:%l"   "\C-d" "Remove breakpoint at current line")
# Line 2058  gud, see `gud-mode'." Line 2081  gud, see `gud-mode'."
2081    (run-hooks 'jdb-mode-hook)    (run-hooks 'jdb-mode-hook)
2082    
2083    (if gud-jdb-use-classpath    (if gud-jdb-use-classpath
2084        ;; Get the classpath information from the debugger (this is much        ;; Get the classpath information from the debugger
       ;; faster) and does not need the constant updating of  
       ;; gud-jdb-directories  
2085        (progn        (progn
2086          (if (string-match "-attach" command-line)          (if (string-match "-attach" command-line)
2087              (gud-call "classpath"))              (gud-call "classpath"))
# Line 2662  Link exprs of the form: Line 2683  Link exprs of the form:
2683    
2684  (defun gud-find-class (f)  (defun gud-find-class (f)
2685    "Find fully qualified class corresponding to file F.    "Find fully qualified class corresponding to file F.
2686  This function uses the `gud-jdb-classpath' list to derive a file  This function uses the `gud-jdb-classpath' (and optional
2687    `gud-jdb-sourcepath') list(s) to derive a file
2688  pathname relative to its classpath directory. The values in  pathname relative to its classpath directory. The values in
2689  `gud-jdb-classpath' are assumed to have been converted to absolute  `gud-jdb-classpath' are assumed to have been converted to absolute
2690  pathname standards using file-truename."  pathname standards using file-truename."
2691    ;; Convert f to a standard representation and remove suffix    ;; Convert f to a standard representation and remove suffix
2692    (setq f (file-name-sans-extension (file-truename f)))    (if (and gud-jdb-use-classpath (or gud-jdb-classpath gud-jdb-sourcepath))
   (if gud-jdb-classpath  
2693        (save-match-data        (save-match-data
2694          (let ((cplist gud-jdb-classpath)          (let ((cplist (append gud-jdb-sourcepath gud-jdb-classpath))
2695                class-found)                class-found)
2696              (setq f (file-name-sans-extension (file-truename f)))
2697            ;; Search through classpath list for an entry that is            ;; Search through classpath list for an entry that is
2698            ;; contained in f            ;; contained in f
2699            (while (and cplist (not class-found))            (while (and cplist (not class-found))
# Line 2685  pathname standards using file-truename." Line 2707  pathname standards using file-truename."
2707            (if (not class-found)            (if (not class-found)
2708               (message "gud-find-class: class for file %s not found!" f))               (message "gud-find-class: class for file %s not found!" f))
2709            class-found))            class-found))
2710      (message "gud-find-class: classpath information not available!")))      ;; Not using classpath - try class/source association list
2711        (let ((class-found (rassoc f gud-jdb-class-source-alist)))
2712          (if class-found
2713              (car class-found)
2714            (message "gud-find-class: class for file %s not found in gud-jdb-class-source-alist!" f)
2715            nil))))
2716    
2717  (provide 'gud)  (provide 'gud)
2718    

Legend:
Removed from v.1.154  
changed lines
  Added in v.1.155

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26