1 /* |
1 /* |
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
26 |
26 |
27 import java.io.IOException; |
27 import java.io.IOException; |
28 import java.nio.file.Files; |
28 import java.nio.file.Files; |
29 import java.nio.file.Path; |
29 import java.nio.file.Path; |
30 import java.nio.file.Paths; |
30 import java.nio.file.Paths; |
|
31 import java.text.SimpleDateFormat; |
|
32 import java.util.Date; |
31 |
33 |
32 import jdk.internal.vm.compiler.collections.EconomicMap; |
34 import jdk.internal.vm.compiler.collections.EconomicMap; |
33 import org.graalvm.compiler.options.EnumOptionKey; |
35 import org.graalvm.compiler.options.EnumOptionKey; |
34 import org.graalvm.compiler.options.Option; |
36 import org.graalvm.compiler.options.Option; |
35 import org.graalvm.compiler.options.OptionKey; |
37 import org.graalvm.compiler.options.OptionKey; |
|
38 import org.graalvm.compiler.options.OptionStability; |
36 import org.graalvm.compiler.options.OptionType; |
39 import org.graalvm.compiler.options.OptionType; |
37 import org.graalvm.compiler.options.OptionValues; |
40 import org.graalvm.compiler.options.OptionValues; |
38 import org.graalvm.compiler.serviceprovider.GraalServices; |
41 import org.graalvm.compiler.serviceprovider.GraalServices; |
39 |
42 |
40 /** |
43 /** |
90 public static final OptionKey<String> Time = new OptionKey<>(null); |
93 public static final OptionKey<String> Time = new OptionKey<>(null); |
91 |
94 |
92 @Option(help = "Pattern for specifying scopes in which logging is enabled. " + |
95 @Option(help = "Pattern for specifying scopes in which logging is enabled. " + |
93 "See the Dump option for the pattern syntax.", type = OptionType.Debug) |
96 "See the Dump option for the pattern syntax.", type = OptionType.Debug) |
94 public static final OptionKey<String> Verify = new OptionKey<>(null); |
97 public static final OptionKey<String> Verify = new OptionKey<>(null); |
95 @Option(help = "file:doc-files/DumpHelp.txt", type = OptionType.Debug) |
98 @Option(help = "file:doc-files/DumpHelp.txt", type = OptionType.Debug, stability = OptionStability.STABLE) |
96 public static final OptionKey<String> Dump = new OptionKey<>(null); |
99 public static final OptionKey<String> Dump = new OptionKey<>(null); |
97 @Option(help = "Pattern for specifying scopes in which logging is enabled. " + |
100 @Option(help = "Pattern for specifying scopes in which logging is enabled. " + |
98 "See the Dump option for the pattern syntax.", type = OptionType.Debug) |
101 "See the Dump option for the pattern syntax.", type = OptionType.Debug) |
99 public static final OptionKey<String> Log = new OptionKey<>(null); |
102 public static final OptionKey<String> Log = new OptionKey<>(null); |
100 @Option(help = "file:doc-files/MethodFilterHelp.txt") |
103 @Option(help = "file:doc-files/MethodFilterHelp.txt", stability = OptionStability.STABLE) |
101 public static final OptionKey<String> MethodFilter = new OptionKey<>(null); |
104 public static final OptionKey<String> MethodFilter = new OptionKey<>(null); |
102 @Option(help = "Only check MethodFilter against the root method in the context if true, otherwise check all methods", type = OptionType.Debug) |
105 @Option(help = "Only check MethodFilter against the root method in the context if true, otherwise check all methods", type = OptionType.Debug) |
103 public static final OptionKey<Boolean> MethodFilterRootOnly = new OptionKey<>(false); |
106 public static final OptionKey<Boolean> MethodFilterRootOnly = new OptionKey<>(false); |
104 @Option(help = "Dump a before and after graph if the named phase changes the graph.%n" + |
107 @Option(help = "Dump a before and after graph if the named phase changes the graph.%n" + |
105 "The argument is substring matched against the simple name of the phase class", type = OptionType.Debug) |
108 "The argument is substring matched against the simple name of the phase class", type = OptionType.Debug) |
117 |
120 |
118 @Option(help = "Only report metrics for threads whose name matches the regular expression.", type = OptionType.Debug) |
121 @Option(help = "Only report metrics for threads whose name matches the regular expression.", type = OptionType.Debug) |
119 public static final OptionKey<String> MetricsThreadFilter = new OptionKey<>(null); |
122 public static final OptionKey<String> MetricsThreadFilter = new OptionKey<>(null); |
120 @Option(help = "Enable debug output for stub code generation and snippet preparation.", type = OptionType.Debug) |
123 @Option(help = "Enable debug output for stub code generation and snippet preparation.", type = OptionType.Debug) |
121 public static final OptionKey<Boolean> DebugStubsAndSnippets = new OptionKey<>(false); |
124 public static final OptionKey<Boolean> DebugStubsAndSnippets = new OptionKey<>(false); |
122 @Option(help = "Send Graal compiler IR to dump handlers on error.", type = OptionType.Debug) |
125 @Option(help = "Send compiler IR to dump handlers on error.", type = OptionType.Debug) |
123 public static final OptionKey<Boolean> DumpOnError = new OptionKey<>(false); |
126 public static final OptionKey<Boolean> DumpOnError = new OptionKey<>(false); |
124 @Option(help = "Intercept also bailout exceptions", type = OptionType.Debug) |
127 @Option(help = "Intercept also bailout exceptions", type = OptionType.Debug) |
125 public static final OptionKey<Boolean> InterceptBailout = new OptionKey<>(false); |
128 public static final OptionKey<Boolean> InterceptBailout = new OptionKey<>(false); |
126 @Option(help = "Enable more verbose log output when available", type = OptionType.Debug) |
129 @Option(help = "Enable more verbose log output when available", type = OptionType.Debug) |
127 public static final OptionKey<Boolean> LogVerbose = new OptionKey<>(false); |
130 public static final OptionKey<Boolean> LogVerbose = new OptionKey<>(false); |
201 public static Path getDumpDirectory(OptionValues options) throws IOException { |
204 public static Path getDumpDirectory(OptionValues options) throws IOException { |
202 Path dumpDir; |
205 Path dumpDir; |
203 if (DumpPath.hasBeenSet(options)) { |
206 if (DumpPath.hasBeenSet(options)) { |
204 dumpDir = Paths.get(DumpPath.getValue(options)); |
207 dumpDir = Paths.get(DumpPath.getValue(options)); |
205 } else { |
208 } else { |
206 dumpDir = Paths.get(DumpPath.getValue(options), String.valueOf(GraalServices.getGlobalTimeStamp())); |
209 Date date = new Date(GraalServices.getGlobalTimeStamp()); |
|
210 SimpleDateFormat formatter = new SimpleDateFormat( "YYYY.MM.dd.HH.mm.ss.SSS" ); |
|
211 dumpDir = Paths.get(DumpPath.getValue(options), formatter.format(date)); |
207 } |
212 } |
208 dumpDir = dumpDir.toAbsolutePath(); |
213 dumpDir = dumpDir.toAbsolutePath(); |
209 if (!Files.exists(dumpDir)) { |
214 if (!Files.exists(dumpDir)) { |
210 synchronized (DebugConfigImpl.class) { |
215 synchronized (DebugConfigImpl.class) { |
211 if (!Files.exists(dumpDir)) { |
216 if (!Files.exists(dumpDir)) { |