Mercurial > hg > truffle
diff graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java @ 18690:abcff66a23b0
Add ability to programmatically set the dump level
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Mon, 15 Dec 2014 16:00:14 -0800 |
parents | f1d839174e71 |
children | 41d12b67bc9e |
line wrap: on
line diff
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Dec 15 13:10:44 2014 -0800 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Dec 15 16:00:14 2014 -0800 @@ -169,6 +169,58 @@ return currentDumpLevel >= dumpLevel; } + /** + * Enable dumping at the new {@code dumpLevel} for remainder of compile. Requires a + * TopLevelDebugConfig + * + * @param dumpLevel + */ + public static void setDumpLevel(int dumpLevel) { + TopLevelDebugConfig config = fetchTopLevelDebugConfig("setLogLevel"); + if (config != null) { + config.override(DelegatingDebugConfig.Level.DUMP, dumpLevel); + recursiveUpdateFlags(); + } + } + + /** + * Enable logging at the new {@code logLevel} for remainder of compile. Requires a + * TopLevelDebugConfig + * + * @param logLevel + */ + public static void setLogLevel(int logLevel) { + TopLevelDebugConfig config = fetchTopLevelDebugConfig("setLogLevel"); + if (config != null) { + config.override(DelegatingDebugConfig.Level.LOG, logLevel); + config.delegate(DelegatingDebugConfig.Feature.LOG_METHOD); + recursiveUpdateFlags(); + } + } + + private static void recursiveUpdateFlags() { + DebugScope c = DebugScope.getInstance(); + while (c != null) { + c.updateFlags(); + c = c.parent; + } + } + + private static TopLevelDebugConfig fetchTopLevelDebugConfig(String msg) { + DebugConfig config = getConfig(); + if (config instanceof TopLevelDebugConfig) { + return (TopLevelDebugConfig) config; + } else { + PrintStream out = System.out; + if (config == null) { + out.printf("DebugScope.%s ignored because debugging is disabled%n", msg); + } else { + out.printf("DebugScope.%s ignored because top level delegate config missing%n", msg); + } + return null; + } + } + public boolean isVerifyEnabled() { return verifyEnabled; }