annotate graal/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/JVMCIDebugConfig.java @ 21780:3d15183f3c93

Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Wed, 03 Jun 2015 15:47:54 +0200
parents graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java@a9f347ae6f5f
children 5b9adb645217
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
23 package com.oracle.jvmci.debug;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import java.io.*;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import java.util.*;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27
21592
a9f347ae6f5f GraalDebugConfig: dump LSRA intervals with -G:+DumpOnError.
Josef Eisl <josef.eisl@jku.at>
parents: 21556
diff changeset
28 import com.oracle.jvmci.code.*;
a9f347ae6f5f GraalDebugConfig: dump LSRA intervals with -G:+DumpOnError.
Josef Eisl <josef.eisl@jku.at>
parents: 21556
diff changeset
29 import com.oracle.jvmci.meta.*;
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: 21531
diff changeset
30 import com.oracle.jvmci.options.*;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
32 public class JVMCIDebugConfig implements DebugConfig {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
33 @SuppressWarnings("all")
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
34 private static boolean assertionsEnabled() {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
35 boolean assertionsEnabled = false;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
36 assert assertionsEnabled = true;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
37 return assertionsEnabled;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
38 }
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
40 // @formatter:off
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17303
diff changeset
41 @Option(help = "Pattern for scope(s) in which dumping is enabled (see DebugFilter and Debug.dump)", type = OptionType.Debug)
9914
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
42 public static final OptionValue<String> Dump = new OptionValue<>(null);
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: 19716
diff changeset
43 @Option(help = "Pattern for scope(s) in which metering is enabled (see DebugFilter and Debug.metric). " +
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: 19716
diff changeset
44 "An empty value enables all metrics unconditionally.", type = OptionType.Debug)
9914
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
45 public static final OptionValue<String> Meter = new OptionValue<>(null);
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: 19716
diff changeset
46 @Option(help = "Pattern for scope(s) in which verification is enabled (see DebugFilter and Debug.verify).", type = OptionType.Debug)
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
47 public static final OptionValue<String> Verify = new OptionValue<String>() {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
48 @Override
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
49 protected String defaultValue() {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
50 return assertionsEnabled() ? "" : null;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
51 }
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
52 };
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: 19716
diff changeset
53 @Option(help = "Pattern for scope(s) in which memory use tracking is enabled (see DebugFilter and Debug.metric). " +
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: 19716
diff changeset
54 "An empty value enables all memory use trackers unconditionally.", type = OptionType.Debug)
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15453
diff changeset
55 public static final OptionValue<String> TrackMemUse = new OptionValue<>(null);
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: 19716
diff changeset
56 @Option(help = "Pattern for scope(s) in which timing is enabled (see DebugFilter and Debug.timer). " +
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: 19716
diff changeset
57 "An empty value enables all timers unconditionally.", type = OptionType.Debug)
9914
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
58 public static final OptionValue<String> Time = new OptionValue<>(null);
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17303
diff changeset
59 @Option(help = "Pattern for scope(s) in which logging is enabled (see DebugFilter and Debug.log)", type = OptionType.Debug)
9914
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
60 public static final OptionValue<String> Log = new OptionValue<>(null);
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17303
diff changeset
61 @Option(help = "Pattern for filtering debug scope output based on method context (see MethodFilter)", type = OptionType.Debug)
9914
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
62 public static final OptionValue<String> MethodFilter = new OptionValue<>(null);
18903
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
63 @Option(help = "Only check MethodFilter against the root method in the context if true, otherwise check all methods", type = OptionType.Debug)
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
64 public static final OptionValue<Boolean> MethodFilterRootOnly = new OptionValue<>(false);
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
65
11366
d335c16d2fe7 replaced PerThreadDebugValues, SummarizeDebugValues and SummarisePerPhase options with DebugValueSummary option
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
66 @Option(help = "How to print metric and timing values:%n" +
d335c16d2fe7 replaced PerThreadDebugValues, SummarizeDebugValues and SummarisePerPhase options with DebugValueSummary option
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
67 "Name - aggregate by unqualified name%n" +
11369
03fb03763b63 small fixes for handling of -G:DebugValueSummary option
Doug Simon <doug.simon@oracle.com>
parents: 11366
diff changeset
68 "Partial - aggregate by partially qualified name (e.g., A.B.C.D.Counter and X.Y.Z.D.Counter will be merged to D.Counter)%n" +
11366
d335c16d2fe7 replaced PerThreadDebugValues, SummarizeDebugValues and SummarisePerPhase options with DebugValueSummary option
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
69 "Complete - aggregate by qualified name%n" +
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17303
diff changeset
70 "Thread - aggregate by qualified name and thread", type = OptionType.Debug)
11598
ecbeceacca98 changed default for -G:DebugValueSummary to "Name"
Doug Simon <doug.simon@oracle.com>
parents: 11564
diff changeset
71 public static final OptionValue<String> DebugValueSummary = new OptionValue<>("Name");
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17303
diff changeset
72 @Option(help = "Omit reporting 0-value metrics", type = OptionType.Debug)
19716
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19239
diff changeset
73 public static final OptionValue<Boolean> SuppressZeroDebugValues = new OptionValue<>(true);
20030
33b1be0d91fc Add option to filter DebugValueSummary by map name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
74 @Option(help = "Only report debug values for maps which match the regular expression.", type = OptionType.Debug)
33b1be0d91fc Add option to filter DebugValueSummary by map name
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20016
diff changeset
75 public static final OptionValue<String> DebugValueThreadFilter = new OptionValue<>(null);
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17303
diff changeset
76 @Option(help = "Send Graal IR to dump handlers on error", type = OptionType.Debug)
9914
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
77 public static final OptionValue<Boolean> DumpOnError = new OptionValue<>(false);
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19165
diff changeset
78 @Option(help = "Intercept also bailout exceptions", type = OptionType.Debug)
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19165
diff changeset
79 public static final OptionValue<Boolean> InterceptBailout = new OptionValue<>(false);
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17303
diff changeset
80 @Option(help = "Enable more verbose log output when available", type = OptionType.Debug)
15453
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13516
diff changeset
81 public static final OptionValue<Boolean> LogVerbose = new OptionValue<>(false);
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
82 // @formatter:on
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
83
21531
01319414783b added extension point for post Option parsing actions and used it to remove another JVMCI to non-JVMCI dependency (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21140
diff changeset
84 static boolean isNotEmpty(OptionValue<String> option) {
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: 19716
diff changeset
85 return option.getValue() != null && !option.getValue().isEmpty();
12518
0916da3633ac only show metric and timer values if -G:Meter or -G:Time is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12506
diff changeset
86 }
0916da3633ac only show metric and timer values if -G:Meter or -G:Time is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12506
diff changeset
87
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
88 public static boolean areDebugScopePatternsEnabled() {
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: 19716
diff changeset
89 return DumpOnError.getValue() || Dump.getValue() != null || Log.getValue() != null || areScopedMetricsOrTimersEnabled();
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: 19716
diff changeset
90 }
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: 19716
diff changeset
91
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: 19716
diff changeset
92 /**
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: 19716
diff changeset
93 * Determines if any of {@link #Meter}, {@link #Time} or {@link #TrackMemUse} has a non-null,
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: 19716
diff changeset
94 * non-empty value.
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: 19716
diff changeset
95 */
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: 19716
diff changeset
96 public static boolean areScopedMetricsOrTimersEnabled() {
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: 19716
diff changeset
97 return isNotEmpty(Meter) || isNotEmpty(Time) || isNotEmpty(TrackMemUse);
11561
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11504
diff changeset
98 }
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11504
diff changeset
99
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 private final DebugFilter logFilter;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 private final DebugFilter meterFilter;
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15453
diff changeset
102 private final DebugFilter trackMemUseFilter;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 private final DebugFilter timerFilter;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 private final DebugFilter dumpFilter;
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
105 private final DebugFilter verifyFilter;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 private final MethodFilter[] methodFilter;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 private final List<DebugDumpHandler> dumpHandlers;
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
108 private final List<DebugVerifyHandler> verifyHandlers;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 private final PrintStream output;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 private final Set<Object> extraFilters = new HashSet<>();
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
112 public JVMCIDebugConfig(String logFilter, String meterFilter, String trackMemUseFilter, String timerFilter, String dumpFilter, String verifyFilter, String methodFilter, PrintStream output,
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
113 List<DebugDumpHandler> dumpHandlers, List<DebugVerifyHandler> verifyHandlers) {
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 this.logFilter = DebugFilter.parse(logFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 this.meterFilter = DebugFilter.parse(meterFilter);
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15453
diff changeset
116 this.trackMemUseFilter = DebugFilter.parse(trackMemUseFilter);
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 this.timerFilter = DebugFilter.parse(timerFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 this.dumpFilter = DebugFilter.parse(dumpFilter);
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
119 this.verifyFilter = DebugFilter.parse(verifyFilter);
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 if (methodFilter == null || methodFilter.isEmpty()) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 this.methodFilter = null;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 } else {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
123 this.methodFilter = com.oracle.jvmci.debug.MethodFilter.parse(methodFilter);
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 // Report the filters that have been configured so the user can verify it's what they expect
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 if (logFilter != null || meterFilter != null || timerFilter != null || dumpFilter != null || methodFilter != null) {
7561
0fdea35766a8 disabled verbose reporting of non-null options for -G:Dump, -G:Meter, -G:Log, -G:Timer as it means these options cannot be used when running the 'mx bench' command
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
128 // TTY.println(Thread.currentThread().getName() + ": " + toString());
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 this.dumpHandlers = dumpHandlers;
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
131 this.verifyHandlers = verifyHandlers;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 this.output = output;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
135 public int getLogLevel() {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
136 return getLevel(logFilter);
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138
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: 12705
diff changeset
139 public 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: 12705
diff changeset
140 return isEnabledForMethod(logFilter);
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: 12705
diff changeset
141 }
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: 12705
diff changeset
142
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 public boolean isMeterEnabled() {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 return isEnabled(meterFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146
15581
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15453
diff changeset
147 public boolean isMemUseTrackingEnabled() {
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15453
diff changeset
148 return isEnabled(trackMemUseFilter);
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15453
diff changeset
149 }
0dc0926cf0d8 added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents: 15453
diff changeset
150
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
151 public int getDumpLevel() {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
152 return getLevel(dumpFilter);
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154
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: 12705
diff changeset
155 public 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: 12705
diff changeset
156 return isEnabledForMethod(dumpFilter);
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: 12705
diff changeset
157 }
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: 12705
diff changeset
158
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
159 public boolean isVerifyEnabled() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
160 return isEnabled(verifyFilter);
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
161 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
162
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
163 public boolean isVerifyEnabledForMethod() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
164 return isEnabledForMethod(verifyFilter);
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
165 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
166
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 public boolean isTimeEnabled() {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 return isEnabled(timerFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 public PrintStream output() {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 return output;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 private boolean isEnabled(DebugFilter filter) {
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
176 return getLevel(filter) > 0;
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
177 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
178
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
179 private int getLevel(DebugFilter filter) {
21140
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20030
diff changeset
180 int level;
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20030
diff changeset
181 if (filter == null) {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20030
diff changeset
182 level = 0;
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20030
diff changeset
183 } else {
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20030
diff changeset
184 level = filter.matchLevel(Debug.currentScope());
7d2f6dd603b0 Make DebugScope lazier and generally reduce overhead of Debug being enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20030
diff changeset
185 }
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
186 if (level > 0 && !checkMethodFilter()) {
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
187 level = 0;
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
188 }
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
189 return level;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191
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: 12705
diff changeset
192 private boolean isEnabledForMethod(DebugFilter filter) {
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: 12705
diff changeset
193 return filter != null && checkMethodFilter();
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: 12705
diff changeset
194 }
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: 12705
diff changeset
195
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
196 /**
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
197 * Extracts a {@link JavaMethod} from an opaque debug context.
15453
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13516
diff changeset
198 *
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
199 * @return the {@link JavaMethod} represented by {@code context} or null
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
200 */
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
201 public static JavaMethod asJavaMethod(Object context) {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
202 if (context instanceof JavaMethodContex) {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
203 return ((JavaMethodContex) context).asJavaMethod();
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
204 }
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
205 return null;
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
206 }
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
207
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 private boolean checkMethodFilter() {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 if (methodFilter == null && extraFilters.isEmpty()) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 return true;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 } else {
18903
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
212 JavaMethod lastMethod = null;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 for (Object o : Debug.context()) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 if (extraFilters.contains(o)) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 return true;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 } else if (methodFilter != null) {
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
217 JavaMethod method = asJavaMethod(o);
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 7561
diff changeset
218 if (method != null) {
18903
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
219 if (!MethodFilterRootOnly.getValue()) {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
220 if (com.oracle.jvmci.debug.MethodFilter.matches(methodFilter, method)) {
18903
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
221 return true;
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
222 }
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
223 } else {
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
224 /*
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
225 * The context values operate as a stack so if we want MethodFilter to
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
226 * only apply to the root method we have to check only the last method
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
227 * seen.
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
228 */
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
229 lastMethod = method;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 }
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
234 if (lastMethod != null && com.oracle.jvmci.debug.MethodFilter.matches(methodFilter, lastMethod)) {
18903
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
235 return true;
11ec0a5c5518 Add option to restrict MethodFilter to the root method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
236 }
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 return false;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 @Override
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 public String toString() {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 StringBuilder sb = new StringBuilder();
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 sb.append("Debug config:");
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 add(sb, "Log", logFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 add(sb, "Meter", meterFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 add(sb, "Time", timerFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 add(sb, "Dump", dumpFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 add(sb, "MethodFilter", methodFilter);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 return sb.toString();
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 private static void add(StringBuilder sb, String name, Object filter) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 if (filter != null) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 sb.append(' ');
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 sb.append(name);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257 sb.append('=');
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258 if (filter instanceof Object[]) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 sb.append(Arrays.toString((Object[]) filter));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 } else {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 sb.append(String.valueOf(filter));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 @Override
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 public RuntimeException interceptException(Throwable e) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19165
diff changeset
268 if (e instanceof BailoutException && !InterceptBailout.getValue()) {
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 return null;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
16463
f1d839174e71 Support for specifying log and dump levels.
Roland Schatz <roland.schatz@oracle.com>
parents: 16144
diff changeset
271 Debug.setConfig(Debug.fixedConfig(Debug.DEFAULT_LOG_LEVEL, Debug.DEFAULT_LOG_LEVEL, false, false, false, false, dumpHandlers, verifyHandlers, output));
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 Debug.log(String.format("Exception occurred in scope: %s", Debug.currentScope()));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273 for (Object o : Debug.context()) {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
274 if (DumpOnError.getValue()) {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
275 Debug.dump(o, "Exception");
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276 } else {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 Debug.log("Context obj %s", o);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 }
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21592
diff changeset
279
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 return null;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 @Override
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 public Collection<DebugDumpHandler> dumpHandlers() {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 return dumpHandlers;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 @Override
16144
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
290 public Collection<DebugVerifyHandler> verifyHandlers() {
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
291 return verifyHandlers;
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
292 }
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
293
af9f3a5f091b extended Debug API with DebugVerifyHandlers
Doug Simon <doug.simon@oracle.com>
parents: 15581
diff changeset
294 @Override
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 public void addToContext(Object o) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 extraFilters.add(o);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 @Override
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300 public void removeFromContext(Object o) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 extraFilters.remove(o);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303 }