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 import org.graalvm.compiler.options.OptionValues;
  29 
  30 public interface DebugConfig {
  31 
  32     /**
  33      * Returns the option values that can be used to configure details of debug clients.
  34      */
  35     OptionValues getOptions();
  36 
  37     /**
  38      * Determines the current log level in the {@linkplain Debug#currentScope() current debug scope}
  39      * .
  40      */
  41     int getLogLevel();
  42 
  43     /**
  44      * Determines the current dump level in the {@linkplain Debug#currentScope() current debug
  45      * scope}.
  46      */
  47     int getDumpLevel();
  48 
  49     /**
  50      * Determines if logging can be enabled in the current method, regardless of the
  51      * {@linkplain Debug#currentScope() current debug scope}.
  52      */
  53     boolean isLogEnabledForMethod();
  54 
  55     /**
  56      * Determines if counting is enabled in the {@linkplain Debug#currentScope() current debug
  57      * scope}.
  58      *
  59      * @see Debug#counter(CharSequence)
  60      */
  61     boolean isCountEnabled();
  62 
  63     /**
  64      * Determines if memory use tracking is enabled in the {@linkplain Debug#currentScope() current
  65      * debug scope}.
  66      *
  67      * @see Debug#memUseTracker(CharSequence)
  68      */
  69     boolean isMemUseTrackingEnabled();
  70 
  71     /**
  72      * Determines if dumping can be enabled in the current method, regardless of the
  73      * {@linkplain Debug#currentScope() current debug scope}.
  74      */
  75     boolean isDumpEnabledForMethod();
  76 
  77     /**
  78      * @see Debug#isVerifyEnabled()
  79      */
  80     boolean isVerifyEnabled();
  81 
  82     /**
  83      * @see Debug#isVerifyEnabledForMethod()
  84      */
  85     boolean isVerifyEnabledForMethod();
  86 
  87     /**
  88      * @see Debug#isMethodMeterEnabled()
  89      */
  90     boolean isMethodMeterEnabled();
  91 
  92     /**
  93      * Adds an object the context used by this configuration to do filtering.
  94      */
  95     void addToContext(Object o);
  96 
  97     /**
  98      * Removes an object the context used by this configuration to do filtering.
  99      *
 100      * This should only removes extra context added by {@link #addToContext(Object)}.
 101      */
 102     void removeFromContext(Object o);
 103 
 104     /**
 105      * @see Debug#timer(CharSequence)
 106      */
 107     boolean isTimeEnabled();
 108 
 109     /**
 110      * Handles notification of an exception occurring within a debug scope.
 111      *
 112      * @return the exception object that is to be propagated to parent scope. A value of
 113      *         {@code null} indicates that {@code e} is to be propagated.
 114      */
 115     RuntimeException interceptException(Throwable e);
 116 
 117     /**
 118      * Gets the modifiable collection of dump handlers registered with this configuration.
 119      */
 120     Collection<DebugDumpHandler> dumpHandlers();
 121 
 122     PrintStream output();
 123 
 124     /**
 125      * Gets the modifiable collection of verify handlers registered with this configuration.
 126      */
 127     Collection<DebugVerifyHandler> verifyHandlers();
 128 
 129 }