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 void setDebugTarget(IDebugTarget target) {
82 public ILaunch getLaunch() {
83 return this.getDebugTarget().getLaunch();
86 public boolean canResume() {
90 public boolean canSuspend() {
94 public boolean isSuspended() {
98 protected void setSuspended(boolean isSuspended) {
99 this.isSuspended = isSuspended;
102 protected void prepareForResume() {
106 DebugEvent ev = new DebugEvent(this, DebugEvent.RESUME, DebugEvent.CLIENT_REQUEST);
107 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
110 public void resume() throws DebugException {
111 this.prepareForResume() ;
112 ((PHPDebugTarget) this.getDebugTarget()).getPHPDBGProxy().resume();
116 public void doSuspend(SuspensionPoint suspensionPoint) {
117 // this.getPHPDebuggerProxy().readFrames(this);
118 this.createName(suspensionPoint) ;
123 public void suspend() {
126 DebugEvent ev = new DebugEvent(this, DebugEvent.SUSPEND, DebugEvent.BREAKPOINT);
127 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
130 public boolean canStepInto() {
131 return isSuspended && this.hasStackFrames();
134 public boolean canStepOver() {
135 return isSuspended && this.hasStackFrames();
138 public boolean canStepReturn() {
142 public boolean isStepping() {
146 public void stepInto() throws DebugException {
150 frames[0].stepInto();
153 public void stepOver() throws DebugException {
157 frames[0].stepOver() ;
160 public void stepReturn() throws DebugException {
163 public boolean canTerminate() {
164 return !isTerminated;
167 public boolean isTerminated() {
171 public void terminate() throws DebugException {
174 getDebugTarget().terminate();
177 public Object getAdapter(Class arg0) {
181 public void setStackFrames(PHPStackFrame[] frames) {
182 this.frames = frames;
185 public String getName() {
189 public void setName(String name) {
193 protected void createName() {
194 //this.createName(null) ;
198 protected void createName(SuspensionPoint suspensionPoint) {
199 this.name = "PHP Thread - " + this.getId() ;
200 if (suspensionPoint != null) {
201 this.name += " (" + suspensionPoint + ")" ;
210 public void setId(int id) {