Search in sources :

Example 91 with DebuggerSession

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

the class DebuggerSessionTest method testSuspendThread3.

@Test
public void testSuspendThread3() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        suspend(session, getEvalThread());
        startEval(testSource);
        expectSuspended((SuspendedEvent event) -> {
            checkState(event, 2, true, "STATEMENT").prepareKill();
        });
        // For prepareKill additional suspensions should be ignored
        suspend(session, getEvalThread());
        expectKilled();
    }
}
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 92 with DebuggerSession

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

the class DebuggerSessionTest method testSuspendNextExecution2.

@Test
public void testSuspendNextExecution2() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        // calling it multiple times should not make a difference
        session.suspendNextExecution();
        session.suspendNextExecution();
        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 93 with DebuggerSession

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

the class DebuggerSessionTest method testSuspendAll1.

@Test
public void testSuspendAll1() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        for (int i = 0; i < 10; i++) {
            suspendAll(session);
            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) Breakpoint(com.oracle.truffle.api.debug.Breakpoint) Test(org.junit.Test)

Example 94 with DebuggerSession

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

the class DebuggerSessionTest method testClosing1.

@Test
public void testClosing1() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    DebuggerSession session = startSession();
    session.install(Breakpoint.newBuilder(getSourceImpl(testSource)).lineIs(3).build());
    session.suspendNextExecution();
    startEval(testSource);
    expectSuspended((SuspendedEvent event) -> {
        checkState(event, 2, true, "STATEMENT").prepareStepOver(1);
    });
    // closing the session should disable breakpoints and current stepping
    session.close();
    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 95 with DebuggerSession

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

the class DebuggerSessionTest method testSuspendThread1.

@Test
public void testSuspendThread1() {
    Source testSource = testSource("ROOT(\n" + "STATEMENT,\n" + "STATEMENT)");
    try (DebuggerSession session = startSession()) {
        // do suspend next for a few times
        for (int i = 0; i < 100; i++) {
            suspend(session, getEvalThread());
            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) Breakpoint(com.oracle.truffle.api.debug.Breakpoint) 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