X-Git-Url: http://git.phpeclipse.com 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..00f460a 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 @@ -13,6 +13,7 @@ package net.sourceforge.phpdt.internal.debug.core.model; import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy; import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin; +import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.resources.IMarkerDelta; @@ -28,6 +29,7 @@ import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.model.IWorkbenchAdapter; @@ -35,7 +37,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 +75,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; @@ -104,6 +107,11 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, fireThreadCreateEvent(phpThread); } + public void updateThreads (PHPThread phpThread) { + fireChangeEvent (); + fireThreadCreateEvent (phpThread); + } + private void fireChangeEvent() { DebugEvent ev = new DebugEvent(this, DebugEvent.CHANGE); DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); @@ -114,14 +122,14 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev }); } - protected PHPThread getThreadById(int id) { - for (int i = 0; i < threads.length; i++) { - if (threads[i].getId() == id) { - return threads[i]; - } - } - return null; - } +// protected PHPThread getThreadById(int id) { +// for (int i = 0; i < threads.length; i++) { +// if (threads[i].getId() == id) { +// return threads[i]; +// } +// } +// return null; +// } public IThread[] getThreads() { return threads; @@ -146,6 +154,10 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, return PHPDebugCorePlugin.PLUGIN_ID; } + public IStackFrame[] getStackFrames () throws DebugException { + return (IStackFrame[]) this.phpDBGProxy.getDBGInterface ().getStackList (); + } + public IDebugTarget getDebugTarget() { return this; } @@ -162,6 +174,17 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, return state.isTerminated(); } + private synchronized void terminateThreads () { + int i; + + try { + for (i = 0; i < threads.length; i++) { + threads[i].terminate (); + } + } catch (DebugException e) { + } + } + public synchronized void terminate() { // This method is synchronized to control a race condition between the // UI thread that terminates the debugging session, and the slave @@ -171,6 +194,7 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, return; state.setTerminated(true); phpDBGProxy.stop(); + terminateThreads (); this.threads = new PHPThread[0]; fireChangeEvent(); IBreakpointManager manager = DebugPlugin.getDefault() @@ -223,33 +247,46 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, this.getPHPDBGProxy().removeBreakpoint(breakpoint); } - public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta arg1) { - // This method is called whenever a source file has changed in which - // case - // we terminate since the source will be out of sync with the debugger - // The method will also be called when the user enables/disables - // breakpoints - // in this case we add or remove the breakpoint + /** + * The method will be called when the user enables/disables + * breakpoints. In this case we add or remove the breakpoint. + * It's also called when leaving the breakpoint properties dialog + * (skip count and breakpoint condition) with the OK button. + * + * This method is also called whenever a source file has changed. + * In this case we terminate since the source will be out of sync with the debugger. + * TODO Is it correct to call this method when a sourcefile is modified? + * + */ + public void breakpointChanged (IBreakpoint breakpoint, IMarkerDelta arg1) { + PHPLineBreakpoint bp; + bp = (PHPLineBreakpoint) breakpoint; + try { - // Check if breakpoint state changed from disabled to enabled - if (breakpoint.isEnabled() - && !arg1.getAttribute("org.eclipse.debug.core.enabled", - false)) { + if (breakpoint.isEnabled () && // Check if breakpoint state changed from disabled to enabled + !arg1.getAttribute ("org.eclipse.debug.core.enabled", false)) { this.getPHPDBGProxy().addBreakpoint(breakpoint); - // Check if breakpoint state changed from enabled to disabled - } else if (!breakpoint.isEnabled() - && arg1 - .getAttribute("org.eclipse.debug.core.enabled", - true)) { + } + else if (!breakpoint.isEnabled () && // Check if breakpoint state changed from enabled to disabled + arg1.getAttribute ("org.eclipse.debug.core.enabled", true)) { this.getPHPDBGProxy().removeBreakpoint(breakpoint); - } else { - // All other cases will terminate the debugger - terminate(); + } + else if (bp.getChangeID() != arg1.getAttribute ("net.sourceforge.phpeclipse.debug.changeID", 0)) { + if (breakpoint.isEnabled()) { // If the breakpoint is already enabled + this.getPHPDBGProxy().removeBreakpoint(breakpoint); // we remove this breakpoint first + this.getPHPDBGProxy().addBreakpoint(breakpoint); // and then we add again (else DBG would have two breakpoints!). + } + else { + this.getPHPDBGProxy().removeBreakpoint(breakpoint); + } + } + else { // All other cases will terminate the debugger + terminate (); } } catch (CoreException e) { // Do nothing } - } + } public boolean canDisconnect() { return false; @@ -304,7 +341,13 @@ public class PHPDebugTarget implements IPHPDebugTarget, ILaunchListener, } }; } - return null; + else { + if (arg0 == PHPDebugElement.class) { + return this; + } + + return super.getAdapter(arg0); + } } public IProcess getProcess() { @@ -352,7 +395,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) {