Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java @ 11598:ecbeceacca98
changed default for -G:DebugValueSummary to "Name"
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 10 Sep 2013 22:05:17 +0200 |
parents | 4cf51b630049 |
children | 0d3b767e5356 |
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 */ |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler; |
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 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.code.*; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.debug.*; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.graph.*; |
9620
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
32 import com.oracle.graal.nodes.*; |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.util.*; |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9620
diff
changeset
|
34 import com.oracle.graal.options.*; |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 public class GraalDebugConfig implements DebugConfig { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9620
diff
changeset
|
38 // @formatter:off |
11489
0cb481a62384
added help text to debug scope related options
Doug Simon <doug.simon@oracle.com>
parents:
11369
diff
changeset
|
39 @Option(help = "Pattern for scope(s) to in which dumping is enabled (see DebugFilter and Debug.dump)") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
40 public static final OptionValue<String> Dump = new OptionValue<>(null); |
11489
0cb481a62384
added help text to debug scope related options
Doug Simon <doug.simon@oracle.com>
parents:
11369
diff
changeset
|
41 @Option(help = "Pattern for scope(s) to in which metering is enabled (see DebugFilter and Debug.metric)") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
42 public static final OptionValue<String> Meter = new OptionValue<>(null); |
11489
0cb481a62384
added help text to debug scope related options
Doug Simon <doug.simon@oracle.com>
parents:
11369
diff
changeset
|
43 @Option(help = "Pattern for scope(s) to in which timing is enabled (see DebugFilter and Debug.timer)") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
44 public static final OptionValue<String> Time = new OptionValue<>(null); |
11489
0cb481a62384
added help text to debug scope related options
Doug Simon <doug.simon@oracle.com>
parents:
11369
diff
changeset
|
45 @Option(help = "Pattern for scope(s) to in which logging is enabled (see DebugFilter and Debug.log)") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
46 public static final OptionValue<String> Log = new OptionValue<>(null); |
11489
0cb481a62384
added help text to debug scope related options
Doug Simon <doug.simon@oracle.com>
parents:
11369
diff
changeset
|
47 @Option(help = "Pattern for filtering debug scope output based on method context (see MethodFilter)") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
48 public static final OptionValue<String> MethodFilter = new OptionValue<>(null); |
11366
d335c16d2fe7
replaced PerThreadDebugValues, SummarizeDebugValues and SummarisePerPhase options with DebugValueSummary option
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
49 @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
|
50 "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
|
51 "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
|
52 "Complete - aggregate by qualified name%n" + |
11369
03fb03763b63
small fixes for handling of -G:DebugValueSummary option
Doug Simon <doug.simon@oracle.com>
parents:
11366
diff
changeset
|
53 "Thread - aggregate by qualified name and thread") |
11598
ecbeceacca98
changed default for -G:DebugValueSummary to "Name"
Doug Simon <doug.simon@oracle.com>
parents:
11564
diff
changeset
|
54 public static final OptionValue<String> DebugValueSummary = new OptionValue<>("Name"); |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9620
diff
changeset
|
55 @Option(help = "Send Graal IR to dump handlers on error") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
56 public static final OptionValue<Boolean> DumpOnError = new OptionValue<>(false); |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
57 @Option(help = "Enable expensive assertions") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
58 public static final OptionValue<Boolean> DetailedAsserts = new StableOptionValue<Boolean>() { |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
59 @Override |
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
60 protected Boolean initialValue() { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9855
diff
changeset
|
61 boolean enabled = false; |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
62 // turn detailed assertions on when the general assertions are on (misusing the assert keyword for this) |
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
63 assert (enabled = true) == true; |
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
64 return enabled; |
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
65 } |
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
66 }; |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9620
diff
changeset
|
67 // @formatter:on |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9620
diff
changeset
|
68 |
11563
9d9c944f2940
removed side effect of -XX:+CITime on -G:Meter and -G:Time (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
11561
diff
changeset
|
69 public static boolean areDebugScopePatternsEnabled() { |
11564
4cf51b630049
re-enabled -G:+DumpOnError
Doug Simon <doug.simon@oracle.com>
parents:
11563
diff
changeset
|
70 return DumpOnError.getValue() || Dump.getValue() != null || Meter.getValue() != null || Time.getValue() != null || Log.getValue() != null; |
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
|
71 } |
e1309fc4d17f
ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents:
11504
diff
changeset
|
72 |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 private final DebugFilter logFilter; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 private final DebugFilter meterFilter; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 private final DebugFilter timerFilter; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 private final DebugFilter dumpFilter; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 private final MethodFilter[] methodFilter; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 private final List<DebugDumpHandler> dumpHandlers; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 private final PrintStream output; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 private final Set<Object> extraFilters = new HashSet<>(); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 public GraalDebugConfig(String logFilter, String meterFilter, String timerFilter, String dumpFilter, String methodFilter, PrintStream output, List<DebugDumpHandler> dumpHandlers) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 this.logFilter = DebugFilter.parse(logFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 this.meterFilter = DebugFilter.parse(meterFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 this.timerFilter = DebugFilter.parse(timerFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 this.dumpFilter = DebugFilter.parse(dumpFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 if (methodFilter == null || methodFilter.isEmpty()) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 this.methodFilter = null; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 } else { |
11491
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11489
diff
changeset
|
90 this.methodFilter = com.oracle.graal.compiler.MethodFilter.parse(methodFilter); |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 // 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
|
94 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
|
95 // TTY.println(Thread.currentThread().getName() + ": " + toString()); |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 this.dumpHandlers = dumpHandlers; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 this.output = output; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 public boolean isLogEnabled() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 return isEnabled(logFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 public boolean isMeterEnabled() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 return isEnabled(meterFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 public boolean isDumpEnabled() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 return isEnabled(dumpFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 public boolean isTimeEnabled() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 return isEnabled(timerFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 public PrintStream output() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 return output; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 private boolean isEnabled(DebugFilter filter) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 return checkDebugFilter(Debug.currentScope(), filter) && checkMethodFilter(); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 } |
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 private static boolean checkDebugFilter(String currentScope, DebugFilter filter) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 return filter != null && filter.matches(currentScope); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 |
9620
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
129 /** |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
130 * Extracts a {@link JavaMethod} from an opaque debug context. |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
131 * |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
132 * @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
|
133 */ |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
134 public static JavaMethod asJavaMethod(Object context) { |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
135 if (context instanceof JavaMethod) { |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
136 return (JavaMethod) context; |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
137 } |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
138 if (context instanceof StructuredGraph) { |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
139 ResolvedJavaMethod method = ((StructuredGraph) context).method(); |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
140 if (method != null) { |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
141 return method; |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
142 } |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
143 } |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
144 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
|
145 } |
0eda2b7df748
fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents:
7561
diff
changeset
|
146 |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 private boolean checkMethodFilter() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 if (methodFilter == null && extraFilters.isEmpty()) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 return true; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 } else { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 for (Object o : Debug.context()) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 if (extraFilters.contains(o)) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 return true; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 } 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
|
155 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
|
156 if (method != null) { |
11491
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11489
diff
changeset
|
157 if (com.oracle.graal.compiler.MethodFilter.matches(methodFilter, method)) { |
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11489
diff
changeset
|
158 return true; |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 return false; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 @Override |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 public String toString() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 StringBuilder sb = new StringBuilder(); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 sb.append("Debug config:"); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 add(sb, "Log", logFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 add(sb, "Meter", meterFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 add(sb, "Time", timerFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 add(sb, "Dump", dumpFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 add(sb, "MethodFilter", methodFilter); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 return sb.toString(); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 private static void add(StringBuilder sb, String name, Object filter) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 if (filter != null) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 sb.append(' '); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 sb.append(name); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 sb.append('='); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 if (filter instanceof Object[]) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 sb.append(Arrays.toString((Object[]) filter)); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 } else { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 sb.append(String.valueOf(filter)); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 } |
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 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 @Override |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 public RuntimeException interceptException(Throwable e) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 if (e instanceof BailoutException) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 return null; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 Debug.setConfig(Debug.fixedConfig(true, true, false, false, dumpHandlers, output)); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 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
|
199 for (Object o : Debug.context()) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 if (o instanceof Graph) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 Debug.log("Context obj %s", o); |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9620
diff
changeset
|
202 if (DumpOnError.getValue()) { |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 Debug.dump(o, "Exception graph"); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 } else { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 Debug.log("Use -G:+DumpOnError to enable dumping of graphs on this error"); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 } else if (o instanceof Node) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 String location = GraphUtil.approxSourceLocation((Node) o); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 if (location != null) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 Debug.log("Context obj %s (approx. location: %s)", o, location); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 } else { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 Debug.log("Context obj %s", o); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 } else { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 Debug.log("Context obj %s", o); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 return null; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 @Override |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 public Collection<DebugDumpHandler> dumpHandlers() { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 return dumpHandlers; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 @Override |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 public void addToContext(Object o) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 extraFilters.add(o); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 } |
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 @Override |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 public void removeFromContext(Object o) { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 extraFilters.remove(o); |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
234 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
235 } |