2 * Created on 23.11.2004
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package net.sourceforge.phpeclipse.xdebug.php.model;
9 import org.eclipse.debug.core.DebugEvent;
10 import org.eclipse.debug.core.DebugException;
11 import org.eclipse.debug.core.DebugPlugin;
12 import org.eclipse.debug.core.IDebugEventSetListener;
13 import org.eclipse.debug.core.model.IBreakpoint;
14 import org.eclipse.debug.core.model.IStackFrame;
15 import org.eclipse.debug.core.model.IThread;
20 * TODO To change the template for this generated type comment go to Window -
21 * Preferences - Java - Code Style - Code Templates
23 public class XDebugThread extends XDebugElement implements IThread,
24 IDebugEventSetListener {
27 * Breakpoints this thread is suspended at or <code>null</code> if none.
30 private IStackFrame[] fStackFrames = null;
32 private IBreakpoint[] fBreakpoints;
35 * Whether this thread is stepping
37 private boolean fStepping = false;
40 * Constructs a new thread for the given target
45 public XDebugThread(XDebugTarget target) {
47 DebugPlugin.getDefault().addDebugEventListener(this);
53 * @see org.eclipse.debug.core.model.IThread#getStackFrames()
55 public IStackFrame[] getStackFrames() throws DebugException {
57 if (fStackFrames == null) {
58 // XDebugCorePlugin.log(IStatus.INFO,"vor getStackFrames");
59 fStackFrames = ((XDebugTarget) getDebugTarget())
61 // XDebugCorePlugin.log(IStatus.INFO,"nach getStackFrames");
65 return new IStackFrame[0];
72 * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
74 public boolean hasStackFrames() throws DebugException {
81 * @see org.eclipse.debug.core.model.IThread#getPriority()
83 public int getPriority() throws DebugException {
90 * @see org.eclipse.debug.core.model.IThread#getTopStackFrame()
92 public IStackFrame getTopStackFrame() throws DebugException {
93 IStackFrame[] frames = getStackFrames();
94 if (frames.length > 0) {
103 * @see org.eclipse.debug.core.model.IThread#getName()
105 public String getName() throws DebugException {
106 // if (fStackFrames!=null)
107 // return fStackFrames[0].getName();
115 * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
117 public IBreakpoint[] getBreakpoints() {
118 if (fBreakpoints == null) {
119 return new IBreakpoint[0];
125 * Sets the breakpoints this thread is suspended at, or <code>null</code>
129 * the breakpoints this thread is suspended at, or
130 * <code>null</code> if none
132 protected void setBreakpoints(IBreakpoint[] breakpoints) {
133 fBreakpoints = breakpoints;
139 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
141 public boolean canResume() {
142 return isSuspended();
148 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
150 public boolean canSuspend() {
151 return !isSuspended();
157 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
159 public boolean isSuspended() {
160 return getDebugTarget().isSuspended();
166 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
168 public void resume() throws DebugException {
171 getDebugTarget().resume();
177 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
179 public void suspend() throws DebugException {
180 getDebugTarget().suspend();
186 * @see org.eclipse.debug.core.model.IStep#canStepInto()
188 public boolean canStepInto() {
189 return isSuspended();
195 * @see org.eclipse.debug.core.model.IStep#canStepOver()
197 public boolean canStepOver() {
198 return isSuspended();
204 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
206 public boolean canStepReturn() {
207 if (fStackFrames != null)
208 return (fStackFrames.length > 1);
216 * @see org.eclipse.debug.core.model.IStep#isStepping()
218 public boolean isStepping() {
225 * @see org.eclipse.debug.core.model.IStep#stepInto()
227 public void stepInto() throws DebugException {
230 ((XDebugTarget) getDebugTarget()).step_into();
236 * @see org.eclipse.debug.core.model.IStep#stepOver()
238 public void stepOver() throws DebugException {
241 ((XDebugTarget) getDebugTarget()).step_over();
247 * @see org.eclipse.debug.core.model.IStep#stepReturn()
249 public void stepReturn() throws DebugException {
252 ((XDebugTarget) getDebugTarget()).step_out();
259 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
261 public boolean canTerminate() {
262 return !isTerminated();
268 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
270 public boolean isTerminated() {
271 return getDebugTarget().isTerminated();
277 * @see org.eclipse.debug.core.model.ITerminate#terminate()
279 public void terminate() throws DebugException {
280 getDebugTarget().terminate();
284 * Sets whether this thread is stepping
289 protected void setStepping(boolean stepping) {
290 fStepping = stepping;
293 public void handleDebugEvents(DebugEvent[] events) {
294 DebugEvent de = events[0];
295 System.out.println(de.toString());
299 public void removeEventListeners() {
300 DebugPlugin.getDefault().removeDebugEventListener(this);