emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fw: lisp/gud.el Jdb support for nested class breakpoints


From: Zoltan Kemenczy
Subject: Fw: lisp/gud.el Jdb support for nested class breakpoints
Date: Fri, 13 Dec 2002 22:38:47 -0500

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" <address@hidden>
To: "Zoltan Kemenczy" <address@hidden>
Sent: Friday, December 13, 2002 3:27 PM
Subject: Re: address@hidden: 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" <address@hidden>
To: <address@hidden>
Cc: <address@hidden>
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 address@hidden

* 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 ****
        ;;     (<file-name> . <line-number>) .
        (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 ----
        ;;     (<file-name> . <line-number>) .
        (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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]