1 ;;; jde-db.el -- Debugger mode for jdb.
2 ;; $Revision: 1.131 $ $Date: 2005/01/18 05:23:31 $
4 ;; Author: Paul Kinnucan <paulk@mathworks.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
8 ;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005 Paul Kinnucan.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, US
26 ;; This package interfaces emacs to jdb, the debugger
27 ;; distributed as part of JavaSoft's Java
28 ;; Development Kit (JDK).
30 ;; Please send bug reports and enhancement suggestions
31 ;; to Paul Kinnucan at <paulk@mathworks.com>
33 ;; See end of this file for change history.
45 (unless (fboundp 'make-overlay)
49 ;; ======================================================================
53 (defcustom jde-db-query-missing-source-files t
54 "If nonnil, this variable causes the debugger to query you
55 for the path of a class source file that it cannot find in
60 (defcustom jde-db-mode-hook nil
61 "*Customization hook for jde-db inferior mode."
66 (defcustom jde-db-initial-step-p t
67 "*If non-nil, this option causes the debugger
68 to issue a step-into command after launching
69 a program. This causes the vm to step to the
70 first line of the debuggee program."
74 (defcustom jde-db-read-vm-args nil
75 "*Read vm arguments from the minibuffer.
76 If this variable is non-nil, the jde-db command reads vm arguments
77 from the minibuffer and appends them to those specified by
78 the `jde-db-option' variable group."
82 (defvar jde-db-interactive-vm-arg-history nil
83 "History of vm arguments read from the minibuffer")
85 (defcustom jde-db-read-app-args nil
86 "*Read arguments to be passed to application from the minibuffer."
90 (defvar jde-db-interactive-app-arg-history nil
91 "History of application arguments read from the minibuffer")
93 (defcustom jde-db-classic-mode-vm nil
94 "Runs applications in the classic (i.e., not HotSpot) mode when
99 (defgroup jde-db-options nil
100 "JDE Debugger Options"
102 :prefix "jde-db-option-")
104 (defcustom jde-db-option-classpath nil
105 "*Specify paths of classes required to run this application.
106 The JDE uses the specified paths to construct a -classpath
107 argument to pass to the Java interpreter. This option overrides the
108 `jde-global-classpath' option."
109 :group 'jde-db-options
110 :type '(repeat (file :tag "Path")))
112 (defcustom jde-db-option-verbose (list nil nil nil)
113 "*Print messages about the running process.
114 The messages are printed in the run buffer."
115 :group 'jde-db-options
116 :type '(list :indent 2
117 (checkbox :format "\n %[%v%] %h \n"
118 :doc "Print classes loaded.
119 Prints a message in the run buffer each time a class is loaded.")
120 (checkbox :format "%[%v%] %h \n"
121 :doc "Print memory freed.
122 Prints a message in the run buffer each time the garbage collector
124 (checkbox :format "%[%v%] %h \n"
125 :doc "Print JNI info.
126 Prints JNI-related messages including information about which native
127 methods have been linked and warnings about excessive creation of
128 local references.")))
130 (defcustom jde-db-option-properties nil
131 "*Specify property values.
132 Enter the name of the property, for example, awt.button.color, in the
133 Property Name field; enter its value, for example, green, in the
134 Property Value field. You can specify as many properties as you like."
135 :group 'jde-db-options
137 (string :tag "Property Name")
138 (string :tag "Property Value"))))
140 (defcustom jde-db-option-heap-size (list
142 (cons 16 "megabytes"))
143 "*Specify the initial and maximum size of the interpreter heap."
144 :group 'jde-db-options
146 (cons (integer :tag "Start")
147 (radio-button-choice (const "bytes")
150 (const "gigabytes")))
151 (cons (integer :tag "Max")
152 (radio-button-choice (const "bytes")
155 (const "gigabytes")))))
158 (defcustom jde-db-option-stack-size (list
159 (cons 128 "kilobytes")
160 (cons 400 "kilobytes"))
161 "*Specify size of the C and Java stacks."
162 :group 'jde-db-options
164 (cons (integer :tag "C Stack")
165 (radio-button-choice (const "bytes")
168 (const "gigabytes")))
169 (cons (integer :tag "Java Stack")
170 (radio-button-choice (const "bytes")
173 (const "gigabytes")))))
175 (defcustom jde-db-option-garbage-collection (list t t)
176 "*Specify garbage collection options."
177 :group 'jde-db-options
178 :type '(list :indent 2
179 (checkbox :format "%[%v%] %t \n"
180 :tag "Collect garbage asynchronously.")
181 (checkbox :format "%[%v%] %t \n"
182 :tag "Collect unused classes.")))
184 (defcustom jde-db-option-java-profile (cons nil "./java.prof")
185 "*Enable Java profiling."
186 :group 'jde-db-options
190 "Specify where to put profile results here.")))
192 (defcustom jde-db-option-heap-profile (cons nil
196 "Allocation objects"))
197 "*Output heap profiling data."
198 :group 'jde-db-options
201 (string :tag "Output File Path")
202 (integer :tag "Stack Trace Depth")
203 (integer :tag "Allocation Sites")
204 (radio-button-choice :format "%t \n%v"
205 :tag "Sort output based on:"
206 (const "Allocation objects")
207 (const "Live objects")))))
209 (defcustom jde-db-option-verify (list nil t)
211 :group 'jde-db-options
212 :type '(list :indent 2
213 (checkbox :format "%[%v%] %t \n"
214 :tag "Executed code in all classes.")
215 (checkbox :format "%[%v%] %t \n"
216 :tag "Classes loaded by a classloader.")))
218 (defcustom jde-db-option-host ""
219 "Host of a remote process to which you wish to attach. This
220 option is invalid for JDK verions greater than JDK 1.1.x."
221 :group 'jde-db-options
225 ;; (makunbound 'jde-db-option-connect-socket)
226 (defcustom jde-db-option-connect-socket (list nil "4444")
227 "Specify address of socket to be used to connect the debugger and a
228 debuggee process. Selecting \"Prompt\" from the customization value
229 menu causes the debugger to prompt you to enter the shared memory name
230 when you command it to attach to or listen for an existing
231 process. Selecting \"Specify\" allows you to specify a default socket
232 host and port to be used by the debugger. "
233 :group 'jde-db-options
235 (const :menu-tag "Prompt" nil)
237 :menu-tag "Specify" :tag "Socket Address" :inline nil
240 (const :menu-tag "Local" nil)
241 (string :menu-tag "Remote" :tag "Name"))
244 (const :menu-tag "Default" "4444")
245 (string :menu-tag "Custom")))))
250 ;; (makunbound 'jde-db-option-connect-shared-memory-name)
251 (defcustom jde-db-option-connect-shared-memory-name "javadebug"
252 "Specify name to use to establish a shared memory connection
253 between the debugger and a debuggee process. Selecting \"Prompt\" from
254 the customization value menu causes a debugger attach or listen
255 command, e.g., `jde-jdb-attach-via-shared-memory', to prompt you to
256 enter the shared memory name. Selecting \"Specify\" allows you to
257 specify a name of your choosing."
258 :group 'jde-db-options
260 (const :menu-tag "Prompt" nil)
261 (string :menu-tag "Specify" :tag "Name")))
264 (defcustom jde-db-option-vm-args nil
265 "*Specify arguments to be passed to the Java vm.
266 This option allows you to specify one or more arguments to be passed
267 to the Java interpreter. It is an alternative to using JDE Run Option
268 variables, such as `jde-run-option-stack-size', to specify Java
269 interpreter options. Also, it makes it possible to use the JDE with
270 interpreters that accept command line arguments not supported by
271 the JDE Run Option variable set."
272 :group 'jde-db-options
273 :type '(repeat (string :tag "Argument")))
276 (defcustom jde-db-option-application-args nil
277 "*Specify command-line arguments to pass to the application.
278 The JDE passes the specified arguments to the application on
280 :group 'jde-db-options
281 :type '(repeat (string :tag "Argument")))
283 (defmacro jde-assert-source-or-debug-buffer ()
284 "Asserts that the current buffer is a
285 Java source or a debug buffer."
288 (eq major-mode 'jde-mode)
289 (and (slot-boundp 'jde-db-debugger 'the-debugger)
291 (oref (oref 'jde-db-debugger the-debugger) buffer))))
293 "This command works only in a Java source or debug buffer."))
295 (defcustom jde-db-log-debugger-output-flag nil
296 "Log raw debugger output to a buffer. This variable is intended
297 to be used for debugging the JDEE's debuggers."
298 :group 'jde-db-options
301 (defun jde-db-log-debugger-output (output)
302 (if jde-db-log-debugger-output-flag
303 (let ((buf (get-buffer "debugger output")))
305 (setq buf (get-buffer-create "debugger output"))
309 (goto-char (point-max))
310 (insert-string output)))))
312 (defun jde-db-get-debuggee-status ()
313 "Get the`jde-db-debuggee-status' of the
314 current debuggee process."
315 (if (slot-boundp 'jde-db-debugger 'the-debugger)
316 (let* ((debugger (oref 'jde-db-debugger the-debugger))
317 (debuggee (oref debugger debuggee)))
318 (oref debuggee status))))
321 (defun jde-db-debuggee-stopped-p ()
322 "Return t if current debuggee process is stopped."
323 (let ((status (jde-db-get-debuggee-status)))
325 (oref status stopped-p))))
327 (defun jde-db-debuggee-suspended-p ()
328 "Return t if current debuggee process is suspended."
329 (let ((status (jde-db-get-debuggee-status)))
331 (oref status suspended-p))))
333 (defun jde-db-debuggee-running-p ()
334 "Return t if current debuggee process is running."
335 (let ((status (jde-db-get-debuggee-status)))
337 (oref status running-p))))
341 (defun jde-db-set-debugger (name is-executable)
342 "Specify the pathname of the debugger, if an executable, or the
343 debugger's fully qualified class name, if a class."
345 "sEnter name of Java interpreter: \nsIs %s executable? (yes): ")
348 (if (stringp is-executable)
350 (string= is-executable "")
351 (eq (aref is-executable 0) ?y))
355 (setq jde-db-debugger (cons "Other" (cons db type)))))
358 (defun jde-db-set-args (args)
359 "Specify the arguments (except -classpath) to be passed to the debugger."
361 "sEnter arguments: ")
362 (setq jde-db-option-vm-args (jde-run-parse-args args)))
365 (defun jde-db-set-app-args (args)
366 "Specify the arguments to be passed to the Java application class."
368 "sEnter arguments: ")
369 (setq jde-db-option-application-args (jde-run-parse-args args)))
372 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
378 (defcustom jde-db-spec-breakpoint-face-colors (cons "black" "green")
379 "*Specifies the foreground and background colors used to highlight
380 the line at which you have specified that a breakpoint to be set."
382 :type '(cons :tag "Colors"
383 (string :tag "Foreground")
384 (string :tag "Background"))
385 :set '(lambda (sym val)
386 (make-face 'jde-db-spec-breakpoint-face)
387 (set-face-foreground 'jde-db-spec-breakpoint-face (car val))
388 (set-face-background 'jde-db-spec-breakpoint-face (cdr val))
389 (set-default sym val)))
391 (defcustom jde-db-requested-breakpoint-face-colors (cons "black" "yellow")
392 "*Specifies the foreground and background colors used to highlight
393 the line at which you have requested a breakpoint to be set."
395 :type '(cons :tag "Colors"
396 (string :tag "Foreground")
397 (string :tag "Background"))
398 :set '(lambda (sym val)
399 (make-face 'jde-db-requested-breakpoint-face)
400 (set-face-foreground 'jde-db-requested-breakpoint-face (car val))
401 (set-face-background 'jde-db-requested-breakpoint-face (cdr val))
402 (set-default sym val)))
404 (defcustom jde-db-active-breakpoint-face-colors (cons "black" "red")
405 "*Specifies the foreground and background colors used to highlight
406 a line where an active breakpoint exists."
408 :type '(cons :tag "Colors"
409 (string :tag "Foreground")
410 (string :tag "Background"))
411 :set '(lambda (sym val)
412 (make-face 'jde-db-active-breakpoint-face)
413 (set-face-foreground 'jde-db-active-breakpoint-face (car val))
414 (set-face-background 'jde-db-active-breakpoint-face (cdr val))
415 (set-default sym val)))
418 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
420 ;; Breakpoint Marker Class ;;
422 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
424 (defclass jde-db-breakpoint-marker ()
425 ((marker :initarg :marker
427 "Overlay in Emacs, extent in XEmacs"))
428 "Indicates the location of breakpoints in a source buffer. This class
429 uses overlays as markers in Emacs and extents in XEmacs.")
431 (defmethod initialize-instance ((this jde-db-breakpoint-marker) &rest fields)
432 "Create a breakpoint overlay at LINE in FILE."
434 ;; Call parent initializer.
438 (if (featurep 'xemacs)
439 (if (or (not (extent-at (jde-line-beginning-position)))
440 (not (jde-db-breakpoint-marker-p
441 (extent-at (jde-line-beginning-position)))))
443 (jde-line-beginning-position)
444 (1+ (jde-line-end-position))))
446 (jde-line-beginning-position)
447 (1+ (jde-line-end-position))
448 (current-buffer) nil t))))
451 (defmethod jde-db-breakpoint-marker-set-face ((this jde-db-breakpoint-marker) face)
452 "Apply FACE to OVERLAY."
453 (let ((marker (oref this marker)))
454 (if (featurep 'xemacs)
456 (set-extent-face marker face)
457 (set-extent-priority marker 98))
459 (overlay-put marker 'face face)
460 (overlay-put marker 'priority 98)))))
462 (defun jde-db-breakpoint-marker-p (marker)
463 "Return t if overlay is a breakpoint marker overlay."
465 (if (featurep 'xemacs)
466 (extent-property marker 'face nil)
467 (overlay-get marker 'face))))
469 (eq marker-face 'jde-db-spec-breakpoint-face)
470 (eq marker-face 'jde-db-requested-breakpoint-face)
471 (eq marker-face 'jde-db-active-breakpoint-face))))
473 (defmethod jde-db-breakpoint-marker-delete ((this jde-db-breakpoint-marker))
474 "Remove breakpoint overlay at LINE in FILE."
475 (if (featurep 'xemacs)
476 (delete-extent (oref this marker))
477 (delete-overlay (oref this marker))))
481 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
483 ;; Breakpoint Class ;;
485 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
486 (defclass jde-db-breakpoint ()
490 "Identifies this breakpoint.")
495 "Pathname of file containing this breakpoint.")
499 "Number of line at which breakpoint is set.")
500 (marker :initarg :marker
501 :type (or null jde-db-breakpoint-marker)
504 "Marker used to highlight breakpoint line.")
505 (class :initarg :class
508 "Qualified name of class containing breakpoint.")
509 (status :initarg status
513 "Status of this breakpoint. Legal values are `specified', `requested', `active'."))
514 (:allow-nil-initform t)
515 "Class of breakpoints.")
518 (defmethod initialize-instance ((this jde-db-breakpoint) &rest fields)
519 "Constructor for a breakpoint specification."
521 ;; Call parent initializer.
524 (assert (oref this file))
528 (jde-db-breakpoint-marker "breakpoint marker"))
530 (jde-db-breakpoint-marker-set-face
531 (oref this marker) 'jde-db-spec-breakpoint-face))
533 (defmethod jde-db-breakpoint-get-line ((this jde-db-breakpoint))
534 "Get the number of the line at which this breakpoint is set."
536 (set-buffer (find-file-noselect (oref this file)))
537 (if (oref this marker)
539 (if (featurep 'xemacs)
540 (extent-start-position (oref (oref this marker) marker))
541 (overlay-start (oref (oref this marker) marker)))))
542 (jde-get-line-at-point marker-start))
545 (defvar jde-db-breakpoints nil
546 "Current breakpoints.")
549 (defun jde-db-get-breakpoint-marker (file line)
550 "Get breakpoint marker at FILE and LINE."
551 (let ((bp (jde-db-find-breakpoint file line)))
555 (defun jde-db-mark-breakpoint-specified (file line)
556 "Changes the face of the breakpoint marker at LINE in FILE
557 to the specified face."
558 (let ((marker (jde-db-get-breakpoint-marker file line)))
560 (jde-db-breakpoint-marker-set-face marker 'jde-db-spec-breakpoint-face))))
562 (defun jde-db-mark-breakpoint-active (file line)
563 "Changes the face of the breakpoint marker at LINE in FILE
565 (let ((marker (jde-db-get-breakpoint-marker file line)))
567 (jde-db-breakpoint-marker-set-face marker 'jde-db-active-breakpoint-face))))
569 (defun jde-db-mark-breakpoint-requested (file line)
570 "Changes the face of the breakpoint marker at LINE in FILE
572 (let ((marker (jde-db-get-breakpoint-marker file line)))
574 (jde-db-breakpoint-marker-set-face marker 'jde-db-requested-breakpoint-face))))
576 (defun jde-db-set-all-breakpoints-specified ()
577 "Changes the face of all breakpoints to `jde-db-spec-breakpoint-face'
578 and sets the status of all breakpoints to `specified'."
579 (loop for bp-assoc in jde-db-breakpoints do
580 (let* ((bp (cdr bp-assoc))
581 (marker (oref bp marker)))
582 (oset bp status 'specified)
584 (jde-db-breakpoint-marker-set-face marker 'jde-db-spec-breakpoint-face)))))
586 (defun jde-db-delete-breakpoint (bp)
587 "Delete the breakpoint at LINE in FILE."
588 (setq jde-db-breakpoints
589 ;; bp will be in the list so don't run the risk of using a
591 (let ((bpline (jde-db-breakpoint-get-line bp)))
594 (let* ((xbp (cdr assoc-x))
595 (xfile (oref xbp file))
598 (string= (oref bp file) xfile)
599 (equal bpline (jde-db-breakpoint-get-line xbp)))))
601 (jde-db-breakpoint-marker-delete
604 jde-db-breakpoints))))
606 (defun jde-db-clear-breakpoints ()
607 "Clear all breakpoints from all buffers."
610 (let* ((xbp (cdr assoc-x))
611 (file (oref xbp file))
612 (buf (find-buffer-visiting file)))
616 (let ((xmarker (oref xbp marker)))
617 (jde-db-breakpoint-marker-delete xmarker))))))
619 (setq jde-db-breakpoints nil))
621 (defvar jde-db-bp-list nil)
622 (defun jde-debug-list-breakpoints (&optional active)
623 "Brings a list of all set breakpoints. It allows the user to jump to a
624 particular breakpoint and to select breakpoints to be clear."
626 (if jde-db-breakpoints
628 (switch-to-buffer "*Breakpoints List*")
629 (kill-all-local-variables)
630 (make-local-variable 'jde-db-bp-list)
631 (setq jde-db-bp-list nil)
632 (let ((inhibit-read-only t))
634 (setq active (not active))
635 (widget-insert "Breakpoints:\n\n")
638 (let* ((xbp (cdr assoc-x))
640 (class (oref xbp class))
641 (file (oref xbp file))
642 (line (oref xbp line))
643 (status (oref xbp status)))
646 :notify (lambda (widget &rest ignore)
647 (if (widget-value widget)
649 (delete (widget-get widget :id)
652 (append jde-db-bp-list
653 (list (widget-get widget :id))))))
657 (setq jde-db-bp-list (append jde-db-bp-list (list id))))
659 (widget-create 'push-button
660 :notify (lambda (widget &rest ignore)
662 (find-file-other-window
663 (widget-get widget :file))
665 (widget-get widget :line))))
669 ((eq status 'specified)
670 'jde-db-spec-breakpoint-face)
672 'jde-db-active-breakpoint-face)
673 (t 'jde-db-requested-breakpoint-face))
676 (format "%s:%d" class line))
677 (widget-insert "\n")))
680 (widget-create 'push-button
681 :notify (lambda (&rest ignore)
682 (jde-debug-list-breakpoints t))
685 (widget-create 'push-button
686 :notify (lambda (&rest ignore)
688 (jde-db-process-breakpoints)
689 (kill-buffer "*Breakpoints List*")))
691 (use-local-map widget-keymap)
694 (message "No breakpoints")))
696 (defun jde-db-process-breakpoints ()
697 "Deletes all the breakpoints found in `jde-db-bp-list'"
699 (if (jde-db-debuggee-running-p)
700 (let* ((debugger (oref 'jde-db-debugger the-debugger))
701 (bp-cmd (oref (oref debugger cmd-set) clear-bp)))
707 (jde-db-find-breakpoint-by-id assoc-x))
709 (jde-db-exec-cmd debugger bp-cmd))
710 (loop for bp-assoc in jde-db-bp-list do
711 (let ((bp (jde-db-find-breakpoint-by-id bp-assoc)))
712 (jde-db-delete-breakpoint bp))))))
714 (defun jde-db-breakpoints-add (bp)
715 "Adds this breakpoint to the list of breakpoints."
716 (setq jde-db-breakpoints
717 (cons (cons (oref bp id) bp)
718 jde-db-breakpoints)))
721 (defun jde-db-find-breakpoint-by-id (id)
722 "Finds the breakpoint object with ID"
725 (let ((bp (cdr assoc-x)))
726 (= (oref bp id) id)))
727 jde-db-breakpoints)))
729 (defun jde-db-find-breakpoint (file line)
730 "Finds the breakpoint object for the breakpoint at FILE and LINE."
733 (let ((bp (cdr assoc-x)))
734 (and (string= (oref bp file) file)
735 (equal (jde-db-breakpoint-get-line bp) line))))
736 jde-db-breakpoints)))
739 (defvar jde-db-breakpoint-id-counter 0
740 "Counter for generating breakpoint ids")
742 (defun jde-db-nullify-breakpoint-markers ()
743 "Set the marker field for each breakpoint
744 in the current buffer to nil."
745 (when (eq major-mode 'jde-mode)
746 (let ((file (buffer-file-name)))
747 (loop for bp-assoc in jde-db-breakpoints do
748 (let ((bp (cdr bp-assoc)))
749 (when (string= (oref bp file) file)
750 (oset bp line (jde-db-breakpoint-get-line bp))
751 (oset bp marker nil)))))))
753 (add-hook 'kill-buffer-hook 'jde-db-nullify-breakpoint-markers)
755 (defun jde-db-remark-breakpoints ()
756 "Highlights all breakpoints in the current buffer if not
757 already highlighted."
759 (loop for bp-assoc in jde-db-breakpoints do
760 (let* ((bp (cdr bp-assoc))
761 (file (buffer-file-name))
762 (line (oref bp line))
763 (status (oref bp status)))
764 (if (string-equal file (oref bp file))
769 (jde-db-breakpoint-marker "breakpoint marker"))
771 ((eq status 'specified)
772 (jde-db-mark-breakpoint-specified file line))
773 ((eq status 'requested)
774 (jde-db-mark-breakpoint-requested file line))
776 (jde-db-mark-breakpoint-active file line))
778 (error "Unknown breakpoint status: %s"
779 (symbol-name status))))))))
783 (add-hook 'jde-mode-hook 'jde-db-remark-breakpoints)
786 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
788 ;; Debug Cursor Handling ;;
790 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
792 (defun jde-db-query-source-file (class)
795 (format "Cannot find %s source. Enter path: " class))))
798 (file-exists-p source-file)
799 (not (file-directory-p source-file)))
800 (find-file-noselect source-file))))
802 (defun jde-db-find-class-source (class)
803 "Find and open the source file for a class. CLASS is the fully
804 qualified name of the class. If this function is unable to find the
805 source for CLASS in `jde-sourcepath' and
806 `jde-db-query-missing-source-files' is nonnil, this function queries
807 the user for the path to the source file. If successful, this function
808 returns an unselected buffer containing the source file for the
809 class. Otherwise, it returns nil."
810 (let* ((source-file (jde-find-class-source-file class))
813 (find-file-noselect source-file)
814 (if jde-db-query-missing-source-files
815 (jde-db-query-source-file class)))))
818 (defun jde-db-set-debug-cursor (class file line)
819 "Shows the source at LINE in CLASS."
820 (let* ((buffer (jde-db-find-class-source class))
823 (or (get-buffer-window buffer)
828 (if (not (get-buffer-window buffer))
829 (set-window-buffer window buffer))
836 (setq overlay-arrow-string "=>")
837 (or overlay-arrow-position
838 (setq overlay-arrow-position (make-marker)))
839 (set-marker overlay-arrow-position (point) (current-buffer)))
840 (cond ((or (< pos (point-min)) (> pos (point-max)))
843 (set-window-point window overlay-arrow-position)))))
846 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
848 ;; Debuggee Process Status Class ;;
850 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
851 (defclass jde-db-debuggee-status ()
852 ((running-p :initarg :running-p
856 "Non-nil if debuggee process is running.")
857 (stopped-p :initarg :stopped-p
861 "Non-nil if debuggee process is stopped.")
862 (suspended-p :initarg :suspended-p
866 "Non-nil if debuggee process is suspended."))
867 "Status of debuggee process.")
869 (defmethod initialize-instance ((this jde-db-debuggee-status) &rest fields)
870 "Status of debuggee process."
873 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
875 ;; Debuggee Process Class ;;
877 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
878 (defclass jde-db-connector () ()
879 "Proxy for debugger connectors.")
881 (defclass jde-db-launch-connector (jde-db-connector) ()
882 "Launched by the debugger.")
884 (defclass jde-db-socket-connector (jde-db-connector)
885 ((port :initarg :port
886 :type (or null string)
889 "Port to the debuggee process."))
890 "Connect via a socket.")
892 (defclass jde-db-shared-memory-connector (jde-db-connector)
893 ((name :initarg :name
894 :type (or null string)
897 "Shared memory name of debuggee process."))
898 "Connect via a shared-memory transport (Windows only).")
901 (defclass jde-db-attach-connector (jde-db-connector) ()
902 "Attaches to debuggee.")
904 (defclass jde-db-listen-connector (jde-db-connector) ()
905 "Listens for debuggee.")
908 (defclass jde-db-socket-attach-connector (jde-db-socket-connector
909 jde-db-attach-connector)
910 ((host :initarg :host
911 :type (or null string)
914 "Host on which the debuggee process runs."))
915 "Attach via a socket.")
917 (defclass jde-db-shared-memory-attach-connector (jde-db-shared-memory-connector
918 jde-db-attach-connector)
920 "Attach via a shared memory connection.")
922 (defclass jde-db-socket-listen-connector (jde-db-socket-connector
923 jde-db-listen-connector)
925 "Listen via a socket.")
927 (defclass jde-db-shared-memory-listen-connector (jde-db-shared-memory-connector
928 jde-db-listen-connector)
930 "Listen via a shared memory connection.")
933 (defclass jde-db-debuggee ()
934 ((status :initarg :status
935 :type jde-db-debuggee-status
937 "Status of debuggee process.")
939 (stack-depth :initarg :stack-depth
944 "Program being debugged.")
946 (defmethod initialize-instance ((this jde-db-debuggee) &rest fields)
947 "Constructs an instance of a debuggee."
951 (defclass jde-db-debuggee-app (jde-db-debuggee)
952 ((main-class :initarg :main-class
955 "Qualified name of debuggee main class.")
957 (connector :initarg :connector
958 :type jde-db-connector
960 "Type of connector between this debuggee and the debugger."))
961 "Application being debugged.")
963 (defclass jde-db-debuggee-applet (jde-db-debuggee)
967 "Path of applet HTML document."))
968 "Applet being debugged.")
971 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
973 ;; Debugger Command Line Commands ;;
975 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
976 (defclass jde-db-cmd ()
977 ((name :initarg :name
981 (debugger :initarg :debugger
982 :type jde-db-debugger
985 "Super class of debugger commands.")
988 (defmethod initialize-instance ((this jde-db-cmd) &rest fields)
989 "Constructor for debugger commands."
992 (defmethod jde-db-cmd-init ((this jde-db-cmd))
993 "The debugger invokes this method before executing the
996 (defmethod jde-db-cmd-make-command-line ((this jde-db-cmd))
997 "Creates the command line for this command."
1000 (defmethod jde-db-cmd-notify-response ((this jde-db-cmd) response)
1001 "Invoked when the debugger responds to the command. RESPONSE
1004 (defmethod jde-db-cmd-response-p ((this jde-db-cmd) output)
1005 "Returns nonnil if external debugger's output is a
1006 response to this command."
1010 (defclass jde-db-cmd-breakpoint (jde-db-cmd)
1011 ((breakpoints :initarg :breakpoints
1014 "List of breakpoint specification."))
1015 "Class of breakpoint commands.")
1017 (defclass jde-db-cmd-launch (jde-db-cmd)
1019 "Launch a debuggee process.")
1021 (defclass jde-db-cmd-launch-app (jde-db-cmd-launch)
1022 ((main-class :initarg :main-class
1025 "Main class of applications to be debugged."))
1026 "Launch an application in debug mode.")
1028 (defmethod initialize-instance ((this jde-db-cmd-launch-app) &rest fields)
1030 (oset this name "launch application"))
1032 (defclass jde-db-cmd-launch-applet (jde-db-cmd-launch)
1036 "Path of applet document."))
1037 "Launch an applet in debug mode.")
1039 (defmethod initialize-instance ((this jde-db-cmd-launch-applet) &rest fields)
1041 (oset this name "launch applet"))
1043 ;; Generic Debugger Command Set.
1045 (defclass jde-db-cmd-set ()
1046 ((debugger :initarg :debugger
1047 :type jde-db-debugger
1049 "Debugger that owns this command set.")
1050 (launch-app :initarg :launch-app
1051 :type jde-db-cmd-launch-app
1053 "Launch debuggee application")
1054 (launch-applet :initarg :launch-applet
1055 :type jde-db-cmd-launch-applet
1057 "Launch debuggee applet")
1061 "Starts the current debuggee application.")
1062 (cont :initarg :cont
1065 "Continues the current debuggee application.")
1066 (quit :initarg :quit
1069 "Quit debugging the current application.")
1070 (step-over :initarg :step-over
1073 "Step to the next line in the current frame.")
1074 (step-into :initarg :step-into
1077 "Step to the next line in the current program.")
1078 (step-out :initarg :step-out
1081 "Continue to the end of the current method.")
1085 "Move up the stack.")
1086 (down :initarg :down
1089 "Move down the stack.")
1090 (where :initarg :where
1093 "Point to the current stopping point.")
1094 (set-bp :initarg :set-bp
1097 "Cmd that asks debugger to set a breakpoint.")
1098 (clear-bp :initarg :clear-bp
1101 "Cmd that asks debugger to set a breakpoint."))
1102 "Set of debugger commands implemented by this debugger.")
1106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1108 ;; Debug Process Listener ;;
1110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1111 (defclass jde-db-listener ()
1112 ((debugger :initarg :debugger
1113 :type jde-db-debugger
1116 "Listens to the output from the debugger.")
1118 (defmethod jde-db-listener-filter-output ((this jde-db-listener) output)
1119 "Filters the output of the debugger."
1123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1125 ;; Class of JDE Debuggers ;;
1127 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1128 (defclass jde-db-debugger ()
1129 ((name :initarg :name
1131 :initform "Java debugger"
1133 "Name of this Java debugger.")
1134 (buffer-name :initarg :buffer-name
1135 :initform "Java Debugger"
1138 "Name of buffer used to interact with debugger.")
1139 (buffer :initarg :buffer
1142 "Buffer used to interact with debugger.")
1144 (process :initarg :process
1146 "Debugger process.")
1148 (running-p :initarg :process
1152 "Non-nil if debugger process is running.")
1154 (proc-filter :initarg :proc-filter
1157 "Function used to parse debug output.")
1159 (listeners :initarg :listeners
1163 "List of debugger output listeners.")
1165 (cmd-set :initarg :cmd-set
1166 :type jde-db-cmd-set
1168 "Commands implemented by this debugger.")
1170 (next-cmd :initarg :next-cmd
1174 "Next command(s) to execute.")
1176 (last-cmd :initarg :last-cmd
1177 :type (or null jde-db-cmd)
1179 "Last command send to the debugger.")
1181 (debuggee :initarg :debuggee
1182 :type jde-db-debuggee
1184 "Application process being debugged.")
1186 (the-debugger :type jde-db-debugger
1189 "The currently active debugger."))
1190 "Class of Java debuggers.")
1192 (defmethod initialize-instance ((this jde-db-debugger) &rest fields)
1193 "Constructor for generic debugger."
1195 (jde-db-cmd-set "Generic commands" :debugger this))
1196 (oset this last-cmd nil))
1199 (defmethod jde-db-create-debuggee-app ((this jde-db-debugger) main-class))
1201 (defmethod jde-db-create-debuggee-applet ((this jde-db-debugger applet-doc)))
1203 (defmethod jde-db-ready-p ((this jde-db-debugger) output)
1204 "Nonnil if OUTPUT indicates that the debugger is
1205 ready to accept the next command."
1208 (string-match ">[ ]*$" output)
1209 (string-match "[a-zA-Z0-9]+\[[0-9]+\][ ]*$" output)
1210 (string-match "VM Started:[ ]*$" output))))
1213 (defmethod jde-db-process-debugger-output ((this jde-db-debugger) output)
1214 "Process debugger output."
1215 (jde-db-log-debugger-output (concat "<<" output ">>"))
1216 (let ((proc (oref this process))
1217 (listeners (oref this listeners))
1219 (last-cmd (oref this last-cmd)))
1221 (loop for listener in listeners do
1223 (jde-db-listener-filter-output listener output)))
1225 (comint-output-filter proc output)
1228 (jde-db-cmd-notify-response last-cmd response))
1230 (if (jde-db-ready-p this (car (last (split-string output "\n"))))
1231 (jde-db-exec-next-cmd this))))
1233 (defmethod jde-db-add-listener ((this jde-db-debugger) listener)
1234 "Adds LISTENER to the list of listeners listening for response
1235 from the debugger. LISTENER must be an object of type
1237 (assert (typep listener jde-db-listener))
1238 (oset this listeners (cons listener (oref this listeners))))
1240 (defmethod jde-db-remove-listener ((this jde-db-debugger) listener)
1241 "Removes LISTENER from the list of listeners listening for a
1242 response from the debugger. LISTENER must be an object of type
1244 (assert (typep listener jde-db-listener))
1245 (oset this listeners (remove listener (oref this listeners))))
1247 (defmethod jde-db-set-process-filter ((this jde-db-debugger))
1248 "Set debugger process output filter. The default method sets a
1249 function that invokes `jde-db-process-debugger-output'."
1252 (lambda (process output)
1253 (jde-db-process-debugger-output
1254 (oref 'jde-db-debugger the-debugger) output))))
1256 (defmethod jde-db-notify-process-exit ((this jde-db-debugger) msg)
1257 "The default debugger process sentinel invokes this method
1258 when the debugger process terminates."
1259 (let ((proc (oref this process)))
1260 (cond ((null (buffer-name (process-buffer proc)))
1262 ;; Stop displaying an arrow in a source file.
1263 (setq overlay-arrow-position nil)
1264 (set-process-buffer proc nil))
1265 ((memq (process-status proc) '(signal exit))
1266 ;; Stop displaying an arrow in a source file.
1267 (setq overlay-arrow-position nil)
1268 (let* ((obuf (current-buffer)))
1269 ;; save-excursion isn't the right thing if
1270 ;; process-buffer is current-buffer
1273 ;; Write something in debugger buffer and hack its mode line,
1274 (set-buffer (process-buffer proc))
1275 ;; Fix the mode line.
1276 (setq mode-line-process
1278 (symbol-name (process-status proc))))
1279 (force-mode-line-update)
1281 (insert ?\n mode-name " " msg)
1283 (goto-char (point-max))
1284 (insert ?\n mode-name " " msg)))
1285 ;; If buffer and mode line will show that the process
1286 ;; is dead, we can delete it now. Otherwise it
1287 ;; will stay around until M-x list-processes.
1288 (delete-process proc))
1289 ;; Restore old buffer, but don't restore old point
1290 ;; if obuf is the command buffer.
1291 (set-buffer obuf)))))))
1294 (defmethod jde-db-notify-process-status-change ((this jde-db-debugger) msg)
1295 "The debugger process sentinel invokes this method when the status of
1296 the debugger process changes. The default method invokes
1297 `jde-db-notify-process-exit'."
1298 (jde-db-notify-process-exit this msg))
1301 (defmethod jde-db-set-process-sentinel ((this jde-db-debugger))
1302 (set-process-sentinel
1304 (lambda (process msg)
1305 (jde-db-notify-process-status-change
1306 (oref 'jde-db-debugger the-debugger) msg))))
1308 (defmethod jde-db-exec-next-cmd ((this jde-db-debugger))
1309 "Executes the next command on the debugger's pending
1311 (let ((curr-cmd (car (oref this next-cmd))))
1314 (oset this next-cmd (cdr (oref this next-cmd)))
1315 (oset this last-cmd curr-cmd)
1316 (jde-db-cmd-init curr-cmd)
1318 (set-buffer (oref this buffer))
1319 (let ((proc (oref this process))
1320 (cmd-line (jde-db-cmd-make-command-line curr-cmd)))
1323 (goto-char (point-max))
1325 (comint-send-input)))))))))
1327 (defmethod jde-db-exec-cmds ((this jde-db-debugger) cmds)
1328 "Executes list of debugger CMDS."
1329 (oset this next-cmd cmds)
1330 (jde-db-exec-next-cmd this))
1332 (defmethod jde-db-exec-cmd ((this jde-db-debugger) cmd)
1334 (assert (and cmd (typep cmd 'jde-db-cmd)))
1335 (jde-db-exec-cmds this (list cmd)))
1337 (defmethod jde-db-classpath-arg ((this jde-db-debugger))
1338 "Generate the -classpath command line argument for jdb."
1340 ;; Set the classpath option. Use the local
1341 ;; classpath, if set; otherwise, the global
1344 (if jde-db-option-classpath
1345 jde-db-option-classpath
1346 jde-global-classpath))
1348 (if jde-db-option-classpath
1349 'jde-db-option-classpath
1350 'jde-global-classpath)))
1354 (jde-build-classpath
1355 classpath symbol)))))
1357 (defmethod jde-db-classic-mode-arg ((this jde-db-debugger))
1358 "Generate the classic mode command-line argument for jdb."
1359 (if jde-db-classic-mode-vm
1362 (defmethod jde-db-property-args ((this jde-db-debugger))
1363 "Generate property arguments."
1364 (if jde-db-option-properties
1367 (concat "-D" (car prop) "=" (cdr prop)))
1368 jde-db-option-properties)))
1371 (defmethod jde-db-verbose-args ((this jde-db-debugger))
1372 "Get the debugger verbosity arguments for jdb."
1373 (let ((print-classes-loaded
1374 (nth 0 jde-db-option-verbose))
1376 (nth 1 jde-db-option-verbose))
1378 (nth 2 jde-db-option-verbose))
1381 (if print-classes-loaded
1382 (add-to-list 'options "-verbose:class"))
1384 (if print-memory-freed
1385 (add-to-list 'options "-verbosegc"))
1388 (add-to-list options "-verbosejni"))
1392 (defmethod jde-db-heap-size-args ((this jde-db-debugger))
1393 "Generate heap size options."
1394 (let* ((memory-unit-abbrevs
1395 (list (cons "bytes" "")
1396 (cons "kilobytes" "k")
1397 (cons "megabytes" "m")
1398 (cons "gigabytes" "g")))
1399 (start-cons (nth 0 jde-db-option-heap-size))
1400 (start-size (format "%d%s" (car start-cons)
1401 (cdr (assoc (cdr start-cons)
1402 memory-unit-abbrevs))))
1403 (max-cons (nth 1 jde-db-option-heap-size))
1404 (max-size (format "%d%s" (car max-cons)
1405 (cdr (assoc (cdr max-cons)
1406 memory-unit-abbrevs))))
1408 (if (not (string= start-size "1m"))
1410 (append options (list (concat "-Xms" start-size)))))
1411 (if (not (string= max-size "16m"))
1413 (append options (list (concat "-Xmx" max-size)))))
1416 (defmethod jde-db-stack-size-args ((this jde-db-debugger))
1417 "Generate stack size arguments."
1418 (let* ((memory-unit-abbrevs
1419 (list (cons "bytes" "")
1420 (cons "kilobytes" "k")
1421 (cons "megabytes" "m")
1422 (cons "gigabytes" "g")))
1423 (c-cons (nth 0 jde-db-option-stack-size))
1424 (c-size (format "%d%s" (car c-cons)
1425 (cdr (assoc (cdr c-cons)
1426 memory-unit-abbrevs))))
1427 (java-cons (nth 1 jde-db-option-stack-size))
1428 (java-size (format "%d%s" (car java-cons)
1429 (cdr (assoc (cdr java-cons)
1430 memory-unit-abbrevs))))
1433 (if (not (string= c-size "128k"))
1435 (append option (list (concat "-Xss" c-size)))))
1437 (if (not (string= java-size "400k"))
1439 (append option (list (concat "-Xoss" java-size)))))
1442 (defmethod jde-db-garbage-collection-args ((this jde-db-debugger))
1443 "Set garbage collection options."
1444 (let ((no-gc-asynch (not
1445 (nth 0 jde-db-option-garbage-collection)))
1447 (nth 1 jde-db-option-garbage-collection)))
1451 (setq options (append options '("-Xnoasyncgc"))))
1454 (setq options (append options '("-Xnoclassgc"))))
1458 (defmethod jde-db-garbage-collection-arg ((this jde-db-debugger))
1459 "Generate Java profile arg."
1460 (let ((profilep (car jde-db-option-java-profile))
1461 (file (cdr jde-db-option-java-profile)))
1464 (if (string= file "./java.prof")
1466 (list (concat "-Xprof:" file))))))
1469 (defmethod jde-db-heap-profile-arg ((this jde-db-debugger))
1470 "Generate heap profile option."
1471 (let* ((profilep (car jde-db-option-heap-profile))
1472 (prof-options (cdr jde-db-option-heap-profile))
1473 (file (nth 0 prof-options))
1474 (depth (nth 1 prof-options))
1475 (top (nth 2 prof-options))
1477 (downcase (substring (nth 3 prof-options) 0 1))))
1479 (if (and (string= file "./java.hprof")
1486 "-Xhprof:file=%s,depth=%d,top=%d,sort=%s"
1487 file depth top sort))))))
1489 (defmethod jde-db-verify-arg ((this jde-db-debugger))
1490 ;; Set verify options.
1491 (let ((verify-all (nth 0 jde-db-option-verify))
1492 (verify-remote (nth 1 jde-db-option-verify)))
1496 ; (list "-Xverifyremote"))
1499 (not verify-remote))
1500 (list "-Xnoverify")))))
1503 (defmethod jde-db-command-line-args ((this jde-db-debugger))
1504 "Generate command line args."
1505 (if jde-db-option-vm-args
1509 jde-db-option-vm-args)))
1512 (defmethod jde-db-host-arg ((this jde-db-debugger))
1513 (if (not (string= jde-db-option-host ""))
1514 (list "-host" jde-db-option-host)))
1516 (defmethod jde-db-launch-arg ((this jde-db-debugger))
1517 "Argument that tells the debugger to launch the
1518 debuggee vm immediately instead of waiting for a
1519 run command. Only the new (JDK 1.3) version of jdb
1520 provides this option."
1523 (defmethod jde-db-get-vm-args ((this jde-db-debugger))
1525 (jde-db-classic-mode-arg this)
1526 (jde-db-launch-arg this)
1527 (jde-db-classpath-arg this)
1528 (jde-db-property-args this)
1529 (jde-db-verbose-args this)
1530 (jde-db-heap-size-args this)
1531 (jde-db-command-line-args this)))
1533 (defmethod jde-db-debugger-get-working-dir ((this jde-db-debugger))
1534 (if (string= jde-run-working-directory "")
1536 (jde-normalize-path 'jde-run-working-directory)))
1538 (defmethod jde-db-debugger-get-prog-args ((this jde-db-debugger))
1541 (defmethod jde-db-debugger-start ((this jde-db-debugger))
1542 "Start the debugger.")
1545 (defmethod jde-db-debugger-launch ((this jde-db-debugger) main-class)
1546 "Launch the application whose main class is MAIN-CLASS in debug mode.")
1549 (defmethod jde-db-debugger-connect ((this jde-db-debugger) &optional listenp)
1550 "Connect the debugger to an existing process.")
1553 (defun jde-db-get-the-debugger ()
1554 "Get the currently selected debugger. This function
1555 returns an eieio object of type `jde-db-debugger'."
1556 (if (string= (car jde-debugger) "JDEbug")
1557 jde-dbs-the-debugger
1561 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1563 ;; Generic Debug Commands ;;
1565 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1567 ;; The following commands serve as a generalized interface between the
1568 ;; JDE user and JDE-supported debuggers, e.g., jdb or JDEbug.
1570 ;; This section is a work in progress. It entails generalizing the
1571 ;; existing jdb and JDEbug commands and replacing those commands
1572 ;; with the generalized commands.
1576 "Run the debugger specified by `jde-debugger' on the Java application
1577 whose source resides in the current buffer. This command determines
1578 the main class of the application either from the variable
1579 `jde-run-application-class' or from the source in the current
1580 buffer. If `jde-run-application-class' does not specify a class, the
1581 main class is assumed to be the class defined by the current source
1582 buffer. This command creates a command buffer for the debug session."
1585 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1586 ;; This is a temporary hack until I
1587 ;; wire up the JDEbug to this command.
1588 (if (string= (car jde-debugger) "JDEbug")
1590 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1591 (let* ((debugger (jde-db-get-the-debugger))
1592 (application-main-class
1593 (let ((main-class jde-run-application-class))
1596 (string= main-class ""))
1598 (if (buffer-file-name)
1599 (concat (jde-db-get-package)
1600 (file-name-sans-extension
1601 (file-name-nondirectory (buffer-file-name))))
1602 (read-string "Java class to debug: "))))
1604 (cmd-set (oref debugger cmd-set))
1605 (launch-cmd (oref cmd-set launch-app)))
1608 (jde-db-create-debuggee-app debugger application-main-class)
1610 (if (not (oref debugger running-p))
1611 (jde-db-debugger-start debugger))
1613 (oset-default 'jde-db-debugger the-debugger debugger)
1615 ;; Forward to the debugger any breakpoint requests made
1616 ;; by the user before launching the application.
1617 (if jde-db-breakpoints
1618 (let ((bp-cmd (oref (oref debugger cmd-set) set-bp)))
1622 (mapcar (lambda (assoc-x) (cdr assoc-x)) jde-db-breakpoints))
1623 (jde-db-exec-cmds debugger (list launch-cmd bp-cmd)))
1624 (jde-db-exec-cmd debugger launch-cmd)))))
1626 (defun jde-debugger-running-p ()
1627 "Returns nonnil if the debugger is running."
1630 (string= (car jde-debugger) "JDEbug")
1631 (jde-dbs-debugger-running-p)
1632 (jde-dbs-get-target-process))
1634 (if (slot-boundp (jde-db-get-the-debugger) 'the-debugger)
1635 (oref (jde-db-get-the-debugger) the-debugger))))
1637 (oref debugger running-p)))))
1639 (defun jde-debug-applet-init (applet-class applet-doc-path)
1640 (let* ((debugger (jde-db-get-the-debugger))
1641 (cmd-set (oref debugger cmd-set))
1642 (launch-cmd (oref cmd-set launch-applet))
1643 (debug-buf-name (concat "*debug-" applet-class "*"))
1644 (applet-doc (file-name-nondirectory applet-doc-path))
1645 (applet-doc-directory (file-name-directory applet-doc-path))
1646 (source-directory default-directory)
1648 (if applet-doc-directory
1649 applet-doc-directory
1652 (jde-db-create-debuggee-applet debugger applet-doc-path)
1654 (oset-default 'jde-db-debugger the-debugger debugger)
1656 ;; Forward to the debugger any breakpoint requests made
1657 ;; by the user before launching the application.
1658 (if jde-db-breakpoints
1659 (let ((bp-cmd (oref (oref debugger cmd-set) set-bp)))
1663 (mapcar (lambda (assoc-x) (cdr assoc-x)) jde-db-breakpoints))
1664 (jde-db-exec-cmds debugger (list launch-cmd bp-cmd)))
1665 (jde-db-exec-cmd debugger launch-cmd))))
1670 (defun jde-debug-applet-internal (applet-doc)
1671 (let ((applet-class jde-run-application-class))
1674 (string= applet-class ""))
1676 (concat (jde-db-get-package)
1677 (file-name-sans-extension
1678 (file-name-nondirectory (buffer-file-name))))))
1679 (jde-debug-applet-init applet-class applet-doc)))
1682 (defun jde-debug-applet (&optional doc)
1683 "Runs an applet in the jdb debugger. This function prompts you to enter
1684 the path of an html document that displays the applet. If you
1685 do not enter a path, this function next checks
1686 whether `jde-run-applet-doc' specifies a document. If so, it displays
1687 that specified document. Next, it checks whether the current directory
1688 contains any html files. If so, it displays the first html file that
1689 it finds. If if cannot find an html file, it signals an error. This
1690 function runs appletviewer in jdb to permit debugging. On startup, it
1691 sets a breakpoint in the init method of the class specified by
1692 `jde-run-application-class' or in the class corresponding to the Java
1693 file in the current buffer."
1695 (let ((insert-default-directory nil))
1696 (list (read-file-name "Applet doc: " nil nil nil jde-run-applet-last-doc))))
1697 (setq jde-run-applet-last-doc doc)
1698 (let ((applet-doc-path
1701 (if (and jde-run-applet-doc
1702 (not (string= jde-run-applet-doc "")))
1704 (car (jde-run-find-html-files))))))
1706 (jde-debug-applet-internal applet-doc-path)
1707 (signal 'error "Could not find html document to display applet."))))
1711 (defun jde-debug-run ()
1712 "Start the current debuggee application."
1714 (jde-assert-source-or-debug-buffer)
1715 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1716 (debuggee (oref debugger debuggee))
1717 (debuggee-status (oref debuggee status)))
1718 (if (and (oref debugger running-p)
1719 (oref debuggee-status running-p))
1720 (error "Application %s is already running."
1721 (oref debuggee main-class))
1722 (let* ((cmd-set (oref debugger cmd-set))
1723 (run (oref cmd-set run)))
1724 (oset debuggee-status running-p t)
1725 (oset debuggee-status stopped-p nil)
1726 (oset debuggee-status suspended-p nil)
1727 (jde-db-exec-cmd debugger run)))))
1730 (defun jde-debug-cont ()
1731 "Continues the current debuggee application from its current
1734 (jde-assert-source-or-debug-buffer)
1735 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1736 (debuggee (oref debugger debuggee))
1737 (debuggee-status (oref debuggee status)))
1738 (if (and (oref debugger running-p)
1740 (oref debuggee-status stopped-p)
1741 (oref debuggee-status suspended-p)))
1742 (let* ((cmd-set (oref debugger cmd-set))
1743 (cont (oref cmd-set cont)))
1744 (oset debuggee-status stopped-p nil)
1745 (oset debuggee-status suspended-p nil)
1746 (jde-db-exec-cmd debugger cont))
1747 (let ((class (oref debuggee main-class)))
1748 (message "Application %s is not stopped" class)))))
1751 (defun jde-debug-quit ()
1752 "Quit debugging the current application."
1754 (jde-assert-source-or-debug-buffer)
1755 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1756 (debuggee (oref debugger debuggee))
1757 (debuggee-status (oref debuggee status)))
1758 (if (and (oref debugger running-p)
1759 (oref debuggee-status running-p))
1760 (let* ((cmd-set (oref debugger cmd-set))
1761 (quit (oref cmd-set quit)))
1762 (jde-db-exec-cmd debugger quit))
1763 (let ((class (oref debuggee main-class)))
1764 (error "Application %s is not running" class)))))
1766 (defun jde-debug-step-over ()
1767 "Step to the next line in the current stack frame."
1769 (jde-assert-source-or-debug-buffer)
1770 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1771 (debuggee (oref debugger debuggee))
1772 (debuggee-status (oref debuggee status)))
1773 (if (and (oref debugger running-p)
1774 (oref debuggee-status stopped-p))
1775 (let* ((cmd-set (oref debugger cmd-set))
1776 (step-over (oref cmd-set step-over)))
1777 (oset debuggee-status stopped-p nil)
1778 (jde-db-exec-cmd debugger step-over))
1779 (let ((class (oref debuggee main-class)))
1780 (error "Application %s is not stopped" class)))))
1782 (defun jde-debug-step-into ()
1783 "Step to the next line in the current program."
1785 (jde-assert-source-or-debug-buffer)
1786 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1787 (debuggee (oref debugger debuggee))
1788 (debuggee-status (oref debuggee status)))
1789 (if (and (oref debugger running-p)
1790 (oref debuggee-status stopped-p))
1791 (let* ((cmd-set (oref debugger cmd-set))
1792 (step-into (oref cmd-set step-into)))
1793 (oset debuggee-status stopped-p nil)
1794 (jde-db-exec-cmd debugger step-into))
1795 (let ((class (oref debuggee main-class)))
1796 (error "Application %s is not stopped" class)))))
1798 (defun jde-debug-step-out ()
1799 "Continue execution to the end of the current method."
1801 (jde-assert-source-or-debug-buffer)
1802 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1803 (debuggee (oref debugger debuggee))
1804 (debuggee-status (oref debuggee status)))
1805 (if (and (oref debugger running-p)
1806 (oref debuggee-status stopped-p))
1807 (let* ((cmd-set (oref debugger cmd-set))
1808 (step-out (oref cmd-set step-out)))
1809 (oset debuggee-status stopped-p nil)
1810 (jde-db-exec-cmd debugger step-out))
1811 (let ((class (oref debuggee main-class)))
1812 (error "Application %s is not stopped" class)))))
1815 (defun jde-debug-up ()
1816 "Move up the stack."
1818 (jde-assert-source-or-debug-buffer)
1819 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1820 (debuggee (oref debugger debuggee))
1821 (debuggee-status (oref debuggee status)))
1822 (if (and (oref debugger running-p)
1823 (oref debuggee-status stopped-p))
1824 (let* ((cmd-set (oref debugger cmd-set))
1825 (up (oref cmd-set up)))
1826 (jde-db-exec-cmd debugger up))
1827 (let ((class (oref debuggee main-class)))
1828 (error "Application %s is not stopped" class)))))
1830 (defun jde-debug-down ()
1831 "Move down the stack."
1833 (jde-assert-source-or-debug-buffer)
1834 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1835 (debuggee (oref debugger debuggee))
1836 (debuggee-status (oref debuggee status)))
1837 (if (and (oref debugger running-p)
1838 (oref debuggee-status stopped-p))
1839 (let* ((cmd-set (oref debugger cmd-set))
1840 (down (oref cmd-set down)))
1841 (jde-db-exec-cmd debugger down))
1842 (let ((class (oref debuggee main-class)))
1843 (error "Application %s is not stopped" class)))))
1845 (defun jde-debug-where ()
1846 "Show current stopping point."
1848 (jde-assert-source-or-debug-buffer)
1849 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1850 (debuggee (oref debugger debuggee))
1851 (debuggee-status (oref debuggee status)))
1852 (if (and (oref debugger running-p)
1853 (oref debuggee-status stopped-p))
1854 (let* ((cmd-set (oref debugger cmd-set))
1855 (where (oref cmd-set where)))
1856 (jde-db-exec-cmd debugger where))
1857 (let ((class (oref debuggee main-class)))
1858 (error "Application %s is not stopped" class)))))
1860 (defun jde-db-spec-breakpoint ()
1861 "Creates a specification for the breakpoint at the
1862 current line in the current file. Returns an object of
1863 type `jde-db-breakpoint'."
1864 (let ((file (buffer-file-name)))
1865 (setq jde-db-breakpoint-id-counter
1866 (1+ jde-db-breakpoint-id-counter))
1868 (format "breakpoint: %s %d"
1869 (file-name-nondirectory file)
1870 jde-db-breakpoint-id-counter)
1871 :id jde-db-breakpoint-id-counter
1873 :class (concat (jde-db-get-package)
1874 (jde-db-get-class)))))
1877 (defun jde-debug-set-breakpoint ()
1878 "Ask debugger to set a breakpoint at the current line
1879 in the current buffer."
1881 (let* ((file (buffer-file-name))
1882 (line (jde-get-line-at-point))
1883 (bp (jde-db-find-breakpoint file line)))
1885 (setq bp (jde-db-spec-breakpoint))
1887 (jde-db-breakpoints-add bp)
1888 (if (jde-db-debuggee-running-p)
1889 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1890 (bp-cmd (oref (oref debugger cmd-set) set-bp)))
1891 (oset bp-cmd breakpoints (list bp))
1892 (jde-db-exec-cmd debugger bp-cmd))))))
1894 (defun jde-debug-clear-breakpoint()
1895 "Clear the breakpoint at the current line in the current buffer."
1897 (jde-assert-source-buffer)
1898 (let* ((file (buffer-file-name))
1899 (line (jde-get-line-at-point))
1900 (bp (jde-db-find-breakpoint file line)))
1902 (if (jde-db-debuggee-running-p)
1903 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1904 (bp-cmd (oref (oref debugger cmd-set) clear-bp)))
1905 (oset bp-cmd breakpoints (list bp))
1906 (jde-db-exec-cmd debugger bp-cmd))
1907 (jde-db-delete-breakpoint bp)))))
1909 (defun jde-debug-toggle-breakpoint ()
1910 "Sets or clears a breakpoint at the current line."
1912 (assert (eq major-mode 'jde-mode) nil
1913 "This command works only in a Java source buffer.")
1914 (let* ((file (buffer-file-name))
1915 (line (jde-get-line-at-point))
1916 (bp (jde-db-find-breakpoint file line)))
1917 (assert (jde-db-src-dir-matches-file-p file) nil
1918 "You cannot set a breakpoint in a file that is not in `jde-sourcepath'.")
1920 (jde-debug-clear-breakpoint)
1921 (jde-debug-set-breakpoint))))
1923 (defun jde-debug-clear-breakpoints()
1924 "Clear all existing breakpoints."
1926 (if jde-db-breakpoints
1927 (if (jde-db-debuggee-running-p)
1928 (let* ((debugger (oref 'jde-db-debugger the-debugger))
1929 (bp-cmd (oref (oref debugger cmd-set) clear-bp)))
1934 (lambda (assoc-x) (cdr assoc-x))
1935 jde-db-breakpoints))
1936 (jde-db-exec-cmd debugger bp-cmd))
1937 (loop for bp-assoc in jde-db-breakpoints do
1938 (let ((bp (cdr bp-assoc)))
1939 (jde-db-delete-breakpoint bp))))))
1942 (defvar jde-db-minibuffer-local-map nil
1943 "Keymap for minibuffer prompting of jdb startup command.")
1944 (if jde-db-minibuffer-local-map
1946 (setq jde-db-minibuffer-local-map (copy-keymap minibuffer-local-map))
1948 jde-db-minibuffer-local-map "\C-i" 'comint-dynamic-complete-filename))
1951 (defun class-from-file-name (file-name)
1952 (file-name-sans-extension (file-name-nondirectory file-name)))
1955 (defun jde-db-get-vm-args-from-user ()
1956 (if jde-db-read-vm-args
1958 (read-from-minibuffer
1960 (car jde-db-interactive-vm-arg-history)
1962 'jde-db-interactive-vm-arg-history))))
1964 (defun jde-db-get-app-args-from-user ()
1965 (if jde-db-read-app-args
1967 (read-from-minibuffer
1968 "Application args: "
1969 (car jde-db-interactive-app-arg-history)
1971 'jde-db-interactive-app-arg-history))))
1974 (defun jde-db-get-package ()
1975 "Return the package of the class whose source file resides in the current
1978 (goto-char (point-min))
1979 (if (re-search-forward "^[ \t]*\\<\\(package\\) +\\([^ \t\n]*\\) *;" (point-max) t)
1980 (concat (buffer-substring-no-properties (match-beginning 2) (match-end 2))
1983 (defun jde-db-get-class () "Lookups and return fully qualified class
1984 name, e.g. A$B if point is in inner class B of A."
1986 (let ((class-info (jde-parse-get-innermost-class-at-point)))
1989 (goto-char (cdr class-info))
1990 (let ((parent (jde-db-get-class)))
1993 (concat parent "$" (car class-info))))))))
1996 (defun jde-db-src-dir-matches-file-p (file)
1997 "Return true if one of `jde-sourcepath'
1999 (let* ((directory-sep-char ?/)
2000 (filename (jde-normalize-path file)))
2016 ;; $Log: jde-db.el,v $
2017 ;; Revision 1.131 2005/01/18 05:23:31 paulk
2018 ;; Change variables named assoc to assoc-x. This is intended to fix a "Symbol's value as variable is void: old-assoc" problem when debugging with the compiled version of JDE in xemacs/cygwin. Thanks to Henry S. Thompson.
2020 ;; Revision 1.130 2004/12/06 05:50:51 paulk
2021 ;; Fix problem in jde-debugger-running-p.
2023 ;; Revision 1.129 2004/12/06 05:38:30 paulk
2024 ;; Fixed regression in jde-debugger-running-p and moved it from jde.el to this package.
2026 ;; Revision 1.128 2004/09/20 05:30:36 paulk
2027 ;; Changes needed to make restructured debugging code work for applets.
2029 ;; Revision 1.127 2004/09/02 04:50:19 paulk
2030 ;; More infrastructure work to support applet debugging.
2032 ;; Revision 1.126 2004/09/01 06:20:32 paulk
2033 ;; Restructured to accommodate debugging applets.
2035 ;; Revision 1.125 2004/06/21 15:03:51 jslopez
2036 ;; Fixes problem with jdb breakpoints. Opening a new java file after setting a
2037 ;; breakpoint will prevent the user from removing the breakpoint. The method
2038 ;; jde-db-remark-breakpoints was not taking into account if the current buffer was
2039 ;; the same as the buffer of the breakpoint. This has the side effect of messing
2040 ;; th e markers for all the breakpoints that did not belong to the current buffer.
2042 ;; Revision 1.124 2004/05/14 03:18:24 paulk
2043 ;; Moved jde-line-beginning-position and jde-line-end-position from
2044 ;; jde-db.el to jde-util.el. Ultimately, these functions should be
2045 ;; replaced by line-beginning-position and line-end-position as
2046 ;; jde-xemacs.el provides XEmacs definitions for both functions.
2048 ;; Revision 1.123 2004/02/18 13:42:20 jslopez
2049 ;; Prevents issuing multiple set breakpoint commands to jdb once a breakpoint is
2052 ;; Revision 1.122 2004/02/10 05:13:21 jslopez
2053 ;; Adds the option "gigabytes" for stack size and heap size.
2055 ;; Revision 1.121 2003/09/18 05:28:29 paulk
2056 ;; Created a set of proxie classes for standard JPDA connectors. Added
2057 ;; a connector slot to jde-db-debuggee class. This is intended to
2058 ;; support connecting a debugger to a debuggee class in attach or
2061 ;; Revision 1.120 2003/05/28 05:54:20 paulk
2062 ;; Deleted definition of jde-db-startup-commands variable, which is no longer used.
2064 ;; Revision 1.119 2003/05/14 06:36:42 paulk
2065 ;; Replace jde-db-option-connect-address with jde-db-option-listen-address and
2066 ;; jde-db-option-attach-address.
2068 ;; Revision 1.118 2003/05/13 05:03:47 paulk
2069 ;; Change the jde-db-option-connect-address variable so that a nil
2070 ;; value means that the debugger attach and listen commands should
2071 ;; prompt for a connect address.
2073 ;; Revision 1.117 2003/03/28 05:33:29 andyp
2074 ;; XEmacs optimizations for JDEbug and efc.
2076 ;; Revision 1.116 2003/02/26 03:30:52 jslopez
2077 ;; Adds color to the list of breakpoints.
2078 ;; The color correspond to the status of the breakpoint, active, speficied,
2081 ;; Revision 1.115 2003/02/25 17:45:26 jslopez
2082 ;; Removes the file name from the breakpoints list.
2083 ;; Changes the format to class:line number.
2085 ;; Revision 1.114 2003/02/25 06:53:29 paulk
2086 ;; Created a generalized jde-debug command and wired it up to jdb.
2087 ;; Next step is to wire it up to JDEbug.
2089 ;; Revision 1.113 2003/01/12 19:15:20 jslopez
2090 ;; Adds function jde-debug-list-breakpoints.
2092 ;; Revision 1.112 2002/10/30 12:59:59 paulk
2093 ;; Fixed XEmacs compatibility fix for beginning/end-of-line functions
2094 ;; and moved the fix from jde-bug.el to this file where the
2095 ;; functions are used. Thanks to Daniel Serodio and Eric Ludlum.
2097 ;; Revision 1.111 2002/08/27 04:19:01 paulk
2098 ;; Fixes bug in jde-db-src-dir-matches-file-p. Thanks to Andy Piper.
2100 ;; Revision 1.110 2002/08/10 03:18:30 paulk
2101 ;; Modified jde-db-breakpoint-marker class so that breakpoint highlighting extends
2102 ;; the entire width of the buffer window--not just to the end of the line.
2103 ;; Thanks to Kevin A. Burton.
2105 ;; Revision 1.109 2002/08/07 06:36:18 paulk
2106 ;; Removed code intended to eliminate spurious warnings when byte-compiling the JDEE. The
2107 ;; removed code now resides in a separate package, jde-compat.el. Thanks to Andy Piper
2108 ;; for suggesting this restructuring. Also fixed a number of compiler warnings caused
2111 ;; Revision 1.108 2002/07/12 12:20:27 jslopez
2112 ;; Fixes jde-db-option-verbose when set to load classes.
2113 ;; It was appending -v instead -f -verbose:class.
2115 ;; Revision 1.107 2002/06/17 07:24:08 paulk
2116 ;; Updated the JDEE's applet debugging command to
2117 ;; work with its new jdb interface.
2119 ;; Revision 1.106 2002/06/12 07:04:28 paulk
2120 ;; XEmacs compatibility fix: set win32-quote-process-args wherever
2121 ;; the JDEE sets w32-quote-process-args. This allows use of spaces in
2122 ;; paths passed as arguments to processes (e.g., javac) started by
2125 ;; Revision 1.105 2002/06/11 06:34:38 paulk
2126 ;; Provides support for paths containing spaces as jdb arguments via the following change:
2127 ;; locally set the w32-quote-process-args variable to a quotation mark when launching
2130 ;; Revision 1.104 2002/05/21 06:34:27 paulk
2131 ;; Updated to support J2SDK 1.4.0 version of jdb.
2133 ;; Revision 1.103 2002/05/12 06:37:33 paulk
2134 ;; Moved jde-db-search-src-dirs to the jde-util package as jde-search-src-dirs.
2136 ;; Revision 1.102 2002/03/31 07:49:51 paulk
2137 ;; Renamed jde-db-source-directories. The new name is jde-sourcepath.
2139 ;; Revision 1.101 2002/03/12 04:43:38 paulk
2140 ;; Removed initarg for class slots to silence eieio warning.
2142 ;; Revision 1.100 2002/03/06 13:00:18 paulk
2143 ;; * Removed references to obsolete jde-db-option-attach variable.
2144 ;; * The jdb launch, attach, and listen commands now update the
2145 ;; the-debugger field in the jde-db-debugger class.
2147 ;; Revision 1.99 2002/03/04 06:43:41 paulk
2148 ;; Adds support for connecting debugger to an independently started
2149 ;; process, using either attach or listen mode.
2151 ;; Revision 1.98 2002/02/04 05:47:17 paulk
2152 ;; Added code to rehighlight breakpoints if the user kills a
2153 ;; buffer for a source file that contains breakpoints and
2154 ;; then reopens the file.
2156 ;; Revision 1.97 2002/01/19 06:42:22 paulk
2159 ;; Revision 1.96 2002/01/15 13:33:27 paulk
2160 ;; Adds a Clear Breakpoints command for jdb.
2162 ;; Revision 1.95 2002/01/14 13:30:42 paulk
2163 ;; - Now defines three breakpoint marker colors: green for a specified breakpoint,
2164 ;; yellow for a requested breakpoint, and red for an enabled breakpoint.
2166 ;; - The debug application command now requests all specified
2167 ;; breakpoints at the beginning of a debug session.
2169 ;; - The debug application command now changes the color of all breakpoints
2170 ;; to specified at the end of a debug session.
2172 ;; Revision 1.94 2002/01/11 05:43:37 paulk
2173 ;; - Use overlays/extents to record location of breakpoints in a buffer.
2174 ;; - Use different colors to indicate requested and enabled breakpoints.
2176 ;; Revision 1.93 2002/01/04 07:12:17 paulk
2177 ;; Fixed XEmacs compatibility bug that caused the toggle
2178 ;; breakpoint command to signal an error that it could not
2179 ;; find the source file in jde-db-source-directories.
2181 ;; Revision 1.92 2002/01/02 05:29:45 paulk
2182 ;; Added a stack-depth field to the jde-db-debuggee class.
2184 ;; Revision 1.91 2001/12/31 07:51:09 paulk
2185 ;; Implemented generalized quit, step-over, step-into, stack up, stack down,
2186 ;; and stack where commands.
2188 ;; Revision 1.90 2001/12/28 05:32:55 paulk
2189 ;; Implemented generalized debuggee process run and continue commands.
2191 ;; Revision 1.89 2001/12/17 08:02:05 paulk
2192 ;; Initial version of generalized clear breakpoint command. Created generalized
2193 ;; classes to represent the debuggee process.
2195 ;; Revision 1.88 2001/12/14 05:08:37 paulk
2196 ;; Setup generic methods for processing the debugger output and status
2197 ;; change notification.
2199 ;; Revision 1.87 2001/12/10 04:29:55 paulk
2200 ;; Created generalized breakpoint framework. Provided initial
2201 ;; implementation for jdb. A lot of work remains.
2203 ;; Revision 1.86 2001/12/04 05:37:35 paulk
2204 ;; Moved jdb related code to jde-jdb.el.
2206 ;; Revision 1.85 2001/11/30 03:08:03 jslopez
2207 ;; Fixes reference to free variables.
2209 ;; Revision 1.84 2001/11/27 08:03:46 paulk
2210 ;; Updated jdb-db to invoke the version of jdb appropriate to the JDK for the current project.
2212 ;; Revision 1.83 2001/11/26 02:45:51 paulk
2213 ;; Added reference to jde-db-source-directories in invocation of jde-normalize-path
2214 ;; in jde-db-src-dir-matches-file-p.
2216 ;; Revision 1.82 2001/11/25 06:34:12 paulk
2217 ;; Added function jde-db-src-dir-matches-file-p. Thanks to
2218 ;; Kevin Burton for initial implementation.
2220 ;; Revision 1.81 2001/11/04 14:58:05 paulk
2221 ;; Restored jde-db-classic-mode-vm option.
2223 ;; Revision 1.80 2001/11/04 14:51:23 paulk
2224 ;; Fixed typo in classic mode argument (i.e., -tclassic should be -classic).
2226 ;; Revision 1.79 2001/09/30 05:29:32 paulk
2227 ;; Changed the name of the customization variable jde-db-debugger to be consistent with jde-compiler and to avoid conflict with jde-db-debugger class.
2229 ;; Revision 1.78 2001/09/28 04:48:00 paulk
2230 ;; Defines a new eieio class of debuggers that serves as the parent
2231 ;; for jdb and JDEbug debuggers. Create a jde-db-jdb class that serves
2232 ;; as the root of jdb and oldjdb.
2234 ;; Revision 1.77 2001/07/31 05:11:50 paulk
2237 ;; Revision 1.76 2001/04/16 05:49:34 paulk
2238 ;; Normalized paths. Thanks to Nick Sieger.
2240 ;; Revision 1.75 2001/04/12 04:42:23 paulk
2241 ;; Normalize jde-run-working-directory.
2243 ;; Revision 1.74 2001/04/11 03:21:33 paulk
2244 ;; Updated to resolve relative paths relative to the project file that defines them. Thanks to Nick Sieger.
2246 ;; Revision 1.73 2001/04/08 04:14:29 paulk
2247 ;; jdb interface has been fixed to work around JDK 1.3 bug that causes the jdb command prompt to sometimes appear in the wrong place in jdb output. Thanks to Andy Bennett <andrew.bennett@ericsson.com> for this fix.
2249 ;; Revision 1.72 2001/03/16 04:07:03 paulk
2250 ;; Fixed regular expression for finding package in source buffer so that there must be a space between package and the package name. This is to prevent false hits. Thanks to Rory Molinari <molinari@math.lsa.umich.edu>.
2252 ;; Revision 1.71 2001/03/13 04:14:54 paulk
2253 ;; Split jde-find-class-source into to files, one of which returns the path of the source file while the other opens the file in a buffer.
2255 ;; Revision 1.70 2001/02/26 04:17:50 paulk
2256 ;; jde-db now handles case where jde-global-classpath and jde-db-option-classpath are nil.
2258 ;; Revision 1.69 2001/02/03 08:44:56 paulk
2259 ;; Changed declaration of customized variables to allow path completion.
2260 ;; Now allows environment variables in jde-db-source-directories.
2262 ;; Revision 1.68 2001/02/03 07:28:06 paulk
2263 ;; Now uses generalized jde-build-classpath function to build classpath argument to debugger.
2265 ;; Revision 1.67 2000/12/18 05:22:45 paulk
2266 ;; *** empty log message ***
2268 ;; Revision 1.66 2000/10/10 06:36:59 paulk
2269 ;; Fixed bug where selecting Other and Executable as the debugger results in the executable name being inserted twice.
2271 ;; Revision 1.65 2000/10/08 12:55:39 paulk
2272 ;; *** empty log message ***
2274 ;; Revision 1.64 2000/08/19 06:46:22 paulk
2275 ;; Updated to handle JDK 1.3 version of jdb. Source pointer now moves to
2276 ;; current location in current stack frame.
2278 ;; Revision 1.63 2000/06/12 08:37:43 paulk
2279 ;; Now displays JDEbug menu when running XEmacs.
2281 ;; Revision 1.62 2000/05/10 05:41:32 paulk
2282 ;; The JDEbug menu now appears or disappears when you select or deselect JDEbug as the current debugger.
2284 ;; Revision 1.61 2000/03/16 05:08:25 paulk
2285 ;; Added JDEbug option to jde-db-debugger.
2287 ;; Revision 1.60 2000/03/08 05:40:01 paulk
2288 ;; jde-db-format-command now signals an error it it cannot determine the containing class.
2290 ;; Revision 1.59 2000/02/10 02:50:32 paulk
2291 ;; Replaced jde expand file name function with expand-file-name.
2293 ;; Revision 1.58 2000/02/01 04:08:12 paulk
2294 ;; Modified the Jdb->Set Breakpoint command (gud-break) to set breakpoints correctly
2295 ;; in inner classes.
2297 ;; Revision 1.57 2000/01/15 08:01:52 paulk
2298 ;; Reimplemented directory search functions.
2300 ;; Revision 1.56 1999/11/16 05:58:17 paulk
2301 ;; Added trace method commands and skeletons for trace class and cancel
2304 ;; Revision 1.55 1999/11/04 05:49:10 paulk
2305 ;; Amended jde-db-make-qualified-class-name-regexp to permit package names to begin
2306 ;; with non-word characters, e.g., underscores. Contributed by "Patrick J. McNerthney"
2307 ;; <pat@mcnerthney.com>.
2309 ;; Revision 1.54 1999/09/28 04:06:59 paulk
2310 ;; Supplied missing left parentheses.
2312 ;; Revision 1.53 1999/09/05 04:33:28 paulk
2313 ;; Added support for running vm in classic mode.
2315 ;; Revision 1.52 1999/03/10 16:55:02 paulk
2316 ;; Fixed jde-db-find-file to return the current buffer if it cannot find a file and
2317 ;; XEmacs is the editor.
2319 ;; Revision 1.51 1999/03/06 00:55:38 paulk
2320 ;; Changed default value of jde-db-source-directories to be nil.
2322 ;; Revision 1.50 1999/03/06 00:44:08 paulk
2323 ;; Make sure that case-sensitive matching is used when extracting package names from
2324 ;; debugger breakpoint messages.
2326 ;; Revision 1.49 1999/02/26 15:52:52 paulk
2327 ;; Catch non-existent directory errors when searching for source
2328 ;; files and packages. Thanks to Thanh Nguyen <Thanh.Nguyen@Eng.Sun.COM>
2329 ;; for finding and providing a fix for this bug.
2331 ;; Revision 1.48 1999/02/25 15:24:43 paulk
2332 ;; Fixed jde-db-find-file so that it displays an error when it cannot find a file instead of
2333 ;; opening an empty source buffer.
2335 ;; Provided a set-value function for jde-db-source-directories that appends a slash to
2336 ;; the end of each path if the path does not already end in a slash.
2338 ;; Defined a new command, jde-find-class-source, that finds and opens the source file
2339 ;; for a specified class.
2341 ;; Improved the regular expression used by jde-db-get-package to ignore tabs at the
2342 ;; beginning of a line.
2344 ;; Revision 1.47 1999/02/15 02:02:35 paulk
2345 ;; Forgot to concatenate in last fix.
2347 ;; Revision 1.46 1999/02/15 00:52:44 paulk
2348 ;; Fixed bug in qualified-class-name-regexp.
2350 ;; Revision 1.45 1999/02/10 18:35:51 paulk
2351 ;; Added support for appletviewer -encoding and -J options.
2353 ;; Revision 1.44 1999/02/08 17:18:17 paulk
2354 ;; jde-db-applet now supports file completion and remembers the last path entered.
2356 ;; Revision 1.43 1999/02/06 03:55:11 paulk
2357 ;; Fixed bug and generalized regular expression in jde-db-make-qualified-class-name-regexp.
2359 ;; Revision 1.42 1999/02/03 18:12:03 paulk
2360 ;; Fixed regular expression in jde-db-get-package to eliminate spurious hits, e.g.
2361 ;; commented out package statements. Thanks to Frederic Baumann <baumann@ilog.fr>
2362 ;; for reporting this bug.
2364 ;; Revision 1.41 1999/02/03 17:48:34 paulk
2365 ;; Patched jde-db-get-app-args-from-user to remember arguments.
2366 ;; Thanks to Brian Burton <brian@burton-computer.com>
2368 ;; Revision 1.40 1999/02/03 17:41:56 paulk
2369 ;; Fixed jde-db-make-qualified-class-name-regexp to handle packages with underscores.
2370 ;; Thanks to Brian Burton <brian@burton-computer.com>.
2372 ;; Revision 1.39 1999/02/03 17:26:46 paulk
2373 ;; Changed jde-db-make-qualified-class-name-regexp to handle inner classes.
2374 ;; Thanks to Michael Lepore <lepore@process.com> for this fix.
2376 ;; Revision 1.38 1999/02/03 01:53:49 paulk
2377 ;; Fixed jde-db-applet to check the current directory for the html file to run.
2379 ;; Revision 1.37 1999/02/02 16:06:01 paulk
2380 ;; Added the jde-db-applet command. This command allows you to debug an applet, using
2383 ;; Revision 1.36 1999/02/02 15:25:28 paulk
2384 ;; Removed unwanted space in -D (properties) debug option.
2386 ;; Revision 1.35 1999/01/17 00:36:43 paulk
2387 ;; Now uses gud-find-c-expr or find-c-expr, whichever is bound.
2389 ;; Revision 1.34 1999/01/13 22:18:08 paulk
2390 ;; Added Andy Piper's NT/XEmacs 21 compatibility changes.
2391 ;; Changed find-c-expr to gud-findc-expr
2393 ;; Revision 1.33 1998/11/22 18:18:36 paulk
2394 ;; Made comint-prompt-regexp and paragraph-start local variables.
2396 ;; Revision 1.32 1998/11/04 02:59:09 paulk
2397 ;; Corrected verbiage in Jde Debugger Options description.
2399 ;; Revision 1.31 1998/09/12 00:05:57 paulk
2400 ;; Debugger now runs application from directory specified by jde-run-working-directory.
2402 ;; Revision 1.30 1998/06/30 04:03:19 paulk
2403 ;; Added variables `jde-db-read-vm-args' and `jde-db-read-app-args'. The use of
2404 ;; these variables is the same as the corresponding jde-run variables.
2406 ;; Revision 1.29 1998/06/29 02:50:44 paulk
2407 ;; Fixed bug in marker filter.
2409 ;; Revision 1.28 1998/06/27 03:34:31 paulk
2410 ;; Provided a hack to handle reordering of threaded messages on Solaris.
2412 ;; Provided code to handle case where current class has no line number
2415 ;; Revision 1.27 1998/06/25 04:27:23 paulk
2416 ;; Removed debug messages from jde-db-marker-filter.
2418 ;; Revision 1.26 1998/06/25 04:21:10 paulk
2419 ;; Modified jde-db-marker-filter to accummulate debugger output
2420 ;; in chunks. Fixes bug reported by Eric Prud'hommeaux (eric@w3.org).
2422 ;; Revision 1.25 1998/06/22 03:52:28 paulk
2423 ;; Added jde-db-startup-commands variable. This variable allows you to
2424 ;; specify debugger commands to run when the debugger is started.
2426 ;; Revision 1.24 1998/06/21 00:09:43 paulk
2427 ;; Added a customizable feature, jde-db-set-initial-breakpoint, that causes
2428 ;; the JDE to set an initial breakpoint in an app's main routine and run
2429 ;; to the breakpoint on debugger startup. The feature is enabled by default.
2431 ;; Revision 1.23 1998/06/20 23:42:07 paulk
2432 ;; Made jde-db-marker-regexp a custom variable to facilitate the use of the JDE
2433 ;; with debuggers other than jdb.
2435 ;; Changed the marker regular expression to detect only jdb breakpoint messages,
2436 ;; i.e., messages of the form
2438 ;; Breakpoint hit: qualified.class.name (class:line)
2440 ;; This should eliminate the problem of spurious hits when exceptions occur and
2441 ;; stack traces are printed.
2443 ;; Revision 1.22 1998/05/27 06:09:46 paulk
2444 ;; Added autoload comments.
2446 ;; Revision 1.21 1998/03/27 04:16:12 kinnucan
2447 ;; Fixed typo in the code that displays the jdb menu on XEmacs.
2449 ;; Revision 1.20 1998/03/27 04:14:53 kinnucan
2450 ;; Modified jde-db-search-src-dirs to take current package as an
2451 ;; argument rather than use a global variable. This allows
2452 ;; it to be used by jde-java-build function.
2454 ;; Revision 1.19 1998/03/18 03:54:06 kinnucan
2455 ;; Changed jde-db-marker-regexp to account for inner classes.
2456 ;; Thanks to Andreas Rasmusson <Andreas.Rasmusson@sics.se> for
2457 ;; providing this fix.
2459 ;; Revision 1.18 1998/03/04 04:28:36 kinnucan
2460 ;; Added test for jde-run-application-class = "" to jde-db
2462 ;; Revision 1.17 1998/02/27 22:16:34 kinnucan
2463 ;; Changed copyright to Paul Kinnucan.
2464 ;; Have not yet assigned rights to FSF.
2466 ;; Revision 1.16 1998/02/27 22:15:24 kinnucan
2467 ;; Added support for Emacs customization feature.
2469 ;; Revision 1.15 1998/02/17 04:16:38 kinnucan
2470 ;; Fixed bug in jde-deb-set-source-paths that caused the last
2471 ;; directory to not be normalized (i.e., slash appended).
2473 ;; Revision 1.14 1998/02/12 05:15:38 kinnucan
2474 ;; Changed the jde-db-search-src-dirs to search the source directory list from
2475 ;; front to back instead of back to front. The former search order did not allow newer versions of the same class to shadow older versions. Thanks to "David J. Biesack" <sasdjb@unx.sas.com> for supplying this fix.
2477 ;; Revision 1.13 1998/02/12 04:57:13 kinnucan
2478 ;; Fixed bug in jde-db-marker-filter that sometimes prevented the JDE from
2479 ;; loading the correct source file. Thanks to David J. Biesack
2480 ;; <sasdjb@unx.sas.com> for supplying the fix.
2482 ;; Revision 1.12 1997/10/30 05:42:37 kinnucan
2483 ;; Made configuration variables settable.
2485 ;; Revision 1.11 1997/10/26 05:49:59 kinnucan
2486 ;; Applied Derek Young's patch to cause jde to qualify class names
2487 ;; when setting a breakpoint.
2489 ;; Revision 1.10 1997/10/20 05:27:48 kinnucan
2490 ;; Removed reference to deleted function jde-db-massage-args
2492 ;; Revision 1.9 1997/10/11 01:36:05 kinnucan
2493 ;; Fixed bug in jde-db-search-src-dirs discovered by Jonathan Payne.
2495 ;; Revision 1.8 1997/10/06 14:40:53 kinnucan
2496 ;; Fixed bugs in jde-db-set-debugger command.
2498 ;; Revision 1.7 1997/10/05 21:20:15 kinnucan
2499 ;; 1. Added the variables jde-db-debugger and jde-db-debugger-is-executable
2500 ;; and the associated setter function jde-db-set-debugger. These allow
2501 ;; you to specify a custom debugger for the JDE>
2503 ;; 2. Added jde-db-args and jde-db-app-args and the associated setter
2504 ;; functions. These allow you to specify debugger and application
2505 ;; command line arguments.
2507 ;; Revision 1.6 1997/10/05 04:53:04 kinnucan
2508 ;; Fixed bug in print object menu item.
2510 ;; Revision 1.5 1997/08/26 14:53:39 paulk
2511 ;; Fixed bug in check-source-path.
2513 ;; Revision 1.4 1997/08/26 08:52:14 kinnucan
2514 ;; Tweaked JDE Version number for JDE 1.8 release.
2516 ;; Revision 1.3 1997/07/05 04:18:10 kinnucan
2517 ;; Updated make-jdb-command to run either the class previously specifed with
2518 ;; the jde-run-set-app command or the class corresponding to the code in the
2521 ;; Revision 1.2 1997/06/18 18:45:11 paulk
2522 ;; Added error-checking to jde-db-set-source-paths function. Now checks for
2523 ;; existence of specified directories and appends a terminal slash to paths
2526 ;; Revision 1.1 1997/06/18 17:21:59 paulk
2530 ;;; end of jde-db.el