/** * Starts a new {@link DebuggerSession session} provided with a callback that gets notified * whenever the execution is suspended. Uses {@link SourceElement#STATEMENT} as the source * element available for stepping. Use * {@link #startSession(SuspendedCallback, SourceElement...)} to specify a different set of * source elements. * * @param callback the callback to notify * @see DebuggerSession * @see SuspendedEvent * @see #startSession(SuspendedCallback, SourceElement...) * @since 0.17 */ public DebuggerSession startSession(SuspendedCallback callback) { return startSession(callback, SourceElement.STATEMENT); }
/** * Starts a new {@link DebuggerSession session} provided with a callback that gets notified * whenever the execution is suspended. Uses {@link SourceElement#STATEMENT} as the source * element available for stepping. Use * {@link #startSession(SuspendedCallback, SourceElement...)} to specify a different set of * source elements. * * @param callback the callback to notify * @see DebuggerSession * @see SuspendedEvent * @see #startSession(SuspendedCallback, SourceElement...) * @since 0.17 */ public DebuggerSession startSession(SuspendedCallback callback) { return startSession(callback, SourceElement.STATEMENT); }
public void run() { Debugger.find(engine).startSession(new SuspendedCallback() { public void onSuspend(SuspendedEvent event) { pauseRequested = true; event.prepareKill(); } }); } }, 10, TimeUnit.SECONDS);
/** * Starts a new {@link Debugger#startSession(SuspendedCallback, SourceElement...) debugger * session} in the context's {@link Engine engine}. The debugger session allows to suspend the * execution on the provided source elements and to install breakpoints. If multiple sessions * are created for one {@link #startEval(Source) evaluation} then all suspended events are * delegated to this debugger tester instance. * * @param sourceElements a list of source elements * @return a new debugger session * @since 0.33 */ public DebuggerSession startSession(SourceElement... sourceElements) { return getDebugger().startSession(new SuspendedCallback() { public void onSuspend(SuspendedEvent event) { DebuggerTester.this.onSuspend(event); } }, sourceElements); }
/** * Starts a new {@link Debugger#startSession(SuspendedCallback) debugger session} in the * context's {@link Engine engine}. The debugger session allows to suspend the execution and to * install breakpoints. If multiple sessions are created for one {@link #startEval(Source) * evaluation} then all suspended events are delegated to this debugger tester instance. * * @return a new debugger session * @since 0.16 */ public DebuggerSession startSession() { return getDebugger().startSession(new SuspendedCallback() { public void onSuspend(SuspendedEvent event) { DebuggerTester.this.onSuspend(event); } }); }
/** * Starts a new {@link Debugger#startSession(SuspendedCallback) debugger session} in the * context's {@link Engine engine}. The debugger session allows to suspend the execution and to * install breakpoints. If multiple sessions are created for one {@link #startEval(Source) * evaluation} then all suspended events are delegated to this debugger tester instance. * * @return a new debugger session * @since 0.16 */ public DebuggerSession startSession() { return getDebugger().startSession(new SuspendedCallback() { public void onSuspend(SuspendedEvent event) { DebuggerTester.this.onSuspend(event); } }); }
/** * Starts a new {@link Debugger#startSession(SuspendedCallback, SourceElement...) debugger * session} in the context's {@link Engine engine}. The debugger session allows to suspend the * execution on the provided source elements and to install breakpoints. If multiple sessions * are created for one {@link #startEval(Source) evaluation} then all suspended events are * delegated to this debugger tester instance. * * @param sourceElements a list of source elements * @return a new debugger session * @since 0.33 */ public DebuggerSession startSession(SourceElement... sourceElements) { return getDebugger().startSession(new SuspendedCallback() { public void onSuspend(SuspendedEvent event) { DebuggerTester.this.onSuspend(event); } }, sourceElements); }
/** @since 0.15 */ @Test public void testRootNodeName() throws Exception { final int[] haltCount = new int[1]; final String name = applyNumbers(); final String[] actualName = new String[1]; final PolyglotEngine engine = prepareVM(PolyglotEngine.newBuilder()); final PolyglotEngine.Value apply = engine.findGlobalSymbol(name); final int value = RANDOM.nextInt(100); final TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value)); try (DebuggerSession session = Debugger.find(engine).startSession(new SuspendedCallback() { public void onSuspend(SuspendedEvent ev) { actualName[0] = ev.getTopStackFrame().getName(); haltCount[0] = haltCount[0] + 1; } })) { session.suspendNextExecution(); apply.execute(fn).as(Number.class); } assertEquals(1, haltCount[0]); assertEquals(name, actualName[0]); }