use of com.oracle.truffle.api.debug.DebugStackFrame in project graal by oracle.
the class SuspendedEventTest method testStackFrames.
@Test
public void testStackFrames() throws Throwable {
final Source source = testSource("ROOT(\n" + " DEFINE(bar, VARIABLE(bar0, 41), VARIABLE(bar1, 40), STATEMENT),\n" + " DEFINE(foo, ROOT(VARIABLE(foo0, 42), \n" + " STATEMENT(CALL(bar)))),\n" + " STATEMENT(VARIABLE(root0, 43)),\n" + " STATEMENT(CALL(foo))\n" + ")\n");
try (DebuggerSession session = startSession()) {
session.suspendNextExecution();
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 5, true, "STATEMENT(VARIABLE(root0, 43))").prepareStepOver(1);
Iterator<DebugStackFrame> frameIterator = event.getStackFrames().iterator();
checkStack(frameIterator.next());
Assert.assertFalse(frameIterator.hasNext());
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 6, true, "STATEMENT(CALL(foo))", "root0", "43").prepareStepInto(1);
Iterator<DebugStackFrame> frameIterator = event.getStackFrames().iterator();
checkStack(frameIterator.next(), "root0", "43");
Assert.assertFalse(frameIterator.hasNext());
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 4, true, "STATEMENT(CALL(bar))", "foo0", "42").prepareStepInto(1);
Iterator<DebugStackFrame> frameIterator = event.getStackFrames().iterator();
checkStack(frameIterator.next(), "foo0", "42");
checkStack(frameIterator.next(), "root0", "43");
Assert.assertFalse(frameIterator.hasNext());
});
expectSuspended((SuspendedEvent event) -> {
checkState(event, 2, true, "STATEMENT", "bar0", "41", "bar1", "40").prepareContinue();
Iterator<DebugStackFrame> frameIterator = event.getStackFrames().iterator();
checkStack(frameIterator.next(), "bar0", "41", "bar1", "40");
checkStack(frameIterator.next(), "foo0", "42");
checkStack(frameIterator.next(), "root0", "43");
Assert.assertFalse(frameIterator.hasNext());
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebugStackFrame in project graal by oracle.
the class SuspendedEventTest method testOtherThreadAccess.
@Test
public void testOtherThreadAccess() throws Throwable {
final Source source = testSource("ROOT(\n" + " DEFINE(bar, VARIABLE(bar0, 41), VARIABLE(bar1, 40), STATEMENT),\n" + " DEFINE(foo, ROOT(VARIABLE(foo0, 42), \n" + " STATEMENT(CALL(bar)))),\n" + " STATEMENT(VARIABLE(root0, 43)),\n" + " STATEMENT(CALL(foo))\n" + ")\n");
try (DebuggerSession session = startSession()) {
final Breakpoint breakpoint = session.install(Breakpoint.newBuilder(getSourceImpl(source)).lineIs(4).build());
startEval(source);
expectSuspended((SuspendedEvent event) -> {
run(() -> event.getBreakpointConditionException(breakpoint));
run(() -> event.getSession());
run(() -> event.getSourceSection());
run(() -> event.getBreakpoints());
run(() -> event.getSuspendAnchor());
run(() -> event.toString());
run(() -> {
event.prepareStepInto(1);
return null;
});
run(() -> {
event.prepareStepOut(1);
return null;
});
run(() -> {
event.prepareStepOver(1);
return null;
});
run(() -> {
event.prepareContinue();
return null;
});
run(() -> {
event.prepareKill();
return null;
});
runExpectIllegalState(() -> event.getStackFrames());
runExpectIllegalState(() -> event.getTopStackFrame());
runExpectIllegalState(() -> event.getReturnValue());
for (DebugStackFrame frame : event.getStackFrames()) {
for (DebugValue value : frame) {
runExpectIllegalState(() -> value.as(String.class));
runExpectIllegalState(() -> {
value.set(null);
return null;
});
// Name is known
value.getName();
runExpectIllegalState(() -> value.isReadable());
runExpectIllegalState(() -> value.isWritable());
}
run(() -> frame.getName());
run(() -> frame.getSourceSection());
run(() -> frame.isInternal());
run(() -> frame.toString());
runExpectIllegalState(() -> frame.getScope().getDeclaredValue(""));
runExpectIllegalState(() -> frame.getScope().getDeclaredValues().iterator());
runExpectIllegalState(() -> frame.eval(""));
}
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebugStackFrame in project graal by oracle.
the class DebugStackFrameTest method testFrameValidity.
@Test
public void testFrameValidity() throws Throwable {
final Source source = testSource("ROOT(\n" + " VARIABLE(a, 42), \n" + " VARIABLE(b, 43), \n" + " VARIABLE(c, 44), \n" + " STATEMENT(),\n" + " STATEMENT()\n" + ")\n");
try (DebuggerSession session = startSession()) {
session.suspendNextExecution();
startEval(source);
class SharedData {
DebugStackFrame frame;
DebugValue stackValueWithGetValue;
DebugValue stackValueWithIterator;
Iterator<DebugStackFrame> frameIterator2;
DebugValue heapValue;
}
SharedData data = new SharedData();
expectSuspended((SuspendedEvent event) -> {
data.frame = event.getTopStackFrame();
Iterator<DebugStackFrame> frameIterator = event.getStackFrames().iterator();
assertSame(data.frame, frameIterator.next());
assertFalse(frameIterator.hasNext());
checkStack(data.frame, "a", "42", "b", "43", "c", "44");
// values for verifying state checks
data.frameIterator2 = event.getStackFrames().iterator();
data.stackValueWithGetValue = data.frame.getScope().getDeclaredValue("a");
data.stackValueWithIterator = data.frame.getScope().getDeclaredValues().iterator().next();
// should dynamically create a local variable
data.heapValue = data.frame.eval("VARIABLE(d, 45)");
// should render all pointers invalid
event.prepareStepInto(1);
});
expectSuspended((SuspendedEvent event) -> {
// next event everything should be invalidated except heap values
assertInvalidFrame(data.frame);
assertInvalidIterator(data.frameIterator2);
assertInvalidDebugValue(data.stackValueWithGetValue);
assertInvalidDebugValue(data.stackValueWithIterator);
assertEquals("45", data.heapValue.as(String.class));
assertFalse(data.heapValue.isWritable());
assertTrue(data.heapValue.isReadable());
try {
data.heapValue.set(data.heapValue);
fail();
} catch (IllegalStateException e) {
}
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.DebugStackFrame in project graal by oracle.
the class DebugValueTest method testNumValue.
@Test
public void testNumValue() throws Throwable {
final Source source = testSource("ROOT(\n" + " VARIABLE(a, 42), \n" + " VARIABLE(inf, infinity), \n" + " STATEMENT()\n" + ")\n");
try (DebuggerSession session = startSession()) {
session.suspendNextExecution();
startEval(source);
expectSuspended((SuspendedEvent event) -> {
DebugStackFrame frame = event.getTopStackFrame();
DebugValue value42 = frame.getScope().getDeclaredValue("a");
assertEquals("a", value42.getName());
assertFalse(value42.isArray());
assertNull(value42.getArray());
assertNull(value42.getProperties());
assertEquals("Integer", value42.getMetaObject().as(String.class));
assertEquals("Infinity", frame.getScope().getDeclaredValue("inf").getMetaObject().as(String.class));
SourceSection integerSS = value42.getSourceLocation();
assertEquals("source integer", integerSS.getCharacters());
SourceSection infinitySS = frame.getScope().getDeclaredValue("inf").getSourceLocation();
assertEquals("source infinity", infinitySS.getCharacters());
});
expectDone();
}
}
Aggregations