Pārlūkot izejas kodu

Bugfix: State of debug commands Step Stop Resume

Andreas Mülder 14 gadi atpakaļ
vecāks
revīzija
113a7b1905

+ 0 - 1
plugins/org.yakindu.sct.core.simulation/src/org/yakindu/sct/core/simulation/SGraphSimulationSessionRegistry.java

@@ -13,7 +13,6 @@ package org.yakindu.sct.core.simulation;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.yakindu.sct.core.simulation.extensions.Extensions;
 import org.yakindu.sct.core.simulation.extensions.IExtensionPoints;
 
 /**

+ 0 - 53
plugins/org.yakindu.sct.core.simulation/src/org/yakindu/sct/core/simulation/debugmodel/SCTDebugElement.java

@@ -1,53 +0,0 @@
-package org.yakindu.sct.core.simulation.debugmodel;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IDebugTarget;
-
-public abstract class SCTDebugElement extends PlatformObject implements
-		IDebugElement {
-
-	protected IDebugTarget target;
-
-	public SCTDebugElement(IDebugTarget target) {
-		this.target = target;
-	}
-
-	public String getModelIdentifier() {
-		return IDebugConstants.ID_DEBUG_MODEL;
-	}
-
-	public IDebugTarget getDebugTarget() {
-		return target;
-	}
-
-
-	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == IDebugElement.class) {
-			return this;
-		}
-		return super.getAdapter(adapter);
-	}
-
-	protected void fireEvent(DebugEvent event) {
-		DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
-	}
-
-	protected void fireCreationEvent() {
-		fireEvent(new DebugEvent(this, DebugEvent.CREATE));
-	}
-
-	public void fireResumeEvent(int detail) {
-		fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail));
-	}
-
-	public void fireSuspendEvent(int detail) {
-		fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail));
-	}
-
-	protected void fireTerminateEvent() {
-		fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
-	}
-}

+ 16 - 4
plugins/org.yakindu.sct.core.simulation/src/org/yakindu/sct/core/simulation/debugmodel/SCTDebugTarget.java

@@ -2,6 +2,7 @@ package org.yakindu.sct.core.simulation.debugmodel;
 
 import org.eclipse.core.resources.IMarkerDelta;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.PlatformObject;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
@@ -11,12 +12,13 @@ import org.eclipse.debug.core.model.IMemoryBlock;
 import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.IThread;
 import org.yakindu.sct.core.simulation.ISGraphExecutionFacade;
+
 /**
  * 
- * @author andreas muelder
- *
+ * @author andreas muelder - Initial contribution and API
+ * 
  */
-public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
+public class SCTDebugTarget extends PlatformObject implements IDebugTarget {
 
 	private IProcess process;
 
@@ -26,7 +28,6 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
 
 	public SCTDebugTarget(ILaunch launch, ISGraphExecutionFacade facade)
 			throws CoreException {
-		super(null);
 		this.launch = launch;
 		thread = new SCTDebugThread(this, facade);
 		DebugPlugin.getDefault().getBreakpointManager()
@@ -62,6 +63,7 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
 	}
 
 	public void terminate() throws DebugException {
+
 		thread.terminate();
 	}
 
@@ -127,4 +129,14 @@ public class SCTDebugTarget extends SCTDebugElement implements IDebugTarget {
 	public ILaunch getLaunch() {
 		return launch;
 	}
+
+	@Override
+	public String getModelIdentifier() {
+		return IDebugConstants.DEBUG_TARGET;
+	}
+
+	@Override
+	public IDebugTarget getDebugTarget() {
+		return this;
+	}
 }

+ 32 - 9
plugins/org.yakindu.sct.core.simulation/src/org/yakindu/sct/core/simulation/debugmodel/SCTDebugThread.java

@@ -1,8 +1,12 @@
 package org.yakindu.sct.core.simulation.debugmodel;
 
+import org.eclipse.core.runtime.PlatformObject;
+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.IBreakpoint;
+import org.eclipse.debug.core.model.IDebugTarget;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IThread;
 import org.yakindu.sct.core.simulation.ISGraphExecutionFacade;
@@ -10,19 +14,20 @@ import org.yakindu.sct.core.simulation.SGraphSimulationSession;
 
 /**
  * 
- * @author andreas muelder
+ * @author andreas muelder - Initial contribution and API
  * 
  */
-public class SCTDebugThread extends SCTDebugElement implements IThread {
+public class SCTDebugThread extends PlatformObject implements IThread {
 
 	private boolean stepping = false;
-	private boolean terminated;
-	private boolean suspended;
+	private boolean terminated = false;
+	private boolean suspended = false;
 	private Thread thread;
 	private SGraphSimulationSession session;
+	private final SCTDebugTarget target;
 
 	public SCTDebugThread(SCTDebugTarget target, ISGraphExecutionFacade facade) {
-		super(target);
+		this.target = target;
 		session = new SGraphSimulationSession(facade);
 		thread = new Thread(session);
 		thread.start();
@@ -30,7 +35,7 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public IStackFrame[] getStackFrames() throws DebugException {
-		return null;
+		return new IStackFrame[] {};
 	}
 
 	public boolean hasStackFrames() throws DebugException {
@@ -50,7 +55,7 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public boolean canResume() {
-		return suspended;
+		return suspended && !terminated;
 	}
 
 	public boolean canSuspend() {
@@ -62,11 +67,13 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public void resume() throws DebugException {
+		fireEvent(new DebugEvent(this, DebugEvent.RESUME));
 		session.resume();
 		suspended = false;
 	}
 
 	public void suspend() throws DebugException {
+		fireEvent(new DebugEvent(this, DebugEvent.SUSPEND));
 		session.suspend();
 		suspended = true;
 	}
@@ -76,7 +83,7 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public boolean canStepOver() {
-		return isSuspended();
+		return isSuspended() && !isTerminated();
 	}
 
 	public boolean canStepReturn() {
@@ -91,6 +98,7 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public void stepOver() throws DebugException {
+		fireEvent(new DebugEvent(getDebugTarget(), DebugEvent.STEP_OVER));
 		session.singleStep();
 	}
 
@@ -106,8 +114,9 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	}
 
 	public void terminate() throws DebugException {
-		session.terminate();
+		fireEvent(new DebugEvent(getDebugTarget(), DebugEvent.TERMINATE));
 		terminated = true;
+		session.terminate();
 	}
 
 	@Override
@@ -119,4 +128,18 @@ public class SCTDebugThread extends SCTDebugElement implements IThread {
 	public ILaunch getLaunch() {
 		return getDebugTarget().getLaunch();
 	}
+
+	protected void fireEvent(DebugEvent event) {
+		DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
+	}
+
+	@Override
+	public String getModelIdentifier() {
+		return IDebugConstants.DEBUG_THREAD;
+	}
+
+	@Override
+	public IDebugTarget getDebugTarget() {
+		return target;
+	}
 }

+ 0 - 1
plugins/org.yakindu.sct.core.simulation/src/org/yakindu/sct/core/simulation/extensions/IExtensionPoints.java

@@ -3,6 +3,5 @@ package org.yakindu.sct.core.simulation.extensions;
 public interface IExtensionPoints {
 
 	public static final String EXECUTION_BUILDER = "org.yakindu.sct.simulation.core.sgraph.executionbuilder";
-	public static final String SESSION_LISTENER = "org.yakindu.sct.simulation.core.sgraph.sessionlistener";
 
 }