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 boolean hasVariables() throws DebugException {
68 if (variables == null) {
71 return variables.length > 0;
74 public int getLineNumber() {
78 public int getCharStart() throws DebugException {
83 public int getCharEnd() throws DebugException {
88 public String getName() {
89 if(!this.getDescription().equals(""))
90 return this.getDescription() + " [line: " + this.getLineNumber() + "]";
92 return this.getFileName() + " [line: " + this.getLineNumber() + "]";
95 public String getFileName() {
99 public void setDescription(String desc) {
100 this.description= desc;
103 public String getDescription() {
104 return this.description;
107 public IRegisterGroup[] getRegisterGroups() throws DebugException {
111 public boolean hasRegisterGroups() throws DebugException {
115 public String getModelIdentifier() {
116 return this.getThread().getModelIdentifier();
119 public IDebugTarget getDebugTarget() {
120 return this.getThread().getDebugTarget();
123 public ILaunch getLaunch() {
124 return this.getDebugTarget().getLaunch();
127 public boolean canStepInto() {
131 public boolean canStepOver() {
135 public boolean canStepReturn() {
139 public boolean isStepping() {
143 public void stepInto() throws DebugException {
144 thread.prepareForResume() ;
145 this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ;
146 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_INTO);
147 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
150 public void stepOver() throws DebugException {
151 thread.prepareForResume() ;
152 this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this) ;
153 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_OVER);
154 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
157 public void stepReturn() throws DebugException {
158 thread.prepareForResume() ;
159 this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ;
160 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
161 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
165 public boolean canResume() {
166 return this.getThread().canResume();
169 public boolean canSuspend() {
170 return this.getThread().canSuspend();
173 public boolean isSuspended() {
174 return this.getThread().isSuspended();
177 public void resume() throws DebugException {
178 this.getThread().resume();
181 public void suspend() throws DebugException {
184 public boolean canTerminate() {
185 return this.getThread().canTerminate();
188 public boolean isTerminated() {
189 return this.getThread().isTerminated();
192 public void terminate() throws DebugException {
193 getPHPDBGProxy().stop();
196 public Object getAdapter(Class arg0) {
200 public int getIndex() {
204 public PHPDBGProxy getPHPDBGProxy() {
205 PHPDebugTarget DebugTarget;
206 DebugTarget= (PHPDebugTarget)thread.getDebugTarget();
207 return DebugTarget.getPHPDBGProxy();
210 public void setFile(String file) {
214 public int getModNo() {