2 * Created on 23.11.2004
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package net.sourceforge.phpeclipse.xdebug.php.model;
9 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
10 import net.sourceforge.phpeclipse.xdebug.core.DebugConnection.DebugResponse;
12 import org.eclipse.core.runtime.Path;
13 import org.eclipse.debug.core.DebugException;
14 import org.eclipse.debug.core.model.IRegisterGroup;
15 import org.eclipse.debug.core.model.IStackFrame;
16 import org.eclipse.debug.core.model.IThread;
17 import org.eclipse.debug.core.model.IVariable;
18 import org.w3c.dom.Node;
19 import org.w3c.dom.NodeList;
24 * TODO To change the template for this generated type comment go to Window -
25 * Preferences - Java - Code Style - Code Templates
27 public class XDebugStackFrame extends XDebugElement implements IStackFrame {
29 private XDebugThread fThread;
31 // private String fName;
34 private String fFileName;
38 private IVariable[] fVariables;
40 private String fLevel;
44 private String fWhere;
47 * Constructs a stack frame in the given thread with the given frame data.
53 * stack frame id (0 is the bottom of the stack)
55 public XDebugStackFrame(XDebugThread thread, Node stackNode, int id) {
56 super((XDebugTarget) thread.getDebugTarget());
63 * Initializes this frame based on its data
67 private void init(Node stackNode) {
69 fLevel = PHPDebugUtils.getAttributeValue(stackNode, "level");
70 fType = PHPDebugUtils.getAttributeValue(stackNode, "type");
71 String fileName = PHPDebugUtils.unescapeString(PHPDebugUtils
72 .getAttributeValue(stackNode, "filename"));
73 String lineNo = PHPDebugUtils.getAttributeValue(stackNode, "lineno");
76 fLineNo = Integer.parseInt(lineNo);
78 fWhere = PHPDebugUtils.getAttributeValue(stackNode, "where");
80 fFileName = (new Path(fileName)).lastSegment();
83 id = ((XDebugTarget) getDebugTarget()).sendRequest("context_get",
85 } catch (DebugException e) {
86 // TODO Auto-generated catch block
89 DebugResponse response = ((XDebugTarget) getDebugTarget())
91 Node responseNode = response.getParentNode();
92 NodeList property = responseNode.getChildNodes();
93 fVariables = new IVariable[property.getLength()];
94 for (int i = 0; i < property.getLength(); i++) {
95 Node propertyNode = property.item(i);
96 fVariables[i] = new XDebugVariable(this, propertyNode);
99 // int numVars = strings.length - 3;
100 // fVariables = new IVariable[numVars];
101 // for (int i = 0; i < numVars; i++) {
102 // fVariables[i] = new XDebugVariable(this, strings[i + 3]);
109 * @see org.eclipse.debug.core.model.IStackFrame#getThread()
111 public IThread getThread() {
118 * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
120 public IVariable[] getVariables() throws DebugException {
127 * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
129 public boolean hasVariables() throws DebugException {
130 return fVariables.length > 0;
136 * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
138 public int getLineNumber() throws DebugException {
145 * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
147 public int getCharStart() throws DebugException {
154 * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
156 public int getCharEnd() throws DebugException {
163 * @see org.eclipse.debug.core.model.IStackFrame#getName()
165 public String getName() throws DebugException {
166 return fFileName + "::" + fWhere + " : lineno " + fLineNo;
172 * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
174 public IRegisterGroup[] getRegisterGroups() throws DebugException {
181 * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
183 public boolean hasRegisterGroups() throws DebugException {
190 * @see org.eclipse.debug.core.model.IStep#canStepInto()
192 public boolean canStepInto() {
193 return getThread().canStepInto();
199 * @see org.eclipse.debug.core.model.IStep#canStepOver()
201 public boolean canStepOver() {
202 return getThread().canStepOver();
208 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
210 public boolean canStepReturn() {
211 return getThread().canStepReturn();
217 * @see org.eclipse.debug.core.model.IStep#isStepping()
219 public boolean isStepping() {
220 return getThread().isStepping();
226 * @see org.eclipse.debug.core.model.IStep#stepInto()
228 public void stepInto() throws DebugException {
229 getThread().stepInto();
235 * @see org.eclipse.debug.core.model.IStep#stepOver()
237 public void stepOver() throws DebugException {
238 getThread().stepOver();
244 * @see org.eclipse.debug.core.model.IStep#stepReturn()
246 public void stepReturn() throws DebugException {
247 getThread().stepReturn();
253 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
255 public boolean canResume() {
256 return getThread().canResume();
262 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
264 public boolean canSuspend() {
265 return getThread().canSuspend();
271 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
273 public boolean isSuspended() {
274 return getThread().isSuspended();
280 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
282 public void resume() throws DebugException {
283 getThread().resume();
289 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
291 public void suspend() throws DebugException {
292 getThread().suspend();
298 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
300 public boolean canTerminate() {
301 return getThread().canTerminate();
307 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
309 public boolean isTerminated() {
310 return getThread().isTerminated();
316 * @see org.eclipse.debug.core.model.ITerminate#terminate()
318 public void terminate() throws DebugException {
319 getThread().terminate();
323 * Returns the name of the source file this stack frame is associated with.
325 * @return the name of the source file this stack frame is associated with
327 public String getSourceName() {
334 * @see java.lang.Object#equals(java.lang.Object)
336 public boolean equals(Object obj) {
337 if (obj instanceof XDebugStackFrame) {
338 XDebugStackFrame sf = (XDebugStackFrame) obj;
340 return sf.getSourceName().equals(getSourceName())
341 && sf.getLineNumber() == getLineNumber()
343 } catch (DebugException e) {
352 * @see java.lang.Object#hashCode()
354 public int hashCode() {
355 return getSourceName().hashCode() + fId;
359 * Returns this stack frame's unique identifier within its thread
361 * @return this stack frame's unique identifier within its thread
363 protected int getIdentifier() {