Function: gud-jdb-marker-filter
gud-jdb-marker-filter is a byte-compiled function defined in
gud.el.gz.
Signature
(gud-jdb-marker-filter STRING)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; See commentary for other debugger's marker filters - there you will find
;; important notes about STRING.
(defun gud-jdb-marker-filter (string)
;; Build up the accumulator.
(setq gud-marker-acc
(if gud-marker-acc
(concat gud-marker-acc string)
string))
;; Look for classpath information until gud-jdb-classpath-string is found
;; (interactive, multiple settings of classpath from jdb
;; not supported/followed)
(if (and gud-jdb-use-classpath
(not gud-jdb-classpath-string)
(or (string-match "classpath:[ \t[]+\\([^]]+\\)" gud-marker-acc)
(string-match "-classpath[ \t\"]+\\([^ \"]+\\)" gud-marker-acc)))
(setq gud-jdb-classpath
(gud-jdb-parse-classpath-string
(setq gud-jdb-classpath-string
(match-string 1 gud-marker-acc)))))
;; We process STRING from left to right. Each time through the
;; following loop we process at most one marker. After we've found a
;; marker, delete gud-marker-acc up to and including the match
(let (file-found)
;; Process each complete marker in the input.
(while
;; Do we see a marker?
(string-match
;; jdb puts out a string of the following form when it
;; hits a breakpoint:
;;
;; <fully-qualified-class><method> (<class>:<line-number>)
;;
;; <fully-qualified-class>'s are composed of Java ID's
;; separated by periods. <method> and <class> are
;; also Java ID's. <method> begins with a period and
;; may contain less-than and greater-than (constructors,
;; for instance, are called <init> in the symbol table.)
;; Java ID's begin with a letter followed by letters
;; and/or digits. The set of letters includes underscore
;; and dollar sign.
;;
;; The first group matches <fully-qualified-class>,
;; the second group matches <class> and the third group
;; matches <line-number>. We don't care about using
;; <method> so we don't "group" it.
;;
;; FIXME: Java ID's are UNICODE strings, this matches ASCII
;; ID's only.
;;
;; The ".," in the last square-bracket are necessary because
;; of Sun's total disrespect for backwards compatibility in
;; reported line numbers from jdb - starting in 1.4.0 they
;; print line numbers using LOCALE, inserting a comma or a
;; period at the thousands positions (how ingenious!).
"\\(\\[[0-9]+] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \
\\(([a-zA-Z0-9.$_]+:\\|line=\\)\\([0-9.,]+\\)"
gud-marker-acc)
;; A good marker is one that:
;; 1) does not have a "[n] " prefix (not part of a stack backtrace)
;; 2) does have an "[n] " prefix and n is the lowest prefix seen
;; since the last prompt
;; Figure out the line on which to position the debugging arrow.
;; Return the info as a cons of the form:
;;
;; (<file-name> . <line-number>) .
(if (if (match-beginning 1)
(let (n)
(setq n (string-to-number (substring
gud-marker-acc
(1+ (match-beginning 1))
(- (match-end 1) 2))))
(if (< n gud-jdb-lowest-stack-level)
(progn (setq gud-jdb-lowest-stack-level n) t)))
t)
(let ((class (match-string 2 gud-marker-acc)))
(if (setq file-found (gud-jdb-find-source class))
(setq gud-last-frame
(cons file-found
(string-to-number
(let
((numstr (match-string 4 gud-marker-acc)))
(if (string-match "[.,]" numstr)
(replace-match "" nil nil numstr)
numstr)))))
(message "Could not find source file for %s" class))))
;; Set the accumulator to the remaining text.
(setq gud-marker-acc (substring gud-marker-acc (match-end 0))))
(if (string-match comint-prompt-regexp gud-marker-acc)
(setq gud-jdb-lowest-stack-level 999)))
;; Do not allow gud-marker-acc to grow without bound. If the source
;; file information is not within the last 3/4
;; gud-marker-acc-max-length characters, well,...
(if (> (length gud-marker-acc) gud-marker-acc-max-length)
(setq gud-marker-acc
(substring gud-marker-acc
(- (/ (* gud-marker-acc-max-length 3) 4)))))
;; We don't filter any debugger output so just return what we were given.
string)