X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java index bf59b50..4130898 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java @@ -11,6 +11,8 @@ Contributors: **********************************************************************/ package net.sourceforge.phpdt.internal.debug.core.model; +import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy; + import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; @@ -20,69 +22,141 @@ import org.eclipse.debug.core.model.IRegisterGroup; import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.core.model.IVariable; -import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy; -import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget; -public class PHPStackFrame implements IStackFrame { +public class PHPStackFrame extends PHPDebugElement implements IStackFrame { - private PHPThread thread; - private String file; - private int lineNumber; - private int index; - private PHPVariable[] variables; - private String description; + private PHPThread thread; // The thread to which this stackframe belongs + private String file; // The file name??? + private int lineNumber; // + private int index; // + private int modno; // + private PHPVariable[] variables; // The array of variables + private String description; // - public PHPStackFrame(PHPThread thread, String file, int line, int index, String desc) { - this.lineNumber = line; - this.index = index; - this.file = file; - this.thread = thread; + /** + * + * @param thread + * @param file + * @param line + * @param index + * @param desc + * @param modno + */ + public PHPStackFrame (PHPThread thread, String file, int line, int index, String desc, int modno) { + super (null); + + this.lineNumber = line; + this.index = index; + this.file = file; + this.thread = thread; this.description = desc; - } - - public PHPStackFrame(PHPThread thread, String file, int line, int index) { + this.modno = modno; + } + + /** + * + * @param thread + * @param file + * @param line + * @param index + */ + public PHPStackFrame (PHPThread thread, String file, int line, int index) { + super (null); + this.lineNumber = line; - this.index = index; - this.file = file; - this.thread = thread; - } - - public IThread getThread() { + this.index = index; + this.file = file; + this.thread = thread; + } + + /** + * + */ + public IThread getThread () { return thread; } - - public void setThread(PHPThread thread) { + + /** + * @param thread + */ + public void setThread (PHPThread thread) { this.thread = thread; } - + + /** + * + * This function returns the array of PHPVariables for this stackframe + * The PHPVariables should not change (newly build up) between two steps + * (or breaks). + * A PHPVariable with the same name but with different object ID is + * handled as a new variable. + * + * TODO Remove the intermediate storage array + * + * @return The array of PHPVariables for this stackframe. + */ public IVariable[] getVariables() throws DebugException { - if (variables == null) { - variables = this.getPHPDBGProxy().readVariables(this); + PHPVariable[] variablesNew; // The intermediate storage of the variable array we get from DBG proxy + + variablesNew = this.getPHPDBGProxy ().readVariables (this); // Get the variable array from DBG proxy + variables = variablesNew; // Store the array the stackframes member variable + + return variables; // Give the array back to user interface + } + + /** + * TODO Is this really used (who calls this) + * I think this method could be removed + * + * @param s The variables name we are looking for. + * @return + */ + public IVariable findVariable (String s) throws DebugException { + String name; + int i; + + if (this.hasVariables ()) { // Does this stackframe have variables? + name = "$" + s; // Prefix the variable name with $ + + for (i = 0; i < variables.length; i++) { // For all variables + if ((variables[i].getName ()).equals (name)) { + return variables[i]; + } + } } - return variables; + + return null; } - - public boolean hasVariables() throws DebugException { - if (variables == null) { - return false; + + /** + * + */ + public boolean hasVariables () throws DebugException { + if (variables == null) { // Do we have a variables array? + return false; // No } - return variables.length > 0; + + return variables.length > 0; // Is there something within the array? } - + public int getLineNumber() { return lineNumber; } - + + public void setLineNumber(int line) { + lineNumber = line; + } + public int getCharStart() throws DebugException { // not supported return -1; } - + public int getCharEnd() throws DebugException { // not supported return -1; } - + public String getName() { if(!this.getDescription().equals("")) return this.getDescription() + " [line: " + this.getLineNumber() + "]"; @@ -93,7 +167,7 @@ public class PHPStackFrame implements IStackFrame { public String getFileName() { return file; } - + public void setDescription(String desc) { this.description= desc; } @@ -101,98 +175,112 @@ public class PHPStackFrame implements IStackFrame { public String getDescription() { return this.description; } - + public IRegisterGroup[] getRegisterGroups() throws DebugException { return null; } - + public boolean hasRegisterGroups() throws DebugException { return false; } - + public String getModelIdentifier() { return this.getThread().getModelIdentifier(); } - + public IDebugTarget getDebugTarget() { return this.getThread().getDebugTarget(); } - + public ILaunch getLaunch() { return this.getDebugTarget().getLaunch(); } - + public boolean canStepInto() { return canResume(); } - + public boolean canStepOver() { return canResume(); } - + public boolean canStepReturn() { return canResume(); } - + public boolean isStepping() { return false; } - - public void stepInto() throws DebugException { - thread.prepareForResume() ; - this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ; - DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_INTO); - DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); + + /** + * + */ + public void stepInto () throws DebugException { + DebugEvent ev; + + thread.prepareForResume (DebugEvent.STEP_INTO); // Don't know why, but this is necessary + this.getPHPDBGProxy ().readStepIntoEnd (PHPStackFrame.this); + + ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_INTO); + DebugPlugin.getDefault().fireDebugEventSet (new DebugEvent[] { ev }); } - - public void stepOver() throws DebugException { - thread.prepareForResume() ; - this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this) ; - DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_OVER); - DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); + + /** + * + */ + public void stepOver () throws DebugException { + DebugEvent ev; + + thread.prepareForResume (DebugEvent.STEP_OVER); + this.getPHPDBGProxy ().readStepOverEnd (PHPStackFrame.this) ; + + ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_OVER); + DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev }); } - public void stepReturn() throws DebugException { - thread.prepareForResume() ; - this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ; - DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_RETURN); - DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); + /** + * + */ + public void stepReturn () throws DebugException { + DebugEvent ev; + + thread.prepareForResume (DebugEvent.STEP_RETURN); + this.getPHPDBGProxy ().readStepReturnEnd (PHPStackFrame.this) ; + + ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_RETURN); + DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev }); } - + public boolean canResume() { return this.getThread().canResume(); } - + public boolean canSuspend() { return this.getThread().canSuspend(); } - + public boolean isSuspended() { return this.getThread().isSuspended(); - } - + } + public void resume() throws DebugException { this.getThread().resume(); } - + public void suspend() throws DebugException { } - + public boolean canTerminate() { return this.getThread().canTerminate(); } - + public boolean isTerminated() { return this.getThread().isTerminated(); - } - + } + public void terminate() throws DebugException { getPHPDBGProxy().stop(); - } - - public Object getAdapter(Class arg0) { - return null; } public int getIndex() { @@ -201,8 +289,17 @@ public class PHPStackFrame implements IStackFrame { public PHPDBGProxy getPHPDBGProxy() { PHPDebugTarget DebugTarget; - DebugTarget= (PHPDebugTarget)thread.getDebugTarget(); - return DebugTarget.getPHPDBGProxy(); + + DebugTarget = (PHPDebugTarget) thread.getDebugTarget (); + + return DebugTarget.getPHPDBGProxy (); } + public void setFile(String file) { + this.file = file; + } + + public int getModNo() { + return modno; + } }