* 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;
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;
private PHPDBGInterface DBGInt = null;
- private IPHPDebugTarget debugTarget = null;
+ private PHPDebugTarget debugTarget = null;
private PHPLoop phpLoop;
private boolean remote;
private boolean pathtranslation;
-
+
private Map pathmap;
-
+
private IPath remoteSourcePath;
public PHPDBGProxy() {
}
return path;
}
-
+
public void addBreakpoint(IBreakpoint breakpoint) {
if (DBGInt == null)
return;
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) {
}
}
- protected IPHPDebugTarget getDebugTarget() {
+ protected PHPDebugTarget getDebugTarget() {
return debugTarget;
}
- public void setDebugTarget(IPHPDebugTarget debugTarget) {
+ public void setDebugTarget(PHPDebugTarget debugTarget) {
this.debugTarget = debugTarget;
debugTarget.setPHPDBGProxy(this);
}
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) {
--- /dev/null
+/*******************************************************************************
+ * 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 <code>CREATE</code> event for this element.
+ */
+ protected void fireCreationEvent() {
+ fireEvent(new DebugEvent(this, DebugEvent.CREATE));
+ }
+
+ /**
+ * Fires a <code>RESUME</code> 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 <code>SUSPEND</code> 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 <code>TERMINATE</code> event for this element.
+ */
+ protected void fireTerminateEvent() {
+ fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
+ }
+}
/**
* Debug target for PHP debug model.
*/
-public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener,
+public class PHPDebugTarget extends PHPDebugElement implements IPHPDebugTarget, ILaunchListener,
IDebugEventSetListener {
private IProcess process;
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;
} catch (CoreException e) {
// Do nothing
}
- }
+ }
public boolean canDisconnect() {
return false;
/**
* When a debug target or process terminates, terminate DBG Proxy.
- *
+ *
* @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
*/
public void handleDebugEvents(DebugEvent[] events) {
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;
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() + "]";
public String getFileName() {
return file;
}
-
+
public void setDescription(String desc) {
this.description= desc;
}
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) ;
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;
public void setFile(String file) {
this.file = file;
}
-
+
public int getModNo() {
return modno;
}
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;
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);
}
return target;
}
- public void setDebugTarget(IDebugTarget target) {
+ public void setDebugTarget(PHPDebugTarget target) {
this.target = target;
}