KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > cs > drjava > model > debug > Debugger


1 /*BEGIN_COPYRIGHT_BLOCK
2  *
3  * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
4  * or http://sourceforge.net/projects/drjava/
5  *
6  * DrJava Open Source License
7  *
8  * Copyright (C) 2001-2005 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
9  *
10  * Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13  * documentation files (the "Software"), to deal with the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15  * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16  *
17  * - Redistributions of source code must retain the above copyright notice, this list of conditions and the
18  * following disclaimers.
19  * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
20  * following disclaimers in the documentation and/or other materials provided with the distribution.
21  * - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
22  * endorse or promote products derived from this Software without specific prior written permission.
23  * - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
24  * names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
27  * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * WITH THE SOFTWARE.
31  *
32  *END_COPYRIGHT_BLOCK*/

33
34 package edu.rice.cs.drjava.model.debug;
35
36 import java.util.Vector JavaDoc;
37 import edu.rice.cs.drjava.model.DocumentRegion;
38 import edu.rice.cs.drjava.model.OpenDefinitionsDocument;
39
40 import com.sun.jdi.request.StepRequest;
41
42 /** Interface for any debugger implementation to be used by DrJava.
43  *
44  * @version $Id: Debugger.java 4076 2007-01-19 23:01:04Z dlsmith $
45  */

46 public interface Debugger {
47   public static final int STEP_INTO = StepRequest.STEP_INTO;
48   public static final int STEP_OVER = StepRequest.STEP_OVER;
49   public static final int STEP_OUT = StepRequest.STEP_OUT;
50
51   /** Adds a listener to this Debugger.
52    * @param listener a listener that reacts on events generated by the Debugger
53    */

54   public void addListener(DebugListener listener);
55
56   /** Removes a listener to this Debugger.
57    * @param listener listener to remove
58    */

59   public void removeListener(DebugListener listener);
60
61   /** Returns whether the debugger can be used in this copy of DrJava. This does not indicate whether it is ready to be
62    * used, which is indicated by isReady().
63    */

64   public boolean isAvailable();
65
66   /** Attaches the debugger to the Interactions JVM to prepare for debugging. */
67   public void startUp() throws DebugException;
68
69   /** Disconnects the debugger from the Interactions JVM and cleans up any state. */
70   public void shutdown();
71
72   /** Returns whether the debugger is enabled. */
73   public boolean isReady();
74   
75 // /** Suspends execution of the thread referenced by d */
76
// public void suspend(DebugThreadData d) throws DebugException;
77

78 // /** Suspends all the threads in the VM the debugger is attached to. */
79
// public void suspendAll();
80

81   /** Sets the current thread we are debugging to the thread referenced by d. */
82   public void setCurrentThread(DebugThreadData d) throws DebugException;
83
84   /** Resumes execution of the currently loaded document. */
85   public void resume() throws DebugException;
86
87   /** Resumes execution of the given thread.
88    * @param data the DebugThreadData representing the thread to resume
89    */

90   public void resume(DebugThreadData data) throws DebugException;
91
92   /** Steps into the execution of the currently loaded document.
93    * @param flag The flag denotes what kind of step to take. The following mark valid options:
94    * StepRequest.STEP_INTO
95    * StepRequest.STEP_OVER
96    * StepRequest.STEP_OUT
97    */

98   public void step(int flag) throws DebugException;
99
100   /** Adds a watch on the given field or variable.
101    * @param field the name of the field we will watch
102    */

103   public void addWatch(String JavaDoc field) throws DebugException;
104
105   /** Removes any watches on the given field or variable.
106    * @param field the name of the field we will watch
107    */

108   public void removeWatch(String JavaDoc field) throws DebugException;
109
110   /** Removes the watch at the given index.
111    * @param index Index of the watch to remove
112    */

113   public void removeWatch(int index) throws DebugException;
114
115   /** Removes all watches on existing fields and variables. */
116   public void removeAllWatches() throws DebugException;
117
118
119   /** Toggles whether a breakpoint is set at the given line in the given document.
120    * @param doc Document in which to set or remove the breakpoint
121    * @param offset Start offset on the line to set the breakpoint
122    * @param lineNum Line on which to set or remove the breakpoint
123    * @param isEnabled {@code true} if this breakpoint should be enabled
124    */

125   public void toggleBreakpoint(OpenDefinitionsDocument doc, int offset, int lineNum, boolean isEnabled) throws DebugException;
126
127   /** Sets a breakpoint.
128    * @param breakpoint The new breakpoint to set
129    */

130   public void setBreakpoint(final Breakpoint breakpoint) throws DebugException;
131
132  /** Removes a breakpoint. Called from ToggleBreakpoint -- even with BPs that are not active.
133   * @param breakpoint The breakpoint to remove.
134   */

135   public void removeBreakpoint(final Breakpoint breakpoint) throws DebugException;
136
137   /** Returns all currently watched fields and variables. */
138   public Vector JavaDoc<DebugWatchData> getWatches() throws DebugException;
139
140   /** Returns a Vector of ThreadData. */
141   public Vector JavaDoc<DebugThreadData> getCurrentThreadData() throws DebugException;
142
143   /** Returns a Vector of StackData for the current thread. */
144   public Vector JavaDoc<DebugStackData> getCurrentStackFrameData() throws DebugException;
145
146   /**
147    * @return true if there are any threads in the program currently being
148    * debugged which have been suspended (by the user or by hitting a breakpoint).
149    */

150   public boolean hasSuspendedThreads() throws DebugException;
151
152   /**
153    * Returns whether the thread the debugger is tracking is now running.
154    */

155   public boolean hasRunningThread() throws DebugException;
156
157   /**
158    * Returns whether the debugger's current thread is suspended.
159    */

160   public boolean isCurrentThreadSuspended() throws DebugException;
161
162   /**
163    * scrolls to the source indicated by the given DebugStackData
164    * @param data the DebugStackData representing the source location
165    */

166   public void scrollToSource(DebugStackData data) throws DebugException;
167
168   /**
169    * scrolls to the source indicated by the given Breakpoint
170    * @param bp the Breakpoint representing the source location
171    */

172   public void scrollToSource(Breakpoint bp);
173
174   /**
175    * Gets the Breakpoint object at the specified line in the given class.
176    * If the given data do not correspond to an actual breakpoint, null is returned.
177    * @param line the line number of the breakpoint
178    * @param className the name of the class the breakpoint's in
179    * @return the Breakpoint corresponding to the line and className, or null if
180    * there is no such breakpoint.
181    */

182   public Breakpoint getBreakpoint(int line, String JavaDoc className) throws DebugException;
183 }
184
Popular Tags