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