annotate graal/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/Debug.java @ 21558:d563baeca9df

changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 13:43:27 +0200
parents b1530a6cce8c
children 7a7cf422160b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21140
diff changeset
23 package com.oracle.jvmci.debug;
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21140
diff changeset
25 import static com.oracle.jvmci.debug.Debug.Initialization.*;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21140
diff changeset
26 import static com.oracle.jvmci.debug.DelegatingDebugConfig.Feature.*;
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
27 import static java.util.FormattableFlags.*;
5302
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
28
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
29 import java.io.*;
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
30 import java.util.*;
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
31 import java.util.concurrent.*;
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
32
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21140
diff changeset
33 import com.oracle.jvmci.debug.DelegatingDebugConfig.Level;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21140
diff changeset
34 import com.oracle.jvmci.debug.internal.*;
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
35
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
36 /**
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
37 * Scope based debugging facility. This facility is {@link #isEnabled()} if assertions are enabled
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
38 * for the {@link Debug} class or the {@value Initialization#INITIALIZER_PROPERTY_NAME} system
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
39 * property is {@code "true"} when {@link Debug} is initialized.
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
40 */
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
41 public class Debug {
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
43 /**
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
44 * Class to assist with initialization of {@link Debug}.
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
45 */
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
46 public static class Initialization {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
47
21558
d563baeca9df changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
48 public static final String INITIALIZER_PROPERTY_NAME = "jvmci.debug.enable";
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
49
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
50 private static boolean initialized;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
51
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
52 /**
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
53 * Determines if {@link Debug} has been initialized.
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
54 */
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
55 public static boolean isDebugInitialized() {
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
56 return initialized;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
57 }
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
58
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
59 }
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
61 @SuppressWarnings("all")
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
62 private static boolean initialize() {
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
63 boolean assertionsEnabled = false;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
64 assert assertionsEnabled = true;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
65 Initialization.initialized = true;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
66 return assertionsEnabled || Boolean.getBoolean(INITIALIZER_PROPERTY_NAME);
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
67 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
68
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
69 private static final boolean ENABLED = initialize();
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
70
4369
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
71 public static boolean isEnabled() {
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
72 return ENABLED;
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
73 }
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
74
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
75 public static boolean isDumpEnabledForMethod() {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
76 if (!ENABLED) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
77 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
78 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
79 DebugConfig config = DebugScope.getConfig();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
80 if (config == null) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
81 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
82 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
83 return config.isDumpEnabledForMethod();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
84 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
85
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
86 public static final int DEFAULT_LOG_LEVEL = 2;
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
87
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
88 public static boolean isDumpEnabled() {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
89 return isDumpEnabled(DEFAULT_LOG_LEVEL);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
90 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
91
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
92 public static boolean isDumpEnabled(int dumpLevel) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
93 return ENABLED && DebugScope.getInstance().isDumpEnabled(dumpLevel);
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
94 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
95
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
96 /**
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
97 * Determines if verification is enabled in the current method, regardless of the
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
98 * {@linkplain Debug#currentScope() current debug scope}.
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
99 *
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
100 * @see Debug#verify(Object, String)
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
101 */
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
102 public static boolean isVerifyEnabledForMethod() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
103 if (!ENABLED) {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
104 return false;
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
105 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
106 DebugConfig config = DebugScope.getConfig();
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
107 if (config == null) {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
108 return false;
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
109 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
110 return config.isVerifyEnabledForMethod();
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
111 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
112
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
113 /**
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
114 * Determines if verification is enabled in the {@linkplain Debug#currentScope() current debug
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
115 * scope}.
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
116 *
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
117 * @see Debug#verify(Object, String)
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
118 */
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
119 public static boolean isVerifyEnabled() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
120 return ENABLED && DebugScope.getInstance().isVerifyEnabled();
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
121 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
122
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
123 public static boolean isMeterEnabled() {
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
124 return ENABLED && DebugScope.getInstance().isMeterEnabled();
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
125 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
126
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
127 public static boolean isTimeEnabled() {
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
128 return ENABLED && DebugScope.getInstance().isTimeEnabled();
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
129 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
130
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
131 public static boolean isMemUseTrackingEnabled() {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
132 return ENABLED && DebugScope.getInstance().isMemUseTrackingEnabled();
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
133 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
134
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
135 public static boolean isLogEnabledForMethod() {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
136 if (!ENABLED) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
137 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
138 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
139 DebugConfig config = DebugScope.getConfig();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
140 if (config == null) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
141 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
142 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
143 return config.isLogEnabledForMethod();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
144 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
145
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
146 public static boolean isLogEnabled() {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
147 return isLogEnabled(DEFAULT_LOG_LEVEL);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
148 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
149
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
150 public static boolean isLogEnabled(int logLevel) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
151 return ENABLED && DebugScope.getInstance().isLogEnabled(logLevel);
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
152 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
153
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
154 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
155 public static Runnable decorateDebugRoot(Runnable runnable, String name, DebugConfig config) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
156 return runnable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
157 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
158
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
159 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
160 public static <T> Callable<T> decorateDebugRoot(Callable<T> callable, String name, DebugConfig config) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
161 return callable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
162 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
163
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
164 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
165 public static Runnable decorateScope(Runnable runnable, String name, Object... context) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
166 return runnable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
167 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
168
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
169 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
170 public static <T> Callable<T> decorateScope(Callable<T> callable, String name, Object... context) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
171 return callable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
172 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
173
9199
2ff3499d408e enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents: 9103
diff changeset
174 /**
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
175 * Gets a string composed of the names in the current nesting of debug
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
176 * {@linkplain #scope(Object) scopes} separated by {@code '.'}.
9199
2ff3499d408e enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents: 9103
diff changeset
177 */
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
178 public static String currentScope() {
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
179 if (ENABLED) {
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
180 return DebugScope.getInstance().getQualifiedName();
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
181 } else {
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
182 return "";
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
183 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
184 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
185
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
186 /**
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
187 * Represents a debug scope entered by {@link Debug#scope(Object)} or
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14873
diff changeset
188 * {@link Debug#sandbox(CharSequence, DebugConfig, Object...)}. Leaving the scope is achieved
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14873
diff changeset
189 * via {@link #close()}.
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
190 */
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
191 public interface Scope extends AutoCloseable {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
192 void close();
5009
e3cc0d407bc6 Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4579
diff changeset
193 }
e3cc0d407bc6 Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4579
diff changeset
194
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
195 /**
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
196 * Creates and enters a new debug scope which will be a child of the current debug scope.
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
197 * <p>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
198 * It is recommended to use the try-with-resource statement for managing entering and leaving
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
199 * debug scopes. For example:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
200 *
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
201 * <pre>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
202 * try (Scope s = Debug.scope(&quot;InliningGraph&quot;, inlineeGraph)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
203 * ...
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
204 * } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
205 * throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
206 * }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
207 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
208 *
14620
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
209 * The {@code name} argument is subject to the following type based conversion before having
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
210 * {@link Object#toString()} called on it:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
211 *
14620
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
212 * <pre>
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
213 * Type | Conversion
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
214 * ------------------+-----------------
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
215 * java.lang.Class | arg.getSimpleName()
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
216 * |
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14616
diff changeset
217 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
218 *
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
219 * @param name the name of the new scope
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
220 * @param contextObjects an array of object to be appended to the {@linkplain #context()
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
221 * current} debug context
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
222 * @throws Throwable used to enforce a catch block.
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
223 * @return the scope entered by this method which will be exited when its {@link Scope#close()}
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
224 * method is called
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
225 */
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
226 public static Scope scope(Object name, Object[] contextObjects) throws Throwable {
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
227 if (ENABLED) {
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
228 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, contextObjects);
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
229 } else {
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
230 return null;
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
231 }
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
232 }
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
233
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
234 /**
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
235 * Similar to {@link #scope(Object, Object[])} but without context objects. Therefore the catch
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
236 * block can be omitted.
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
237 *
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
238 * @see #scope(Object, Object[])
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
239 */
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
240 public static Scope scope(Object name) {
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
241 if (ENABLED) {
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
242 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null);
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
243 } else {
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
244 return null;
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
245 }
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
246 }
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
247
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
248 /**
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
249 * @see #scope(Object, Object[])
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
250 * @param context an object to be appended to the {@linkplain #context() current} debug context
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
251 */
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
252 public static Scope scope(Object name, Object context) throws Throwable {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
253 if (ENABLED) {
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
254 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context);
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
255 } else {
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
256 return null;
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
257 }
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
258 }
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
259
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
260 /**
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
261 * @see #scope(Object, Object[])
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
262 * @param context1 first object to be appended to the {@linkplain #context() current} debug
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
263 * context
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
264 * @param context2 second object to be appended to the {@linkplain #context() current} debug
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
265 * context
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
266 */
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
267 public static Scope scope(Object name, Object context1, Object context2) throws Throwable {
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
268 if (ENABLED) {
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
269 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context1, context2);
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
270 } else {
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
271 return null;
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
272 }
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
273 }
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
274
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
275 /**
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
276 * @see #scope(Object, Object[])
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
277 * @param context1 first object to be appended to the {@linkplain #context() current} debug
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
278 * context
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
279 * @param context2 second object to be appended to the {@linkplain #context() current} debug
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
280 * context
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
281 * @param context3 third object to be appended to the {@linkplain #context() current} debug
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
282 * context
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
283 */
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
284 public static Scope scope(Object name, Object context1, Object context2, Object context3) throws Throwable {
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
285 if (ENABLED) {
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
286 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context1, context2, context3);
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
287 } else {
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
288 return null;
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
289 }
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
290 }
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
291
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
292 /**
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
293 * Creates and enters a new debug scope which will be disjoint from the current debug scope.
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
294 * <p>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
295 * It is recommended to use the try-with-resource statement for managing entering and leaving
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
296 * debug scopes. For example:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
297 *
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
298 * <pre>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
299 * try (Scope s = Debug.sandbox(&quot;CompilingStub&quot;, null, stubGraph)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
300 * ...
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
301 * } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
302 * throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
303 * }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
304 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
305 *
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
306 * @param name the name of the new scope
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
307 * @param config the debug configuration to use for the new scope
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
308 * @param context objects to be appended to the {@linkplain #context() current} debug context
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
309 * @return the scope entered by this method which will be exited when its {@link Scope#close()}
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
310 * method is called
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
311 */
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
312 public static Scope sandbox(CharSequence name, DebugConfig config, Object... context) throws Throwable {
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
313 if (ENABLED) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
314 DebugConfig sandboxConfig = config == null ? silentConfig() : config;
13547
8ea968b6dba9 fix handling of sandboxed debug scopes (don't destroy parent flags)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13326
diff changeset
315 return DebugScope.getInstance().scope(name, sandboxConfig, context);
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
316 } else {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
317 return null;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
318 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
319 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
320
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
321 public static Scope forceLog() throws Throwable {
15851
94a2df2f8e58 preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15665
diff changeset
322 ArrayList<Object> context = new ArrayList<>();
94a2df2f8e58 preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15665
diff changeset
323 for (Object obj : context()) {
94a2df2f8e58 preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15665
diff changeset
324 context.add(obj);
94a2df2f8e58 preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15665
diff changeset
325 }
17069
2740dad59eb7 Fix forceLog
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16924
diff changeset
326 return Debug.sandbox("forceLog", new DelegatingDebugConfig().override(Level.LOG, Integer.MAX_VALUE).enable(LOG_METHOD), context.toArray());
14109
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
327 }
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
328
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
329 /**
15116
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
330 * Opens a scope in which exception {@linkplain DebugConfig#interceptException(Throwable)
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
331 * interception} is disabled. It is recommended to use the try-with-resource statement for
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
332 * managing entering and leaving such scopes:
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
333 *
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
334 * <pre>
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
335 * try (DebugConfigScope s = Debug.disableIntercept()) {
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
336 * ...
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
337 * }
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
338 * </pre>
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
339 *
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
340 * This is particularly useful to suppress extraneous output in JUnit tests that are expected to
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
341 * throw an exception.
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
342 */
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
343 public static DebugConfigScope disableIntercept() {
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
344 return Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT));
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
345 }
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
346
0d296283e87d HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents: 15115
diff changeset
347 /**
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
348 * Handles an exception in the context of the debug scope just exited. The just exited scope
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
349 * must have the current scope as its parent which will be the case if the try-with-resource
14624
f3510d0dcf67 removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents: 14620
diff changeset
350 * pattern recommended by {@link #scope(Object)} and
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14873
diff changeset
351 * {@link #sandbox(CharSequence, DebugConfig, Object...)} is used
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
352 *
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17173
diff changeset
353 * @see #scope(Object, Object[])
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14873
diff changeset
354 * @see #sandbox(CharSequence, DebugConfig, Object...)
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
355 */
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
356 public static RuntimeException handle(Throwable exception) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
357 if (ENABLED) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
358 return DebugScope.getInstance().handle(exception);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
359 } else {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
360 if (exception instanceof Error) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
361 throw (Error) exception;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
362 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
363 if (exception instanceof RuntimeException) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
364 throw (RuntimeException) exception;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
365 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
366 throw new RuntimeException(exception);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
367 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
368 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
369
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
370 public static void log(String msg) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
371 log(DEFAULT_LOG_LEVEL, msg);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
372 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
373
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
374 /**
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
375 * Prints a message to the current debug scope's logging stream if logging is enabled.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
376 *
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
377 * @param msg the message to log
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
378 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
379 public static void log(int logLevel, String msg) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
380 if (ENABLED) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
381 DebugScope.getInstance().log(logLevel, msg);
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
382 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
383 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
384
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
385 public static void log(String format, Object arg) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
386 log(DEFAULT_LOG_LEVEL, format, arg);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
387 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
388
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
389 /**
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
390 * Prints a message to the current debug scope's logging stream if logging is enabled.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
391 *
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
392 * @param format a format string
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
393 * @param arg the argument referenced by the format specifiers in {@code format}
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
394 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
395 public static void log(int logLevel, String format, Object arg) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
396 if (ENABLED) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
397 DebugScope.getInstance().log(logLevel, format, arg);
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
398 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
399 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
400
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
401 public static void log(String format, int arg) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
402 log(DEFAULT_LOG_LEVEL, format, arg);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
403 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
404
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
405 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
406 * Prints a message to the current debug scope's logging stream if logging is enabled.
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
407 *
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
408 * @param format a format string
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
409 * @param arg the argument referenced by the format specifiers in {@code format}
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
410 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
411 public static void log(int logLevel, String format, int arg) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
412 if (ENABLED) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
413 DebugScope.getInstance().log(logLevel, format, arg);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
414 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
415 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
416
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
417 public static void log(String format, Object arg1, Object arg2) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
418 log(DEFAULT_LOG_LEVEL, format, arg1, arg2);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
419 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
420
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
421 /**
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
422 * @see #log(int, String, Object)
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
423 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
424 public static void log(int logLevel, String format, Object arg1, Object arg2) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
425 if (ENABLED) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
426 DebugScope.getInstance().log(logLevel, format, arg1, arg2);
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
427 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
428 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
429
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
430 public static void log(String format, int arg1, Object arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
431 log(DEFAULT_LOG_LEVEL, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
432 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
433
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
434 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
435 * @see #log(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
436 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
437 public static void log(int logLevel, String format, int arg1, Object arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
438 if (ENABLED) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
439 DebugScope.getInstance().log(logLevel, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
440 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
441 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
442
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
443 public static void log(String format, Object arg1, int arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
444 log(DEFAULT_LOG_LEVEL, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
445 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
446
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
447 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
448 * @see #log(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
449 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
450 public static void log(int logLevel, String format, Object arg1, int arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
451 if (ENABLED) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
452 DebugScope.getInstance().log(logLevel, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
453 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
454 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
455
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
456 public static void log(String format, int arg1, int arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
457 log(DEFAULT_LOG_LEVEL, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
458 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
459
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
460 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
461 * @see #log(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
462 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
463 public static void log(int logLevel, String format, int arg1, int arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
464 if (ENABLED) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
465 DebugScope.getInstance().log(logLevel, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
466 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
467 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
468
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
469 public static void log(String format, Object arg1, Object arg2, Object arg3) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
470 log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
471 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
472
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
473 /**
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
474 * @see #log(int, String, Object)
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
475 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
476 public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
477 if (ENABLED) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
478 DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3);
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
479 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
480 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
481
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
482 public static void log(String format, int arg1, int arg2, int arg3) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
483 log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
484 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
485
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
486 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
487 * @see #log(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
488 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
489 public static void log(int logLevel, String format, int arg1, int arg2, int arg3) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
490 if (ENABLED) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
491 DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
492 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
493 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
494
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
495 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
496 log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
497 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
498
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
499 /**
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
500 * @see #log(int, String, Object)
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
501 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
502 public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4) {
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
503 if (ENABLED) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
504 DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4);
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
505 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
506 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
507
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
508 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
509 log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
510 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
511
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
512 /**
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
513 * @see #log(int, String, Object)
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
514 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
515 public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
516 if (ENABLED) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
517 DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4, arg5);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
518 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
519 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
520
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
521 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
522 log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
523 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
524
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
525 /**
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
526 * @see #log(int, String, Object)
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
527 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
528 public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
529 if (ENABLED) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
530 DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6);
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
531 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
532 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
533
18935
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
534 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) {
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
535 log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
536 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
537
19262
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
538 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) {
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
539 log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
540 }
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
541
18935
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
542 /**
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
543 * @see #log(int, String, Object)
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
544 */
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
545 public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) {
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
546 if (ENABLED) {
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
547 DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
548 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
549 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
550
19262
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
551 public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) {
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
552 if (ENABLED) {
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
553 DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
554 }
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
555 }
8632751713af Add 8 arguments Debug.log mehtods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 18935
diff changeset
556
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
557 public static void logv(String format, Object... args) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
558 logv(DEFAULT_LOG_LEVEL, format, args);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
559 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
560
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
561 /**
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
562 * Prints a message to the current debug scope's logging stream. This method must only be called
14634
2496f9f49f6b improved javadoc for Debug.logv() to explain why it should be avoided
Doug Simon <doug.simon@oracle.com>
parents: 14625
diff changeset
563 * if debugging is {@linkplain Debug#isEnabled() enabled} as it incurs allocation at the call
2496f9f49f6b improved javadoc for Debug.logv() to explain why it should be avoided
Doug Simon <doug.simon@oracle.com>
parents: 14625
diff changeset
564 * site. If possible, call one of the other {@code log()} methods in this class that take a
2496f9f49f6b improved javadoc for Debug.logv() to explain why it should be avoided
Doug Simon <doug.simon@oracle.com>
parents: 14625
diff changeset
565 * fixed number of parameters.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
566 *
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
567 * @param format a format string
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
568 * @param args the arguments referenced by the format specifiers in {@code format}
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
569 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
570 public static void logv(int logLevel, String format, Object... args) {
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
571 if (!ENABLED) {
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
572 throw new InternalError("Use of Debug.logv() must be guarded by a test of Debug.isEnabled()");
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
573 }
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
574 DebugScope.getInstance().log(logLevel, format, args);
14625
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
575 }
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
576
3ab42370f636 removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents: 14624
diff changeset
577 /**
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
578 * This override exists to catch cases when {@link #log(String, Object)} is called with one
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
579 * argument bound to a varargs method parameter. It will bind to this method instead of the
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
580 * single arg variant and produce a deprecation warning instead of silently wrapping the
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
581 * Object[] inside of another Object[].
14719
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14634
diff changeset
582 */
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14634
diff changeset
583 @Deprecated
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14634
diff changeset
584 public static void log(String format, Object[] args) {
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14634
diff changeset
585 assert false : "shouldn't use this";
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
586 log(DEFAULT_LOG_LEVEL, format, args);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
587 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
588
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
589 /**
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
590 * This override exists to catch cases when {@link #log(int, String, Object)} is called with one
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
591 * argument bound to a varargs method parameter. It will bind to this method instead of the
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
592 * single arg variant and produce a deprecation warning instead of silently wrapping the
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
593 * Object[] inside of another Object[].
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
594 */
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
595 @Deprecated
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
596 public static void log(int logLevel, String format, Object[] args) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
597 assert false : "shouldn't use this";
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
598 logv(logLevel, format, args);
14719
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14634
diff changeset
599 }
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14634
diff changeset
600
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
601 public static void dump(Object object, String msg) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
602 dump(DEFAULT_LOG_LEVEL, object, msg);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
603 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
604
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
605 public static void dump(int dumpLevel, Object object, String msg) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
606 if (ENABLED && DebugScope.getInstance().isDumpEnabled(dumpLevel)) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
607 DebugScope.getInstance().dump(dumpLevel, object, msg);
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
608 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
609 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
610
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
611 public static void dump(Object object, String format, Object arg) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
612 dump(DEFAULT_LOG_LEVEL, object, format, arg);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
613 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
614
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
615 public static void dump(int dumpLevel, Object object, String format, Object arg) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
616 if (ENABLED && DebugScope.getInstance().isDumpEnabled(dumpLevel)) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
617 DebugScope.getInstance().dump(dumpLevel, object, format, arg);
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
618 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
619 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
620
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
621 public static void dump(Object object, String format, Object arg1, Object arg2) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
622 dump(DEFAULT_LOG_LEVEL, object, format, arg1, arg2);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
623 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
624
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
625 public static void dump(int dumpLevel, Object object, String format, Object arg1, Object arg2) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
626 if (ENABLED && DebugScope.getInstance().isDumpEnabled(dumpLevel)) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
627 DebugScope.getInstance().dump(dumpLevel, object, format, arg1, arg2);
10923
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
628 }
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
629 }
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
630
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
631 public static void dump(Object object, String format, Object arg1, Object arg2, Object arg3) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
632 dump(DEFAULT_LOG_LEVEL, object, format, arg1, arg2, arg3);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
633 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
634
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
635 public static void dump(int dumpLevel, Object object, String format, Object arg1, Object arg2, Object arg3) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
636 if (ENABLED && DebugScope.getInstance().isDumpEnabled(dumpLevel)) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
637 DebugScope.getInstance().dump(dumpLevel, object, format, arg1, arg2, arg3);
14873
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
638 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
639 }
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
640
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
641 /**
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
642 * This override exists to catch cases when {@link #dump(Object, String, Object)} is called with
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
643 * one argument bound to a varargs method parameter. It will bind to this method instead of the
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
644 * single arg variant and produce a deprecation warning instead of silently wrapping the
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
645 * Object[] inside of another Object[].
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
646 */
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
647 @Deprecated
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
648 public static void dump(Object object, String format, Object[] args) {
00eb80d735ed removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents: 14871
diff changeset
649 assert false : "shouldn't use this";
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
650 dump(DEFAULT_LOG_LEVEL, object, format, args);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
651 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
652
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
653 /**
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
654 * This override exists to catch cases when {@link #dump(int, Object, String, Object)} is called
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
655 * with one argument bound to a varargs method parameter. It will bind to this method instead of
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
656 * the single arg variant and produce a deprecation warning instead of silently wrapping the
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
657 * Object[] inside of another Object[].
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
658 */
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
659 @Deprecated
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
660 public static void dump(int dumpLevel, Object object, String format, Object[] args) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
661 assert false : "shouldn't use this";
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
662 if (ENABLED && DebugScope.getInstance().isDumpEnabled(dumpLevel)) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
663 DebugScope.getInstance().dump(dumpLevel, object, format, args);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
664 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
665 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
666
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
667 /**
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
668 * Calls all {@link DebugVerifyHandler}s in the current {@linkplain DebugScope#getConfig()
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
669 * config} to perform verification on a given object.
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
670 *
16193
48f86e56eb75 simplified Debug verification API
Doug Simon <doug.simon@oracle.com>
parents: 16144
diff changeset
671 * @param object object to verify
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
672 * @param message description of verification context
16193
48f86e56eb75 simplified Debug verification API
Doug Simon <doug.simon@oracle.com>
parents: 16144
diff changeset
673 *
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
674 * @see DebugVerifyHandler#verify(Object, String)
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
675 */
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
676 public static void verify(Object object, String message) {
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
677 if (ENABLED && DebugScope.getInstance().isVerifyEnabled()) {
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
678 DebugScope.getInstance().verify(object, message);
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
679 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
680 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
681
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
682 /**
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
683 * Calls all {@link DebugVerifyHandler}s in the current {@linkplain DebugScope#getConfig()
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
684 * config} to perform verification on a given object.
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
685 *
16193
48f86e56eb75 simplified Debug verification API
Doug Simon <doug.simon@oracle.com>
parents: 16144
diff changeset
686 * @param object object to verify
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
687 * @param format a format string for the description of the verification context
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
688 * @param arg the argument referenced by the format specifiers in {@code format}
16193
48f86e56eb75 simplified Debug verification API
Doug Simon <doug.simon@oracle.com>
parents: 16144
diff changeset
689 *
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
690 * @see DebugVerifyHandler#verify(Object, String)
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
691 */
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
692 public static void verify(Object object, String format, Object arg) {
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
693 if (ENABLED && DebugScope.getInstance().isVerifyEnabled()) {
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
694 DebugScope.getInstance().verify(object, format, arg);
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
695 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
696 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
697
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
698 /**
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
699 * This override exists to catch cases when {@link #verify(Object, String, Object)} is called
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
700 * with one argument bound to a varargs method parameter. It will bind to this method instead of
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
701 * the single arg variant and produce a deprecation warning instead of silently wrapping the
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
702 * Object[] inside of another Object[].
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
703 */
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
704 @Deprecated
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
705 public static void verify(Object object, String format, Object[] args) {
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
706 assert false : "shouldn't use this";
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
707 if (ENABLED && DebugScope.getInstance().isVerifyEnabled()) {
16297
b9236eaecf4c simplified DebugVerifyHandler API to be closer to DebugDumpHandler
Doug Simon <doug.simon@oracle.com>
parents: 16193
diff changeset
708 DebugScope.getInstance().verify(object, format, args);
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
709 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
710 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
711
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
712 /**
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
713 * Opens a new indentation level (by adding some spaces) based on the current indentation level.
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
714 * This should be used in a {@linkplain Indent try-with-resources} pattern.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
715 *
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
716 * @return an object that reverts to the current indentation level when
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
717 * {@linkplain Indent#close() closed} or null if debugging is disabled
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
718 * @see #logAndIndent(int, String)
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
719 * @see #logAndIndent(int, String, Object)
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
720 */
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
721 public static Indent indent() {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
722 if (ENABLED) {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
723 DebugScope scope = DebugScope.getInstance();
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
724 return scope.pushIndentLogger();
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
725 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
726 return null;
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
727 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
728
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
729 public static Indent logAndIndent(String msg) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
730 return logAndIndent(DEFAULT_LOG_LEVEL, msg);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
731 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
732
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
733 /**
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
734 * A convenience function which combines {@link #log(String)} and {@link #indent()}.
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
735 *
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
736 * @param msg the message to log
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
737 * @return an object that reverts to the current indentation level when
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
738 * {@linkplain Indent#close() closed} or null if debugging is disabled
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
739 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
740 public static Indent logAndIndent(int logLevel, String msg) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
741 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
742 return logvAndIndentInternal(logLevel, msg);
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
743 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
744 return null;
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
745 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
746
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
747 public static Indent logAndIndent(String format, Object arg) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
748 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
749 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
750
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
751 /**
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
752 * A convenience function which combines {@link #log(String, Object)} and {@link #indent()}.
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
753 *
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
754 * @param format a format string
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
755 * @param arg the argument referenced by the format specifiers in {@code format}
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
756 * @return an object that reverts to the current indentation level when
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
757 * {@linkplain Indent#close() closed} or null if debugging is disabled
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
758 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
759 public static Indent logAndIndent(int logLevel, String format, Object arg) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
760 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
761 return logvAndIndentInternal(logLevel, format, arg);
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
762 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
763 return null;
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
764 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
765
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
766 public static Indent logAndIndent(String format, int arg) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
767 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
768 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
769
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
770 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
771 * A convenience function which combines {@link #log(String, Object)} and {@link #indent()}.
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
772 *
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
773 * @param format a format string
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
774 * @param arg the argument referenced by the format specifiers in {@code format}
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
775 * @return an object that reverts to the current indentation level when
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
776 * {@linkplain Indent#close() closed} or null if debugging is disabled
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
777 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
778 public static Indent logAndIndent(int logLevel, String format, int arg) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
779 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
780 return logvAndIndentInternal(logLevel, format, arg);
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
781 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
782 return null;
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
783 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
784
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
785 public static Indent logAndIndent(String format, int arg1, Object arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
786 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
787 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
788
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
789 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
790 * @see #logAndIndent(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
791 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
792 public static Indent logAndIndent(int logLevel, String format, int arg1, Object arg2) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
793 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
794 return logvAndIndentInternal(logLevel, format, arg1, arg2);
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
795 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
796 return null;
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
797 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
798
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
799 public static Indent logAndIndent(String format, Object arg1, int arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
800 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
801 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
802
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
803 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
804 * @see #logAndIndent(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
805 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
806 public static Indent logAndIndent(int logLevel, String format, Object arg1, int arg2) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
807 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
808 return logvAndIndentInternal(logLevel, format, arg1, arg2);
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
809 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
810 return null;
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
811 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
812
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
813 public static Indent logAndIndent(String format, int arg1, int arg2) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
814 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
815 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
816
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
817 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
818 * @see #logAndIndent(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
819 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
820 public static Indent logAndIndent(int logLevel, String format, int arg1, int arg2) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
821 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
822 return logvAndIndentInternal(logLevel, format, arg1, arg2);
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
823 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
824 return null;
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
825 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
826
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
827 public static Indent logAndIndent(String format, Object arg1, Object arg2) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
828 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
829 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
830
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
831 /**
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
832 * @see #logAndIndent(int, String, Object)
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
833 */
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
834 public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
835 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
836 return logvAndIndentInternal(logLevel, format, arg1, arg2);
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
837 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
838 return null;
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
839 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
840
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
841 public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
842 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
843 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
844
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
845 /**
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
846 * @see #logAndIndent(int, String, Object)
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
847 */
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
848 public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
849 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
850 return logvAndIndentInternal(logLevel, format, arg1, arg2, arg3);
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
851 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
852 return null;
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
853 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
854
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
855 public static Indent logAndIndent(String format, int arg1, int arg2, int arg3) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
856 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
857 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
858
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
859 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
860 * @see #logAndIndent(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
861 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
862 public static Indent logAndIndent(int logLevel, String format, int arg1, int arg2, int arg3) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
863 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
864 return logvAndIndentInternal(logLevel, format, arg1, arg2, arg3);
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
865 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
866 return null;
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
867 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
868
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
869 public static Indent logAndIndent(String format, Object arg1, int arg2, int arg3) {
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
870 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3);
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
871 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
872
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
873 /**
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
874 * @see #logAndIndent(int, String, Object)
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
875 */
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
876 public static Indent logAndIndent(int logLevel, String format, Object arg1, int arg2, int arg3) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
877 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
878 return logvAndIndentInternal(logLevel, format, arg1, arg2, arg3);
20977
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
879 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
880 return null;
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
881 }
820420c8713c Add int overrides for some log methods
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
882
18935
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
883 public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4) {
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
884 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4);
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
885 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
886
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
887 /**
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
888 * @see #logAndIndent(int, String, Object)
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
889 */
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
890 public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
891 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
892 return logvAndIndentInternal(logLevel, format, arg1, arg2, arg3, arg4);
18935
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
893 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
894 return null;
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
895 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
896
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
897 public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
898 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5);
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
899 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
900
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
901 /**
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
902 * @see #logAndIndent(int, String, Object)
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
903 */
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
904 public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
905 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
906 return logvAndIndentInternal(logLevel, format, arg1, arg2, arg3, arg4, arg5);
18935
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
907 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
908 return null;
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
909 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
910
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
911 public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
912 return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6);
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
913 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
914
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
915 /**
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
916 * @see #logAndIndent(int, String, Object)
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
917 */
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
918 public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
919 if (ENABLED && Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
920 return logvAndIndentInternal(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6);
18935
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
921 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
922 return null;
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
923 }
07f2a49f0bfb Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents: 17333
diff changeset
924
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
925 /**
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
926 * A convenience function which combines {@link #logv(int, String, Object...)} and
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
927 * {@link #indent()}.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
928 *
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
929 * @param format a format string
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
930 * @param args the arguments referenced by the format specifiers in {@code format}
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
931 * @return an object that reverts to the current indentation level when
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
932 * {@linkplain Indent#close() closed} or null if debugging is disabled
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
933 */
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
934 public static Indent logvAndIndent(int logLevel, String format, Object... args) {
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
935 if (ENABLED) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
936 if (Debug.isLogEnabled(logLevel)) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
937 return logvAndIndentInternal(logLevel, format, args);
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
938 }
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
939 return null;
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
940 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
941 throw new InternalError("Use of Debug.logvAndIndent() must be guarded by a test of Debug.isEnabled()");
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
942 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
943
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
944 private static Indent logvAndIndentInternal(int logLevel, String format, Object... args) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
945 assert ENABLED && Debug.isLogEnabled(logLevel) : "must have checked Debug.isLogEnabled()";
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
946 DebugScope scope = DebugScope.getInstance();
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
947 scope.log(logLevel, format, args);
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
948 return scope.pushIndentLogger();
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
949 }
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20977
diff changeset
950
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
951 /**
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
952 * This override exists to catch cases when {@link #logAndIndent(String, Object)} is called with
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
953 * one argument bound to a varargs method parameter. It will bind to this method instead of the
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
954 * single arg variant and produce a deprecation warning instead of silently wrapping the
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
955 * Object[] inside of another Object[].
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
956 */
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
957 @Deprecated
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
958 public static void logAndIndent(String format, Object[] args) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14779
diff changeset
959 assert false : "shouldn't use this";
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
960 logAndIndent(DEFAULT_LOG_LEVEL, format, args);
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
961 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
962
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
963 /**
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
964 * This override exists to catch cases when {@link #logAndIndent(int, String, Object)} is called
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
965 * with one argument bound to a varargs method parameter. It will bind to this method instead of
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
966 * the single arg variant and produce a deprecation warning instead of silently wrapping the
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
967 * Object[] inside of another Object[].
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
968 */
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
969 @Deprecated
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
970 public static void logAndIndent(int logLevel, String format, Object[] args) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
971 assert false : "shouldn't use this";
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
972 logvAndIndent(logLevel, format, args);
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
973 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
974
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
975 public static Iterable<Object> context() {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
976 if (ENABLED) {
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
977 return DebugScope.getInstance().getCurrentContext();
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
978 } else {
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
979 return Collections.emptyList();
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
980 }
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
981 }
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
982
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
983 @SuppressWarnings("unchecked")
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
984 public static <T> List<T> contextSnapshot(Class<T> clazz) {
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
985 if (ENABLED) {
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
986 List<T> result = new ArrayList<>();
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
987 for (Object o : context()) {
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
988 if (clazz.isInstance(o)) {
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
989 result.add((T) o);
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
990 }
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
991 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
992 return result;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
993 } else {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
994 return Collections.emptyList();
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
995 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
996 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
997
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5159
diff changeset
998 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6584
diff changeset
999 * Searches the current debug scope, bottom up, for a context object that is an instance of a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6584
diff changeset
1000 * given type. The first such object found is returned.
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5159
diff changeset
1001 */
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1002 @SuppressWarnings("unchecked")
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1003 public static <T> T contextLookup(Class<T> clazz) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1004 if (ENABLED) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1005 for (Object o : context()) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1006 if (clazz.isInstance(o)) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1007 return ((T) o);
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1008 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1009 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1010 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1011 return null;
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1012 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1013
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1014 /**
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1015 * Creates a {@linkplain DebugMemUseTracker memory use tracker} that is enabled iff debugging is
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1016 * {@linkplain #isEnabled() enabled}.
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1017 * <p>
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1018 * A disabled tracker has virtually no overhead.
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1019 */
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1020 public static DebugMemUseTracker memUseTracker(CharSequence name) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1021 if (!isUnconditionalMemUseTrackingEnabled && !ENABLED) {
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1022 return VOID_MEM_USE_TRACKER;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1023 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1024 return createMemUseTracker("%s", name, null);
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1025 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1026
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1027 /**
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1028 * Creates a debug memory use tracker. Invoking this method is equivalent to:
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1029 *
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1030 * <pre>
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1031 * Debug.memUseTracker(format, arg, null)
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1032 * </pre>
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1033 *
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1034 * except that the string formatting only happens if metering is enabled.
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1035 *
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1036 * @see #metric(String, Object, Object)
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1037 */
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1038 public static DebugMemUseTracker memUseTracker(String format, Object arg) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1039 if (!isUnconditionalMemUseTrackingEnabled && !ENABLED) {
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1040 return VOID_MEM_USE_TRACKER;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1041 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1042 return createMemUseTracker(format, arg, null);
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1043 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1044
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1045 /**
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1046 * Creates a debug memory use tracker. Invoking this method is equivalent to:
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1047 *
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1048 * <pre>
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1049 * Debug.memUseTracker(String.format(format, arg1, arg2))
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1050 * </pre>
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1051 *
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1052 * except that the string formatting only happens if memory use tracking is enabled. In
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1053 * addition, each argument is subject to the following type based conversion before being passed
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1054 * as an argument to {@link String#format(String, Object...)}:
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1055 *
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1056 * <pre>
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1057 * Type | Conversion
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1058 * ------------------+-----------------
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1059 * java.lang.Class | arg.getSimpleName()
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1060 * |
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1061 * </pre>
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1062 *
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1063 * @see #memUseTracker(CharSequence)
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1064 */
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1065 public static DebugMemUseTracker memUseTracker(String format, Object arg1, Object arg2) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1066 if (!isUnconditionalMemUseTrackingEnabled && !ENABLED) {
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1067 return VOID_MEM_USE_TRACKER;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1068 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1069 return createMemUseTracker(format, arg1, arg2);
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1070 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1071
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1072 private static DebugMemUseTracker createMemUseTracker(String format, Object arg1, Object arg2) {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1073 String name = formatDebugName(format, arg1, arg2);
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1074 return new MemUseTrackerImpl(name, !isUnconditionalMemUseTrackingEnabled);
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1075 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1076
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1077 /**
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1078 * Creates a {@linkplain DebugMetric metric} that is enabled iff debugging is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1079 * {@linkplain #isEnabled() enabled} or the system property whose name is formed by adding to
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1080 * {@value #ENABLE_METRIC_PROPERTY_NAME_PREFIX} to {@code name} is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1081 * {@linkplain Boolean#getBoolean(String) true}. If the latter condition is true, then the
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1082 * returned metric is {@linkplain DebugMetric#isConditional() unconditional} otherwise it is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1083 * conditional.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1084 * <p>
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1085 * A disabled metric has virtually no overhead.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1086 */
14586
d2fe05d5cc96 added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents: 14582
diff changeset
1087 public static DebugMetric metric(CharSequence name) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1088 if (!areUnconditionalMetricsEnabled() && !ENABLED) {
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
1089 return VOID_METRIC;
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1090 }
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1091 return createMetric("%s", name, null);
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1092 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1093
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1094 public static String applyFormattingFlagsAndWidth(String s, int flags, int width) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1095 if (flags == 0 && width < 0) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1096 return s;
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1097 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1098 StringBuilder sb = new StringBuilder(s);
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1099
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1100 // apply width and justification
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1101 int len = sb.length();
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1102 if (len < width) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1103 for (int i = 0; i < width - len; i++) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1104 if ((flags & LEFT_JUSTIFY) == LEFT_JUSTIFY) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1105 sb.append(' ');
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1106 } else {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1107 sb.insert(0, ' ');
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1108 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1109 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1110 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1111
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1112 String res = sb.toString();
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1113 if ((flags & UPPERCASE) == UPPERCASE) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1114 res = res.toUpperCase();
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1115 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1116 return res;
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1117 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1118
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1119 /**
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1120 * Creates a debug metric. Invoking this method is equivalent to:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1121 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1122 * <pre>
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1123 * Debug.metric(format, arg, null)
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1124 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1125 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1126 * except that the string formatting only happens if metering is enabled.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1127 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1128 * @see #metric(String, Object, Object)
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1129 */
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1130 public static DebugMetric metric(String format, Object arg) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1131 if (!areUnconditionalMetricsEnabled() && !ENABLED) {
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1132 return VOID_METRIC;
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1133 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1134 return createMetric(format, arg, null);
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1135 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1136
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1137 /**
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1138 * Creates a debug metric. Invoking this method is equivalent to:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1139 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1140 * <pre>
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1141 * Debug.metric(String.format(format, arg1, arg2))
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1142 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1143 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1144 * except that the string formatting only happens if metering is enabled. In addition, each
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1145 * argument is subject to the following type based conversion before being passed as an argument
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1146 * to {@link String#format(String, Object...)}:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1147 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1148 * <pre>
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1149 * Type | Conversion
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1150 * ------------------+-----------------
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1151 * java.lang.Class | arg.getSimpleName()
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1152 * |
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1153 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1154 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1155 * @see #metric(CharSequence)
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1156 */
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1157 public static DebugMetric metric(String format, Object arg1, Object arg2) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1158 if (!areUnconditionalMetricsEnabled() && !ENABLED) {
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1159 return VOID_METRIC;
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1160 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1161 return createMetric(format, arg1, arg2);
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1162 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1163
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1164 private static DebugMetric createMetric(String format, Object arg1, Object arg2) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1165 String name = formatDebugName(format, arg1, arg2);
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1166 boolean conditional = enabledMetrics == null || !findMatch(enabledMetrics, enabledMetricsSubstrings, name);
16924
29aa6f015c16 used void timer/metric implementation for conditional timers/metrics if neither -G:Time nor -G:Meter is specified
Doug Simon <doug.simon@oracle.com>
parents: 16900
diff changeset
1167 if (!ENABLED && conditional) {
29aa6f015c16 used void timer/metric implementation for conditional timers/metrics if neither -G:Time nor -G:Meter is specified
Doug Simon <doug.simon@oracle.com>
parents: 16900
diff changeset
1168 return VOID_METRIC;
29aa6f015c16 used void timer/metric implementation for conditional timers/metrics if neither -G:Time nor -G:Meter is specified
Doug Simon <doug.simon@oracle.com>
parents: 16900
diff changeset
1169 }
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1170 return new MetricImpl(name, conditional);
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1171 }
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1172
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1173 /**
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1174 * Changes the debug configuration for the current thread.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1175 *
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1176 * @param config new configuration to use for the current thread
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1177 * @return an object that when {@linkplain DebugConfigScope#close() closed} will restore the
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1178 * debug configuration for the current thread to what it was before this method was
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1179 * called
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1180 */
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1181 public static DebugConfigScope setConfig(DebugConfig config) {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
1182 if (ENABLED) {
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1183 return new DebugConfigScope(config);
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1184 } else {
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
1185 return null;
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
1186 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
1187 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
1188
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 11382
diff changeset
1189 /**
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 11382
diff changeset
1190 * Creates an object for counting value frequencies.
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 11382
diff changeset
1191 */
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
1192 public static DebugHistogram createHistogram(String name) {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
1193 return new DebugHistogramImpl(name);
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
1194 }
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
1195
13189
f444a67ecbae Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents: 13163
diff changeset
1196 public static DebugConfig silentConfig() {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1197 return fixedConfig(0, 0, false, false, false, false, Collections.<DebugDumpHandler> emptyList(), Collections.<DebugVerifyHandler> emptyList(), null);
13189
f444a67ecbae Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents: 13163
diff changeset
1198 }
f444a67ecbae Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents: 13163
diff changeset
1199
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1200 public static DebugConfig fixedConfig(final int logLevel, final int dumpLevel, final boolean isMeterEnabled, final boolean isMemUseTrackingEnabled, final boolean isTimerEnabled,
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1201 final boolean isVerifyEnabled, final Collection<DebugDumpHandler> dumpHandlers, final Collection<DebugVerifyHandler> verifyHandlers, final PrintStream output) {
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1202 return new DebugConfig() {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1203
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1204 @Override
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1205 public int getLogLevel() {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1206 return logLevel;
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1207 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1208
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
1209 public boolean isLogEnabledForMethod() {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1210 return logLevel > 0;
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
1211 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
1212
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1213 @Override
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1214 public boolean isMeterEnabled() {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1215 return isMeterEnabled;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1216 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1217
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1218 @Override
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1219 public boolean isMemUseTrackingEnabled() {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1220 return isMemUseTrackingEnabled;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1221 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1222
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1223 @Override
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1224 public int getDumpLevel() {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1225 return dumpLevel;
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1226 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1227
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
1228 public boolean isDumpEnabledForMethod() {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16405
diff changeset
1229 return dumpLevel > 0;
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
1230 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
1231
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1232 @Override
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1233 public boolean isVerifyEnabled() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1234 return isVerifyEnabled;
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1235 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1236
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1237 public boolean isVerifyEnabledForMethod() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1238 return isVerifyEnabled;
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1239 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1240
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1241 @Override
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
1242 public boolean isTimeEnabled() {
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1243 return isTimerEnabled;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1244 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1245
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1246 @Override
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1247 public RuntimeException interceptException(Throwable e) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1248 return null;
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1249 }
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
1250
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
1251 @Override
6584
a3eb814ea564 added more javadoc to DebugConfig interface
Doug Simon <doug.simon@oracle.com>
parents: 5620
diff changeset
1252 public Collection<DebugDumpHandler> dumpHandlers() {
4428
0bb7ab1add7e enable dumping graphs upon exception, new constructor for NodeInputList, initialize debug system for non-compiler threads
Lukas Stadler <lukas.stadler@jku.at>
parents: 4406
diff changeset
1253 return dumpHandlers;
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
1254 }
5302
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
1255
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
1256 @Override
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1257 public Collection<DebugVerifyHandler> verifyHandlers() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1258 return verifyHandlers;
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1259 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1260
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15851
diff changeset
1261 @Override
5302
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
1262 public PrintStream output() {
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
1263 return output;
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
1264 }
5620
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1265
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1266 @Override
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1267 public void addToContext(Object o) {
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1268 }
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1269
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1270 @Override
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1271 public void removeFromContext(Object o) {
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
1272 }
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1273 };
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1274 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
1275
4356
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4353
diff changeset
1276 private static final DebugMetric VOID_METRIC = new DebugMetric() {
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1277
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1278 public void increment() {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1279 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1280
7557
db90c8b5a861 changed DebugMetric.add() to take a long parameter instead of an int
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
1281 public void add(long value) {
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1282 }
11562
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1283
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1284 public void setConditional(boolean flag) {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1285 throw new InternalError("Cannot make void metric conditional");
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1286 }
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1287
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1288 public boolean isConditional() {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1289 return false;
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1290 }
12778
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1291
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1292 public long getCurrentValue() {
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1293 return 0L;
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1294 }
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
1295 };
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
1296
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1297 private static final DebugMemUseTracker VOID_MEM_USE_TRACKER = new DebugMemUseTracker() {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1298
19693
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19262
diff changeset
1299 public DebugCloseable start() {
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19262
diff changeset
1300 return DebugCloseable.VOID_CLOSEABLE;
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1301 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1302
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1303 public long getCurrentValue() {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1304 return 0;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1305 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1306 };
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1307
21558
d563baeca9df changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1308 public static final String ENABLE_UNSCOPED_TIMERS_PROPERTY_NAME = "jvmci.debug.unscopedTimers";
d563baeca9df changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1309 public static final String ENABLE_UNSCOPED_METRICS_PROPERTY_NAME = "jvmci.debug.unscopedMetrics";
d563baeca9df changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1310 public static final String ENABLE_UNSCOPED_MEM_USE_TRACKERS_PROPERTY_NAME = "jvmci.debug.unscopedMemUseTrackers";
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1311
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1312 /**
14586
d2fe05d5cc96 added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents: 14582
diff changeset
1313 * @see #timer(CharSequence)
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1314 */
21558
d563baeca9df changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1315 public static final String ENABLE_TIMER_PROPERTY_NAME_PREFIX = "jvmci.debug.timer.";
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1316
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1317 /**
14586
d2fe05d5cc96 added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents: 14582
diff changeset
1318 * @see #metric(CharSequence)
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1319 */
21558
d563baeca9df changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1320 public static final String ENABLE_METRIC_PROPERTY_NAME_PREFIX = "jvmci.debug.metric.";
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1321
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1322 /**
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1323 * Set of unconditionally enabled metrics. Possible values and their meanings:
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1324 * <ul>
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1325 * <li>{@code null}: no unconditionally enabled metrics</li>
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1326 * <li>{@code isEmpty()}: all metrics are unconditionally enabled</li>
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1327 * <li>{@code !isEmpty()}: use {@link #findMatch(Set, Set, String)} on this set and
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1328 * {@link #enabledMetricsSubstrings} to determine which metrics are unconditionally enabled</li>
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1329 * </ul>
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1330 */
14582
5fc6b8b54d82 reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents: 14109
diff changeset
1331 private static final Set<String> enabledMetrics;
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1332
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1333 /**
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1334 * Set of unconditionally enabled timers. Same interpretation of values as for
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1335 * {@link #enabledMetrics}.
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1336 */
14582
5fc6b8b54d82 reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents: 14109
diff changeset
1337 private static final Set<String> enabledTimers;
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1338
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1339 private static final Set<String> enabledMetricsSubstrings = new HashSet<>();
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1340 private static final Set<String> enabledTimersSubstrings = new HashSet<>();
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1341
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1342 /**
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1343 * Specifies if all mem use trackers are unconditionally enabled.
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1344 */
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1345 private static final boolean isUnconditionalMemUseTrackingEnabled;
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1346
14582
5fc6b8b54d82 reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents: 14109
diff changeset
1347 static {
5fc6b8b54d82 reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents: 14109
diff changeset
1348 Set<String> metrics = new HashSet<>();
5fc6b8b54d82 reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents: 14109
diff changeset
1349 Set<String> timers = new HashSet<>();
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1350 parseMetricAndTimerSystemProperties(metrics, timers, enabledMetricsSubstrings, enabledTimersSubstrings);
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1351 metrics = metrics.isEmpty() && enabledMetricsSubstrings.isEmpty() ? null : metrics;
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1352 timers = timers.isEmpty() && enabledTimersSubstrings.isEmpty() ? null : timers;
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1353 if (metrics == null && Boolean.getBoolean(ENABLE_UNSCOPED_METRICS_PROPERTY_NAME)) {
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1354 metrics = Collections.emptySet();
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1355 }
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1356 if (timers == null && Boolean.getBoolean(ENABLE_UNSCOPED_TIMERS_PROPERTY_NAME)) {
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1357 timers = Collections.emptySet();
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1358 }
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1359 enabledMetrics = metrics;
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1360 enabledTimers = timers;
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1361 isUnconditionalMemUseTrackingEnabled = Boolean.getBoolean(ENABLE_UNSCOPED_MEM_USE_TRACKERS_PROPERTY_NAME);
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1362 }
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1363
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1364 private static boolean findMatch(Set<String> haystack, Set<String> haystackSubstrings, String needle) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1365 if (haystack.isEmpty()) {
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1366 // Empty haystack means match all
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1367 return true;
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1368 }
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1369 if (haystack.contains(needle)) {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1370 return true;
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1371 }
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1372 if (!haystackSubstrings.isEmpty()) {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1373 for (String h : haystackSubstrings) {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1374 if (needle.startsWith(h)) {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1375 return true;
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1376 }
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1377 }
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1378 }
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1379 return false;
14582
5fc6b8b54d82 reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents: 14109
diff changeset
1380 }
5fc6b8b54d82 reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents: 14109
diff changeset
1381
16900
34b000f69af3 made debug value printing work if individual timers or metrics are enabled without -G:Time or -G:Meter being specified
Doug Simon <doug.simon@oracle.com>
parents: 16680
diff changeset
1382 public static boolean areUnconditionalTimersEnabled() {
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1383 return enabledTimers != null;
16900
34b000f69af3 made debug value printing work if individual timers or metrics are enabled without -G:Time or -G:Meter being specified
Doug Simon <doug.simon@oracle.com>
parents: 16680
diff changeset
1384 }
34b000f69af3 made debug value printing work if individual timers or metrics are enabled without -G:Time or -G:Meter being specified
Doug Simon <doug.simon@oracle.com>
parents: 16680
diff changeset
1385
34b000f69af3 made debug value printing work if individual timers or metrics are enabled without -G:Time or -G:Meter being specified
Doug Simon <doug.simon@oracle.com>
parents: 16680
diff changeset
1386 public static boolean areUnconditionalMetricsEnabled() {
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1387 return enabledMetrics != null;
16900
34b000f69af3 made debug value printing work if individual timers or metrics are enabled without -G:Time or -G:Meter being specified
Doug Simon <doug.simon@oracle.com>
parents: 16680
diff changeset
1388 }
34b000f69af3 made debug value printing work if individual timers or metrics are enabled without -G:Time or -G:Meter being specified
Doug Simon <doug.simon@oracle.com>
parents: 16680
diff changeset
1389
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1390 protected static void parseMetricAndTimerSystemProperties(Set<String> metrics, Set<String> timers, Set<String> metricsSubstrings, Set<String> timersSubstrings) {
16680
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1391 do {
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1392 try {
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1393 for (Map.Entry<Object, Object> e : System.getProperties().entrySet()) {
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1394 String name = e.getKey().toString();
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1395 if (name.startsWith(ENABLE_METRIC_PROPERTY_NAME_PREFIX) && Boolean.parseBoolean(e.getValue().toString())) {
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1396 if (name.endsWith("*")) {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1397 metricsSubstrings.add(name.substring(ENABLE_METRIC_PROPERTY_NAME_PREFIX.length(), name.length() - 1));
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1398 } else {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1399 metrics.add(name.substring(ENABLE_METRIC_PROPERTY_NAME_PREFIX.length()));
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1400 }
16680
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1401 }
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1402 if (name.startsWith(ENABLE_TIMER_PROPERTY_NAME_PREFIX) && Boolean.parseBoolean(e.getValue().toString())) {
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1403 if (name.endsWith("*")) {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1404 timersSubstrings.add(name.substring(ENABLE_TIMER_PROPERTY_NAME_PREFIX.length(), name.length() - 1));
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1405 } else {
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1406 timers.add(name.substring(ENABLE_TIMER_PROPERTY_NAME_PREFIX.length()));
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1407 }
16680
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1408 }
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1409 }
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1410 return;
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1411 } catch (ConcurrentModificationException e) {
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1412 // Iterating over the system properties may race with another thread that is
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1413 // updating the system properties. Simply try again in this case.
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1414 }
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1415 } while (true);
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1416 }
c53c0c153d73 gracefully handle ConcurrentModificationException while iterating over system properties during initialization of the Debug class
Doug Simon <doug.simon@oracle.com>
parents: 16463
diff changeset
1417
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1418 /**
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1419 * Creates a {@linkplain DebugTimer timer} that is enabled iff debugging is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1420 * {@linkplain #isEnabled() enabled} or the system property whose name is formed by adding to
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1421 * {@value #ENABLE_TIMER_PROPERTY_NAME_PREFIX} to {@code name} is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1422 * {@linkplain Boolean#getBoolean(String) true}. If the latter condition is true, then the
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1423 * returned timer is {@linkplain DebugMetric#isConditional() unconditional} otherwise it is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1424 * conditional.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1425 * <p>
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1426 * A disabled timer has virtually no overhead.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
1427 */
14586
d2fe05d5cc96 added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents: 14582
diff changeset
1428 public static DebugTimer timer(CharSequence name) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1429 if (!areUnconditionalTimersEnabled() && !ENABLED) {
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1430 return VOID_TIMER;
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1431 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1432 return createTimer("%s", name, null);
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1433 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1434
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1435 /**
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1436 * Creates a debug timer. Invoking this method is equivalent to:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1437 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1438 * <pre>
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1439 * Debug.timer(format, arg, null)
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1440 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1441 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1442 * except that the string formatting only happens if timing is enabled.
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1443 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1444 * @see #timer(String, Object, Object)
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1445 */
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1446 public static DebugTimer timer(String format, Object arg) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1447 if (!areUnconditionalTimersEnabled() && !ENABLED) {
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
1448 return VOID_TIMER;
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1449 }
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1450 return createTimer(format, arg, null);
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1451 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1452
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1453 /**
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1454 * Creates a debug timer. Invoking this method is equivalent to:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1455 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1456 * <pre>
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1457 * Debug.timer(String.format(format, arg1, arg2))
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1458 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1459 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1460 * except that the string formatting only happens if timing is enabled. In addition, each
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1461 * argument is subject to the following type based conversion before being passed as an argument
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1462 * to {@link String#format(String, Object...)}:
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1463 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1464 * <pre>
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1465 * Type | Conversion
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1466 * ------------------+-----------------
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1467 * java.lang.Class | arg.getSimpleName()
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1468 * |
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1469 * </pre>
14779
0a2c211e9cd1 reverted 3128becfec95
Doug Simon <doug.simon@oracle.com>
parents: 14755
diff changeset
1470 *
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1471 * @see #timer(CharSequence)
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1472 */
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1473 public static DebugTimer timer(String format, Object arg1, Object arg2) {
20016
e7e868a42b3f avoid creation of scopes if -G:Time, -G:Meter and -G:TrackMemUse all have null or empty values and no other debug scope based options are given (e.g., -G:Log, -G:Dump, etc)
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
1474 if (!areUnconditionalTimersEnabled() && !ENABLED) {
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1475 return VOID_TIMER;
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1476 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1477 return createTimer(format, arg1, arg2);
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1478 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1479
17333
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1480 /**
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1481 * There are paths where construction of formatted class names are common and the code below is
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1482 * surprisingly expensive, so compute it once and cache it.
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1483 */
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1484 private static final ClassValue<String> formattedClassName = new ClassValue<String>() {
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1485 @Override
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1486 protected String computeValue(Class<?> c) {
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1487 final String simpleName = c.getSimpleName();
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1488 Class<?> enclosingClass = c.getEnclosingClass();
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1489 if (enclosingClass != null) {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1490 String prefix = "";
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1491 while (enclosingClass != null) {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1492 prefix = enclosingClass.getSimpleName() + "_" + prefix;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1493 enclosingClass = enclosingClass.getEnclosingClass();
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1494 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1495 return prefix + simpleName;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1496 } else {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1497 return simpleName;
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15140
diff changeset
1498 }
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1499 }
17333
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1500 };
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1501
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1502 public static Object convertFormatArg(Object arg) {
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1503 if (arg instanceof Class) {
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1504 return formattedClassName.get((Class<?>) arg);
fa821ca2611a Cache converted classfile name in debug mode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17212
diff changeset
1505 }
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1506 return arg;
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1507 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1508
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1509 private static String formatDebugName(String format, Object arg1, Object arg2) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1510 return String.format(format, convertFormatArg(arg1), convertFormatArg(arg2));
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1511 }
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1512
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1513 private static DebugTimer createTimer(String format, Object arg1, Object arg2) {
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1514 String name = formatDebugName(format, arg1, arg2);
17173
6c299422ba23 added support for substring matching when specifying unconditional timers and meters (e.g., -Dgraal.debug.timer.NodeClass*)
Doug Simon <doug.simon@oracle.com>
parents: 17069
diff changeset
1515 boolean conditional = enabledTimers == null || !findMatch(enabledTimers, enabledTimersSubstrings, name);
16924
29aa6f015c16 used void timer/metric implementation for conditional timers/metrics if neither -G:Time nor -G:Meter is specified
Doug Simon <doug.simon@oracle.com>
parents: 16900
diff changeset
1516 if (!ENABLED && conditional) {
29aa6f015c16 used void timer/metric implementation for conditional timers/metrics if neither -G:Time nor -G:Meter is specified
Doug Simon <doug.simon@oracle.com>
parents: 16900
diff changeset
1517 return VOID_TIMER;
29aa6f015c16 used void timer/metric implementation for conditional timers/metrics if neither -G:Time nor -G:Meter is specified
Doug Simon <doug.simon@oracle.com>
parents: 16900
diff changeset
1518 }
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14586
diff changeset
1519 return new TimerImpl(name, conditional);
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1520 }
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1521
4356
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4353
diff changeset
1522 private static final DebugTimer VOID_TIMER = new DebugTimer() {
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1523
19693
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19262
diff changeset
1524 public DebugCloseable start() {
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19262
diff changeset
1525 return DebugCloseable.VOID_CLOSEABLE;
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
1526 }
11562
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1527
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1528 public void setConditional(boolean flag) {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1529 throw new InternalError("Cannot make void timer conditional");
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1530 }
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1531
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1532 public boolean isConditional() {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1533 return false;
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
1534 }
12778
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1535
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1536 public long getCurrentValue() {
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1537 return 0L;
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1538 }
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1539
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1540 public TimeUnit getTimeUnit() {
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1541 return null;
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
1542 }
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
1543 };
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1544 }