Initial Commit
[packages] / xemacs-packages / jde / lisp / jde-db.el
1 ;;; jde-db.el -- Debugger mode for jdb.
2 ;; $Revision: 1.131 $ $Date: 2005/01/18 05:23:31 $ 
3
4 ;; Author: Paul Kinnucan <paulk@mathworks.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
7
8 ;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005 Paul Kinnucan.
9
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)
13 ;; any later version.
14
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.
19
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
24 ;;; Commentary:
25
26 ;; This package interfaces emacs to jdb, the debugger
27 ;; distributed as part of JavaSoft's Java
28 ;; Development Kit (JDK).
29
30 ;; Please send bug reports and enhancement suggestions
31 ;; to Paul Kinnucan at <paulk@mathworks.com>
32
33 ;; See end of this file for change history.
34
35 ;;; Code:
36
37 (require 'jde-parse)
38 (require 'eieio)
39 (require 'jde-util)
40 (require 'widget)
41  
42 (eval-when-compile
43   (require 'wid-edit))
44
45 (unless (fboundp 'make-overlay)
46   (require 'overlay))
47
48
49 ;; ======================================================================
50 ;; jde-db variables
51
52            
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
56 `jde-sourcepath'."
57   :group 'jde-project
58   :type 'boolean)
59
60 (defcustom jde-db-mode-hook nil
61   "*Customization hook for jde-db inferior mode."
62   :group 'jde-project
63   :type 'hook
64 )
65
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."
71   :group 'jde-project
72   :type 'boolean)
73
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."
79   :group 'jde-project
80   :type 'boolean)
81
82 (defvar jde-db-interactive-vm-arg-history nil
83 "History of vm arguments read from the minibuffer")
84
85 (defcustom jde-db-read-app-args nil
86 "*Read arguments to be passed to application from the minibuffer."
87   :group 'jde-project
88   :type 'boolean)
89
90 (defvar jde-db-interactive-app-arg-history nil
91 "History of application arguments read from the minibuffer")
92
93 (defcustom jde-db-classic-mode-vm nil
94 "Runs applications in the classic (i.e., not HotSpot) mode when
95 debugging."
96   :group 'jde-project
97   :type 'boolean)
98
99 (defgroup jde-db-options nil
100   "JDE Debugger Options"
101   :group 'jde
102   :prefix "jde-db-option-")
103
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")))
111  
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
123 frees memory.")
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.")))
129
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
136   :type '(repeat (cons 
137                   (string :tag "Property Name") 
138                   (string :tag "Property Value"))))
139
140 (defcustom jde-db-option-heap-size (list
141                                     (cons 1 "megabytes")
142                                     (cons 16 "megabytes"))
143 "*Specify the initial and maximum size of the interpreter heap."
144 :group 'jde-db-options
145 :type '(list
146         (cons (integer :tag "Start")
147              (radio-button-choice (const "bytes")
148                                   (const "kilobytes")
149                                   (const "megabytes")
150                                   (const "gigabytes")))
151         (cons (integer :tag "Max")
152                (radio-button-choice (const "bytes")
153                                     (const "kilobytes")
154                                     (const "megabytes")
155                                     (const "gigabytes")))))
156
157
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
163   :type '(list
164           (cons (integer :tag "C Stack")
165                (radio-button-choice (const "bytes")
166                                     (const "kilobytes")
167                                     (const "megabytes")
168                                     (const "gigabytes")))
169           (cons (integer :tag "Java Stack")
170                (radio-button-choice (const "bytes")
171                                     (const "kilobytes")
172                                     (const "megabytes")
173                                     (const "gigabytes")))))
174
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.")))
183
184 (defcustom jde-db-option-java-profile (cons nil "./java.prof")
185   "*Enable Java profiling."
186   :group 'jde-db-options
187   :type '(cons boolean
188                (file :tag "File"
189                      :help-echo 
190 "Specify where to put profile results here.")))
191
192 (defcustom jde-db-option-heap-profile (cons nil
193                                             (list "./java.hprof"
194                                                   5
195                                                   20
196                                                   "Allocation objects"))
197 "*Output heap profiling data."
198   :group 'jde-db-options
199   :type '(cons boolean
200                (list
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")))))
208                  
209 (defcustom jde-db-option-verify (list nil t)
210   "*Verify classes."
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.")))
217
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
222   :type 'string)
223
224
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
234   :type '(choice
235           (const :menu-tag "Prompt" nil)
236           (list 
237            :menu-tag "Specify" :tag "Socket Address" :inline nil
238            (choice 
239             :tag "Host"
240             (const :menu-tag "Local" nil)
241             (string :menu-tag "Remote" :tag "Name"))
242            (choice 
243             :tag "Port"
244             (const :menu-tag "Default" "4444")
245             (string :menu-tag "Custom")))))
246                         
247                  
248
249
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
259   :type '(choice 
260           (const :menu-tag "Prompt" nil)
261           (string :menu-tag "Specify" :tag "Name")))
262
263
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")))
274
275
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
279 the command line."
280   :group 'jde-db-options
281   :type '(repeat (string :tag "Argument")))
282
283 (defmacro jde-assert-source-or-debug-buffer ()
284   "Asserts that the current buffer is a
285 Java source or a debug buffer."
286   '(assert 
287     (or
288      (eq major-mode 'jde-mode)
289      (and (slot-boundp 'jde-db-debugger 'the-debugger)
290           (eq (current-buffer) 
291               (oref (oref 'jde-db-debugger the-debugger) buffer))))
292     nil 
293     "This command works only in a Java source or debug buffer."))
294
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
299   :type 'boolean)
300
301 (defun jde-db-log-debugger-output (output)
302   (if jde-db-log-debugger-output-flag
303       (let ((buf (get-buffer "debugger output")))
304         (when (not buf)
305           (setq buf (get-buffer-create  "debugger output"))
306           (pop-to-buffer buf))
307         (save-excursion
308           (set-buffer buf)
309           (goto-char (point-max))
310           (insert-string output)))))              
311
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))))
319
320
321 (defun jde-db-debuggee-stopped-p ()
322   "Return t if current debuggee process is stopped."
323   (let ((status (jde-db-get-debuggee-status)))
324      (if status
325          (oref status stopped-p))))
326
327 (defun jde-db-debuggee-suspended-p ()
328   "Return t if current debuggee process is suspended."
329   (let ((status (jde-db-get-debuggee-status)))
330      (if status
331          (oref status suspended-p))))
332
333 (defun jde-db-debuggee-running-p ()
334   "Return t if current debuggee process is running."
335   (let ((status (jde-db-get-debuggee-status)))
336      (if status
337          (oref status running-p))))
338
339
340 ;;;###autoload
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."
344   (interactive
345    "sEnter name of Java interpreter: \nsIs %s executable? (yes): ")
346   (let ((db name)
347         (type
348          (if (stringp is-executable)
349              (if (or
350                   (string= is-executable "")
351                   (eq (aref is-executable 0) ?y))
352                  "Executable"
353                "Class")
354            "Executable")))
355     (setq jde-db-debugger (cons "Other" (cons db type)))))
356
357 ;;;###autoload
358 (defun jde-db-set-args (args)
359   "Specify the arguments (except -classpath) to be passed to the debugger."
360   (interactive 
361    "sEnter arguments: ")
362   (setq jde-db-option-vm-args (jde-run-parse-args args)))
363
364 ;;;###autoload
365 (defun jde-db-set-app-args (args)
366   "Specify the arguments to be passed to the Java application class."
367   (interactive 
368    "sEnter arguments: ")
369   (setq jde-db-option-application-args (jde-run-parse-args args)))
370
371
372 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
373 ;;                                                                            ;;
374 ;; Breakpoints                                                                ;;
375 ;;                                                                            ;;
376 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
377
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."
381   :group 'jde-project
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)))
390
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."
394   :group 'jde-project
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)))
403
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."
407   :group 'jde-project
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)))
416
417
418 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
419 ;;                                                                            ;;
420 ;; Breakpoint Marker Class                                                    ;;
421 ;;                                                                            ;;
422 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
423
424 (defclass jde-db-breakpoint-marker ()
425   ((marker :initarg :marker
426            :documentation
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.")
430
431 (defmethod initialize-instance ((this jde-db-breakpoint-marker) &rest fields)
432   "Create a breakpoint overlay at LINE in FILE."
433   
434   ;; Call parent initializer.
435   (call-next-method)
436
437   (oset this marker
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)))))
442                 (make-extent
443                  (jde-line-beginning-position)
444                  (1+ (jde-line-end-position))))
445           (make-overlay
446            (jde-line-beginning-position)
447            (1+ (jde-line-end-position))
448            (current-buffer) nil t))))
449
450
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)
455         (progn
456           (set-extent-face marker face)
457           (set-extent-priority marker 98))
458       (progn
459         (overlay-put marker  'face face)
460         (overlay-put marker 'priority 98)))))
461
462 (defun jde-db-breakpoint-marker-p (marker)
463   "Return t if overlay is a breakpoint marker overlay."
464     (let ((marker-face 
465            (if (featurep 'xemacs)
466                (extent-property marker 'face nil)
467              (overlay-get marker 'face))))
468       (or
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))))
472
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))))
478
479
480
481 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
482 ;;                                                                            ;;
483 ;; Breakpoint Class                                                           ;;
484 ;;                                                                            ;;
485 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
486 (defclass jde-db-breakpoint ()
487   ((id       :initarg :id
488              :type integer
489              :documentation
490              "Identifies this breakpoint.")
491    (file     :initarg :file
492              :initform ""
493              :type string
494              :documentation
495              "Pathname of file containing this breakpoint.")
496    (line     :initarg :line
497              :type integer
498              :documentation
499              "Number of line at which breakpoint is set.")
500    (marker   :initarg :marker
501              :type (or null jde-db-breakpoint-marker)
502              :initform nil
503              :documentation
504              "Marker used to highlight breakpoint line.")
505    (class    :initarg :class
506              :type string
507              :documentation
508              "Qualified name of class containing breakpoint.")
509    (status   :initarg status
510              :type symbol
511              :initform specified
512              :documentation
513              "Status of this breakpoint. Legal values are `specified', `requested', `active'."))
514   (:allow-nil-initform t)
515   "Class of breakpoints.")
516
517
518 (defmethod initialize-instance ((this jde-db-breakpoint) &rest fields)
519   "Constructor for a breakpoint specification."
520
521   ;; Call parent initializer.
522   (call-next-method)
523
524   (assert (oref this file))
525
526   (oset this 
527         marker 
528         (jde-db-breakpoint-marker "breakpoint marker"))
529   
530   (jde-db-breakpoint-marker-set-face 
531    (oref this marker) 'jde-db-spec-breakpoint-face))
532
533 (defmethod jde-db-breakpoint-get-line ((this jde-db-breakpoint))
534   "Get the number of the line at which this breakpoint is set."
535   (save-excursion
536     (set-buffer (find-file-noselect (oref this file)))
537     (if (oref this marker)
538         (let ((marker-start
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))
543       (oref this line))))
544
545 (defvar jde-db-breakpoints nil
546 "Current breakpoints.")
547
548
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)))
552     (if bp
553         (oref bp marker))))
554
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)))
559     (if marker
560         (jde-db-breakpoint-marker-set-face marker 'jde-db-spec-breakpoint-face))))
561
562 (defun jde-db-mark-breakpoint-active (file line)
563   "Changes the face of the breakpoint marker at LINE in FILE 
564 to the active face."
565   (let ((marker (jde-db-get-breakpoint-marker file line)))
566     (if marker
567         (jde-db-breakpoint-marker-set-face marker 'jde-db-active-breakpoint-face))))
568
569 (defun jde-db-mark-breakpoint-requested (file line)
570   "Changes the face of the breakpoint marker at LINE in FILE 
571 to the active face."
572   (let ((marker (jde-db-get-breakpoint-marker file line)))
573     (if marker
574         (jde-db-breakpoint-marker-set-face marker 'jde-db-requested-breakpoint-face))))
575
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)
583           (if marker
584               (jde-db-breakpoint-marker-set-face marker 'jde-db-spec-breakpoint-face)))))
585
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
590         ;; deleted extent.
591         (let ((bpline (jde-db-breakpoint-get-line bp)))
592           (remove-if
593            (lambda (assoc-x)
594              (let* ((xbp (cdr assoc-x))
595                     (xfile (oref xbp file))
596                     (deletep
597                      (and
598                       (string= (oref bp file) xfile)
599                       (equal bpline (jde-db-breakpoint-get-line  xbp)))))
600                (if deletep
601                    (jde-db-breakpoint-marker-delete
602                     (oref bp marker)))
603                deletep))
604            jde-db-breakpoints))))
605
606 (defun jde-db-clear-breakpoints ()
607   "Clear all breakpoints from all buffers."
608   (mapc
609    (lambda (assoc-x)
610      (let* ((xbp (cdr assoc-x))
611             (file (oref xbp file))
612             (buf (find-buffer-visiting file)))
613        (if buf
614            (save-excursion
615              (set-buffer buf)
616              (let ((xmarker (oref xbp marker)))
617                (jde-db-breakpoint-marker-delete xmarker))))))
618       jde-db-breakpoints)
619   (setq jde-db-breakpoints nil))
620
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."
625   (interactive "i")
626   (if jde-db-breakpoints
627       (progn
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))
633           (erase-buffer))
634         (setq active (not active))
635         (widget-insert "Breakpoints:\n\n")
636         (mapc
637          (lambda (assoc-x)
638            (let* ((xbp (cdr assoc-x))
639                   (id (oref xbp id))
640                   (class (oref xbp class))
641                   (file (oref xbp file))
642                   (line (oref xbp line))
643                   (status (oref xbp status)))
644              (widget-create
645               'checkbox
646               :notify (lambda (widget &rest ignore)
647                         (if (widget-value widget)
648                             (setq jde-db-bp-list
649                                   (delete (widget-get widget :id)
650                                           jde-db-bp-list))
651                           (setq jde-db-bp-list
652                                 (append jde-db-bp-list
653                                         (list (widget-get widget :id))))))
654               :id id
655               active)
656            (if (not active)
657                 (setq jde-db-bp-list (append jde-db-bp-list (list id))))
658             (widget-insert " ")
659             (widget-create 'push-button
660                            :notify (lambda (widget &rest ignore)
661                                      (progn
662                                        (find-file-other-window
663                                         (widget-get widget :file))
664                                        (goto-line
665                                         (widget-get widget :line))))
666                            
667                            :button-face 
668                             (cond
669                              ((eq status 'specified)
670                               'jde-db-spec-breakpoint-face)
671                              ((eq status 'active)
672                               'jde-db-active-breakpoint-face)
673                              (t 'jde-db-requested-breakpoint-face))
674                            :file file
675                            :line line
676                            (format "%s:%d" class line))
677             (widget-insert "\n")))
678          jde-db-breakpoints)
679         (widget-insert "\n")
680         (widget-create 'push-button
681                        :notify (lambda (&rest ignore)
682                                  (jde-debug-list-breakpoints t))
683                        "Clear All")
684         (widget-insert " ")
685         (widget-create 'push-button 
686                        :notify (lambda (&rest ignore)
687                                  (progn
688                                    (jde-db-process-breakpoints)
689                                    (kill-buffer "*Breakpoints List*")))
690                        "Apply Form")
691         (use-local-map widget-keymap)
692         (widget-insert "\n")
693         (widget-setup))
694     (message "No breakpoints")))
695
696 (defun jde-db-process-breakpoints ()
697   "Deletes all the breakpoints found in `jde-db-bp-list'"
698   (if 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)))    
702             (oset 
703              bp-cmd 
704              breakpoints 
705              (mapcar 
706               (lambda (assoc-x)
707                 (jde-db-find-breakpoint-by-id assoc-x))
708               jde-db-bp-list))
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))))))
713
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)))
719
720
721 (defun jde-db-find-breakpoint-by-id (id)
722   "Finds the breakpoint object with ID"
723   (cdr (find-if 
724         (lambda (assoc-x)
725           (let ((bp (cdr assoc-x)))
726             (= (oref bp id) id)))
727         jde-db-breakpoints)))
728
729 (defun jde-db-find-breakpoint (file line)
730   "Finds the breakpoint object for the breakpoint at FILE and LINE."
731   (cdr (find-if 
732         (lambda (assoc-x)
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)))
737
738
739 (defvar jde-db-breakpoint-id-counter 0
740 "Counter for generating breakpoint ids")
741
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)))))))
752
753 (add-hook 'kill-buffer-hook 'jde-db-nullify-breakpoint-markers)
754
755 (defun jde-db-remark-breakpoints ()
756   "Highlights all breakpoints in the current buffer if not 
757 already highlighted."
758   (save-excursion
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)) 
765                 (progn
766                   (goto-line line)
767                   (oset bp
768                         marker 
769                         (jde-db-breakpoint-marker "breakpoint marker"))
770                   (cond
771                    ((eq status 'specified)
772                     (jde-db-mark-breakpoint-specified file line))
773                    ((eq status 'requested)
774                     (jde-db-mark-breakpoint-requested file line))
775                    ((eq status 'active)
776                     (jde-db-mark-breakpoint-active file line))
777                    (t
778                     (error "Unknown breakpoint status: %s"
779                            (symbol-name status))))))))
780     ))
781           
782
783 (add-hook 'jde-mode-hook 'jde-db-remark-breakpoints)
784
785
786 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
787 ;;                                                                            ;;
788 ;; Debug Cursor Handling                                                      ;;
789 ;;                                                                            ;;
790 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
791
792 (defun jde-db-query-source-file (class)
793   (let ((source-file
794          (read-file-name 
795           (format "Cannot find %s source. Enter path: " class))))
796   (if (and
797        source-file
798        (file-exists-p source-file)
799        (not (file-directory-p source-file)))
800       (find-file-noselect source-file))))
801
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))
811          (source-buffer
812           (if source-file         
813               (find-file-noselect source-file)
814             (if jde-db-query-missing-source-files
815                 (jde-db-query-source-file class)))))
816     source-buffer))
817
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))
821          (window 
822           (and buffer
823                (or (get-buffer-window buffer)
824                    (selected-window))))
825           pos) 
826     (if buffer
827         (progn
828           (if (not (get-buffer-window buffer))
829               (set-window-buffer window buffer))
830           (save-excursion
831             (set-buffer buffer)
832             (save-restriction
833               (widen)
834               (goto-line line)
835               (setq pos (point))
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)))
841                    (widen)
842                    (goto-char pos))))
843           (set-window-point window overlay-arrow-position)))))   
844
845
846 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
847 ;;                                                                            ;;
848 ;; Debuggee Process Status Class                                              ;;
849 ;;                                                                            ;;
850 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
851 (defclass jde-db-debuggee-status ()
852   ((running-p   :initarg :running-p
853                 :type boolean
854                 :initform nil
855                 :documentation
856                 "Non-nil if debuggee process is running.")
857    (stopped-p   :initarg :stopped-p
858                 :type boolean
859                 :initform nil
860                 :documentation
861                 "Non-nil if debuggee process is stopped.")
862    (suspended-p :initarg :suspended-p
863                 :type boolean
864                 :initform nil
865                 :documentation
866                 "Non-nil if debuggee process is suspended."))
867   "Status of debuggee process.")
868
869 (defmethod initialize-instance ((this jde-db-debuggee-status) &rest fields)
870   "Status of debuggee process."
871   (call-next-method))
872
873 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
874 ;;                                                                            ;;
875 ;; Debuggee Process Class                                                     ;;
876 ;;                                                                            ;;
877 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
878 (defclass jde-db-connector () ()
879   "Proxy for debugger connectors.")
880
881 (defclass jde-db-launch-connector (jde-db-connector) ()
882   "Launched by the debugger.")
883
884 (defclass jde-db-socket-connector (jde-db-connector) 
885   ((port :initarg :port
886          :type (or null string)
887          :initform nil
888          :documentation
889          "Port to the debuggee process."))
890   "Connect via a socket.")
891
892 (defclass jde-db-shared-memory-connector (jde-db-connector) 
893   ((name  :initarg :name
894           :type (or null string)
895           :initform nil
896           :documentation
897           "Shared memory name of debuggee process."))
898   "Connect via a shared-memory transport (Windows only).")
899
900
901 (defclass jde-db-attach-connector (jde-db-connector) ()
902   "Attaches to debuggee.")
903
904 (defclass jde-db-listen-connector (jde-db-connector) ()
905   "Listens for debuggee.")
906
907
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)
912                 :initform nil
913                 :documentation
914                 "Host on which the debuggee process runs."))
915   "Attach via a socket.")
916
917 (defclass jde-db-shared-memory-attach-connector (jde-db-shared-memory-connector
918                                                  jde-db-attach-connector) 
919   ()
920   "Attach via a shared memory connection.")
921
922 (defclass jde-db-socket-listen-connector (jde-db-socket-connector
923                                           jde-db-listen-connector) 
924   ()
925   "Listen via a socket.")
926
927 (defclass jde-db-shared-memory-listen-connector (jde-db-shared-memory-connector
928                                                  jde-db-listen-connector) 
929   ()
930   "Listen via a shared memory connection.")
931
932
933 (defclass jde-db-debuggee ()
934   ((status      :initarg :status
935                 :type jde-db-debuggee-status
936                 :documentation
937                 "Status of debuggee process.")
938
939   (stack-depth  :initarg :stack-depth
940                 :type string
941                 :initform ""
942                 :documentation
943                 "Stack depth."))
944   "Program being debugged.")
945
946 (defmethod initialize-instance ((this jde-db-debuggee) &rest fields)
947   "Constructs an instance of a debuggee."
948   (call-next-method))
949
950
951 (defclass jde-db-debuggee-app (jde-db-debuggee)
952   ((main-class  :initarg :main-class
953                 :type string
954                 :documentation
955                 "Qualified name of debuggee main class.")
956
957    (connector   :initarg :connector
958                 :type jde-db-connector
959                 :documentation
960                 "Type of connector between this debuggee and the debugger."))
961   "Application being debugged.")
962
963 (defclass jde-db-debuggee-applet (jde-db-debuggee)
964   ((doc :initarg :doc
965         :type string
966         :documentation
967         "Path of applet HTML document."))
968   "Applet being debugged.")
969
970
971 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
972 ;;                                                                            ;;
973 ;; Debugger Command Line Commands                                             ;;
974 ;;                                                                            ;;
975 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
976 (defclass jde-db-cmd ()
977   ((name           :initarg :name
978                    :type string
979                    :documentation
980                    "Name of command.")
981    (debugger       :initarg :debugger
982                    :type jde-db-debugger
983                    :documentation
984                    "Debugger."))
985   "Super class of debugger commands.")
986  
987
988 (defmethod initialize-instance ((this jde-db-cmd) &rest fields)
989   "Constructor for debugger commands."
990   (call-next-method))
991
992 (defmethod jde-db-cmd-init ((this jde-db-cmd))
993   "The debugger invokes this method before executing the 
994 command.")
995
996 (defmethod jde-db-cmd-make-command-line ((this jde-db-cmd))
997   "Creates the command line for this command."
998   (oref this name))
999     
1000 (defmethod jde-db-cmd-notify-response ((this jde-db-cmd) response)
1001   "Invoked when the debugger responds to the command. RESPONSE
1002 is the response.")
1003
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."
1007   t)
1008
1009
1010 (defclass jde-db-cmd-breakpoint (jde-db-cmd)
1011   ((breakpoints :initarg :breakpoints
1012                 :type list
1013                 :documentation
1014                 "List of breakpoint specification."))
1015   "Class of breakpoint commands.")
1016
1017 (defclass jde-db-cmd-launch (jde-db-cmd)
1018   ()
1019    "Launch a debuggee process.")
1020
1021 (defclass jde-db-cmd-launch-app (jde-db-cmd-launch)
1022   ((main-class :initarg :main-class
1023                :type string
1024                :documentation
1025                "Main class of applications to be debugged."))
1026    "Launch an application in debug mode.")
1027
1028 (defmethod initialize-instance ((this jde-db-cmd-launch-app) &rest fields)
1029   (call-next-method)
1030   (oset this name "launch application"))
1031
1032 (defclass jde-db-cmd-launch-applet (jde-db-cmd-launch)
1033   ((doc  :initarg :doc
1034          :type string
1035          :documentation
1036          "Path of applet document."))
1037    "Launch an applet in debug mode.")
1038
1039 (defmethod initialize-instance ((this jde-db-cmd-launch-applet) &rest fields)
1040   (call-next-method)
1041   (oset this name "launch applet"))
1042   
1043 ;; Generic Debugger Command Set.
1044
1045 (defclass jde-db-cmd-set ()
1046   ((debugger          :initarg :debugger
1047                       :type jde-db-debugger
1048                       :documentation
1049                       "Debugger that owns this command set.")
1050    (launch-app        :initarg :launch-app
1051                       :type jde-db-cmd-launch-app
1052                       :documentation
1053                       "Launch debuggee application")
1054    (launch-applet     :initarg :launch-applet
1055                       :type jde-db-cmd-launch-applet
1056                       :documentation
1057                       "Launch debuggee applet")
1058    (run               :initarg :run
1059                       :type jde-db-cmd
1060                       :documentation
1061                       "Starts the current debuggee application.")
1062    (cont              :initarg :cont
1063                       :type jde-db-cmd
1064                       :documentation
1065                       "Continues the current debuggee application.")
1066    (quit              :initarg :quit
1067                       :type jde-db-cmd
1068                       :documentation
1069                       "Quit debugging the current application.")
1070    (step-over         :initarg :step-over
1071                       :type jde-db-cmd
1072                       :documentation
1073                       "Step to the next line in the current frame.")
1074    (step-into         :initarg :step-into
1075                       :type jde-db-cmd
1076                       :documentation
1077                       "Step to the next line in the current program.")
1078    (step-out          :initarg :step-out
1079                       :type jde-db-cmd
1080                       :documentation
1081                       "Continue to the end of the current method.")
1082    (up                :initarg :up
1083                       :type jde-db-cmd
1084                       :documentation
1085                       "Move up the stack.")
1086    (down              :initarg :down
1087                       :type jde-db-cmd
1088                       :documentation
1089                       "Move down the stack.")
1090    (where             :initarg :where
1091                       :type jde-db-cmd
1092                       :documentation
1093                       "Point to the current stopping point.")
1094    (set-bp            :initarg :set-bp
1095                       :type jde-db-cmd
1096                       :documentation
1097                       "Cmd that asks debugger to set a breakpoint.")
1098    (clear-bp          :initarg :clear-bp
1099                       :type jde-db-cmd
1100                       :documentation
1101                       "Cmd that asks debugger to set a breakpoint."))
1102   "Set of debugger commands implemented by this debugger.")
1103
1104
1105
1106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1107 ;;                                                                            ;;
1108 ;; Debug Process Listener                                                     ;;
1109 ;;                                                                            ;;
1110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1111 (defclass jde-db-listener ()
1112   ((debugger   :initarg :debugger
1113                :type jde-db-debugger
1114                :documentation
1115                "The debugger"))
1116   "Listens to the output from the debugger.")
1117
1118 (defmethod jde-db-listener-filter-output ((this jde-db-listener) output)
1119   "Filters the output of the debugger."
1120   output)
1121
1122
1123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1124 ;;                                                                            ;;
1125 ;; Class of JDE Debuggers                                                     ;;
1126 ;;                                                                            ;;
1127 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1128 (defclass jde-db-debugger ()
1129   ((name          :initarg :name
1130                   :type string
1131                   :initform "Java debugger"
1132                   :documentation 
1133                   "Name of this Java debugger.")
1134    (buffer-name   :initarg :buffer-name
1135                   :initform "Java Debugger"
1136                   :type string
1137                   :documentation
1138                   "Name of buffer used to interact with debugger.")
1139    (buffer        :initarg :buffer
1140                   :type buffer
1141                   :documentation
1142                   "Buffer used to interact with debugger.")
1143
1144    (process       :initarg :process
1145                   :documentation 
1146                   "Debugger process.")
1147
1148    (running-p     :initarg :process
1149                   :type boolean
1150                   :initform nil
1151                   :documentation
1152                   "Non-nil if debugger process is running.")
1153   
1154    (proc-filter   :initarg :proc-filter
1155                   :type function
1156                   :documentation
1157                   "Function used to parse debug output.")
1158
1159    (listeners     :initarg :listeners
1160                   :type list
1161                   :initform nil
1162                   :documentation
1163                   "List of debugger output listeners.")
1164
1165    (cmd-set       :initarg :cmd-set
1166                   :type jde-db-cmd-set
1167                   :documentation
1168                   "Commands implemented by this debugger.")
1169
1170    (next-cmd      :initarg :next-cmd
1171                   :type list
1172                   :initform nil
1173                   :documentation
1174                   "Next command(s) to execute.")
1175
1176    (last-cmd      :initarg :last-cmd
1177                   :type (or null jde-db-cmd)
1178                   :documentation
1179                   "Last command send to the debugger.")
1180
1181    (debuggee      :initarg :debuggee
1182                   :type jde-db-debuggee
1183                   :documentation
1184                   "Application process being debugged.")
1185
1186    (the-debugger  :type jde-db-debugger
1187                   :allocation :class
1188                   :documentation
1189                   "The currently active debugger."))
1190    "Class of Java debuggers.")
1191
1192 (defmethod initialize-instance ((this jde-db-debugger) &rest fields)
1193   "Constructor for generic debugger."
1194   (oset this cmd-set 
1195         (jde-db-cmd-set "Generic commands" :debugger this))
1196   (oset this last-cmd nil))
1197
1198
1199 (defmethod jde-db-create-debuggee-app ((this jde-db-debugger) main-class))
1200
1201 (defmethod jde-db-create-debuggee-applet ((this jde-db-debugger applet-doc)))
1202
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."
1206   (and output
1207        (or
1208         (string-match ">[ ]*$" output)
1209         (string-match "[a-zA-Z0-9]+\[[0-9]+\][ ]*$" output)
1210         (string-match "VM Started:[ ]*$" output))))
1211
1212
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))
1218         (response output)
1219         (last-cmd (oref this last-cmd)))
1220
1221     (loop for listener in listeners do
1222           (setq output
1223                 (jde-db-listener-filter-output listener output)))
1224
1225     (comint-output-filter proc output)
1226
1227     (if last-cmd
1228         (jde-db-cmd-notify-response last-cmd response))
1229
1230     (if (jde-db-ready-p this (car (last (split-string output "\n"))))
1231         (jde-db-exec-next-cmd this))))
1232
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
1236 `jde-db-listener'."
1237   (assert (typep listener jde-db-listener))
1238   (oset this listeners (cons listener (oref this listeners))))
1239
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
1243 `jde-db-listener'."
1244   (assert (typep listener jde-db-listener))
1245   (oset this listeners (remove listener (oref this listeners))))
1246
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'."
1250   (set-process-filter 
1251    (oref this process) 
1252    (lambda (process output)
1253      (jde-db-process-debugger-output 
1254       (oref 'jde-db-debugger the-debugger) output))))
1255
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)))
1261          ;; buffer killed
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
1271              (unwind-protect
1272                  (progn
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
1277                          (concat ":"
1278                                  (symbol-name (process-status proc))))
1279                    (force-mode-line-update)
1280                    (if (eobp)
1281                        (insert ?\n mode-name " " msg)
1282                      (save-excursion
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)))))))
1292
1293
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))
1299
1300
1301 (defmethod jde-db-set-process-sentinel ((this jde-db-debugger))
1302   (set-process-sentinel
1303    (oref this process)
1304    (lambda (process msg)
1305        (jde-db-notify-process-status-change
1306         (oref 'jde-db-debugger the-debugger) msg))))
1307
1308 (defmethod jde-db-exec-next-cmd ((this jde-db-debugger))
1309   "Executes the next command on the debugger's pending
1310 command list."
1311   (let ((curr-cmd (car (oref this next-cmd))))
1312     (if curr-cmd
1313         (progn
1314           (oset this next-cmd (cdr (oref this next-cmd)))
1315           (oset this last-cmd curr-cmd)
1316           (jde-db-cmd-init curr-cmd)
1317           (save-excursion
1318             (set-buffer (oref this buffer))
1319             (let ((proc (oref this process))
1320                   (cmd-line (jde-db-cmd-make-command-line curr-cmd)))
1321               (if cmd-line
1322                   (progn
1323                     (goto-char (point-max))
1324                     (insert cmd-line)
1325                     (comint-send-input)))))))))
1326
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))
1331
1332 (defmethod jde-db-exec-cmd ((this jde-db-debugger) cmd)
1333   "Executes CMD."
1334   (assert (and cmd (typep cmd 'jde-db-cmd)))
1335   (jde-db-exec-cmds this (list cmd)))
1336
1337 (defmethod jde-db-classpath-arg ((this jde-db-debugger))
1338   "Generate the -classpath command line argument for jdb."
1339
1340   ;; Set the classpath option. Use the local
1341   ;; classpath, if set; otherwise, the global
1342   ;; classpath.
1343   (let ((classpath
1344          (if jde-db-option-classpath
1345              jde-db-option-classpath
1346            jde-global-classpath))
1347         (symbol
1348          (if jde-db-option-classpath
1349              'jde-db-option-classpath
1350            'jde-global-classpath)))
1351     (if classpath
1352         (list
1353          "-classpath"
1354          (jde-build-classpath
1355           classpath symbol)))))
1356
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
1360       (list "-classic")))
1361
1362 (defmethod jde-db-property-args ((this jde-db-debugger))
1363   "Generate property arguments."
1364   (if jde-db-option-properties
1365       (mapcar
1366        (lambda (prop)
1367          (concat "-D" (car prop) "=" (cdr prop)))
1368        jde-db-option-properties)))
1369
1370
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))
1375         (print-memory-freed
1376          (nth 1 jde-db-option-verbose))
1377         (print-jni-info
1378          (nth 2 jde-db-option-verbose))
1379         options)
1380
1381     (if print-classes-loaded
1382         (add-to-list 'options "-verbose:class"))
1383
1384     (if print-memory-freed
1385         (add-to-list 'options "-verbosegc"))
1386
1387     (if print-jni-info
1388         (add-to-list options "-verbosejni"))
1389
1390     options))
1391
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))))
1407          options)
1408     (if (not (string= start-size "1m"))
1409         (setq options 
1410               (append options (list (concat "-Xms" start-size)))))
1411     (if (not (string= max-size "16m"))
1412         (setq options 
1413               (append options (list (concat "-Xmx" max-size)))))
1414     options))
1415
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))))
1431          option)
1432
1433     (if (not (string= c-size "128k"))
1434         (setq option
1435               (append option (list (concat "-Xss" c-size)))))
1436
1437     (if (not (string= java-size "400k"))
1438         (setq option 
1439               (append option (list (concat "-Xoss" java-size)))))
1440     option))
1441
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)))
1446         (no-gc-classes (not 
1447                         (nth 1 jde-db-option-garbage-collection)))
1448         options)
1449
1450     (if no-gc-asynch
1451         (setq options (append options '("-Xnoasyncgc"))))
1452
1453     (if no-gc-classes
1454         (setq options (append options '("-Xnoclassgc"))))
1455
1456     options))
1457
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)))
1462
1463     (if profilep
1464         (if (string= file "./java.prof")
1465             (list "-Xprof")
1466           (list (concat "-Xprof:" file))))))
1467
1468
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))
1476          (sort 
1477           (downcase (substring (nth 3 prof-options) 0 1))))
1478     (if profilep
1479         (if (and (string= file "./java.hprof")
1480                  (equal depth 5)
1481                  (equal top 20)
1482                  (string= sort "a"))
1483             (list "-Xhprof")
1484           (list
1485            (format 
1486             "-Xhprof:file=%s,depth=%d,top=%d,sort=%s"
1487             file depth top sort))))))
1488
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)))
1493     (if verify-all
1494         (list"-Xverify")
1495       ;      (if verify-remote
1496       ;   (list "-Xverifyremote"))
1497       (if (and
1498            (not verify-all)
1499            (not verify-remote))
1500           (list "-Xnoverify")))))
1501
1502
1503 (defmethod jde-db-command-line-args ((this jde-db-debugger))
1504   "Generate command line args."
1505   (if jde-db-option-vm-args
1506       (mapcar
1507        (lambda (arg)
1508          arg)
1509        jde-db-option-vm-args)))
1510
1511
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)))
1515
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."
1521   nil)
1522
1523 (defmethod jde-db-get-vm-args ((this jde-db-debugger))
1524   (append 
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)))
1532
1533 (defmethod jde-db-debugger-get-working-dir ((this jde-db-debugger))
1534   (if (string= jde-run-working-directory "")
1535       default-directory
1536     (jde-normalize-path 'jde-run-working-directory)))
1537
1538 (defmethod jde-db-debugger-get-prog-args ((this jde-db-debugger))
1539   )
1540
1541 (defmethod jde-db-debugger-start ((this jde-db-debugger))
1542   "Start the debugger.")
1543
1544
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.")
1547
1548
1549 (defmethod jde-db-debugger-connect ((this jde-db-debugger) &optional listenp)
1550   "Connect the debugger to an existing process.")
1551
1552
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
1558     (jde-jdb-get-jdb)))
1559
1560
1561 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1562 ;;                                                                            ;;
1563 ;; Generic Debug Commands                                                     ;;
1564 ;;                                                                            ;;
1565 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1566
1567 ;; The following commands serve as a generalized interface between the
1568 ;; JDE user and JDE-supported debuggers, e.g., jdb or JDEbug.
1569
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.
1573
1574 ;;;###autoload             
1575 (defun jde-debug ()
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."
1583   (interactive)
1584
1585   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1586   ;; This is a temporary hack until I 
1587   ;; wire up the JDEbug to this command.
1588   (if (string= (car jde-debugger) "JDEbug")
1589       (jde-bug-debug-app)
1590   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1591     (let* ((debugger (jde-db-get-the-debugger))
1592            (application-main-class
1593             (let ((main-class jde-run-application-class))
1594               (if (or
1595                    (not main-class)
1596                    (string= main-class ""))
1597                   (setq 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: "))))
1603               main-class))
1604            (cmd-set (oref debugger cmd-set))
1605            (launch-cmd (oref cmd-set launch-app)))
1606
1607
1608       (jde-db-create-debuggee-app debugger application-main-class)
1609
1610       (if (not (oref debugger running-p))
1611           (jde-db-debugger-start debugger))
1612
1613       (oset-default 'jde-db-debugger the-debugger debugger)
1614
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)))
1619             (oset 
1620              bp-cmd 
1621              breakpoints
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)))))
1625
1626 (defun jde-debugger-running-p ()
1627   "Returns nonnil if the debugger is running."
1628   (or
1629    (and 
1630     (string= (car jde-debugger) "JDEbug")
1631     (jde-dbs-debugger-running-p)
1632     (jde-dbs-get-target-process))
1633    (let ((debugger
1634           (if (slot-boundp (jde-db-get-the-debugger) 'the-debugger)
1635               (oref (jde-db-get-the-debugger) the-debugger))))
1636     (and debugger
1637          (oref debugger running-p)))))
1638
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)
1647          (working-directory 
1648           (if applet-doc-directory
1649               applet-doc-directory
1650             source-directory)))
1651
1652     (jde-db-create-debuggee-applet debugger applet-doc-path)
1653
1654     (oset-default 'jde-db-debugger the-debugger debugger)
1655
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)))
1660           (oset 
1661            bp-cmd 
1662            breakpoints
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))))
1666
1667
1668
1669
1670 (defun jde-debug-applet-internal (applet-doc)
1671   (let ((applet-class jde-run-application-class))
1672     (if (or
1673          (not applet-class)
1674          (string= applet-class ""))
1675         (setq 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)))
1680
1681 ;;;###autoload 
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."
1694   (interactive
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 
1699          (if doc 
1700              doc
1701            (if (and jde-run-applet-doc
1702                     (not (string= jde-run-applet-doc "")))
1703                jde-run-applet-doc
1704              (car (jde-run-find-html-files))))))
1705     (if applet-doc-path 
1706         (jde-debug-applet-internal applet-doc-path) 
1707       (signal 'error "Could not find html document to display applet."))))
1708
1709
1710
1711 (defun jde-debug-run ()
1712   "Start the current debuggee application."
1713   (interactive)
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)))))
1728
1729   
1730 (defun jde-debug-cont ()
1731   "Continues the current debuggee application from its current
1732 stopping point."
1733   (interactive)
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)
1739              (or
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)))))
1749
1750
1751 (defun jde-debug-quit ()
1752   "Quit debugging the current application."
1753   (interactive)
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)))))
1765
1766 (defun jde-debug-step-over ()
1767   "Step to the next line in the current stack frame."
1768   (interactive)
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)))))
1781  
1782 (defun jde-debug-step-into ()
1783   "Step to the next line in the current program."
1784   (interactive)
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)))))
1797
1798 (defun jde-debug-step-out ()
1799   "Continue execution to the end of the current method."
1800   (interactive)
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)))))
1813
1814
1815 (defun jde-debug-up ()
1816   "Move up the stack."
1817   (interactive)
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)))))
1829
1830 (defun jde-debug-down ()
1831   "Move down the stack."
1832   (interactive)
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)))))
1844  
1845 (defun jde-debug-where ()
1846   "Show current stopping point."
1847   (interactive)
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)))))
1859  
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))
1867     (jde-db-breakpoint 
1868      (format "breakpoint: %s %d" 
1869              (file-name-nondirectory file)
1870              jde-db-breakpoint-id-counter)
1871      :id   jde-db-breakpoint-id-counter
1872      :file file 
1873      :class (concat (jde-db-get-package) 
1874                     (jde-db-get-class)))))
1875
1876
1877 (defun jde-debug-set-breakpoint ()
1878   "Ask debugger to set a breakpoint at the current line 
1879 in the current buffer."
1880   (interactive)
1881   (let* ((file (buffer-file-name))
1882          (line (jde-get-line-at-point))
1883          (bp (jde-db-find-breakpoint file line)))
1884     (unless bp
1885       (setq bp (jde-db-spec-breakpoint))
1886       (oset bp line line)
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))))))
1893
1894 (defun jde-debug-clear-breakpoint()
1895   "Clear the breakpoint at the current line in the current buffer."
1896   (interactive)
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)))
1901     (if bp
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)))))
1908
1909 (defun jde-debug-toggle-breakpoint ()
1910   "Sets or clears a breakpoint at the current line."
1911   (interactive)
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'.")
1919     (if bp
1920         (jde-debug-clear-breakpoint)
1921       (jde-debug-set-breakpoint))))
1922
1923 (defun jde-debug-clear-breakpoints()
1924   "Clear all existing breakpoints."
1925   (interactive)
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)))    
1930             (oset 
1931              bp-cmd 
1932              breakpoints 
1933              (mapcar 
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))))))
1940
1941
1942 (defvar jde-db-minibuffer-local-map nil
1943   "Keymap for minibuffer prompting of jdb startup command.")
1944 (if jde-db-minibuffer-local-map
1945     ()
1946   (setq jde-db-minibuffer-local-map (copy-keymap minibuffer-local-map))
1947   (define-key
1948     jde-db-minibuffer-local-map "\C-i" 'comint-dynamic-complete-filename))
1949
1950
1951 (defun class-from-file-name (file-name)
1952   (file-name-sans-extension (file-name-nondirectory file-name)))
1953
1954
1955 (defun jde-db-get-vm-args-from-user ()
1956   (if jde-db-read-vm-args
1957       (jde-run-parse-args
1958        (read-from-minibuffer
1959         "Vm args: "
1960         (car jde-db-interactive-vm-arg-history)
1961         nil nil
1962         'jde-db-interactive-vm-arg-history))))
1963
1964 (defun jde-db-get-app-args-from-user ()
1965   (if jde-db-read-app-args
1966       (jde-run-parse-args
1967        (read-from-minibuffer
1968         "Application args: "
1969         (car jde-db-interactive-app-arg-history)
1970         nil nil
1971         'jde-db-interactive-app-arg-history))))
1972           
1973
1974 (defun jde-db-get-package ()
1975   "Return the package of the class whose source file resides in the current
1976 buffer."
1977   (save-excursion
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))
1981                 "."))))
1982
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."
1985   (interactive)
1986   (let ((class-info (jde-parse-get-innermost-class-at-point)))
1987     (if class-info
1988       (save-excursion
1989         (goto-char (cdr class-info))
1990         (let ((parent (jde-db-get-class)))
1991         (if (not parent)
1992             (car class-info)
1993             (concat parent "$" (car class-info))))))))
1994
1995
1996 (defun jde-db-src-dir-matches-file-p (file)
1997   "Return true if one of `jde-sourcepath'
1998 matches FILE."
1999   (let* ((directory-sep-char ?/)
2000          (filename (jde-normalize-path file)))
2001     (find-if
2002      (lambda (dir-x)
2003        (string-match 
2004         (concat 
2005          "^" 
2006          (jde-normalize-path 
2007           dir-x
2008           'jde-sourcepath)) 
2009         filename))
2010      jde-sourcepath)))
2011
2012 (provide 'jde-db)
2013
2014
2015 ;; Change History
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.
2019 ;;
2020 ;; Revision 1.130  2004/12/06 05:50:51  paulk
2021 ;; Fix problem in jde-debugger-running-p.
2022 ;;
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.
2025 ;;
2026 ;; Revision 1.128  2004/09/20 05:30:36  paulk
2027 ;; Changes needed to make restructured debugging code work for applets.
2028 ;;
2029 ;; Revision 1.127  2004/09/02 04:50:19  paulk
2030 ;; More infrastructure work to support applet debugging.
2031 ;;
2032 ;; Revision 1.126  2004/09/01 06:20:32  paulk
2033 ;; Restructured to accommodate debugging applets.
2034 ;;
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.
2041 ;;
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.
2047 ;;
2048 ;; Revision 1.123  2004/02/18 13:42:20  jslopez
2049 ;; Prevents issuing multiple set breakpoint commands to jdb once a breakpoint is
2050 ;; already set.
2051 ;;
2052 ;; Revision 1.122  2004/02/10 05:13:21  jslopez
2053 ;; Adds the option "gigabytes" for stack size and heap size.
2054 ;;
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
2059 ;; listen mode.
2060 ;;
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.
2063 ;;
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.
2067 ;;
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.
2072 ;;
2073 ;; Revision 1.117  2003/03/28 05:33:29  andyp
2074 ;; XEmacs optimizations for JDEbug and efc.
2075 ;;
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,
2079 ;; or requested.
2080 ;;
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.
2084 ;;
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.
2088 ;;
2089 ;; Revision 1.113  2003/01/12 19:15:20  jslopez
2090 ;; Adds function jde-debug-list-breakpoints.
2091 ;;
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.
2096 ;;
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.
2099 ;;
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.
2104 ;;
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
2109 ;; by genuine bugs.
2110 ;;
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.
2114 ;;
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.
2118 ;;
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
2123 ;; the JDEE.
2124 ;;
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
2128 ;; the jdb process.
2129 ;;
2130 ;; Revision 1.104  2002/05/21 06:34:27  paulk
2131 ;; Updated to support J2SDK 1.4.0 version of jdb.
2132 ;;
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.
2135 ;;
2136 ;; Revision 1.102  2002/03/31 07:49:51  paulk
2137 ;; Renamed jde-db-source-directories. The new name is jde-sourcepath.
2138 ;;
2139 ;; Revision 1.101  2002/03/12 04:43:38  paulk
2140 ;; Removed initarg for class slots to silence eieio warning.
2141 ;;
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.
2146 ;;
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.
2150 ;;
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.
2155 ;;
2156 ;; Revision 1.97  2002/01/19 06:42:22  paulk
2157 ;; Minor updates.
2158 ;;
2159 ;; Revision 1.96  2002/01/15 13:33:27  paulk
2160 ;; Adds a Clear Breakpoints command for jdb.
2161 ;;
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.
2165 ;;
2166 ;; - The debug application command now requests all specified
2167 ;;   breakpoints at the beginning of a debug session.
2168 ;;
2169 ;; - The debug application command now changes the color of all breakpoints
2170 ;;   to specified at the end of a debug session.
2171 ;;
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.
2175 ;;
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.
2180 ;;
2181 ;; Revision 1.92  2002/01/02 05:29:45  paulk
2182 ;; Added a stack-depth field to the jde-db-debuggee class.
2183 ;;
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.
2187 ;;
2188 ;; Revision 1.90  2001/12/28 05:32:55  paulk
2189 ;; Implemented generalized debuggee process run and continue commands.
2190 ;;
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.
2194 ;;
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.
2198 ;;
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.
2202 ;;
2203 ;; Revision 1.86  2001/12/04 05:37:35  paulk
2204 ;; Moved jdb related code to jde-jdb.el.
2205 ;;
2206 ;; Revision 1.85  2001/11/30 03:08:03  jslopez
2207 ;; Fixes reference to free variables.
2208 ;;
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.
2211 ;;
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.
2215 ;;
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.
2219 ;;
2220 ;; Revision 1.81  2001/11/04 14:58:05  paulk
2221 ;; Restored jde-db-classic-mode-vm option.
2222 ;;
2223 ;; Revision 1.80  2001/11/04 14:51:23  paulk
2224 ;; Fixed typo in classic mode argument (i.e., -tclassic should be -classic).
2225 ;;
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.
2228 ;;
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.
2233 ;;
2234 ;; Revision 1.77  2001/07/31 05:11:50  paulk
2235 ;; ReleaseNotes.txt
2236 ;;
2237 ;; Revision 1.76  2001/04/16 05:49:34  paulk
2238 ;; Normalized paths. Thanks to Nick Sieger.
2239 ;;
2240 ;; Revision 1.75  2001/04/12 04:42:23  paulk
2241 ;; Normalize jde-run-working-directory.
2242 ;;
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.
2245 ;;
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.
2248 ;;
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>.
2251 ;;
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.
2254 ;;
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.
2257 ;;
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.
2261 ;;
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.
2264 ;;
2265 ;; Revision 1.67  2000/12/18 05:22:45  paulk
2266 ;; *** empty log message ***
2267 ;;
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.
2270 ;;
2271 ;; Revision 1.65  2000/10/08 12:55:39  paulk
2272 ;; *** empty log message ***
2273 ;;
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.
2277 ;;
2278 ;; Revision 1.63  2000/06/12 08:37:43  paulk
2279 ;; Now displays JDEbug menu when running XEmacs.
2280 ;;
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.
2283 ;;
2284 ;; Revision 1.61  2000/03/16 05:08:25  paulk
2285 ;; Added JDEbug option to jde-db-debugger.
2286 ;;
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.
2289 ;;
2290 ;; Revision 1.59  2000/02/10 02:50:32  paulk
2291 ;; Replaced jde expand file name function with expand-file-name.
2292 ;;
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.
2296 ;;
2297 ;; Revision 1.57  2000/01/15 08:01:52  paulk
2298 ;; Reimplemented directory search functions.
2299 ;;
2300 ;; Revision 1.56  1999/11/16 05:58:17  paulk
2301 ;; Added trace method commands and skeletons for trace class and cancel
2302 ;; trace commands.
2303 ;;
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>.
2308 ;;
2309 ;; Revision 1.54  1999/09/28 04:06:59  paulk
2310 ;; Supplied missing left parentheses.
2311 ;;
2312 ;; Revision 1.53  1999/09/05 04:33:28  paulk
2313 ;; Added support for running vm in classic mode.
2314 ;;
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.
2318 ;;
2319 ;; Revision 1.51  1999/03/06 00:55:38  paulk
2320 ;; Changed default value of jde-db-source-directories to be nil.
2321 ;;
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.
2325 ;;
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.
2330 ;;
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.
2334 ;;
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.
2337 ;;
2338 ;; Defined a new command, jde-find-class-source, that finds and opens the source file
2339 ;; for a specified class.
2340 ;;
2341 ;; Improved the regular expression used by jde-db-get-package to ignore tabs at the
2342 ;; beginning of a line.
2343 ;;
2344 ;; Revision 1.47  1999/02/15 02:02:35  paulk
2345 ;; Forgot to concatenate in last fix.
2346 ;;
2347 ;; Revision 1.46  1999/02/15 00:52:44  paulk
2348 ;; Fixed bug in qualified-class-name-regexp.
2349 ;;
2350 ;; Revision 1.45  1999/02/10 18:35:51  paulk
2351 ;; Added support for appletviewer -encoding and -J options.
2352 ;;
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.
2355 ;;
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.
2358 ;;
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.
2363 ;;
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>
2367 ;;
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>.
2371 ;;
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.
2375 ;;
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.
2378 ;;
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
2381 ;; appletviewer.
2382 ;;
2383 ;; Revision 1.36  1999/02/02 15:25:28  paulk
2384 ;; Removed unwanted space in -D (properties) debug option.
2385 ;;
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.
2388 ;;
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
2392 ;;
2393 ;; Revision 1.33  1998/11/22 18:18:36  paulk
2394 ;; Made comint-prompt-regexp and  paragraph-start local variables.
2395 ;;
2396 ;; Revision 1.32  1998/11/04 02:59:09  paulk
2397 ;; Corrected verbiage in Jde Debugger Options description.
2398 ;;
2399 ;; Revision 1.31  1998/09/12 00:05:57  paulk
2400 ;; Debugger now runs application from directory specified by jde-run-working-directory.
2401 ;;
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.
2405 ;;
2406 ;; Revision 1.29  1998/06/29 02:50:44  paulk
2407 ;; Fixed bug in marker filter.
2408 ;;
2409 ;; Revision 1.28  1998/06/27 03:34:31  paulk
2410 ;; Provided a hack to handle reordering of threaded messages on Solaris.
2411 ;;
2412 ;; Provided code to handle case where current class has no line number
2413 ;; information.
2414 ;;
2415 ;; Revision 1.27  1998/06/25 04:27:23  paulk
2416 ;; Removed debug messages from jde-db-marker-filter.
2417 ;;
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).
2421 ;;
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.
2425 ;;
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.
2430 ;;
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.
2434 ;;
2435 ;; Changed the marker regular expression to detect only jdb breakpoint messages,
2436 ;; i.e., messages of the form
2437 ;;
2438 ;;   Breakpoint hit: qualified.class.name (class:line)
2439 ;;
2440 ;; This should eliminate the problem of spurious hits when exceptions occur and
2441 ;; stack traces are printed.
2442 ;;
2443 ;; Revision 1.22  1998/05/27 06:09:46  paulk
2444 ;; Added autoload comments.
2445 ;;
2446 ;; Revision 1.21  1998/03/27 04:16:12  kinnucan
2447 ;; Fixed typo in the code that displays the jdb menu on XEmacs.
2448 ;;
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.
2453 ;;
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.
2458 ;;
2459 ;; Revision 1.18  1998/03/04 04:28:36  kinnucan
2460 ;; Added test for jde-run-application-class = "" to jde-db
2461 ;;
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.
2465 ;;
2466 ;; Revision 1.16  1998/02/27 22:15:24  kinnucan
2467 ;; Added support for Emacs customization feature.
2468 ;;
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).
2472 ;;
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.
2476 ;;
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.
2481 ;;
2482 ;; Revision 1.12  1997/10/30 05:42:37  kinnucan
2483 ;; Made configuration variables settable.
2484 ;;
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.
2488 ;;
2489 ;; Revision 1.10  1997/10/20 05:27:48  kinnucan
2490 ;; Removed reference to deleted function jde-db-massage-args
2491 ;;
2492 ;; Revision 1.9  1997/10/11 01:36:05  kinnucan
2493 ;; Fixed bug in jde-db-search-src-dirs discovered by Jonathan Payne.
2494 ;;
2495 ;; Revision 1.8  1997/10/06 14:40:53  kinnucan
2496 ;; Fixed bugs in jde-db-set-debugger command.
2497 ;;
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>
2502 ;;
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.
2506 ;;
2507 ;; Revision 1.6  1997/10/05 04:53:04  kinnucan
2508 ;; Fixed bug in print object menu item.
2509 ;;
2510 ;; Revision 1.5  1997/08/26 14:53:39  paulk
2511 ;; Fixed bug in check-source-path.
2512 ;;
2513 ;; Revision 1.4  1997/08/26 08:52:14  kinnucan
2514 ;; Tweaked JDE Version number for JDE 1.8 release.
2515 ;;
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
2519 ;; current buffer.
2520 ;;
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
2524 ;; that lack it.
2525 ;;
2526 ;; Revision 1.1  1997/06/18 17:21:59  paulk
2527 ;; Initial revision
2528 ;;
2529
2530 ;;; end of jde-db.el