1 /*
   2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.debug;
  24 
  25 import java.io.PrintStream;
  26 import java.util.Collection;
  27 
  28 public interface DebugConfig {
  29 
  30     /**
  31      * Determines the current log level in the {@linkplain Debug#currentScope() current debug scope}
  32      * .
  33      */
  34     int getLogLevel();
  35 
  36     /**
  37      * Determines the current dump level in the {@linkplain Debug#currentScope() current debug
  38      * scope}.
  39      */
  40     int getDumpLevel();
  41 
  42     /**
  43      * Determines if logging can be enabled in the current method, regardless of the
  44      * {@linkplain Debug#currentScope() current debug scope}.
  45      */
  46     boolean isLogEnabledForMethod();
  47 
  48     /**
  49      * Determines if counting is enabled in the {@linkplain Debug#currentScope() current debug
  50      * scope}.
  51      *
  52      * @see Debug#counter(CharSequence)
  53      */
  54     boolean isCountEnabled();
  55 
  56     /**
  57      * Determines if memory use tracking is enabled in the {@linkplain Debug#currentScope() current
  58      * debug scope}.
  59      *
  60      * @see Debug#memUseTracker(CharSequence)
  61      */
  62     boolean isMemUseTrackingEnabled();
  63 
  64     /**
  65      * Determines if dumping can be enabled in the current method, regardless of the
  66      * {@linkplain Debug#currentScope() current debug scope}.
  67      */
  68     boolean isDumpEnabledForMethod();
  69 
  70     /**
  71      * @see Debug#isVerifyEnabled()
  72      */
  73     boolean isVerifyEnabled();
  74 
  75     /**
  76      * @see Debug#isVerifyEnabledForMethod()
  77      */
  78     boolean isVerifyEnabledForMethod();
  79 
  80     /**
  81      * @see Debug#isMethodMeterEnabled()
  82      */
  83     boolean isMethodMeterEnabled();
  84 
  85     /**
  86      * Adds an object the context used by this configuration to do filtering.
  87      */
  88     void addToContext(Object o);
  89 
  90     /**
  91      * Removes an object the context used by this configuration to do filtering.
  92      *
  93      * This should only removes extra context added by {@link #addToContext(Object)}.
  94      */
  95     void removeFromContext(Object o);
  96 
  97     /**
  98      * @see Debug#timer(CharSequence)
  99      */
 100     boolean isTimeEnabled();
 101 
 102     /**
 103      * Handles notification of an exception occurring within a debug scope.
 104      *
 105      * @return the exception object that is to be propagated to parent scope. A value of
 106      *         {@code null} indicates that {@code e} is to be propagated.
 107      */
 108     RuntimeException interceptException(Throwable e);
 109 
 110     /**
 111      * Gets the modifiable collection of dump handlers registered with this configuration.
 112      */
 113     Collection<DebugDumpHandler> dumpHandlers();
 114 
 115     PrintStream output();
 116 
 117     /**
 118      * Gets the modifiable collection of verify handlers registered with this configuration.
 119      */
 120     Collection<DebugVerifyHandler> verifyHandlers();
 121 
 122 }