diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/gud.el | 334 |
1 files changed, 268 insertions, 66 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 98e918f098f..28f8233322f 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -104,12 +104,12 @@ If SOFT is non-nil, returns nil if the symbol doesn't already exist." | |||
| 104 | :enable (memq gud-minor-mode '(gdb sdb xdb))) | 104 | :enable (memq gud-minor-mode '(gdb sdb xdb))) |
| 105 | ([break] "Set Breakpoint" . gud-break) | 105 | ([break] "Set Breakpoint" . gud-break) |
| 106 | ([up] menu-item "Up Stack" gud-up | 106 | ([up] menu-item "Up Stack" gud-up |
| 107 | :enable (memq gud-minor-mode '(gdb dbx xdb))) | 107 | :enable (memq gud-minor-mode '(gdb dbx xdb jdb))) |
| 108 | ([down] menu-item "Down Stack" gud-down | 108 | ([down] menu-item "Down Stack" gud-down |
| 109 | :enable (memq gud-minor-mode '(gdb dbx xdb))) | 109 | :enable (memq gud-minor-mode '(gdb dbx xdb jdb))) |
| 110 | ([print] "Print Expression" . gud-print) | 110 | ([print] "Print Expression" . gud-print) |
| 111 | ([finish] menu-item "Finish Function" gud-finish | 111 | ([finish] menu-item "Finish Function" gud-finish |
| 112 | :enable (memq gud-minor-mode '(gdb xdb))) | 112 | :enable (memq gud-minor-mode '(gdb xdb jdb))) |
| 113 | ([stepi] "Step Instruction" . gud-stepi) | 113 | ([stepi] "Step Instruction" . gud-stepi) |
| 114 | ([step] "Step Line" . gud-step) | 114 | ([step] "Step Line" . gud-step) |
| 115 | ([next] "Next Line" . gud-next) | 115 | ([next] "Next Line" . gud-next) |
| @@ -1427,8 +1427,10 @@ and source-file directory for your debugger." | |||
| 1427 | ;; JDB support. | 1427 | ;; JDB support. |
| 1428 | ;; | 1428 | ;; |
| 1429 | ;; AUTHOR: Derek Davies <ddavies@world.std.com> | 1429 | ;; AUTHOR: Derek Davies <ddavies@world.std.com> |
| 1430 | ;; Zoltan Kemenczy <zoltan@ieee.org;zkemenczy@rim.net> | ||
| 1430 | ;; | 1431 | ;; |
| 1431 | ;; CREATED: Sun Feb 22 10:46:38 1998 Derek Davies. | 1432 | ;; CREATED: Sun Feb 22 10:46:38 1998 Derek Davies. |
| 1433 | ;; UPDATED: Nov 11, 2001 Zoltan Kemenczy | ||
| 1432 | ;; | 1434 | ;; |
| 1433 | ;; INVOCATION NOTES: | 1435 | ;; INVOCATION NOTES: |
| 1434 | ;; | 1436 | ;; |
| @@ -1484,6 +1486,11 @@ and source-file directory for your debugger." | |||
| 1484 | ;; 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 |
| 1485 | ;; from the command line. See gud-jdb-massage-args for details. | 1487 | ;; from the command line. See gud-jdb-massage-args for details. |
| 1486 | ;; | 1488 | ;; |
| 1489 | ;; Note: The following applies only if `gud-jdb-use-classpath' is nil; | ||
| 1490 | ;; refer to the documentation of `gud-jdb-use-classpath' and | ||
| 1491 | ;; `gud-jdb-classpath' variables for information on using the classpath | ||
| 1492 | ;; for locating java source files. | ||
| 1493 | ;; | ||
| 1487 | ;; If any of the source files in the directories listed in | 1494 | ;; If any of the source files in the directories listed in |
| 1488 | ;; gud-jdb-directories won't parse you'll have problems. Make sure | 1495 | ;; gud-jdb-directories won't parse you'll have problems. Make sure |
| 1489 | ;; every file ending in ".java" in these directories parses without error. | 1496 | ;; every file ending in ".java" in these directories parses without error. |
| @@ -1503,8 +1510,56 @@ and source-file directory for your debugger." | |||
| 1503 | ;; ====================================================================== | 1510 | ;; ====================================================================== |
| 1504 | ;; gud jdb variables and functions | 1511 | ;; gud jdb variables and functions |
| 1505 | 1512 | ||
| 1506 | ;; History of argument lists passed to jdb. | 1513 | (defcustom gud-jdb-command-name "jdb" |
| 1507 | (defvar gud-jdb-history nil) | 1514 | "Command that executes the Java debugger." |
| 1515 | :type 'string | ||
| 1516 | :group 'gud) | ||
| 1517 | |||
| 1518 | (defcustom gud-jdb-use-classpath t | ||
| 1519 | "If non-nil, search for Java source files in classpath directories. | ||
| 1520 | The list of directories to search is the value of `gud-jdb-classpath'. | ||
| 1521 | The file pathname is obtained by converting the fully qualified | ||
| 1522 | class information output by jdb to a relative pathname and appending | ||
| 1523 | it to `gud-jdb-classpath' element by element until a match is found. | ||
| 1524 | |||
| 1525 | This method has a significant jdb startup time reduction advantage | ||
| 1526 | since it does not require the scanning of all `gud-jdb-directories' | ||
| 1527 | and parsing all Java files for class information. | ||
| 1528 | |||
| 1529 | Set to nil to use `gud-jdb-directories' to scan java sources for | ||
| 1530 | class information on jdb startup (original method)." | ||
| 1531 | :type 'boolean | ||
| 1532 | :group 'gud) | ||
| 1533 | |||
| 1534 | (defvar gud-jdb-classpath nil | ||
| 1535 | "Java/jdb classpath directories list. | ||
| 1536 | If `gud-jdb-use-classpath' is non-nil, gud-jdb derives the `gud-jdb-classpath' | ||
| 1537 | list automatically using the following methods in sequence | ||
| 1538 | (with subsequent successful steps overriding the results of previous | ||
| 1539 | steps): | ||
| 1540 | |||
| 1541 | 1) Read the CLASSPATH environment variable, | ||
| 1542 | 2) Read any \"-classpath\" argument used to run jdb, | ||
| 1543 | or detected in jdb output (e.g. if jdb is run by a script | ||
| 1544 | that echoes the actual jdb command before starting jdb) | ||
| 1545 | 3) Send a \"classpath\" command to jdb and scan jdb output for | ||
| 1546 | classpath information if jdb is invoked with an \"-attach\" (to | ||
| 1547 | an already running VM) argument (This case typically does not | ||
| 1548 | have a \"-classpath\" command line argument - that is provided | ||
| 1549 | to the VM when it is started). | ||
| 1550 | |||
| 1551 | 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 | |||
| 1554 | (defvar gud-marker-acc-max-length 4000 | ||
| 1555 | "Maximum number of debugger output characters to keep. | ||
| 1556 | This variable limits the size of `gud-marker-acc' which holds | ||
| 1557 | the most recent debugger output history while searching for | ||
| 1558 | source file information.") | ||
| 1559 | |||
| 1560 | (defvar gud-jdb-history nil | ||
| 1561 | "History of argument lists passed to jdb.") | ||
| 1562 | |||
| 1508 | 1563 | ||
| 1509 | ;; List of Java source file directories. | 1564 | ;; List of Java source file directories. |
| 1510 | (defvar gud-jdb-directories (list ".") | 1565 | (defvar gud-jdb-directories (list ".") |
| @@ -1519,20 +1574,25 @@ package-qualified class names output by the jdb debugger to the source | |||
| 1519 | file from which the class originated. This allows gud mode to keep | 1574 | file from which the class originated. This allows gud mode to keep |
| 1520 | the source code display in sync with the debugging session.") | 1575 | the source code display in sync with the debugging session.") |
| 1521 | 1576 | ||
| 1522 | ;; List of the java source files for this debugging session. | 1577 | (defvar gud-jdb-source-files nil |
| 1523 | (defvar gud-jdb-source-files nil) | 1578 | "List of the java source files for this debugging session.") |
| 1524 | 1579 | ||
| 1525 | ;; Association list of fully qualified class names (package + class name) and | 1580 | ;; Association list of fully qualified class names (package + class name) |
| 1526 | ;; their source files. | 1581 | ;; and their source files. |
| 1527 | (defvar gud-jdb-class-source-alist nil) | 1582 | (defvar gud-jdb-class-source-alist nil |
| 1583 | "Association list of fully qualified class names and source files.") | ||
| 1528 | 1584 | ||
| 1529 | ;; This is used to hold a source file during analysis. | 1585 | ;; This is used to hold a source file during analysis. |
| 1530 | (defvar gud-jdb-analysis-buffer nil) | 1586 | (defvar gud-jdb-analysis-buffer nil) |
| 1531 | 1587 | ||
| 1532 | ;; Return a list of java source files. PATH gives the directories in | 1588 | (defvar gud-jdb-classpath-string nil |
| 1533 | ;; which to search for files with extension EXTN. Normally EXTN is | 1589 | "Holds temporary classpath values.") |
| 1534 | ;; given as the regular expression "\\.java$" . | 1590 | |
| 1535 | (defun gud-jdb-build-source-files-list (path extn) | 1591 | (defun gud-jdb-build-source-files-list (path extn) |
| 1592 | "Return a list of java source files. | ||
| 1593 | PATH gives the directories in which to search for files with | ||
| 1594 | extension EXTN. Normally EXTN is given as the regular expression | ||
| 1595 | \"\\.java$\" ." | ||
| 1536 | (apply 'nconc (mapcar (lambda (d) | 1596 | (apply 'nconc (mapcar (lambda (d) |
| 1537 | (when (file-directory-p d) | 1597 | (when (file-directory-p d) |
| 1538 | (directory-files d t extn nil))) | 1598 | (directory-files d t extn nil))) |
| @@ -1783,9 +1843,10 @@ the source code display in sync with the debugging session.") | |||
| 1783 | massaged-args | 1843 | massaged-args |
| 1784 | (list "-classpath") | 1844 | (list "-classpath") |
| 1785 | (list | 1845 | (list |
| 1786 | (substring | 1846 | (setq gud-jdb-classpath-string |
| 1787 | (car args) | 1847 | (substring |
| 1788 | (match-beginning 1) (match-end 1))) | 1848 | (car args) |
| 1849 | (match-beginning 1) (match-end 1)))) | ||
| 1789 | (cdr args))) | 1850 | (cdr args))) |
| 1790 | massaged-args)))) | 1851 | massaged-args)))) |
| 1791 | 1852 | ||
| @@ -1795,6 +1856,50 @@ the source code display in sync with the debugging session.") | |||
| 1795 | (defun gud-jdb-find-source-file (p) | 1856 | (defun gud-jdb-find-source-file (p) |
| 1796 | (cdr (assoc p gud-jdb-class-source-alist))) | 1857 | (cdr (assoc p gud-jdb-class-source-alist))) |
| 1797 | 1858 | ||
| 1859 | ;; Note: Reset to this value every time a prompt is seen | ||
| 1860 | (defvar gud-jdb-lowest-stack-level 999) | ||
| 1861 | |||
| 1862 | (defun gud-jdb-find-source-using-classpath (p) | ||
| 1863 | "Find source file corresponding to fully qualified class p. | ||
| 1864 | Convert p from jdb's output, converted to a pathname | ||
| 1865 | relative to a classpath directory." | ||
| 1866 | (save-match-data | ||
| 1867 | (let | ||
| 1868 | (;; Replace dots with slashes and append ".java" to generate file | ||
| 1869 | ;; name relative to classpath | ||
| 1870 | (filename | ||
| 1871 | (concat | ||
| 1872 | (mapconcat (lambda (x) x) | ||
| 1873 | (split-string | ||
| 1874 | ;; Eliminate any subclass references in the class | ||
| 1875 | ;; name string. These start with a "$" | ||
| 1876 | ((lambda (x) | ||
| 1877 | (if (string-match "$.*" x) | ||
| 1878 | (replace-match "" t t x) p)) | ||
| 1879 | p) | ||
| 1880 | "\\.") "/") | ||
| 1881 | ".java")) | ||
| 1882 | (cplist gud-jdb-classpath) | ||
| 1883 | found-file) | ||
| 1884 | (while (and cplist | ||
| 1885 | (not (setq found-file | ||
| 1886 | (file-readable-p | ||
| 1887 | (concat (car cplist) "/" filename))))) | ||
| 1888 | (setq cplist (cdr cplist))) | ||
| 1889 | (if found-file (concat (car cplist) "/" filename))))) | ||
| 1890 | |||
| 1891 | (defun gud-jdb-find-source (string) | ||
| 1892 | "Alias for function used to locate source files. | ||
| 1893 | Set to `gud-jdb-find-source-using-classpath' or `gud-jdb-find-source-file' | ||
| 1894 | during jdb initialization depending on the value of | ||
| 1895 | `gud-jdb-use-classpath'." | ||
| 1896 | nil) | ||
| 1897 | |||
| 1898 | (defun gud-jdb-parse-classpath-string (string) | ||
| 1899 | "Parse the classpath list and convert each item to an absolute pathname." | ||
| 1900 | (mapcar 'file-truename (split-string string | ||
| 1901 | (concat "[ \t\n\r,\"" path-separator "]+")))) | ||
| 1902 | |||
| 1798 | ;; See comentary for other debugger's marker filters - there you will find | 1903 | ;; See comentary for other debugger's marker filters - there you will find |
| 1799 | ;; important notes about STRING. | 1904 | ;; important notes about STRING. |
| 1800 | (defun gud-jdb-marker-filter (string) | 1905 | (defun gud-jdb-marker-filter (string) |
| @@ -1805,14 +1910,22 @@ the source code display in sync with the debugging session.") | |||
| 1805 | (concat gud-marker-acc string) | 1910 | (concat gud-marker-acc string) |
| 1806 | string)) | 1911 | string)) |
| 1807 | 1912 | ||
| 1808 | ;; We process STRING from left to right. Each time through the following | 1913 | ;; Look for classpath information until gud-jdb-classpath-string is found |
| 1809 | ;; loop we process at most one marker. The start variable keeps track of | 1914 | (if (and gud-jdb-use-classpath |
| 1810 | ;; where we are in the input string through the iterations of this loop. | 1915 | (not gud-jdb-classpath-string) |
| 1811 | (let (start file-found) | 1916 | (or (string-match "classpath:[ \t[]+\\([^]]+\\)" gud-marker-acc) |
| 1812 | 1917 | (string-match "-classpath[ \t\"]+\\([^ \"]+\\)" gud-marker-acc))) | |
| 1813 | ;; Process each complete marker in the input. There may be an incomplete | 1918 | (setq gud-jdb-classpath |
| 1814 | ;; marker at the end of the input string. Incomplete markers are left | 1919 | (gud-jdb-parse-classpath-string |
| 1815 | ;; in the accumulator for processing the next time the function is called. | 1920 | (setq gud-jdb-classpath-string |
| 1921 | (substring gud-marker-acc | ||
| 1922 | (match-beginning 1) (match-end 1)))))) | ||
| 1923 | |||
| 1924 | ;; We process STRING from left to right. Each time through the | ||
| 1925 | ;; following loop we process at most one marker. After we've found a | ||
| 1926 | ;; marker, delete gud-marker-acc up to and including the match | ||
| 1927 | (let (file-found) | ||
| 1928 | ;; Process each complete marker in the input. | ||
| 1816 | (while | 1929 | (while |
| 1817 | 1930 | ||
| 1818 | ;; Do we see a marker? | 1931 | ;; Do we see a marker? |
| @@ -1838,31 +1951,53 @@ the source code display in sync with the debugging session.") | |||
| 1838 | ;; | 1951 | ;; |
| 1839 | ;; FIXME: Java ID's are UNICODE strings, this matches ASCII | 1952 | ;; FIXME: Java ID's are UNICODE strings, this matches ASCII |
| 1840 | ;; ID's only. | 1953 | ;; ID's only. |
| 1841 | "\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>]+ (\\([a-zA-Z0-9$_]+\\):\\([0-9]+\\))" | 1954 | "\\(\[[0-9]+\] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \ |
| 1842 | gud-marker-acc start) | 1955 | \\(([a-zA-Z0-9.$_]+:\\|line=\\)\\([0-9]+\\)" |
| 1843 | 1956 | gud-marker-acc) | |
| 1957 | |||
| 1958 | ;; A good marker is one that: | ||
| 1959 | ;; 1) does not have a "[n] " prefix (not part of a stack backtrace) | ||
| 1960 | ;; 2) does have an "[n] " prefix and n is the lowest prefix seen | ||
| 1961 | ;; since the last prompt | ||
| 1844 | ;; Figure out the line on which to position the debugging arrow. | 1962 | ;; Figure out the line on which to position the debugging arrow. |
| 1845 | ;; Return the info as a cons of the form: | 1963 | ;; Return the info as a cons of the form: |
| 1846 | ;; | 1964 | ;; |
| 1847 | ;; (<file-name> . <line-number>) . | 1965 | ;; (<file-name> . <line-number>) . |
| 1848 | (if (setq | 1966 | (if (if (match-beginning 1) |
| 1849 | file-found | 1967 | (let (n) |
| 1850 | (gud-jdb-find-source-file | 1968 | (setq n (string-to-int (substring |
| 1851 | (substring gud-marker-acc | 1969 | gud-marker-acc |
| 1852 | (match-beginning 1) | 1970 | (1+ (match-beginning 1)) |
| 1853 | (match-end 1)))) | 1971 | (- (match-end 1) 2)))) |
| 1854 | (setq gud-last-frame | 1972 | (if (< n gud-jdb-lowest-stack-level) |
| 1855 | (cons | 1973 | (progn (setq gud-jdb-lowest-stack-level n) t))) |
| 1856 | file-found | 1974 | t) |
| 1857 | (string-to-int | 1975 | (if (setq file-found |
| 1858 | (substring gud-marker-acc | 1976 | (gud-jdb-find-source |
| 1859 | (match-beginning 3) | 1977 | (substring gud-marker-acc |
| 1860 | (match-end 3))))) | 1978 | (match-beginning 2) |
| 1861 | (message "Could not find source file.")) | 1979 | (match-end 2)))) |
| 1862 | 1980 | (setq gud-last-frame | |
| 1863 | ;; Set start after the last character of STRING that we've looked at | 1981 | (cons file-found |
| 1864 | ;; and loop to look for another marker. | 1982 | (string-to-int |
| 1865 | (setq start (match-end 0)))) | 1983 | (substring gud-marker-acc |
| 1984 | (match-beginning 4) | ||
| 1985 | (match-end 4))))) | ||
| 1986 | (message "Could not find source file."))) | ||
| 1987 | |||
| 1988 | ;; Set the accumulator to the remaining text. | ||
| 1989 | (setq gud-marker-acc (substring gud-marker-acc (match-end 0)))) | ||
| 1990 | |||
| 1991 | (if (string-match comint-prompt-regexp gud-marker-acc) | ||
| 1992 | (setq gud-jdb-lowest-stack-level 999))) | ||
| 1993 | |||
| 1994 | ;; Do not allow gud-marker-acc to grow without bound. If the source | ||
| 1995 | ;; file information is not within the last 3/4 | ||
| 1996 | ;; gud-marker-acc-max-length characters, well,... | ||
| 1997 | (if (> (length gud-marker-acc) gud-marker-acc-max-length) | ||
| 1998 | (setq gud-marker-acc | ||
| 1999 | (substring gud-marker-acc | ||
| 2000 | (- (/ (* gud-marker-acc-max-length 3) 4))))) | ||
| 1866 | 2001 | ||
| 1867 | ;; We don't filter any debugger output so just return what we were given. | 2002 | ;; We don't filter any debugger output so just return what we were given. |
| 1868 | string) | 2003 | string) |
| @@ -1871,39 +2006,75 @@ the source code display in sync with the debugging session.") | |||
| 1871 | (and (file-readable-p f) | 2006 | (and (file-readable-p f) |
| 1872 | (find-file-noselect f))) | 2007 | (find-file-noselect f))) |
| 1873 | 2008 | ||
| 1874 | (defvar gud-jdb-command-name "jdb" "Command that executes the Java debugger.") | ||
| 1875 | |||
| 1876 | ;;;###autoload | 2009 | ;;;###autoload |
| 1877 | (defun jdb (command-line) | 2010 | (defun jdb (command-line) |
| 1878 | "Run jdb with command line COMMAND-LINE in a buffer. | 2011 | "Run jdb with command line COMMAND-LINE in a buffer. |
| 1879 | The buffer is named \"*gud*\" if no initial class is given or | 2012 | The buffer is named \"*gud*\" if no initial class is given or |
| 1880 | \"*gud-<initial-class-basename>*\" if there is. If the \"-classpath\" | 2013 | \"*gud-<initial-class-basename>*\" if there is. If the \"-classpath\" |
| 1881 | switch is given, omit all whitespace between it and it's value." | 2014 | switch is given, omit all whitespace between it and its value. |
| 2015 | |||
| 2016 | See `gud-jdb-use-classpath' and `gud-jdb-classpath' documentation for | ||
| 2017 | information on how jdb accesses source files. Alternatively (if | ||
| 2018 | `gud-jdb-use-classpath' is nil), see `gud-jdb-directories' for the | ||
| 2019 | original source file access method. | ||
| 2020 | |||
| 2021 | For general information about commands available to control jdb from | ||
| 2022 | gud, see `gud-mode'." | ||
| 1882 | (interactive | 2023 | (interactive |
| 1883 | (list (gud-query-cmdline 'jdb))) | 2024 | (list (gud-query-cmdline 'jdb))) |
| 1884 | 2025 | ||
| 2026 | ;; Set gud-jdb-classpath from the CLASSPATH environment variable, | ||
| 2027 | ;; if CLASSPATH is set. | ||
| 2028 | (setq gud-jdb-classpath-string (getenv "CLASSPATH")) | ||
| 2029 | (if gud-jdb-classpath-string | ||
| 2030 | (setq gud-jdb-classpath | ||
| 2031 | (gud-jdb-parse-classpath-string gud-jdb-classpath-string))) | ||
| 2032 | (setq gud-jdb-classpath-string nil) ; prepare for next | ||
| 2033 | |||
| 1885 | (gud-common-init command-line 'gud-jdb-massage-args | 2034 | (gud-common-init command-line 'gud-jdb-massage-args |
| 1886 | 'gud-jdb-marker-filter 'gud-jdb-find-file) | 2035 | 'gud-jdb-marker-filter 'gud-jdb-find-file) |
| 1887 | (set (make-local-variable 'gud-minor-mode) 'jdb) | 2036 | (set (make-local-variable 'gud-minor-mode) 'jdb) |
| 1888 | 2037 | ||
| 1889 | (gud-def gud-break "stop at %F:%l" "\C-b" "Set breakpoint at current line.") | 2038 | ;; If a -classpath option was provided, set gud-jdb-classpath |
| 1890 | (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line") | 2039 | (if gud-jdb-classpath-string |
| 1891 | (gud-def gud-step "step" "\C-s" "Step one source line with display.") | 2040 | (setq gud-jdb-classpath |
| 1892 | (gud-def gud-next "next" "\C-n" "Step one line (skip functions).") | 2041 | (gud-jdb-parse-classpath-string gud-jdb-classpath-string))) |
| 1893 | (gud-def gud-cont "cont" "\C-r" "Continue with display.") | 2042 | (setq gud-jdb-classpath-string nil) ; prepare for next |
| 2043 | |||
| 2044 | (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") | ||
| 2046 | (gud-def gud-step "step" "\C-s" "Step one source line with display.") | ||
| 2047 | (gud-def gud-next "next" "\C-n" "Step one line (skip functions).") | ||
| 2048 | (gud-def gud-cont "cont" "\C-r" "Continue with display.") | ||
| 2049 | (gud-def gud-finish "step up" "\C-f" "Continue until current method returns.") | ||
| 2050 | (gud-def gud-up "up\C-Mwhere" "<" "Up one stack frame.") | ||
| 2051 | (gud-def gud-down "down\C-Mwhere" ">" "Up one stack frame.") | ||
| 2052 | (local-set-key [menu-bar debug finish] '("Finish Function" . gud-finish)) | ||
| 2053 | (local-set-key [menu-bar debug up] '("Up Stack" . gud-up)) | ||
| 2054 | (local-set-key [menu-bar debug down] '("Down Stack" . gud-down)) | ||
| 1894 | 2055 | ||
| 1895 | (setq comint-prompt-regexp "^> \\|^.+\\[[0-9]+\\] ") | 2056 | (setq comint-prompt-regexp "^> \\|^[^ ]+\\[[0-9]+\\] ") |
| 1896 | (setq paragraph-start comint-prompt-regexp) | 2057 | (setq paragraph-start comint-prompt-regexp) |
| 1897 | (run-hooks 'jdb-mode-hook) | 2058 | (run-hooks 'jdb-mode-hook) |
| 1898 | 2059 | ||
| 1899 | ;; Create and bind the class/source association list as well as the source | 2060 | (if gud-jdb-use-classpath |
| 1900 | ;; file list. | 2061 | ;; Get the classpath information from the debugger (this is much |
| 1901 | (setq | 2062 | ;; faster) and does not need the constant updating of |
| 1902 | gud-jdb-class-source-alist | 2063 | ;; gud-jdb-directories |
| 1903 | (gud-jdb-build-class-source-alist | 2064 | (progn |
| 1904 | (setq | 2065 | (if (string-match "-attach" command-line) |
| 1905 | gud-jdb-source-files | 2066 | (gud-call "classpath")) |
| 1906 | (gud-jdb-build-source-files-list gud-jdb-directories "\\.java$"))))) | 2067 | (fset 'gud-jdb-find-source |
| 2068 | 'gud-jdb-find-source-using-classpath)) | ||
| 2069 | |||
| 2070 | ;; Else create and bind the class/source association list as well | ||
| 2071 | ;; as the source file list. | ||
| 2072 | (setq gud-jdb-class-source-alist | ||
| 2073 | (gud-jdb-build-class-source-alist | ||
| 2074 | (setq gud-jdb-source-files | ||
| 2075 | (gud-jdb-build-source-files-list gud-jdb-directories | ||
| 2076 | "\\.java$")))) | ||
| 2077 | (fset 'gud-jdb-find-source 'gud-jdb-find-source-file))) | ||
| 1907 | 2078 | ||
| 1908 | 2079 | ||
| 1909 | ;; | 2080 | ;; |
| @@ -1960,9 +2131,9 @@ switch is given, omit all whitespace between it and it's value." | |||
| 1960 | "Major mode for interacting with an inferior debugger process. | 2131 | "Major mode for interacting with an inferior debugger process. |
| 1961 | 2132 | ||
| 1962 | You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx, | 2133 | You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx, |
| 1963 | M-x perldb, or M-x xdb. Each entry point finishes by executing a | 2134 | M-x perldb, M-x xdb, or M-x jdb. Each entry point finishes by executing a |
| 1964 | hook; `gdb-mode-hook', `sdb-mode-hook', `dbx-mode-hook', | 2135 | hook; `gdb-mode-hook', `sdb-mode-hook', `dbx-mode-hook', |
| 1965 | `perldb-mode-hook', or `xdb-mode-hook' respectively. | 2136 | `perldb-mode-hook', `xdb-mode-hook', or `jdb-mode-hook' respectively. |
| 1966 | 2137 | ||
| 1967 | After startup, the following commands are available in both the GUD | 2138 | After startup, the following commands are available in both the GUD |
| 1968 | interaction buffer and any source buffer GUD visits due to a breakpoint stop | 2139 | interaction buffer and any source buffer GUD visits due to a breakpoint stop |
| @@ -2255,7 +2426,7 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2255 | (let ((insource (not (eq (current-buffer) gud-comint-buffer))) | 2426 | (let ((insource (not (eq (current-buffer) gud-comint-buffer))) |
| 2256 | (frame (or gud-last-frame gud-last-last-frame)) | 2427 | (frame (or gud-last-frame gud-last-last-frame)) |
| 2257 | result) | 2428 | result) |
| 2258 | (while (and str (string-match "\\([^%]*\\)%\\([adeflp]\\)" str)) | 2429 | (while (and str (string-match "\\([^%]*\\)%\\([adeflpc]\\)" str)) |
| 2259 | (let ((key (string-to-char (substring str (match-beginning 2)))) | 2430 | (let ((key (string-to-char (substring str (match-beginning 2)))) |
| 2260 | subst) | 2431 | subst) |
| 2261 | (cond | 2432 | (cond |
| @@ -2284,6 +2455,10 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2284 | (setq subst (gud-find-c-expr))) | 2455 | (setq subst (gud-find-c-expr))) |
| 2285 | ((eq key ?a) | 2456 | ((eq key ?a) |
| 2286 | (setq subst (gud-read-address))) | 2457 | (setq subst (gud-read-address))) |
| 2458 | ((eq key ?c) | ||
| 2459 | (setq subst (gud-find-class (if insource | ||
| 2460 | (buffer-file-name) | ||
| 2461 | (car frame))))) | ||
| 2287 | ((eq key ?p) | 2462 | ((eq key ?p) |
| 2288 | (setq subst (if arg (int-to-string arg))))) | 2463 | (setq subst (if arg (int-to-string arg))))) |
| 2289 | (setq result (concat result (match-string 1 str) subst))) | 2464 | (setq result (concat result (match-string 1 str) subst))) |
| @@ -2485,6 +2660,33 @@ Link exprs of the form: | |||
| 2485 | (t nil))) | 2660 | (t nil))) |
| 2486 | (t nil)))) | 2661 | (t nil)))) |
| 2487 | 2662 | ||
| 2663 | (defun gud-find-class (f) | ||
| 2664 | "Find fully qualified class corresponding to file F. | ||
| 2665 | This function uses the `gud-jdb-classpath' list to derive a file | ||
| 2666 | pathname relative to its classpath directory. The values in | ||
| 2667 | `gud-jdb-classpath' are assumed to have been converted to absolute | ||
| 2668 | pathname standards using file-truename." | ||
| 2669 | ;; Convert f to a standard representation and remove suffix | ||
| 2670 | (setq f (file-name-sans-extension (file-truename f))) | ||
| 2671 | (if gud-jdb-classpath | ||
| 2672 | (save-match-data | ||
| 2673 | (let ((cplist gud-jdb-classpath) | ||
| 2674 | class-found) | ||
| 2675 | ;; Search through classpath list for an entry that is | ||
| 2676 | ;; contained in f | ||
| 2677 | (while (and cplist (not class-found)) | ||
| 2678 | (if (string-match (car cplist) f) | ||
| 2679 | (setq class-found | ||
| 2680 | (mapconcat (lambda(x) x) | ||
| 2681 | (split-string | ||
| 2682 | (substring f (+ (match-end 0) 1)) | ||
| 2683 | "/") "."))) | ||
| 2684 | (setq cplist (cdr cplist))) | ||
| 2685 | (if (not class-found) | ||
| 2686 | (message "gud-find-class: class for file %s not found!" f)) | ||
| 2687 | class-found)) | ||
| 2688 | (message "gud-find-class: classpath information not available!"))) | ||
| 2689 | |||
| 2488 | (provide 'gud) | 2690 | (provide 'gud) |
| 2489 | 2691 | ||
| 2490 | ;;; gud.el ends here | 2692 | ;;; gud.el ends here |