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 net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
16 import org.eclipse.debug.core.DebugEvent;
17 import org.eclipse.debug.core.DebugException;
18 import org.eclipse.debug.core.DebugPlugin;
19 import org.eclipse.debug.core.ILaunch;
20 import org.eclipse.debug.core.model.IDebugTarget;
21 import org.eclipse.debug.core.model.IRegisterGroup;
22 import org.eclipse.debug.core.model.IStackFrame;
23 import org.eclipse.debug.core.model.IThread;
24 import org.eclipse.debug.core.model.IVariable;
26 public class PHPStackFrame extends PHPDebugElement 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) {
38 this.lineNumber = line;
42 this.description = desc;
46 public PHPStackFrame(PHPThread thread, String file, int line, int index) {
48 this.lineNumber = line;
54 public IThread getThread() {
58 public void setThread(PHPThread thread) {
62 public IVariable[] getVariables() throws DebugException {
63 if (variables == null) {
64 variables = this.getPHPDBGProxy().readVariables(this);
69 public IVariable findVariable(String s) throws DebugException {
70 if (this.hasVariables()) {
72 for(int i= 0; i < variables.length; i++) {
73 String n= variables[i].getName();
74 if((variables[i].getName()).equals(name))
81 public boolean hasVariables() throws DebugException {
82 if (variables == null) {
85 return variables.length > 0;
88 public int getLineNumber() {
92 public int getCharStart() throws DebugException {
97 public int getCharEnd() throws DebugException {
102 public String getName() {
103 if(!this.getDescription().equals(""))
104 return this.getDescription() + " [line: " + this.getLineNumber() + "]";
106 return this.getFileName() + " [line: " + this.getLineNumber() + "]";
109 public String getFileName() {
113 public void setDescription(String desc) {
114 this.description= desc;
117 public String getDescription() {
118 return this.description;
121 public IRegisterGroup[] getRegisterGroups() throws DebugException {
125 public boolean hasRegisterGroups() throws DebugException {
129 public String getModelIdentifier() {
130 return this.getThread().getModelIdentifier();
133 public IDebugTarget getDebugTarget() {
134 return this.getThread().getDebugTarget();
137 public ILaunch getLaunch() {
138 return this.getDebugTarget().getLaunch();
141 public boolean canStepInto() {
145 public boolean canStepOver() {
149 public boolean canStepReturn() {
153 public boolean isStepping() {
157 public void stepInto() throws DebugException {
158 thread.prepareForResume() ;
159 this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ;
160 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_INTO);
161 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
164 public void stepOver() throws DebugException {
165 thread.prepareForResume() ;
166 this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this) ;
167 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_OVER);
168 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
171 public void stepReturn() throws DebugException {
172 thread.prepareForResume() ;
173 this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ;
174 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
175 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
179 public boolean canResume() {
180 return this.getThread().canResume();
183 public boolean canSuspend() {
184 return this.getThread().canSuspend();
187 public boolean isSuspended() {
188 return this.getThread().isSuspended();
191 public void resume() throws DebugException {
192 this.getThread().resume();
195 public void suspend() throws DebugException {
198 public boolean canTerminate() {
199 return this.getThread().canTerminate();
202 public boolean isTerminated() {
203 return this.getThread().isTerminated();
206 public void terminate() throws DebugException {
207 getPHPDBGProxy().stop();
210 public int getIndex() {
214 public PHPDBGProxy getPHPDBGProxy() {
215 PHPDebugTarget DebugTarget;
216 DebugTarget= (PHPDebugTarget)thread.getDebugTarget();
217 return DebugTarget.getPHPDBGProxy();
220 public void setFile(String file) {
224 public int getModNo() {