/** * Handles the given {@link ResumingReply}. * * @param resumingReply * the {@link ResumingReply} */ private void handleResumingReply(ResumingReply resumingReply) { final Thread eThread = DebugTargetUtils.getThread(getHost(), resumingReply.getThreadName()); if (resumingReply instanceof StepIntoResumingReply) { // EMF model change factory.getModelUpdater().stepIntoReply(eThread); // Eclipse change factory.getThread(eThread).fireResumeEvent(DebugEvent.STEP_INTO); } else if (resumingReply instanceof StepOverResumingReply) { // EMF model change factory.getModelUpdater().stepOverReply(eThread); // Eclipse change factory.getThread(eThread).fireResumeEvent(DebugEvent.STEP_OVER); } else if (resumingReply instanceof StepReturnResumingReply) { // EMF model change factory.getModelUpdater().stepReturnReply(eThread); // Eclipse change factory.getThread(eThread).fireResumeEvent(DebugEvent.STEP_RETURN); } else { // EMF model change factory.getModelUpdater().resumedReply(eThread); // Eclipse change factory.getThread(eThread).fireResumeEvent(DebugEvent.CLIENT_REQUEST); } fireChangeEvent(DebugEvent.STATE); }
/** * Handles the given {@link SuspendedReply}. * * @param suspendReply * the {@link SuspendedReply} */ private void handleSuspendReply(SuspendedReply suspendReply) { final Thread eThread = DebugTargetUtils.getThread(getHost(), suspendReply.getThreadName()); final DSLThreadAdapter thread = factory.getThread(eThread); // EMF model change factory.getModelUpdater().suspendedReply(eThread); // Eclipse change if (suspendReply instanceof SteppedReply) { thread.fireSuspendEvent(DebugEvent.STEP_END); } else if (suspendReply instanceof BreakpointReply) { thread.fireSuspendEvent(DebugEvent.BREAKPOINT); } else { thread.fireSuspendEvent(DebugEvent.CLIENT_REQUEST); } fireChangeEvent(DebugEvent.STATE); // notify our suspend listeners }
@Override public void serverChanged(ServerEvent event) { Preconditions.checkState(server == event.getServer()); switch (event.getState()) { case IServer.STATE_STARTED: openBrowserPage(server); fireChangeEvent(DebugEvent.STATE); return; case IServer.STATE_STOPPED: server.removeServerListener(serverEventsListener); fireTerminateEvent(); try { logger.fine("Server stopped; terminating launch"); //$NON-NLS-1$ launch.terminate(); } catch (DebugException ex) { logger.log(Level.WARNING, "Unable to terminate launch", ex); //$NON-NLS-1$ } return; default: fireChangeEvent(DebugEvent.STATE); return; } }
protected void handleDebugEvent(DebugEvent debugEvent) { updateActions(); switch (debugEvent.getKind()) { case DebugEvent.TERMINATE : setViewerInput(null); break; case DebugEvent.SUSPEND : break; case DebugEvent.RESUME : break; } Display.getDefault().asyncExec(() -> { if (debugEvent.getSource() != null) { sessionDropdown.refresh(); targets.removeIf(dt -> dt.isTerminated()); } }); }
public void onBreakpointHit(ProductMessage productMessage) { System.out.println("MontoDebugTarget.onBreakpointHit()"); HitBreakpoint hitBreakpoint = GsonMonto.fromJson(productMessage, HitBreakpoint.class); if (productMessage.getSource().equals(sessionSource)) { isSuspended = true; MontoThread hitThread = convertMontoToEclipseThread(this, hitBreakpoint.getHitThread()); threads.clear(); threads.add(hitThread); for (Thread montoThread : hitBreakpoint.getOtherThreads()) { threads.add(convertMontoToEclipseThread(this, montoThread)); } threads.forEach(thread -> thread.fireSuspendEvent(DebugEvent.BREAKPOINT)); } }
void onProcessTerminatedProduct(ProductMessage productMessage) { if (productMessage.getSource().equals(sessionSource)) { ProcessTerminated processTerminated = GsonMonto.fromJson(productMessage, ProcessTerminated.class); terminated = true; exitCode = processTerminated.getExitCode(); System.out.println("Process " + sessionId + " terminated"); DebugPlugin.getDefault() .fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)}); // deregister product listeners // Deregistration needs to happen is separate thread, because removing listeners in this // callback method, which is called from the SinkDemultiplexer thread, causes a // ConcurrentModification exception in the SinkDemultiplexer thread, because the listener // map/list is SinkDemultiplexer is modified, before all listeners are called CompletableFuture.runAsync(() -> { Activator.getDefault().getDemultiplexer().removeProductListener(Products.PROCESS_TERMINATED, this); Activator.getDefault().getDemultiplexer().removeProductListener(Products.STREAM_OUTPUT, this); }); } }
/** * When a Server runtime server is started and terminated, and the project has a GWT Facet, start and stop the GWT * Super Dev Mode Code Server with runtime server. */ @Override public void start(BundleContext context) throws Exception { super.start(context); // Observe launch events that are from the WTP server serverProcessListener = new IDebugEventSetListener() { @Override public void handleDebugEvents(DebugEvent[] events) { if (events != null) { onDebugEvents(events); } } }; DebugPlugin.getDefault().addDebugEventListener(serverProcessListener); }
private void onAfterCodeServerStarted(DebugEvent event) { if (!(event.getSource() instanceof IProcess)) { return; } IProcess runtimeProcess = (IProcess) event.getSource(); final ILaunch launch = runtimeProcess.getLaunch(); IProcess[] processes = launch.getProcesses(); final IProcess process = processes[0]; // Look for the links in the sdm console output consoleStreamListenerCodeServer = new IStreamListener() { @Override public void streamAppended(String text, IStreamMonitor monitor) { displayCodeServerUrlInDevMode(launch, text); } }; // Listen to Console output streamMonitorCodeServer = process.getStreamsProxy().getOutputStreamMonitor(); streamMonitorCodeServer.addListener(consoleStreamListenerCodeServer); }
@Override public void interpreterSuspended(InterpreterState state, List<EventReason> eventReasons) { this.suspendedState = state; this.isSuspended = true; synchronized (this.debugElements) { for (DebugElement element : this.debugElements) { if (eventReasons.contains(EventReason.BreakPoint) || eventReasons.contains(EventReason.WatchPoint)) { element.fireSuspendEvent(DebugEvent.BREAKPOINT); } if (eventReasons.contains(EventReason.ClientRequest)) { element.fireSuspendEvent(DebugEvent.CLIENT_REQUEST); } if (eventReasons.contains(EventReason.StepEnd)) { element.fireSuspendEvent(DebugEvent.STEP_END); } } } }
@Override public void interpreterFinished(InterpreterState state, List<EventReason> reasons) { this.isStopped = true; this.isSuspended = false; IDebugTarget target = null; if (DebugPlugin.getDefault() != null) { synchronized (this.debugElements) { for (DebugElement element : this.debugElements) { element.fireTerminateEvent(); target = element.getDebugTarget(); } } DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(BfProcess.this, DebugEvent.TERMINATE)}); if (target != null && target instanceof BfDebugTarget) { ((BfDebugTarget) target).fireTerminateEvent(); } } }
public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent event : events) { switch (event.getKind()) { case DebugEvent.TERMINATE: if (event.getSource().equals(getDebugTarget())) { DebugPlugin.getDefault().getExpressionManager().removeExpression(this); } break; case DebugEvent.SUSPEND: if (event.getDetail() != DebugEvent.EVALUATION_IMPLICIT && event.getSource() instanceof IDebugElement) { IDebugElement source = (IDebugElement) event.getSource(); if (source.getDebugTarget().equals(getDebugTarget())) { DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT) }); } } break; } } }
@Test public void multipleSessionsAreTracked() { FakePlugin fp = new FakePlugin(); RuntimeSessionTracker rst = new RuntimeSessionTracker(null, fp); assertThat("The session should be alive", fp.shutdownWasCalled, is(0)); rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.CREATE)}); rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.CREATE)}); assertThat("The session should be alive", fp.shutdownWasCalled, is(0)); rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.TERMINATE)}); assertThat("The session should be alive", fp.shutdownWasCalled, is(0)); rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.CREATE)}); rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.TERMINATE)}); assertThat("The session should be alive", fp.shutdownWasCalled, is(0)); rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.TERMINATE)}); assertThat("The session should be over", fp.shutdownWasCalled, is(1)); }
@Override public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent debugEvent : events) { if (debugEvent.getSource() instanceof IProcess && ((IProcess)debugEvent.getSource()).getLaunch() == trackedLaunch) { if (debugEvent.getKind() == DebugEvent.CREATE) { liveProcessCount++; assert liveProcessCount > 0; } else if (debugEvent.getKind() == DebugEvent.TERMINATE) { liveProcessCount--; assert liveProcessCount >= 0; if (liveProcessCount == 0) { dispose(); } } } } }
@Override public void handleDebugEvents(final DebugEvent[] events) { for (final DebugEvent event : events) { if (event.getSource().equals(process)) { if (event.getKind() == DebugEvent.TERMINATE) { if (shellConnection != null) { try { shellConnection.disconnect(); } catch (final IOException e) { KarafUIPluginActivator.getLogger().error("Unable to disconnect from SSH server", e); } } DebugPlugin.getDefault().removeDebugEventListener(this); resetName(); } } } }
@Override public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent event : events) { switch (event.getKind()) { case DebugEvent.CREATE: if (event.getSource() instanceof IDebugTarget) { WatchDogEventType.START_DEBUG.process(this); } break; case DebugEvent.TERMINATE: if (event.getSource() instanceof IDebugTarget) { WatchDogEventType.END_DEBUG.process(this); } break; default: break; } } }
private void handleSuspendEvent(DebugEvent event) { switch (event.getDetail()) { case DebugEvent.BREAKPOINT: TrackingEventManager.addEvent(new DebugEventBase( TrackingEventType.SUSPEND_BREAKPOINT, new Date())); break; case DebugEvent.CLIENT_REQUEST: TrackingEventManager.addEvent(new DebugEventBase( TrackingEventType.SUSPEND_CLIENT, new Date())); break; case DebugEvent.EVALUATION: TrackingEventManager.addEvent(new DebugEventBase( TrackingEventType.INSPECT_VARIABLE, new Date())); break; } }
private void handleResumeEvent(DebugEvent event) { switch (event.getDetail()) { case DebugEvent.STEP_INTO: TrackingEventManager.addEvent( new DebugEventBase(TrackingEventType.STEP_INTO, new Date())); break; case DebugEvent.STEP_OVER: TrackingEventManager.addEvent( new DebugEventBase(TrackingEventType.STEP_OVER, new Date())); break; case DebugEvent.STEP_RETURN: TrackingEventManager.addEvent( new DebugEventBase(TrackingEventType.STEP_OUT, new Date())); break; case DebugEvent.CLIENT_REQUEST: TrackingEventManager.addEvent(new DebugEventBase( TrackingEventType.RESUME_CLIENT, new Date())); break; } }
@Override public void handleDebugEvents(final DebugEvent[] events) { // allow views to be selectively enabled/disabled if (!this.isEnabled()) { return; } // dispatch an async update for at most one event DebugEvent updateEvent = null; for (final DebugEvent event : events) { if (event.getKind() == DebugEvent.RESUME || event.getKind() == DebugEvent.SUSPEND || event.getKind() == DebugEvent.TERMINATE || event.getKind() == DebugEvent.STATE) { updateEvent = event; break; } } if (updateEvent != null) { updateActionBar(); } }
PyVariable[] setVariables(PyVariable[] newVars) { IVariable[] oldVars = this.variables; if (newVars == oldVars) { return newVars; } IVariablesContainerParent p = this.parent.get(); if (p == null) { return newVars; } AbstractDebugTarget target = p.getTarget(); this.variables = newVars; if (!gettingInitialVariables) { if (target != null) { target.fireEvent(new DebugEvent(p, DebugEvent.CHANGE, DebugEvent.CONTENT)); } } return newVars; }
@Override public void handleDebugEvents(DebugEvent[] events) { for (int i = 0; i < events.length; i++) { DebugEvent event = events[i]; if (event.getSource().equals(getProcess())) { Runnable r = new Runnable() { @Override public void run() { if (restartLaunchAction != null) { restartLaunchAction.update(); } if (terminateAllLaunchesAction != null) { terminateAllLaunchesAction.update(); } } }; DebugUIPlugin.getStandardDisplay().asyncExec(r); } } }
private void updateBreakpoint(Breakpoint teavmBreakpoint) { IJavaLineBreakpoint breakpoint = breakpointBackMap.get(teavmBreakpoint); if (breakpoint != null) { try { if (!teavmBreakpoint.isValid() || !teavmDebugger.isAttached()) { breakpoint.getMarker().setAttribute(JAVA_BREAKPOINT_INSTALL_COUNT, 0); } else { breakpoint.getMarker().setAttribute(JAVA_BREAKPOINT_INSTALL_COUNT, 1); } DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged(breakpoint); } catch (CoreException e) { throw new RuntimeException(e); } fireEvent(new DebugEvent(breakpoint, DebugEvent.CHANGE)); } }
@Override public void terminate() throws DebugException { streamsProxy.closeInputStream(); shell.exit(); ((AbstractHostShellOutputReader) shell.getStandardOutputReader()).interrupt(); ((AbstractHostShellOutputReader) shell.getStandardErrorReader()).interrupt(); try { cmdSubSystem.disconnect(); } catch (Exception e) { throw new DebugException(new Status( IStatus.WARNING, LaunchPlugin.PLUGIN_ID, "Cannot disconnect command subsystem", e)); //$NON-NLS-1$ } terminated = true; getSystemRegistry().removeSystemResourceChangeListener(this); DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)}); }
@Override public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent e : events) { switch (e.getKind()) { case DebugEvent.TERMINATE: DebugPlugin.getDefault().removeDebugEventListener(this); terminateProcess(); break; default: break; } } }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventSuspendedReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new SuspendedReply(eDebugTarget.getThreads().get(runningThreadIndex) .getName())); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(2, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( runningThreadIndex))); assertEquals(DebugEvent.SUSPEND, event.getKind()); assertEquals(DebugEvent.CLIENT_REQUEST, event.getDetail()); events = listener.getEventsList().get(1); assertEquals(1, events.length); event = events[0]; assertTrue(event.getSource() == debugTarget); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.STATE, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventSteppedReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new SteppedReply(eDebugTarget.getThreads().get(runningThreadIndex) .getName())); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(2, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( runningThreadIndex))); assertEquals(DebugEvent.SUSPEND, event.getKind()); assertEquals(DebugEvent.STEP_END, event.getDetail()); events = listener.getEventsList().get(1); assertEquals(1, events.length); event = events[0]; assertTrue(event.getSource() == debugTarget); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.STATE, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventBreakpointReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new BreakpointReply(eDebugTarget.getThreads().get(runningThreadIndex) .getName())); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(2, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( runningThreadIndex))); assertEquals(DebugEvent.SUSPEND, event.getKind()); assertEquals(DebugEvent.BREAKPOINT, event.getDetail()); events = listener.getEventsList().get(1); assertEquals(1, events.length); event = events[0]; assertTrue(event.getSource() == debugTarget); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.STATE, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventTerminatedReplyThread() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new TerminatedReply(eDebugTarget.getThreads().get(runningThreadIndex) .getName())); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( runningThreadIndex))); assertEquals(DebugEvent.TERMINATE, event.getKind()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventTerminatedReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new TerminatedReply()); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == debugTarget); assertEquals(DebugEvent.TERMINATE, event.getKind()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventSpawnRunningThreadReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); final EObject context = DebugPackage.eINSTANCE.getDebugFactory().createVariable(); try { debugTarget.handleEvent(new SpawnRunningThreadReply("thread", context)); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(9, eDebugTarget.getThreads().size()); assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == debugTarget); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.CONTENT, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventResumingReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new ResumingReply(eDebugTarget.getThreads().get(suspendedThreadIndex) .getName())); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(2, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.RESUME, event.getKind()); assertEquals(DebugEvent.CLIENT_REQUEST, event.getDetail()); events = listener.getEventsList().get(1); assertEquals(1, events.length); event = events[0]; assertTrue(event.getSource() == debugTarget); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.STATE, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventStepOverResumingReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new StepOverResumingReply(eDebugTarget.getThreads().get( suspendedThreadIndex).getName())); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(2, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.RESUME, event.getKind()); assertEquals(DebugEvent.STEP_OVER, event.getDetail()); events = listener.getEventsList().get(1); assertEquals(1, events.length); event = events[0]; assertTrue(event.getSource() == debugTarget); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.STATE, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventVariableReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new VariableReply(eDebugTarget.getThreads().get(suspendedThreadIndex) .getName(), eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame() .getName(), "Object", "variable", null, false)); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(1, eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame().getVariables() .size()); assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.CONTENT, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventDeleteVariableReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event ThreadUtils.setVariableReply(eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame(), "Object", "variable", null, false); DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new DeleteVariableReply(eDebugTarget.getThreads().get( suspendedThreadIndex).getName(), "variable")); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(0, eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame().getVariables() .size()); assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.CONTENT, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventPushStackFrameReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event final EObject context = DebugPackage.eINSTANCE.getDebugFactory().createVariable(); final EObject instruction = DebugPackage.eINSTANCE.getDebugFactory().createVariable(); DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new PushStackFrameReply(eDebugTarget.getThreads().get( suspendedThreadIndex).getName(), "frame", context, instruction, false)); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals("frame", eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame() .getName()); assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.CONTENT, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventPopStackFrameReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event final EObject context = DebugPackage.eINSTANCE.getDebugFactory().createVariable(); final EObject instruction = DebugPackage.eINSTANCE.getDebugFactory().createVariable(); ThreadUtils.pushStackFrameReply(eDebugTarget.getThreads().get(suspendedThreadIndex), "frame", context, instruction, false); DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new PopStackFrameReply(eDebugTarget.getThreads() .get(suspendedThreadIndex).getName())); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(eDebugTarget.getThreads().get(suspendedThreadIndex).getBottomStackFrame(), eDebugTarget .getThreads().get(suspendedThreadIndex).getTopStackFrame()); assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.CONTENT, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventSetCurrentInstructionReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event final EObject instruction = DebugPackage.eINSTANCE.getDebugFactory().createVariable(); DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new SetCurrentInstructionReply(eDebugTarget.getThreads().get( suspendedThreadIndex).getName(), instruction, false)); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(instruction, eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame() .getCurrentInstruction()); assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.CONTENT, event.getDetail()); }
/** * Test {@link DSLDebugTargetAdapter#handleEvent(org.eclipse.gemoc.dsl.debug.ide.event.IDSLDebugEvent)}. * * @throws DebugException * if fail */ @Test public void handleEventSetVariableValueReply() throws DebugException { DebugTarget eDebugTarget = DebugPackage.eINSTANCE.getDebugFactory().createDebugTarget(); eDebugTarget.setName("Debug target"); final TestEventProcessor testEventProcessor = new TestEventProcessor(); final DSLEclipseDebugIntegration integration = new DSLEclipseDebugIntegration("id", null, eDebugTarget, new ModelUpdater(), testEventProcessor); final DSLDebugTargetAdapter debugTarget = integration.getDebugTarget(); TestDebugEventSetListener listener = new TestDebugEventSetListener(); createThreads(eDebugTarget); debugTarget.getThreads(); // force adapter creation to avoid create event debugTarget.handleEvent(new VariableReply(eDebugTarget.getThreads().get(suspendedThreadIndex) .getName(), eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame().getName(), "Object", "variable", null, false)); DebugPlugin.getDefault().addDebugEventListener(listener); try { debugTarget.handleEvent(new SetVariableValueReply(eDebugTarget.getThreads().get( suspendedThreadIndex).getName(), eDebugTarget.getThreads().get(suspendedThreadIndex) .getTopStackFrame().getName(), "variable", "value")); listener.waitForEvent(); } finally { DebugPlugin.getDefault().removeDebugEventListener(listener); } assertEquals(1, eDebugTarget.getThreads().get(suspendedThreadIndex).getTopStackFrame().getVariables() .size()); assertEquals(1, listener.getEventsList().size()); DebugEvent[] events = listener.getEventsList().get(0); assertEquals(1, events.length); DebugEvent event = events[0]; assertTrue(event.getSource() == integration.getThread(eDebugTarget.getThreads().get( suspendedThreadIndex))); assertEquals(DebugEvent.CHANGE, event.getKind()); assertEquals(DebugEvent.CONTENT, event.getDetail()); }
/** * Handles the given {@link SetVariableValueReply}. * * @param variableValueReply * the given {@link SetVariableValueReply} */ private void handleSetVariableValueReply(SetVariableValueReply variableValueReply) { final Thread eThread = DebugTargetUtils.getThread(getHost(), variableValueReply.getThreadName()); final StackFrame eFrame = DebugTargetUtils.getStackFrame(eThread, variableValueReply.getStackName()); final Variable eVariable = DebugTargetUtils.getVariable(eFrame, variableValueReply.getVariableName()); // EMF model change factory.getModelUpdater().setVariableValueReply(eVariable, variableValueReply.getValue()); // Eclipse change factory.getThread(eThread).fireChangeEvent(DebugEvent.CONTENT); }