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
21 * Window - Preferences - Java - Code Style - Code Templates
23 public class XDebugThread extends XDebugElement implements IThread, IDebugEventSetListener {
26 * Breakpoints this thread is suspended at or <code>null</code>
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
44 public XDebugThread(XDebugTarget target) {
46 DebugPlugin.getDefault().addDebugEventListener(this);
50 * @see org.eclipse.debug.core.model.IThread#getStackFrames()
52 public IStackFrame[] getStackFrames() throws DebugException {
54 if (fStackFrames==null)
56 // XDebugCorePlugin.log(IStatus.INFO,"vor getStackFrames");
57 fStackFrames=((XDebugTarget) getDebugTarget()).getStackFrames();
58 // XDebugCorePlugin.log(IStatus.INFO,"nach getStackFrames");
62 return new IStackFrame[0];
66 * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
68 public boolean hasStackFrames() throws DebugException {
72 * @see org.eclipse.debug.core.model.IThread#getPriority()
74 public int getPriority() throws DebugException {
78 * @see org.eclipse.debug.core.model.IThread#getTopStackFrame()
80 public IStackFrame getTopStackFrame() throws DebugException {
81 IStackFrame[] frames = getStackFrames();
82 if (frames.length > 0) {
88 * @see org.eclipse.debug.core.model.IThread#getName()
90 public String getName() throws DebugException {
91 // if (fStackFrames!=null)
92 // return fStackFrames[0].getName();
97 * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
99 public IBreakpoint[] getBreakpoints() {
100 if (fBreakpoints == null) {
101 return new IBreakpoint[0];
106 * Sets the breakpoints this thread is suspended at, or <code>null</code>
109 * @param breakpoints the breakpoints this thread is suspended at, or <code>null</code>
112 protected void setBreakpoints(IBreakpoint[] breakpoints) {
113 fBreakpoints = breakpoints;
116 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
118 public boolean canResume() {
119 return isSuspended();
122 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
124 public boolean canSuspend() {
125 return !isSuspended();
128 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
130 public boolean isSuspended() {
131 return getDebugTarget().isSuspended();
134 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
136 public void resume() throws DebugException {
139 getDebugTarget().resume();
142 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
144 public void suspend() throws DebugException {
145 getDebugTarget().suspend();
148 * @see org.eclipse.debug.core.model.IStep#canStepInto()
150 public boolean canStepInto() {
151 return isSuspended();
154 * @see org.eclipse.debug.core.model.IStep#canStepOver()
156 public boolean canStepOver() {
157 return isSuspended();
160 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
162 public boolean canStepReturn() {
163 if (fStackFrames!=null)
164 return (fStackFrames.length>1);
169 * @see org.eclipse.debug.core.model.IStep#isStepping()
171 public boolean isStepping() {
175 * @see org.eclipse.debug.core.model.IStep#stepInto()
177 public void stepInto() throws DebugException {
180 ((XDebugTarget)getDebugTarget()).step_into();
183 * @see org.eclipse.debug.core.model.IStep#stepOver()
185 public void stepOver() throws DebugException {
188 ((XDebugTarget)getDebugTarget()).step_over();
191 * @see org.eclipse.debug.core.model.IStep#stepReturn()
193 public void stepReturn() throws DebugException {
196 ((XDebugTarget)getDebugTarget()).step_out();
200 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
202 public boolean canTerminate() {
203 return !isTerminated();
206 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
208 public boolean isTerminated() {
209 return getDebugTarget().isTerminated();
212 * @see org.eclipse.debug.core.model.ITerminate#terminate()
214 public void terminate() throws DebugException {
215 getDebugTarget().terminate();
219 * Sets whether this thread is stepping
221 * @param stepping whether stepping
223 protected void setStepping(boolean stepping) {
224 fStepping = stepping;
227 public void handleDebugEvents(DebugEvent[] events) {
228 DebugEvent de=events[0];
229 System.out.println(de.toString());
233 public void removeEventListeners() {
234 DebugPlugin.getDefault().removeDebugEventListener(this);