Search in sources :

Example 26 with DebuggerSession

use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.

the class DebuggerSessionTest method testResumeAll1.

@Test
public void testResumeAll1() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        for (int i = 0; i < 10; i++) {
            session.suspendNextExecution();
            // resume all invalidates suspendNextExecution
            session.resumeAll();
            startEval(testSource);
            expectDone();
        }
    }
}
Also used : DebuggerSession(com.oracle.truffle.api.debug.DebuggerSession) Source(org.graalvm.polyglot.Source) Breakpoint(com.oracle.truffle.api.debug.Breakpoint) Test(org.junit.Test)

Example 27 with DebuggerSession

use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.

the class DebuggerSessionTest method testResumeThread1.

@Test
public void testResumeThread1() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        for (int i = 0; i < 10; i++) {
            session.suspendNextExecution();
            startEval(testSource);
            expectSuspended((SuspendedEvent event) -> {
                checkState(event, 2, true, "STATEMENT").prepareStepOver(1);
            });
            // resume events are ignored by stepping
            resume(session, getEvalThread());
            expectDone();
        }
    }
}
Also used : DebuggerSession(com.oracle.truffle.api.debug.DebuggerSession) SuspendedEvent(com.oracle.truffle.api.debug.SuspendedEvent) Source(org.graalvm.polyglot.Source) Breakpoint(com.oracle.truffle.api.debug.Breakpoint) Test(org.junit.Test)

Example 28 with DebuggerSession

use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.

the class DebuggerSessionTest method testSuspendNextExecution1.

@Test
public void testSuspendNextExecution1() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        session.suspendNextExecution();
        startEval(testSource);
        expectSuspended((SuspendedEvent event) -> {
            checkState(event, 2, true, "STATEMENT").prepareContinue();
        });
        expectDone();
    }
}
Also used : DebuggerSession(com.oracle.truffle.api.debug.DebuggerSession) SuspendedEvent(com.oracle.truffle.api.debug.SuspendedEvent) Source(org.graalvm.polyglot.Source) Test(org.junit.Test)

Example 29 with DebuggerSession

use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.

the class DebuggerSessionTest method testResumeAll2.

@Test
public void testResumeAll2() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        for (int i = 0; i < 10; i++) {
            suspendAll(session);
            session.resumeAll();
            startEval(testSource);
            expectDone();
        }
    }
}
Also used : DebuggerSession(com.oracle.truffle.api.debug.DebuggerSession) Source(org.graalvm.polyglot.Source) Breakpoint(com.oracle.truffle.api.debug.Breakpoint) Test(org.junit.Test)

Example 30 with DebuggerSession

use of com.oracle.truffle.api.debug.DebuggerSession in project graal by oracle.

the class DebuggerThreadsTest method testSingleThread.

@Test
public void testSingleThread() throws Throwable {
    final Source source = testSource("STATEMENT()");
    TestThreadsListener threadsListener = new TestThreadsListener();
    List<ThreadEvent> events = threadsListener.events;
    try (DebuggerSession session = startSession()) {
        session.suspendNextExecution();
        session.setThreadsListener(threadsListener, false);
        startEval(source);
        expectSuspended((SuspendedEvent event) -> {
            assertEquals(1, events.size());
            assertTrue(events.get(0).isNew);
            assertEquals(Thread.currentThread(), events.get(0).thread);
            assertNotNull(events.get(0).context);
        });
        expectDone();
        closeEngine();
        // We're closing the engine not on the execution thread - we get two more thread events.
        assertEquals(4, events.size());
        assertFalse(events.get(3).isNew);
        assertEquals(events.get(0).context, events.get(3).context);
    }
    events.clear();
}
Also used : DebuggerSession(com.oracle.truffle.api.debug.DebuggerSession) SuspendedEvent(com.oracle.truffle.api.debug.SuspendedEvent) Source(org.graalvm.polyglot.Source) Test(org.junit.Test)

Aggregations

DebuggerSession (com.oracle.truffle.api.debug.DebuggerSession)110 Source (org.graalvm.polyglot.Source)103 Test (org.junit.Test)102 SuspendedEvent (com.oracle.truffle.api.debug.SuspendedEvent)97 Breakpoint (com.oracle.truffle.api.debug.Breakpoint)49 DebugStackFrame (com.oracle.truffle.api.debug.DebugStackFrame)20 DebugValue (com.oracle.truffle.api.debug.DebugValue)16 Debugger (com.oracle.truffle.api.debug.Debugger)14 Context (org.graalvm.polyglot.Context)11 SourceSection (com.oracle.truffle.api.source.SourceSection)8 SuspensionFilter (com.oracle.truffle.api.debug.SuspensionFilter)7 DebugContext (com.oracle.truffle.api.debug.DebugContext)6 SuspendedCallback (com.oracle.truffle.api.debug.SuspendedCallback)6 DebugScope (com.oracle.truffle.api.debug.DebugScope)5 Engine (org.graalvm.polyglot.Engine)5 HashMap (java.util.HashMap)3 Value (org.graalvm.polyglot.Value)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2