Skip to content

Commit 24fa958

Browse files
committed
[GR-49221] Add support for --enable-monitoring=threaddump.
PullRequest: graal/15796
2 parents 42df93a + 39bbcd8 commit 24fa958

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

espresso/mx.espresso/mx_espresso.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ def _espresso_gate_runner(args, tasks):
200200
'-R:+EnableSignalHandling',
201201
'-R:+InstallSegfaultHandler',
202202
'--features=com.oracle.truffle.espresso.ref.FinalizationFeature',
203+
'--enable-monitoring=threaddump',
203204
] + mx_sdk_vm_impl.svm_experimental_options([
204205
'-H:-JNIExportSymbols',
205-
'-H:+DumpThreadStacksOnSignal',
206206
]),
207207
)
208208

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This changelog summarizes major changes to GraalVM Native Image.
77
* (GR-48343) Red Hat added support for the JFR events AllocationRequiringGC and SystemGC.
88
* (GR-48612) Enable `--strict-image-heap` by default. The option is now deprecated and can be removed from your argument list. A blog post with more information will follow shortly.
99
* (GR-48354) Remove native-image-agent legacy `build`-option
10+
* (GR-49221) Support for thread dumps can now be enabled with `--enable-monitoring=threaddump`. The option `-H:±DumpThreadStacksOnSignal` is deprecated and marked for removal.
1011

1112
## GraalVM for JDK 21 (Internal Version 23.1.0)
1213
* (GR-35746) Lower the default aligned chunk size from 1 MB to 512 KB for the serial and epsilon GCs, reducing memory usage and image size in many cases.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpThreadStacksOnSignalFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class DumpThreadStacksOnSignalFeature implements InternalFeature {
4848

4949
@Override
5050
public boolean isInConfiguration(IsInConfigurationAccess access) {
51-
return VMInspectionOptions.DumpThreadStacksOnSignal.getValue();
51+
return VMInspectionOptions.hasThreadDumpSupport();
5252
}
5353

5454
@Override

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspectionOptions.java

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,20 @@ public final class VMInspectionOptions {
5656
private static final String MONITORING_JVMSTAT_NAME = "jvmstat";
5757
private static final String MONITORING_JMXCLIENT_NAME = "jmxclient";
5858
private static final String MONITORING_JMXSERVER_NAME = "jmxserver";
59-
private static final String MONITORING_ALLOWED_VALUES = "'" + MONITORING_HEAPDUMP_NAME + "', '" + MONITORING_JFR_NAME + "', '" + MONITORING_JVMSTAT_NAME + "', '" + MONITORING_JMXSERVER_NAME +
60-
"' (experimental), '" + MONITORING_JMXCLIENT_NAME + "' (experimental), or '" + MONITORING_ALL_NAME +
59+
private static final String MONITORING_THREADDUMP_NAME = "threaddump";
60+
61+
private static final List<String> MONITORING_ALL_VALUES = List.of(MONITORING_HEAPDUMP_NAME, MONITORING_JFR_NAME, MONITORING_JVMSTAT_NAME, MONITORING_JMXCLIENT_NAME, MONITORING_JMXSERVER_NAME,
62+
MONITORING_THREADDUMP_NAME, MONITORING_ALL_NAME, MONITORING_DEFAULT_NAME);
63+
private static final String MONITORING_ALLOWED_VALUES_TEXT = "'" + MONITORING_HEAPDUMP_NAME + "', '" + MONITORING_JFR_NAME + "', '" + MONITORING_JVMSTAT_NAME + "', '" + MONITORING_JMXSERVER_NAME +
64+
"' (experimental), '" + MONITORING_JMXCLIENT_NAME + "' (experimental), '" + MONITORING_THREADDUMP_NAME + "', or '" + MONITORING_ALL_NAME +
6165
"' (deprecated behavior: defaults to '" + MONITORING_ALL_NAME + "' if no argument is provided)";
6266

67+
static {
68+
assert MONITORING_ALL_VALUES.stream().allMatch(v -> MONITORING_DEFAULT_NAME.equals(v) || MONITORING_ALLOWED_VALUES_TEXT.contains(v)) : "A value is missing in the user-facing help text";
69+
}
70+
6371
@APIOption(name = ENABLE_MONITORING_OPTION, defaultValue = MONITORING_DEFAULT_NAME) //
64-
@Option(help = "Enable monitoring features that allow the VM to be inspected at run time. Comma-separated list can contain " + MONITORING_ALLOWED_VALUES + ". " +
72+
@Option(help = "Enable monitoring features that allow the VM to be inspected at run time. Comma-separated list can contain " + MONITORING_ALLOWED_VALUES_TEXT + ". " +
6573
"For example: '--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_HEAPDUMP_NAME + "," + MONITORING_JFR_NAME + "'.", type = OptionType.User) //
6674
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> EnableMonitoringFeatures = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter(),
6775
VMInspectionOptions::validateEnableMonitoringFeatures);
@@ -75,11 +83,10 @@ public static void validateEnableMonitoringFeatures(@SuppressWarnings("unused")
7583
getDefaultMonitoringCommandArgument(),
7684
SubstrateOptionsParser.commandArgument(EnableMonitoringFeatures, String.join(",", List.of(MONITORING_HEAPDUMP_NAME, MONITORING_JFR_NAME))));
7785
}
78-
enabledFeatures.removeAll(List.of(MONITORING_HEAPDUMP_NAME, MONITORING_JFR_NAME, MONITORING_JVMSTAT_NAME, MONITORING_JMXCLIENT_NAME, MONITORING_JMXSERVER_NAME, MONITORING_ALL_NAME,
79-
MONITORING_DEFAULT_NAME));
86+
enabledFeatures.removeAll(MONITORING_ALL_VALUES);
8087
if (!enabledFeatures.isEmpty()) {
8188
throw UserError.abort("The '%s' option contains invalid value(s): %s. It can only contain %s.", getDefaultMonitoringCommandArgument(), String.join(", ", enabledFeatures),
82-
MONITORING_ALLOWED_VALUES);
89+
MONITORING_ALLOWED_VALUES_TEXT);
8390
}
8491
}
8592

@@ -89,7 +96,7 @@ private static String getDefaultMonitoringCommandArgument() {
8996
}
9097

9198
@Fold
92-
public static String getHeapdumpsCommandArgument() {
99+
public static String getHeapDumpCommandArgument() {
93100
return SubstrateOptionsParser.commandArgument(EnableMonitoringFeatures, MONITORING_HEAPDUMP_NAME);
94101
}
95102

@@ -121,7 +128,7 @@ public static boolean dumpImageHeap() {
121128
return true;
122129
} else {
123130
System.out.println("Unable to dump heap. Heap dumping is only supported on Linux and MacOS for native executables built with '" +
124-
VMInspectionOptions.getHeapdumpsCommandArgument() + "'.");
131+
VMInspectionOptions.getHeapDumpCommandArgument() + "'.");
125132
return false;
126133
}
127134
}
@@ -151,15 +158,17 @@ public static boolean hasJmxClientSupport() {
151158
return hasAllOrKeywordMonitoringSupport(MONITORING_JMXCLIENT_NAME) && !Platform.includedIn(WINDOWS.class);
152159
}
153160

161+
@Fold
162+
public static boolean hasThreadDumpSupport() {
163+
return hasAllOrKeywordMonitoringSupport(MONITORING_THREADDUMP_NAME) || DeprecatedOptions.DumpThreadStacksOnSignal.getValue();
164+
}
165+
154166
@Option(help = "Dumps all runtime compiled methods on SIGUSR2.", type = OptionType.User) //
155167
public static final HostedOptionKey<Boolean> DumpRuntimeCompilationOnSignal = new HostedOptionKey<>(false);
156168

157-
@Option(help = "Dumps all thread stacktraces on SIGQUIT/SIGBREAK.", type = OptionType.User) //
158-
public static final HostedOptionKey<Boolean> DumpThreadStacksOnSignal = new HostedOptionKey<>(false);
159-
160169
static class DeprecatedOptions {
161170
@Option(help = "Enables features that allow the VM to be inspected during run time.", type = OptionType.User, //
162-
deprecated = true, deprecationMessage = "Please use --" + ENABLE_MONITORING_OPTION) //
171+
deprecated = true, deprecationMessage = "Please use '--" + ENABLE_MONITORING_OPTION + "'") //
163172
static final HostedOptionKey<Boolean> AllowVMInspection = new HostedOptionKey<>(false) {
164173
@Override
165174
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
@@ -168,6 +177,10 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
168177
super.onValueUpdate(values, oldValue, newValue);
169178
}
170179
};
180+
181+
@Option(help = "Dumps all thread stacktraces on SIGQUIT/SIGBREAK.", type = OptionType.User, //
182+
deprecated = true, deprecationMessage = "Please use '--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_THREADDUMP_NAME + "'") //
183+
public static final HostedOptionKey<Boolean> DumpThreadStacksOnSignal = new HostedOptionKey<>(false);
171184
}
172185

173186
private VMInspectionOptions() {

0 commit comments

Comments
 (0)