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.core;
9 import org.eclipse.core.runtime.Path;
10 import org.eclipse.debug.core.DebugException;
11 import org.eclipse.debug.core.model.IRegisterGroup;
12 import org.eclipse.debug.core.model.IStackFrame;
13 import org.eclipse.debug.core.model.IThread;
14 import org.eclipse.debug.core.model.IVariable;
19 * TODO To change the template for this generated type comment go to
20 * Window - Preferences - Java - Code Style - Code Templates
22 public class XDebugStackFrame extends XDebugElement implements IStackFrame {
24 private XDebugThread fThread;
27 private String fFileName;
29 private IVariable[] fVariables;
32 * Constructs a stack frame in the given thread with the given
36 * @param data frame data
37 * @param id stack frame id (0 is the bottom of the stack)
39 public XDebugStackFrame(XDebugThread thread, String data, int id) {
40 super((XDebugTarget) thread.getDebugTarget());
47 * Initializes this frame based on its data
51 private void init(String data) {
52 String[] strings = data.split("\\|");
53 String fileName = strings[0];
54 fFileName = (new Path(fileName)).lastSegment();
55 String pc = strings[1];
56 fPC = Integer.parseInt(pc) + 1;
58 int numVars = strings.length - 3;
59 fVariables = new IVariable[numVars];
60 for (int i = 0; i < numVars; i++) {
61 fVariables[i] = new XDebugVariable(this, strings[i + 3]);
66 * @see org.eclipse.debug.core.model.IStackFrame#getThread()
68 public IThread getThread() {
72 * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
74 public IVariable[] getVariables() throws DebugException {
78 * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
80 public boolean hasVariables() throws DebugException {
81 return fVariables.length > 0;
84 * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
86 public int getLineNumber() throws DebugException {
90 * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
92 public int getCharStart() throws DebugException {
96 * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
98 public int getCharEnd() throws DebugException {
102 * @see org.eclipse.debug.core.model.IStackFrame#getName()
104 public String getName() throws DebugException {
108 * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
110 public IRegisterGroup[] getRegisterGroups() throws DebugException {
114 * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
116 public boolean hasRegisterGroups() throws DebugException {
120 * @see org.eclipse.debug.core.model.IStep#canStepInto()
122 public boolean canStepInto() {
123 return getThread().canStepInto();
126 * @see org.eclipse.debug.core.model.IStep#canStepOver()
128 public boolean canStepOver() {
129 return getThread().canStepOver();
132 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
134 public boolean canStepReturn() {
135 return getThread().canStepReturn();
138 * @see org.eclipse.debug.core.model.IStep#isStepping()
140 public boolean isStepping() {
141 return getThread().isStepping();
144 * @see org.eclipse.debug.core.model.IStep#stepInto()
146 public void stepInto() throws DebugException {
147 getThread().stepInto();
150 * @see org.eclipse.debug.core.model.IStep#stepOver()
152 public void stepOver() throws DebugException {
153 getThread().stepOver();
156 * @see org.eclipse.debug.core.model.IStep#stepReturn()
158 public void stepReturn() throws DebugException {
159 getThread().stepReturn();
162 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
164 public boolean canResume() {
165 return getThread().canResume();
168 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
170 public boolean canSuspend() {
171 return getThread().canSuspend();
174 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
176 public boolean isSuspended() {
177 return getThread().isSuspended();
180 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
182 public void resume() throws DebugException {
183 getThread().resume();
186 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
188 public void suspend() throws DebugException {
189 getThread().suspend();
192 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
194 public boolean canTerminate() {
195 return getThread().canTerminate();
198 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
200 public boolean isTerminated() {
201 return getThread().isTerminated();
204 * @see org.eclipse.debug.core.model.ITerminate#terminate()
206 public void terminate() throws DebugException {
207 getThread().terminate();
211 * Returns the name of the source file this stack frame is associated
214 * @return the name of the source file this stack frame is associated
217 public String getSourceName() {
221 * @see java.lang.Object#equals(java.lang.Object)
223 public boolean equals(Object obj) {
224 if (obj instanceof XDebugStackFrame) {
225 XDebugStackFrame sf = (XDebugStackFrame)obj;
227 return sf.getSourceName().equals(getSourceName()) &&
228 sf.getLineNumber() == getLineNumber() &&
230 } catch (DebugException e) {
236 * @see java.lang.Object#hashCode()
238 public int hashCode() {
239 return getSourceName().hashCode() + fId;
243 * Returns this stack frame's unique identifier within its thread
245 * @return this stack frame's unique identifier within its thread
247 protected int getIdentifier() {