001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.api.debugger.jpda;
043:
044: import com.sun.jdi.AbsentInformationException;
045: import com.sun.jdi.ThreadReference;
046: import java.beans.PropertyChangeListener;
047: import java.util.List;
048: import org.netbeans.spi.debugger.jpda.EditorContext;
049: import org.netbeans.spi.debugger.jpda.EditorContext.Operation;
050:
051: /**
052: * Represents one Java thread in debugged process.
053: *
054: * <pre style="background-color: rgb(255, 255, 102);">
055: * Since JDI interfaces evolve from one version to another, it's strongly recommended
056: * not to implement this interface in client code. New methods can be added to
057: * this interface at any time to keep up with the JDI functionality.</pre>
058: *
059: * @author Jan Jancura
060: */
061: public interface JPDAThread {
062:
063: /** Thread state constant. */
064: public static final int STATE_UNKNOWN = ThreadReference.THREAD_STATUS_UNKNOWN;
065: /** Thread state constant. */
066: public static final int STATE_MONITOR = ThreadReference.THREAD_STATUS_MONITOR;
067: /** Thread state constant. */
068: public static final int STATE_NOT_STARTED = ThreadReference.THREAD_STATUS_NOT_STARTED;
069: /** Thread state constant. */
070: public static final int STATE_RUNNING = ThreadReference.THREAD_STATUS_RUNNING;
071: /** Thread state constant. */
072: public static final int STATE_SLEEPING = ThreadReference.THREAD_STATUS_SLEEPING;
073: /** Thread state constant. */
074: public static final int STATE_WAIT = ThreadReference.THREAD_STATUS_WAIT;
075: /** Thread state constant. */
076: public static final int STATE_ZOMBIE = ThreadReference.THREAD_STATUS_ZOMBIE;
077:
078: /** Property name constant. */
079: public static final String PROP_CALLSTACK = "callStack";
080: /** Property name constant. */
081: public static final String PROP_VARIABLES = "variables";
082:
083: /**
084: * Getter for the name of thread property.
085: *
086: * @return name of thread
087: */
088: public abstract String getName();
089:
090: /**
091: * Returns parent thread group.
092: *
093: * @return parent thread group
094: */
095: public abstract JPDAThreadGroup getParentThreadGroup();
096:
097: /**
098: * Returns line number of the location this thread stopped at.
099: * The thread should be suspended at the moment this method is called.
100: *
101: * @return line number of the current location if the thread is suspended,
102: * contains at least one frame and the topmost frame does not
103: * represent a native method invocation; <CODE>-1</CODE> otherwise
104: * @see CallStackFrame
105: */
106: public abstract int getLineNumber(String stratum);
107:
108: /**
109: * Returns the operation that is being currently executed on this thread.
110: * @return The current operation, or <CODE>null</CODE>.
111: * @see {@link CallStackFrame#getCurrentOperation}
112: */
113: public abstract Operation getCurrentOperation();
114:
115: /**
116: * Returns the list of the last operations, that were performed on this thread.
117: * Typically just operations from the current expression are stored.
118: * The thread should be suspended at the moment this method is called.
119: *
120: * @return The list of last operations if available, the thread is suspended,
121: * contains at least one frame and the topmost frame does not
122: * represent a native method invocation; <CODE>null</CODE> otherwise
123: * @see CallStackFrame
124: */
125: public abstract List<Operation> getLastOperations();
126:
127: /**
128: * Returns current state of this thread.
129: *
130: * @return current state of this thread
131: */
132: public abstract int getState();
133:
134: /**
135: * Returns true if this thread is suspended by debugger.
136: *
137: * @return true if this thread is suspended by debugger
138: */
139: public abstract boolean isSuspended();
140:
141: /**
142: * If this thread is suspended returns class name this thread is
143: * stopped in.
144: *
145: * @return class name this thread is stopped in
146: */
147: public abstract String getClassName();
148:
149: /**
150: * If this thread is suspended returns method name this thread is
151: * stopped in.
152: *
153: * @return method name this thread is stopped in
154: */
155: public abstract String getMethodName();
156:
157: /**
158: * Suspends thread.
159: */
160: public abstract void suspend();
161:
162: /**
163: * Unsuspends thread.
164: */
165: public abstract void resume();
166:
167: /**
168: * Interrupts this thread unless the thread has been suspended.
169: * @since 2.1
170: */
171: public abstract void interrupt();
172:
173: /**
174: * Returns file name this frame is stopped in or null.
175: *
176: * @return file name this frame is stopped in
177: */
178: public abstract String getSourceName(String stratum)
179: throws AbsentInformationException;
180:
181: /**
182: * Returns source path of file this frame is stopped in or null.
183: *
184: * @return source path of file this frame is stopped in or null
185: */
186: public abstract String getSourcePath(String stratum)
187: throws AbsentInformationException;
188:
189: /**
190: * Returns call stack for this thread.
191: *
192: * @throws AbsentInformationException if the thread is running or not able
193: * to return callstack. If the thread is in an incompatible state
194: * (e.g. running), the AbsentInformationException has
195: * IncompatibleThreadStateException as a cause.
196: * @return call stack
197: */
198: public abstract CallStackFrame[] getCallStack()
199: throws AbsentInformationException;
200:
201: /**
202: * Returns call stack for this thread on the given indexes.
203: *
204: * @param from a from index, inclusive
205: * @param to a to index, exclusive
206: * @throws AbsentInformationException if the thread is running or not able
207: * to return callstack. If the thread is in an incompatible state
208: * (e.g. running), the AbsentInformationException has
209: * IncompatibleThreadStateException as a cause.
210: * @return call stack
211: */
212: public abstract CallStackFrame[] getCallStack(int from, int to)
213: throws AbsentInformationException;
214:
215: /**
216: * Returns length of current call stack.
217: *
218: * @return length of current call stack
219: */
220: public abstract int getStackDepth();
221:
222: /**
223: * Sets this thread current.
224: *
225: * @see JPDADebugger#getCurrentThread
226: */
227: public abstract void makeCurrent();
228:
229: /**
230: * Returns monitor this thread is waiting on.
231: *
232: * @return monitor this thread is waiting on
233: */
234: public abstract ObjectVariable getContendedMonitor();
235:
236: /**
237: * Returns monitors owned by this thread.
238: *
239: * @return monitors owned by this thread
240: */
241: public abstract ObjectVariable[] getOwnedMonitors();
242: }
|