From a54252b897e98a6b1ceaaf46d4efbbd3e61f4028 Mon Sep 17 00:00:00 2001 From: axelcl Date: Mon, 3 Oct 2005 09:13:58 +0000 Subject: [PATCH] Patches from user robekras to show the variables view --- .../phpdt/internal/debug/core/PHPDBGProxy.java | 22 ++-- .../internal/debug/core/model/PHPDebugElement.java | 119 ++++++++++++++++++++ .../internal/debug/core/model/PHPDebugTarget.java | 7 +- .../internal/debug/core/model/PHPStackFrame.java | 82 +++++++------- .../phpdt/internal/debug/core/model/PHPThread.java | 9 +- 5 files changed, 180 insertions(+), 59 deletions(-) create mode 100644 net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugElement.java diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java index 4f665aa..0c30b77 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java @@ -2,7 +2,7 @@ * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This program and the accompanying materials are made * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * + * * Contributors: IBM Corporation - Initial implementation Vicente Fernando - www.alfersoft.com.ar Christian Perkonig - remote debug **********************************************************************************************************************************/ package net.sourceforge.phpdt.internal.debug.core; @@ -17,7 +17,7 @@ import java.net.SocketTimeoutException; import java.util.Map; import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint; -import net.sourceforge.phpdt.internal.debug.core.model.IPHPDebugTarget; +import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget; import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame; import net.sourceforge.phpdt.internal.debug.core.model.PHPThread; import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable; @@ -40,7 +40,7 @@ public class PHPDBGProxy { private PHPDBGInterface DBGInt = null; - private IPHPDebugTarget debugTarget = null; + private PHPDebugTarget debugTarget = null; private PHPLoop phpLoop; @@ -53,9 +53,9 @@ public class PHPDBGProxy { private boolean remote; private boolean pathtranslation; - + private Map pathmap; - + private IPath remoteSourcePath; public PHPDBGProxy() { @@ -178,7 +178,7 @@ public class PHPDBGProxy { } return path; } - + public void addBreakpoint(IBreakpoint breakpoint) { if (DBGInt == null) return; @@ -245,7 +245,7 @@ public class PHPDBGProxy { if (null != DBGInt) DBGInt.pauseExecution(); else { - // TODO Make sure the Suspend action is grayed out + // TODO Make sure the Suspend action is grayed out // when DBGInt is null } } catch (IOException e) { @@ -254,11 +254,11 @@ public class PHPDBGProxy { } } - protected IPHPDebugTarget getDebugTarget() { + protected PHPDebugTarget getDebugTarget() { return debugTarget; } - public void setDebugTarget(IPHPDebugTarget debugTarget) { + public void setDebugTarget(PHPDebugTarget debugTarget) { this.debugTarget = debugTarget; debugTarget.setPHPDBGProxy(this); } @@ -349,8 +349,8 @@ public class PHPDBGProxy { public synchronized void setShouldStop() { shouldStop = true; try { - // If the loop thread is blocked on the server socket, - // forcibly unblock it to avoid leaking the thread, + // If the loop thread is blocked on the server socket, + // forcibly unblock it to avoid leaking the thread, // the socket and the port closeServerSocket(); } catch (IOException x) { diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugElement.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugElement.java new file mode 100644 index 0000000..e66ac6d --- /dev/null +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugElement.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Bjorn Freeman-Benson - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.internal.debug.core.model; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugEvent; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.core.model.IDebugTarget; + +/** + * Common function of PHP debug model elements + */ +public abstract class PHPDebugElement extends PlatformObject implements IDebugElement { + + // containing target + protected PHPDebugTarget fTarget; + + /** + * Constructs a new debug element contained in the given + * debug target. + * + * @param target debug target (PHP VM) + */ + public PHPDebugElement(PHPDebugTarget target) { + fTarget = target; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() + */ + public String getModelIdentifier() { + return null; + // return PHPDebugCorePlugin.PLUGIN_ID; + // return IPDAConstants.ID_PDA_DEBUG_MODEL; + } + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() + */ + public IDebugTarget getDebugTarget() { + return fTarget; + } + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() + */ + public ILaunch getLaunch() { + return getDebugTarget().getLaunch(); + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class adapter) { + if (adapter == IDebugElement.class) { + return this; + } + return super.getAdapter(adapter); + } + + protected void abort(String message, Throwable e) throws DebugException { + throw new DebugException(new Status(IStatus.ERROR, null /*DebugExamplesPlugin.getDefault().getDescriptor().getUniqueIdentifier()*/, + DebugPlugin.INTERNAL_ERROR, message, e)); + } + + /** + * Fires a debug event + * + * @param event the event to be fired + */ + protected void fireEvent(DebugEvent event) { + DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event}); + } + + /** + * Fires a CREATE event for this element. + */ + protected void fireCreationEvent() { + fireEvent(new DebugEvent(this, DebugEvent.CREATE)); + } + + /** + * Fires a RESUME event for this element with + * the given detail. + * + * @param detail event detail code + */ + public void fireResumeEvent(int detail) { + fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail)); + } + + /** + * Fires a SUSPEND event for this element with + * the given detail. + * + * @param detail event detail code + */ + public void fireSuspendEvent(int detail) { + fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail)); + } + + /** + * Fires a TERMINATE event for this element. + */ + protected void fireTerminateEvent() { + fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); + } +} diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugTarget.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugTarget.java index 887cee3..1d11803 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugTarget.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDebugTarget.java @@ -35,7 +35,7 @@ import org.eclipse.ui.model.IWorkbenchAdapter; /** * Debug target for PHP debug model. */ -public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, +public class PHPDebugTarget extends PHPDebugElement implements IPHPDebugTarget, ILaunchListener, IDebugEventSetListener { private IProcess process; @@ -73,6 +73,7 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, private final State state = new State(); public PHPDebugTarget(ILaunch launch, IProcess process) { + super (null); if (null == launch && null == process) throw new IllegalArgumentException(); this.launch = launch; @@ -249,7 +250,7 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, } catch (CoreException e) { // Do nothing } - } + } public boolean canDisconnect() { return false; @@ -352,7 +353,7 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, /** * When a debug target or process terminates, terminate DBG Proxy. - * + * * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[]) */ public void handleDebugEvents(DebugEvent[] events) { diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java index af564eb..380e0a7 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java @@ -40,30 +40,30 @@ public class PHPStackFrame implements IStackFrame { this.thread = thread; this.description = desc; this.modno = modno; - } - + } + public PHPStackFrame(PHPThread thread, String file, int line, int index) { this.lineNumber = line; this.index = index; this.file = file; this.thread = thread; - } - + } + public IThread getThread() { return thread; } - + public void setThread(PHPThread thread) { this.thread = thread; } - + public IVariable[] getVariables() throws DebugException { if (variables == null) { variables = this.getPHPDBGProxy().readVariables(this); } return variables; } - + public IVariable findVariable(String s) throws DebugException { if (this.hasVariables()) { String name="$"+s; @@ -72,31 +72,31 @@ public class PHPStackFrame implements IStackFrame { if((variables[i].getName()).equals(name)) return variables[i]; } - } + } return null; } - + public boolean hasVariables() throws DebugException { if (variables == null) { return false; } return variables.length > 0; } - + public int getLineNumber() { return lineNumber; } - + public int getCharStart() throws DebugException { // not supported return -1; } - + public int getCharEnd() throws DebugException { // not supported return -1; } - + public String getName() { if(!this.getDescription().equals("")) return this.getDescription() + " [line: " + this.getLineNumber() + "]"; @@ -107,7 +107,7 @@ public class PHPStackFrame implements IStackFrame { public String getFileName() { return file; } - + public void setDescription(String desc) { this.description= desc; } @@ -115,50 +115,50 @@ public class PHPStackFrame implements IStackFrame { public String getDescription() { return this.description; } - + public IRegisterGroup[] getRegisterGroups() throws DebugException { return null; } - + public boolean hasRegisterGroups() throws DebugException { return false; } - + public String getModelIdentifier() { return this.getThread().getModelIdentifier(); } - + public IDebugTarget getDebugTarget() { return this.getThread().getDebugTarget(); } - + public ILaunch getLaunch() { return this.getDebugTarget().getLaunch(); } - + public boolean canStepInto() { return canResume(); } - + public boolean canStepOver() { return canResume(); } - + public boolean canStepReturn() { return canResume(); } - + public boolean isStepping() { return false; } - + public void stepInto() throws DebugException { thread.prepareForResume() ; - this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ; + this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ; DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_INTO); DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); } - + public void stepOver() throws DebugException { thread.prepareForResume() ; this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this) ; @@ -168,43 +168,43 @@ public class PHPStackFrame implements IStackFrame { public void stepReturn() throws DebugException { thread.prepareForResume() ; - this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ; + this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ; DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_RETURN); - DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); + DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); } - + public boolean canResume() { return this.getThread().canResume(); } - + public boolean canSuspend() { return this.getThread().canSuspend(); } - + public boolean isSuspended() { return this.getThread().isSuspended(); - } - + } + public void resume() throws DebugException { this.getThread().resume(); } - + public void suspend() throws DebugException { } - + public boolean canTerminate() { return this.getThread().canTerminate(); } - + public boolean isTerminated() { return this.getThread().isTerminated(); - } - + } + public void terminate() throws DebugException { getPHPDBGProxy().stop(); - } - + } + public Object getAdapter(Class arg0) { if (arg0==PHPStackFrame.class) return this; @@ -225,7 +225,7 @@ public class PHPStackFrame implements IStackFrame { public void setFile(String file) { this.file = file; } - + public int getModNo() { return modno; } diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPThread.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPThread.java index 231119a..efc55ea 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPThread.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPThread.java @@ -24,11 +24,11 @@ import org.eclipse.debug.core.model.IThread; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.model.IWorkbenchAdapter; -public class PHPThread implements IThread { +public class PHPThread extends PHPDebugElement implements IThread { private PHPStackFrame[] frames; - private IDebugTarget target; + private PHPDebugTarget target; private String name; @@ -76,7 +76,8 @@ public class PHPThread implements IThread { private final State state = new State(); - public PHPThread(IDebugTarget target, int id) { + public PHPThread (PHPDebugTarget target, int id) { + super (target); this.target = target; this.setId(id); } @@ -119,7 +120,7 @@ public class PHPThread implements IThread { return target; } - public void setDebugTarget(IDebugTarget target) { + public void setDebugTarget(PHPDebugTarget target) { this.target = target; } -- 1.7.1