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 org.eclipse.debug.core.DebugEvent;
15 import org.eclipse.debug.core.DebugException;
16 import org.eclipse.debug.core.DebugPlugin;
17 import org.eclipse.debug.core.ILaunch;
18 import org.eclipse.debug.core.model.IDebugTarget;
19 import org.eclipse.debug.core.model.IRegisterGroup;
20 import org.eclipse.debug.core.model.IStackFrame;
21 import org.eclipse.debug.core.model.IThread;
22 import org.eclipse.debug.core.model.IVariable;
23 import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
24 import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget;
26 public class PHPStackFrame implements IStackFrame {
28 private PHPThread thread;
30 private int lineNumber;
33 private PHPVariable[] variables;
34 private String description;
36 public PHPStackFrame(PHPThread thread, String file, int line, int index, String desc, int modno) {
37 this.lineNumber = line;
41 this.description = desc;
45 public PHPStackFrame(PHPThread thread, String file, int line, int index) {
46 this.lineNumber = line;
52 public IThread getThread() {
56 public void setThread(PHPThread thread) {
60 public IVariable[] getVariables() throws DebugException {
61 if (variables == null) {
62 variables = this.getPHPDBGProxy().readVariables(this);
67 public IVariable findVariable(String s) throws DebugException {
68 if (this.hasVariables()) {
70 for(int i= 0; i < variables.length; i++) {
71 String n= variables[i].getName();
72 if((variables[i].getName()).equals(name))
79 public boolean hasVariables() throws DebugException {
80 if (variables == null) {
83 return variables.length > 0;
86 public int getLineNumber() {
90 public int getCharStart() throws DebugException {
95 public int getCharEnd() throws DebugException {
100 public String getName() {
101 if(!this.getDescription().equals(""))
102 return this.getDescription() + " [line: " + this.getLineNumber() + "]";
104 return this.getFileName() + " [line: " + this.getLineNumber() + "]";
107 public String getFileName() {
111 public void setDescription(String desc) {
112 this.description= desc;
115 public String getDescription() {
116 return this.description;
119 public IRegisterGroup[] getRegisterGroups() throws DebugException {
123 public boolean hasRegisterGroups() throws DebugException {
127 public String getModelIdentifier() {
128 return this.getThread().getModelIdentifier();
131 public IDebugTarget getDebugTarget() {
132 return this.getThread().getDebugTarget();
135 public ILaunch getLaunch() {
136 return this.getDebugTarget().getLaunch();
139 public boolean canStepInto() {
143 public boolean canStepOver() {
147 public boolean canStepReturn() {
151 public boolean isStepping() {
155 public void stepInto() throws DebugException {
156 thread.prepareForResume() ;
157 this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ;
158 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_INTO);
159 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
162 public void stepOver() throws DebugException {
163 thread.prepareForResume() ;
164 this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this) ;
165 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_OVER);
166 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
169 public void stepReturn() throws DebugException {
170 thread.prepareForResume() ;
171 this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ;
172 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
173 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
177 public boolean canResume() {
178 return this.getThread().canResume();
181 public boolean canSuspend() {
182 return this.getThread().canSuspend();
185 public boolean isSuspended() {
186 return this.getThread().isSuspended();
189 public void resume() throws DebugException {
190 this.getThread().resume();
193 public void suspend() throws DebugException {
196 public boolean canTerminate() {
197 return this.getThread().canTerminate();
200 public boolean isTerminated() {
201 return this.getThread().isTerminated();
204 public void terminate() throws DebugException {
205 getPHPDBGProxy().stop();
208 public Object getAdapter(Class arg0) {
209 if (arg0==PHPStackFrame.class)
215 public int getIndex() {
219 public PHPDBGProxy getPHPDBGProxy() {
220 PHPDebugTarget DebugTarget;
221 DebugTarget= (PHPDebugTarget)thread.getDebugTarget();
222 return DebugTarget.getPHPDBGProxy();
225 public void setFile(String file) {
229 public int getModNo() {