# HG changeset patch # User Doug Simon # Date 1366573060 -7200 # Node ID 2ff3499d408e6722a9c875c549e64207b38f51e4 # Parent cf470d096a8f390a0fa5f07c6745dedc8122ad55 enhanced support for sandboxed debug scope such that their debug config can be specified diff -r cf470d096a8f -r 2ff3499d408e graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Sun Apr 21 21:15:26 2013 +0200 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Sun Apr 21 21:37:40 2013 +0200 @@ -76,9 +76,26 @@ return callable; } - public static void sandbox(String name, Runnable runnable) { + public static void sandbox(String name, DebugConfig config, Runnable runnable) { if (ENABLED) { - DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]); + DebugScope.getInstance().scope(name, runnable, null, true, config, new Object[0]); + } else { + runnable.run(); + } + } + + /** + * Creates a new debug scope that is unrelated to the current scope and runs a given task in the + * new scope. + * + * @param name new scope name + * @param context the context objects of the new scope + * @param config the debug configuration to use for the new scope + * @param runnable the task to run in the new scope + */ + public static void sandbox(String name, Object[] context, DebugConfig config, Runnable runnable) { + if (ENABLED) { + DebugScope.getInstance().scope(name, runnable, null, true, config, context); } else { runnable.run(); } @@ -98,7 +115,7 @@ public static void scope(String name, Object[] context, Runnable runnable) { if (ENABLED) { - DebugScope.getInstance().scope(name, runnable, null, false, context); + DebugScope.getInstance().scope(name, runnable, null, false, null, context); } else { runnable.run(); } @@ -118,7 +135,7 @@ public static T scope(String name, Object[] context, Callable callable) { if (ENABLED) { - return DebugScope.getInstance().scope(name, null, callable, false, context); + return DebugScope.getInstance().scope(name, null, callable, false, null, context); } else { return DebugScope.call(callable); } diff -r cf470d096a8f -r 2ff3499d408e graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Sun Apr 21 21:15:26 2013 +0200 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Sun Apr 21 21:37:40 2013 +0200 @@ -138,13 +138,26 @@ } } - public T scope(String newName, Runnable runnable, Callable callable, boolean sandbox, Object[] newContext) { + /** + * Runs a task in a new debug scope which is either a child of the current scope or a disjoint + * top level scope. + * + * @param newName the name of the new scope + * @param runnable the task to run (must be null iff {@code callable} is not null) + * @param callable the task to run (must be null iff {@code runnable} is not null) + * @param sandbox specifies if the scope is a child of the current scope or a top level scope + * @param sandboxConfig the config to use of a new top level scope (ignored if + * {@code sandbox == false}) + * @param newContext context objects of the new scope + * @return the value returned by the task + */ + public T scope(String newName, Runnable runnable, Callable callable, boolean sandbox, DebugConfig sandboxConfig, Object[] newContext) { DebugScope oldContext = getInstance(); DebugConfig oldConfig = getConfig(); DebugScope newChild = null; if (sandbox) { newChild = new DebugScope(newName, newName, null, newContext); - setConfig(null); + setConfig(sandboxConfig); } else { newChild = oldContext.createChild(newName, newContext); } @@ -215,7 +228,7 @@ return new RuntimeException("Exception while intercepting exception", t); } } - }, false, new Object[]{e}); + }, false, null, new Object[]{e}); } return null; } diff -r cf470d096a8f -r 2ff3499d408e graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Sun Apr 21 21:15:26 2013 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Sun Apr 21 21:37:40 2013 +0200 @@ -161,7 +161,7 @@ previousInlineContext = inlineContext; final SchedulePhase predefinedSchedule = getPredefinedSchedule(); - Debug.sandbox("PrintingGraph", new Runnable() { + Debug.sandbox("PrintingGraph", null, new Runnable() { @Override public void run() {