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 net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
16 import org.eclipse.debug.core.DebugEvent;
17 import org.eclipse.debug.core.DebugException;
18 import org.eclipse.debug.core.DebugPlugin;
19 import org.eclipse.debug.core.ILaunch;
20 import org.eclipse.debug.core.model.IDebugTarget;
21 import org.eclipse.debug.core.model.IRegisterGroup;
22 import org.eclipse.debug.core.model.IStackFrame;
23 import org.eclipse.debug.core.model.IThread;
24 import org.eclipse.debug.core.model.IVariable;
26 public class PHPStackFrame extends PHPDebugElement implements IStackFrame {
28 private PHPThread thread; // The thread to which this stackframe belongs
29 private String file; // The file name???
30 private int lineNumber; //
33 private PHPVariable[] variables; // The array of variables
34 private String description; //
45 public PHPStackFrame (PHPThread thread, String file, int line, int index, String desc, int modno) {
48 this.lineNumber = line;
52 this.description = desc;
63 public PHPStackFrame (PHPThread thread, String file, int line, int index) {
66 this.lineNumber = line;
75 public IThread getThread () {
82 public void setThread (PHPThread thread) {
88 * This function returns the array of PHPVariables for this stackframe
89 * The PHPVariables should not change (newly build up) between two steps
91 * A PHPVariable with the same name but with different object ID is
92 * handled as a new variable.
94 * TODO Remove the intermediate storage array
96 * @return The array of PHPVariables for this stackframe.
98 public IVariable[] getVariables() throws DebugException {
99 PHPVariable[] variablesNew; // The intermediate storage of the variable array we get from DBG proxy
101 variablesNew = this.getPHPDBGProxy ().readVariables (this); // Get the variable array from DBG proxy
102 variables = variablesNew; // Store the array the stackframes member variable
104 return variables; // Give the array back to user interface
108 * TODO Is this really used (who calls this)
109 * I think this method could be removed
111 * @param s The variables name we are looking for.
114 public IVariable findVariable (String s) throws DebugException {
118 if (this.hasVariables ()) { // Does this stackframe have variables?
119 name = "$" + s; // Prefix the variable name with $
121 for (i = 0; i < variables.length; i++) { // For all variables
122 if ((variables[i].getName ()).equals (name)) {
134 public boolean hasVariables () throws DebugException {
135 if (variables == null) { // Do we have a variables array?
139 return variables.length > 0; // Is there something within the array?
142 public int getLineNumber() {
146 public void setLineNumber(int line) {
150 public int getCharStart() throws DebugException {
155 public int getCharEnd() throws DebugException {
160 public String getName() {
161 if(!this.getDescription().equals(""))
162 return this.getDescription() + " [line: " + this.getLineNumber() + "]";
164 return this.getFileName() + " [line: " + this.getLineNumber() + "]";
167 public String getFileName() {
171 public void setDescription(String desc) {
172 this.description= desc;
175 public String getDescription() {
176 return this.description;
179 public IRegisterGroup[] getRegisterGroups() throws DebugException {
183 public boolean hasRegisterGroups() throws DebugException {
187 public String getModelIdentifier() {
188 return this.getThread().getModelIdentifier();
191 public IDebugTarget getDebugTarget() {
192 return this.getThread().getDebugTarget();
195 public ILaunch getLaunch() {
196 return this.getDebugTarget().getLaunch();
199 public boolean canStepInto() {
203 public boolean canStepOver() {
207 public boolean canStepReturn() {
211 public boolean isStepping() {
218 public void stepInto () throws DebugException {
221 thread.prepareForResume (DebugEvent.STEP_INTO); // Don't know why, but this is necessary
222 this.getPHPDBGProxy ().readStepIntoEnd (PHPStackFrame.this);
224 ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_INTO);
225 DebugPlugin.getDefault().fireDebugEventSet (new DebugEvent[] { ev });
231 public void stepOver () throws DebugException {
234 thread.prepareForResume (DebugEvent.STEP_OVER);
235 this.getPHPDBGProxy ().readStepOverEnd (PHPStackFrame.this) ;
237 ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_OVER);
238 DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });
244 public void stepReturn () throws DebugException {
247 thread.prepareForResume (DebugEvent.STEP_RETURN);
248 this.getPHPDBGProxy ().readStepReturnEnd (PHPStackFrame.this) ;
250 ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
251 DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });
255 public boolean canResume() {
256 return this.getThread().canResume();
259 public boolean canSuspend() {
260 return this.getThread().canSuspend();
263 public boolean isSuspended() {
264 return this.getThread().isSuspended();
267 public void resume() throws DebugException {
268 this.getThread().resume();
271 public void suspend() throws DebugException {
274 public boolean canTerminate() {
275 return this.getThread().canTerminate();
278 public boolean isTerminated() {
279 return this.getThread().isTerminated();
282 public void terminate() throws DebugException {
283 getPHPDBGProxy().stop();
286 public int getIndex() {
290 public PHPDBGProxy getPHPDBGProxy() {
291 PHPDebugTarget DebugTarget;
293 DebugTarget = (PHPDebugTarget) thread.getDebugTarget ();
295 return DebugTarget.getPHPDBGProxy ();
298 public void setFile(String file) {
302 public int getModNo() {