use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.
the class GraphResetDebugTest method test1.
@SuppressWarnings("try")
@Test
public void test1() {
EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
// Configure with an option that enables scopes
map.put(DebugOptions.DumpOnError, true);
DebugContext debug = getDebugContext(new OptionValues(map));
StructuredGraph graph = parseEager("testSnippet", AllowAssumptions.YES, debug);
boolean resetSucceeded = false;
try (Scope scope = debug.scope("some scope")) {
graph.resetDebug(DebugContext.DISABLED);
resetSucceeded = true;
} catch (AssertionError expected) {
}
Assert.assertFalse(resetSucceeded);
}
use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.
the class DerivedOopTest method testFieldOffsetMergeLiveBasePointer.
@Test
@SuppressWarnings("try")
public void testFieldOffsetMergeLiveBasePointer() {
thrown.expect(GraalError.class);
thrown.expectMessage(UNKNOWN_REFERENCE_AT_SAFEPOINT_MSG);
DebugContext debug = getDebugContext();
try (Scope s = debug.disable()) {
// Run a couple times to encourage objects to move
for (int i = 0; i < 4; i++) {
Result r = new Result();
test("fieldOffsetMergeSnippet03", r, new Result(), new Result(), 8L, 16L);
Assert.assertEquals(r.beforeGC.delta(), r.afterGC.delta());
}
}
}
use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.
the class DebugContextTest method testEnabledSandbox.
@Test
public void testEnabledSandbox() {
EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
// Configure with an option that enables scopes
map.put(DebugOptions.DumpOnError, true);
OptionValues options = new OptionValues(map);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DebugContext debug = DebugContext.create(options, NO_DESCRIPTION, NO_GLOBAL_METRIC_VALUES, new PrintStream(baos), DebugHandlersFactory.LOADER);
Exception e = new Exception("testEnabledSandbox");
String scopeName = "";
try {
try (DebugContext.Scope d = debug.sandbox("TestExceptionHandling", debug.getConfig())) {
scopeName = d.getQualifiedName();
throw e;
} catch (Throwable t) {
assert e == t;
debug.handle(t);
}
} catch (Throwable t) {
// The exception object should propagate all the way out through
// a enabled sandbox scope
Assert.assertEquals(e, t);
}
String logged = baos.toString();
String expected = String.format("Exception raised in scope %s: %s", scopeName, e);
String line = "-------------------------------------------------------";
Assert.assertTrue(String.format("Could not find \"%s\" in content between lines below:%n%s%n%s%s", expected, line, logged, line), logged.contains(expected));
}
use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.
the class GraphPrinter method getScheduleOrNull.
@SuppressWarnings("try")
static StructuredGraph.ScheduleResult getScheduleOrNull(Graph graph) {
if (graph instanceof StructuredGraph) {
StructuredGraph sgraph = (StructuredGraph) graph;
StructuredGraph.ScheduleResult scheduleResult = sgraph.getLastSchedule();
if (scheduleResult == null) {
DebugContext debug = graph.getDebug();
try (Scope scope = debug.disable()) {
SchedulePhase schedule = new SchedulePhase(graph.getOptions());
schedule.apply(sgraph);
scheduleResult = sgraph.getLastSchedule();
} catch (Throwable t) {
}
}
return scheduleResult;
}
return null;
}
Aggregations