1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 IBM Corporation - Initial implementation
10 Vicente Fernando - www.alfersoft.com.ar
11 **********************************************************************/
12 package net.sourceforge.phpdt.internal.debug.core.model;
14 import org.eclipse.debug.core.DebugEvent;
15 import org.eclipse.debug.core.DebugException;
16 import org.eclipse.debug.core.DebugPlugin;
17 import org.eclipse.debug.core.ILaunch;
18 import org.eclipse.debug.core.model.IBreakpoint;
19 import org.eclipse.debug.core.model.IDebugTarget;
20 import org.eclipse.debug.core.model.IStackFrame;
21 import org.eclipse.debug.core.model.IThread;
23 public class PHPThread implements IThread {
25 private PHPStackFrame[] frames;
26 private IDebugTarget target;
27 private boolean isSuspended = false;
28 private boolean isTerminated = false;
29 private boolean isStepping = false;
33 public PHPThread(IDebugTarget target, int id) {
39 public IStackFrame[] getStackFrames() throws DebugException {
43 public int getStackFramesSize() {
47 public boolean hasStackFrames() {
51 return frames.length > 0;
54 public int getPriority() throws DebugException {
58 public IStackFrame getTopStackFrame() throws DebugException {
59 if (frames == null || frames.length == 0) {
62 return (IStackFrame) frames[0];
66 public IBreakpoint[] getBreakpoints() {
70 public String getModelIdentifier() {
71 return this.getDebugTarget().getModelIdentifier();
74 public IDebugTarget getDebugTarget() {
78 public ILaunch getLaunch() {
79 return this.getDebugTarget().getLaunch();
82 public boolean canResume() {
86 public boolean canSuspend() {
90 public boolean isSuspended() {
94 protected void setSuspended(boolean isSuspended) {
95 this.isSuspended = isSuspended;
98 protected void prepareForResume() {
102 DebugEvent ev = new DebugEvent(this, DebugEvent.RESUME, DebugEvent.CLIENT_REQUEST);
103 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
106 public void resume() throws DebugException {
107 this.prepareForResume() ;
108 ((PHPDebugTarget) this.getDebugTarget()).getPHPDBGProxy().resume(this);
112 public void doSuspend(SuspensionPoint suspensionPoint) {
113 // this.getPHPDebuggerProxy().readFrames(this);
114 this.createName(suspensionPoint) ;
119 public void suspend() {
122 DebugEvent ev = new DebugEvent(this, DebugEvent.SUSPEND, DebugEvent.BREAKPOINT);
123 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
126 public boolean canStepInto() {
127 return isSuspended && this.hasStackFrames();
130 public boolean canStepOver() {
131 return isSuspended && this.hasStackFrames();
134 public boolean canStepReturn() {
138 public boolean isStepping() {
142 public void stepInto() throws DebugException {
146 frames[0].stepInto();
149 public void stepOver() throws DebugException {
153 frames[0].stepOver() ;
156 public void stepReturn() throws DebugException {
159 public boolean canTerminate() {
160 return !isTerminated;
163 public boolean isTerminated() {
167 public void terminate() throws DebugException {
172 public Object getAdapter(Class arg0) {
176 public void setStackFrames(PHPStackFrame[] frames) {
177 this.frames = frames;
180 public String getName() {
184 public void setName(String name) {
188 protected void createName() {
189 //this.createName(null) ;
193 protected void createName(SuspensionPoint suspensionPoint) {
194 this.name = "PHP Thread - " + this.getId() ;
195 if (suspensionPoint != null) {
196 this.name += " (" + suspensionPoint + ")" ;
205 public void setId(int id) {