001/*
002 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.debug;
024
025import java.io.*;
026import java.util.*;
027
028public interface DebugConfig {
029
030    /**
031     * Determines the current log level in the {@linkplain Debug#currentScope() current debug scope}
032     * .
033     */
034    int getLogLevel();
035
036    /**
037     * Determines the current dump level in the {@linkplain Debug#currentScope() current debug
038     * scope}.
039     */
040    int getDumpLevel();
041
042    /**
043     * Determines if logging can be enabled in the current method, regardless of the
044     * {@linkplain Debug#currentScope() current debug scope}.
045     */
046    boolean isLogEnabledForMethod();
047
048    /**
049     * Determines if metering is enabled in the {@linkplain Debug#currentScope() current debug
050     * scope}.
051     *
052     * @see Debug#metric(CharSequence)
053     */
054    boolean isMeterEnabled();
055
056    /**
057     * Determines if memory use tracking is enabled in the {@linkplain Debug#currentScope() current
058     * debug scope}.
059     *
060     * @see Debug#memUseTracker(CharSequence)
061     */
062    boolean isMemUseTrackingEnabled();
063
064    /**
065     * Determines if dumping can be enabled in the current method, regardless of the
066     * {@linkplain Debug#currentScope() current debug scope}.
067     */
068    boolean isDumpEnabledForMethod();
069
070    /**
071     * @see Debug#isVerifyEnabled()
072     */
073    boolean isVerifyEnabled();
074
075    /**
076     * @see Debug#isVerifyEnabledForMethod()
077     */
078    boolean isVerifyEnabledForMethod();
079
080    /**
081     * Adds an object the context used by this configuration to do filtering.
082     */
083    void addToContext(Object o);
084
085    /**
086     * Removes an object the context used by this configuration to do filtering.
087     *
088     * This should only removes extra context added by {@link #addToContext(Object)}.
089     */
090    void removeFromContext(Object o);
091
092    /**
093     * @see Debug#timer(CharSequence)
094     */
095    boolean isTimeEnabled();
096
097    /**
098     * Handles notification of an exception occurring within a debug scope.
099     *
100     * @return the exception object that is to be propagated to parent scope. A value of
101     *         {@code null} indicates that {@code e} is to be propagated.
102     */
103    RuntimeException interceptException(Throwable e);
104
105    /**
106     * Gets the modifiable collection of dump handlers registered with this configuration.
107     */
108    Collection<DebugDumpHandler> dumpHandlers();
109
110    PrintStream output();
111
112    /**
113     * Gets the modifiable collection of verify handlers registered with this configuration.
114     */
115    Collection<DebugVerifyHandler> verifyHandlers();
116}