From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Zoltan Kemenczy" Newsgroups: gmane.emacs.devel Subject: Fw: lisp/gud.el Jdb support for nested class breakpoints Date: Fri, 13 Dec 2002 22:38:47 -0500 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <000c01c2a322$4f674a20$0701a8c0@rim.net> Reply-To: Zoltan Kemenczy NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1039837665 22554 80.91.224.249 (14 Dec 2002 03:47:45 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 14 Dec 2002 03:47:45 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18N3HC-0005rW-00 for ; Sat, 14 Dec 2002 04:47:42 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18N3TW-0004UZ-00 for ; Sat, 14 Dec 2002 05:00:26 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18N3EL-0005Vj-00 for emacs-devel@quimby.gnus.org; Fri, 13 Dec 2002 22:44:45 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18N3Dr-0005SH-00 for emacs-devel@gnu.org; Fri, 13 Dec 2002 22:44:15 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18N3CE-0004nm-00 for emacs-devel@gnu.org; Fri, 13 Dec 2002 22:42:41 -0500 Original-Received: from fep02-mail.bloor.is.net.cable.rogers.com ([66.185.86.72]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18N38d-0003Ho-00; Fri, 13 Dec 2002 22:38:51 -0500 Original-Received: from zkemenczy1lt ([24.112.238.47]) by fep02-mail.bloor.is.net.cable.rogers.comESMTP <20021214033834.WDVJ513731.fep02-mail.bloor.is.net.cable.rogers.com@zkemenczy1lt>; Fri, 13 Dec 2002 22:38:34 -0500 Original-To: =?iso-8859-1?Q?Pavel_Jan=EDk?= X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4920.2300 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 X-Authentication-Info: Submitted using SMTP AUTH LOGIN at fep02-mail.bloor.is.net.cable.rogers.com from [24.112.238.47] using ID at Fri, 13 Dec 2002 22:38:34 -0500 Original-cc: rms@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10130 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10130 Pavel, The original submission is below... For some reason this message did not remain up on the emacs-devel list archive either...?? Regards, Zoltan ----- Original Message ----- From: "Pavel Janík" To: "Zoltan Kemenczy" Sent: Friday, December 13, 2002 3:27 PM Subject: Re: [kemenczy@rogers.com: lisp/gud.el Jdb support for nested class breakpoints] Zoltan, can you please resend me your patch for installation? Richard sent t to me in a form not applicable to the sources :-( Thank you. -- Pavel Janík The Linux development process aggressively filters bad ideas. -- Alan Cox in LKML ----- Original Message ----- From: "Zoltan Kemenczy" To: Cc: Sent: Tuesday, December 10, 2002 9:51 PM Subject: lisp/gud.el Jdb support for nested class breakpoints This change (finally!) adds correct classname extraction for java source lines within nested classes for breakpoint operations in gud-jdb. It also deals with a change Sun introduced with jdb in SDK 1.4 when displaying source file line numbers (they decided to add a comma at the thousands location (I didn't check the millions :-)). The new marker regexp and filename/linenumber extraction deals with 1.3.1 and 1.4 versions now. Enclosed is the changelog and context diff for an update to lisp/gud.el The changes are limited to gud-jdb operation and are relative to CVS version 1.169. I've tested these using my build of emacs-nt from the latest CVS sources (the gud toolbar (and others), finally in emacs-nt is COOL! - thanks!). Now if one could only add object browsing a'la speedbar... Please let me know if you find any issues. Best regards, Zoltan ----------------------------------------------------------------------------- Changelog entry: 2002-12-10 zoltan@ieee.org * gud.el (gud-menu-map): jdb supports "run" to start program (gud-jdb-find-source-using-classpath): (lambda(x) x) replaced by 'identity (gud-jdb-marker-filter): marker regexp and filename filtering change to support a backwards-incompatible change in Sun's jdb line number display in SDK versions 1.4... (gud-format-command): gud-find-class now requires two parameters: file and linenumber (gud-find-class): Bulk of the change related to using c-syntactic symbols to locate nested class declarations in java sources visited by java-mode(cc-mode). *** /Zoltan/emacs/emacs/lisp/gud.el Tue Dec 10 16:49:24 2002 --- /Zoltan/local/lisp/gud.el Tue Dec 10 21:12:19 2002 *************** *** 93,99 **** '(([refresh] "Refresh" . gud-refresh) ([run] menu-item "Run" gud-run :enable (and (not gud-running) ! (memq gud-minor-mode '(gdba gdb)))) ([goto] menu-item "Continue to selection" gud-goto :enable (and (not gud-running) (memq gud-minor-mode '(gdba gdb)))) --- 93,99 ---- '(([refresh] "Refresh" . gud-refresh) ([run] menu-item "Run" gud-run :enable (and (not gud-running) ! (memq gud-minor-mode '(gdba gdb jdb)))) ([goto] menu-item "Continue to selection" gud-goto :enable (and (not gud-running) (memq gud-minor-mode '(gdba gdb)))) *************** *** 1367,1372 **** --- 1367,1373 ---- ;; ;; CREATED: Sun Feb 22 10:46:38 1998 Derek Davies. ;; UPDATED: Nov 11, 2001 Zoltan Kemenczy + ;; Dec 10, 2002 Zoltan Kemenczy - added nested class support ;; ;; INVOCATION NOTES: ;; *************** *** 1810,1816 **** ;; name relative to classpath (filename (concat ! (mapconcat (lambda (x) x) (split-string ;; Eliminate any subclass references in the class ;; name string. These start with a "$" --- 1811,1817 ---- ;; name relative to classpath (filename (concat ! (mapconcat 'identity (split-string ;; Eliminate any subclass references in the class ;; name string. These start with a "$" *************** *** 1897,1904 **** ;; ;; FIXME: Java ID's are UNICODE strings, this matches ASCII ;; ID's only. ! "\\(?:\[\\([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: --- 1898,1912 ---- ;; ;; FIXME: Java ID's are UNICODE strings, this matches ASCII ;; ID's only. ! ;; ! ;; The "," in the last square-bracket is necessary because of ! ;; Sun's total disrespect for backwards compatibility in ! ;; reported line numbers from jdb - starting in 1.4.0 they ! ;; introduced a comma at the thousands position (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: *************** *** 1911,1917 **** ;; ( . ) . (if (if (match-beginning 1) (let (n) ! (setq n (string-to-int (match-string 1 gud-marker-acc))) (if (< n gud-jdb-lowest-stack-level) (progn (setq gud-jdb-lowest-stack-level n) t))) t) --- 1919,1928 ---- ;; ( . ) . (if (if (match-beginning 1) (let (n) ! (setq n (string-to-int (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) *************** *** 1919,1925 **** (gud-jdb-find-source (match-string 2 gud-marker-acc))) (setq gud-last-frame (cons file-found ! (string-to-int (match-string 4 gud-marker-acc)))) (message "Could not find source file."))) ;; Set the accumulator to the remaining text. --- 1930,1941 ---- (gud-jdb-find-source (match-string 2 gud-marker-acc))) (setq gud-last-frame (cons file-found ! (string-to-int ! (let ! ((numstr (match-string 4 gud-marker-acc))) ! (if (string-match "," numstr) ! (replace-match "" nil nil numstr) ! numstr))))) (message "Could not find source file."))) ;; Set the accumulator to the remaining text. *************** *** 1990,1995 **** --- 2006,2012 ---- (gud-def gud-finish "step up" "\C-f" "Continue until current method returns.") (gud-def gud-up "up\C-Mwhere" "<" "Up one stack frame.") (gud-def gud-down "down\C-Mwhere" ">" "Up one stack frame.") + (gud-def gud-run "run" nil "Run the program.") ;if VM start using jdb (setq comint-prompt-regexp "^> \\|^[^ ]+\\[[0-9]+\\] ") (setq paragraph-start comint-prompt-regexp) *************** *** 2524,2532 **** ((eq key ?a) (setq subst (gud-read-address))) ((eq key ?c) ! (setq subst (gud-find-class (if insource ! (buffer-file-name) ! (car frame))))) ((eq key ?p) (setq subst (if arg (int-to-string arg))))) (setq result (concat result (match-string 1 str) subst))) --- 2541,2557 ---- ((eq key ?a) (setq subst (gud-read-address))) ((eq key ?c) ! (setq subst ! (gud-find-class ! (if insource ! (buffer-file-name) ! (car frame)) ! (if insource ! (save-restriction ! (widen) ! (+ (count-lines (point-min) (point)) ! (if (bolp) 1 0))) ! (cdr frame))))) ((eq key ?p) (setq subst (if arg (int-to-string arg))))) (setq result (concat result (match-string 1 str) subst))) *************** *** 2730,2761 **** (t nil))) (t nil)))) ! (defun gud-find-class (f) ! "Find fully qualified class corresponding to file F. This function uses the `gud-jdb-classpath' (and optional `gud-jdb-sourcepath') list(s) to derive a file pathname relative to its classpath directory. The values in `gud-jdb-classpath' are assumed to have been converted to absolute ! pathname standards using file-truename." ;; Convert f to a standard representation and remove suffix (if (and gud-jdb-use-classpath (or gud-jdb-classpath gud-jdb-sourcepath)) (save-match-data ! (let ((cplist (append gud-jdb-sourcepath gud-jdb-classpath)) ! class-found) ! (setq f (file-name-sans-extension (file-truename f))) ! ;; Search through classpath list for an entry that is ! ;; contained in f ! (while (and cplist (not class-found)) ! (if (string-match (car cplist) f) ! (setq class-found (mapconcat 'identity ! (split-string ! (substring f (+ (match-end 0) 1)) ! "/") "."))) ! (setq cplist (cdr cplist))) ! (if (not class-found) ! (message "gud-find-class: class for file %s not found!" f)) ! class-found)) ;; Not using classpath - try class/source association list (let ((class-found (rassoc f gud-jdb-class-source-alist))) (if class-found --- 2755,2831 ---- (t nil))) (t nil)))) ! (defun gud-find-class (f line) ! "Find fully qualified class in file F at line LINE. This function uses the `gud-jdb-classpath' (and optional `gud-jdb-sourcepath') list(s) to derive a file pathname relative to its classpath directory. The values in `gud-jdb-classpath' are assumed to have been converted to absolute ! pathname standards using file-truename. ! If F is visited by a buffer and its mode is CC-mode(Java), ! syntactic information of LINE is used to find the enclosing (nested) ! class string which is appended to the top level ! class of the file (using s to separate nested class ids)." ;; Convert f to a standard representation and remove suffix (if (and gud-jdb-use-classpath (or gud-jdb-classpath gud-jdb-sourcepath)) (save-match-data ! (let ((cplist (append gud-jdb-sourcepath gud-jdb-classpath)) ! (fbuffer (get-file-buffer f)) ! class-found) ! (setq f (file-name-sans-extension (file-truename f))) ! ;; Search through classpath list for an entry that is ! ;; contained in f ! (while (and cplist (not class-found)) ! (if (string-match (car cplist) f) ! (setq class-found (mapconcat 'identity ! (split-string ! (substring f (+ (match-end 0) 1)) ! "/") "."))) ! (setq cplist (cdr cplist))) ! ;; if f is visited by a java(cc-mode) buffer, walk up the ! ;; syntactic information chain and collect any 'inclass ! ;; symbols until 'topmost-intro is reached to find out if ! ;; point is within a nested class ! (if (and fbuffer (equal (symbol-file 'java-mode) "cc-mode")) ! (save-excursion ! (set-buffer fbuffer) ! (let ((nclass) (syntax) ! (pos (point))) ! ;; While the c-syntactic information does not start ! ;; with the 'topmost-intro symbol, there may be ! ;; nested classes... ! (while (not (eq 'topmost-intro ! (car (car (c-guess-basic-syntax))))) ! ;; Check if the current position c-syntactic ! ;; analysis has 'inclass ! (setq syntax (c-guess-basic-syntax)) ! (while ! (and (not (eq 'inclass (car (car syntax)))) ! (cdr syntax)) ! (setq syntax (cdr syntax))) ! (if (eq 'inclass (car (car syntax))) ! (progn ! (goto-char (cdr (car syntax))) ! ;; Now we're at the beginning of a class ! ;; definition. Find class name ! (looking-at ! "[A-Za-z0-9 \t\n]*class[ \t\n]+\\([^ \t\n]+\\)") ! (setq nclass ! (append (list (match-string-no-properties 1)) ! nclass))) ! (setq syntax (c-guess-basic-syntax)) ! (while (and (not (cdr (car syntax))) (cdr syntax)) ! (setq syntax (cdr syntax))) ! (goto-char (cdr (car syntax))) ! )) ! (string-match (concat (car nclass) "$") class-found) ! (setq class-found ! (replace-match (mapconcat 'identity nclass "$") ! t t class-found))))) ! (if (not class-found) ! (message "gud-find-class: class for file %s not found!" f)) ! class-found)) ;; Not using classpath - try class/source association list (let ((class-found (rassoc f gud-jdb-class-source-alist))) (if class-found