X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStackFrame.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStackFrame.java index 1bc38bb..b0e057f 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStackFrame.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStackFrame.java @@ -6,17 +6,18 @@ */ package net.sourceforge.phpeclipse.xdebug.php.model; -//import java.net.MalformedURLException; +import java.net.MalformedURLException; import java.net.URL; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.DebugException; 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.phpeclipse.xdebug.core.IDebugConnection; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author PHPeclipse team @@ -25,22 +26,13 @@ import org.eclipse.core.runtime.Path; */ public class XDebugStackFrame extends XDebugElement implements IStackFrame { private XDebugThread fThread; - - private int fId; - - //private IPath fName; - private URL fName; - private int fLineNumber; private int fLevel; private String fType; private String fWhere; - private IVariable[] fVariables; - private int fStepCount = 0; - //private int fCurrentStepCount = 0; /** * Constructs a stack frame in the given thread with the given @@ -50,10 +42,20 @@ public class XDebugStackFrame extends XDebugElement implements IStackFrame { * @param data frame data * @param id stack frame id (0 is the bottom of the stack) */ - public XDebugStackFrame(XDebugThread thread, int id) { - super(thread == null ? null : (XDebugTarget) thread.getDebugTarget()); - fId = id; + public XDebugStackFrame(XDebugThread thread, int id, String type, int lineNumber, String where, /*URL*/String filename) { + super(/*thread == null ? null : */(XDebugTarget) thread.getDebugTarget()); + + fLevel = id; fThread = thread; + fType = type; + fLineNumber = lineNumber; + fWhere = where; + + try { + fName = new URL(filename); + } catch (MalformedURLException e) { + e.printStackTrace(); + } } public void incrementStepCounter() { @@ -68,19 +70,46 @@ public class XDebugStackFrame extends XDebugElement implements IStackFrame { } public IVariable[] getVariables() throws DebugException { - if (fVariables == null) { - fVariables = fTarget.getVariables(this, fLevel); - } + /* always read variables, poor performance + * but this fix bug #680. + * need to investigate on. + */ + + //if (fVariables == null) { + Node dfl = ((XDebugTarget) getDebugTarget()).getLocalVariables(fLevel); + Node dfg = ((XDebugTarget) getDebugTarget()).getGlobalVariables(fLevel); + parseVariable(dfl, dfg); + //} return fVariables; } - public void evaluateChange(IStackFrame OldStackFrame) throws DebugException { + private void parseVariable(Node localVariables, Node globalVariables) throws DebugException { + NodeList property = localVariables.getChildNodes(); + + NodeList propertyGlobal = globalVariables.getChildNodes(); + + fVariables = new IVariable[property.getLength() + propertyGlobal.getLength()]; + + int length = property.getLength(); + for (int i = 0; i < length; i++) { + XDebugVariable var = new XDebugVariable(this, property.item(i)); + fVariables[i] = var; + } + + int globalLength = propertyGlobal.getLength(); + for (int k = 0; k < globalLength; k++) { + XDebugVariable var = new XDebugVariable(this, propertyGlobal.item(k)); + fVariables[k + length] = var; + } + } + + /*public void evaluateChange(IStackFrame OldStackFrame) throws DebugException { IVariable[] OldVariable = ((XDebugStackFrame) OldStackFrame).getVariables(); for (int i = 0; i < fVariables.length; i++) { ((XDebugVariable) fVariables[i]).setChange(OldVariable[i]); } - } + }*/ /* (non-Javadoc) * @see org.eclipse.debug.core.model.IStackFrame#hasVariables() @@ -115,8 +144,6 @@ public class XDebugStackFrame extends XDebugElement implements IStackFrame { * @see org.eclipse.debug.core.model.IStackFrame#getName() */ public String getName() throws DebugException { - //String a = fName.getFile(); - //return fName.lastSegment().toString()+"::"+fWhere+ " line: "+ fLineNumber; return fName.toString()+"::"+fWhere+ " line: "+ fLineNumber; } @@ -259,15 +286,9 @@ public class XDebugStackFrame extends XDebugElement implements IStackFrame { if (obj instanceof XDebugStackFrame) { XDebugStackFrame sf = (XDebugStackFrame)obj; - //try { - isSameStackFrame = sf.getSourceName().equals(getSourceName()) && - /*sf.getLineNumber() == getLineNumber() &&*/ - /*sf.getLevel() == getLevel() &&*/ - sf.getType().equals(getType()) && - sf.getWhere().equals(getWhere()); //&& - /*sf.fId == fId;*/ - /*} catch (DebugException e) { - }*/ + isSameStackFrame = sf.getSourceName().equals(getSourceName()) && + sf.getType().equals(getType()) && + sf.getWhere().equals(getWhere()); //&& } return isSameStackFrame; @@ -280,14 +301,11 @@ public class XDebugStackFrame extends XDebugElement implements IStackFrame { if (obj instanceof XDebugStackFrame) { XDebugStackFrame sf = (XDebugStackFrame)obj; try { - return sf.getSourceName().equals(getSourceName()) && - sf.getLineNumber() == getLineNumber() && - sf.getLevel() == getLevel() && - sf.getType().equals(getType()) && - sf.getWhere().equals(getWhere()); -/* sf.getType() == getType() && - sf.getWhere() == getWhere() &&*/ - /*sf.fId == fId;*/ + return sf.getSourceName().equals(new Path(fName.getFile()).lastSegment()) && + sf.getLineNumber() == fLineNumber && + sf.getLevel() == fLevel && + sf.getType().equals(fType) && + sf.getWhere().equals(fWhere); } catch (DebugException e) { } } @@ -296,74 +314,33 @@ public class XDebugStackFrame extends XDebugElement implements IStackFrame { } /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equalsOld(Object obj) { - if (obj instanceof XDebugStackFrame) { - XDebugStackFrame sf = (XDebugStackFrame)obj; - try { - return sf.getSourceName().equals(getSourceName()) && - sf.getLineNumber() == getLineNumber() && - sf.fId == fId; - } catch (DebugException e) { - } - } - return false; - } - - /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { -// return getSourceName().hashCode() + fId; return getSourceName().hashCode() + fLevel; } - /** - * - * @return this stack frame's unique identifier within its thread - */ - protected int getIdentifier() { - return fId; - } - - - public void setFullName(URL name) { - fName = name; - } - - public URL getFullName() { return fName; } - public int getLevel() { return fLevel; } - public void setLevel(int level) { - fLevel = level; - fId = level; - } - public String getType() { return fType; } - public void setType(String type) { - fType = type; - } - public String getWhere() { return fWhere; } - public void setWhere(String where) { - fWhere = where; + public boolean setVariableValue(XDebugVariable variable, String expression) throws DebugException { + return ((XDebugTarget) getDebugTarget()).setVarValue("$" + variable.getName(), expression); } - - public void setLineNumber(int newlineNumber) { - fLineNumber = newlineNumber; + + public Node eval(String expression) throws DebugException { + return ((XDebugTarget) getDebugTarget()).eval(expression); } } \ No newline at end of file