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;
32 private PHPVariable[] variables;
33 private String description;
35 public PHPStackFrame(PHPThread thread, String file, int line, int index, String desc) {
36 this.lineNumber = line;
40 this.description = desc;
43 public PHPStackFrame(PHPThread thread, String file, int line, int index) {
44 this.lineNumber = line;
50 public IThread getThread() {
54 public void setThread(PHPThread thread) {
58 public IVariable[] getVariables() throws DebugException {
59 if (variables == null) {
60 variables = this.getPHPDBGProxy().readVariables(this);
65 public boolean hasVariables() throws DebugException {
66 if (variables == null) {
69 return variables.length > 0;
72 public int getLineNumber() {
76 public int getCharStart() throws DebugException {
81 public int getCharEnd() throws DebugException {
86 public String getName() {
87 if(!this.getDescription().equals(""))
88 return this.getDescription() + " [line: " + this.getLineNumber() + "]";
90 return this.getFileName() + " [line: " + this.getLineNumber() + "]";
93 public String getFileName() {
97 public void setDescription(String desc) {
98 this.description= desc;
101 public String getDescription() {
102 return this.description;
105 public IRegisterGroup[] getRegisterGroups() throws DebugException {
109 public boolean hasRegisterGroups() throws DebugException {
113 public String getModelIdentifier() {
114 return this.getThread().getModelIdentifier();
117 public IDebugTarget getDebugTarget() {
118 return this.getThread().getDebugTarget();
121 public ILaunch getLaunch() {
122 return this.getDebugTarget().getLaunch();
125 public boolean canStepInto() {
129 public boolean canStepOver() {
133 public boolean canStepReturn() {
137 public boolean isStepping() {
141 public void stepInto() throws DebugException {
142 thread.prepareForResume() ;
143 this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ;
144 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_INTO);
145 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
148 public void stepOver() throws DebugException {
149 thread.prepareForResume() ;
150 this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this) ;
151 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_OVER);
152 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
155 public void stepReturn() throws DebugException {
156 thread.prepareForResume() ;
157 this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ;
158 DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
159 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
163 public boolean canResume() {
164 return this.getThread().canResume();
167 public boolean canSuspend() {
168 return this.getThread().canSuspend();
171 public boolean isSuspended() {
172 return this.getThread().isSuspended();
175 public void resume() throws DebugException {
176 this.getThread().resume();
179 public void suspend() throws DebugException {
182 public boolean canTerminate() {
183 return this.getThread().canTerminate();
186 public boolean isTerminated() {
187 return this.getThread().isTerminated();
190 public void terminate() throws DebugException {
191 getPHPDBGProxy().stop();
194 public Object getAdapter(Class arg0) {
198 public int getIndex() {
202 public PHPDBGProxy getPHPDBGProxy() {
203 PHPDebugTarget DebugTarget;
204 DebugTarget= (PHPDebugTarget)thread.getDebugTarget();
205 return DebugTarget.getPHPDBGProxy();