Skip to content

Commit fef8f2d

Browse files
committedJan 15, 2022
8279797: JFR: Show .jfc options in JFR.start help
Reviewed-by: mgronlun
1 parent 9a18190 commit fef8f2d

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed
 

‎src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java

+28-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@
4242
import jdk.jfr.FlightRecorder;
4343
import jdk.jfr.Recording;
4444
import jdk.jfr.internal.JVM;
45+
import jdk.jfr.internal.LogLevel;
46+
import jdk.jfr.internal.LogTag;
47+
import jdk.jfr.internal.Logger;
4548
import jdk.jfr.internal.OldObjectSample;
4649
import jdk.jfr.internal.PlatformRecording;
4750
import jdk.jfr.internal.PrivateAccess;
4851
import jdk.jfr.internal.SecuritySupport.SafePath;
52+
import jdk.jfr.internal.SecuritySupport;
4953
import jdk.jfr.internal.Type;
5054
import jdk.jfr.internal.jfc.JFC;
5155
import jdk.jfr.internal.jfc.model.JFCModel;
@@ -364,7 +368,7 @@ Virtual Machine (JVM) shuts down. If set to 'true' and no value
364368
Turn on this flag only when you have an application that you
365369
suspect has a memory leak. If the settings parameter is set to
366370
'profile', then the information collected includes the stack
367-
trace from where the potential leaking object wasallocated.
371+
trace from where the potential leaking object was allocated.
368372
(BOOLEAN, false)
369373
370374
settings (Optional) Name of the settings file that identifies which events
@@ -394,7 +398,7 @@ Virtual Machine (JVM) shuts down. If set to 'true' and no value
394398
take precedence. The whitespace character can be omitted for timespan values,
395399
i.e. 20s. For more information about the settings syntax, see Javadoc of the
396400
jdk.jfr package.
397-
401+
%s
398402
Options must be specified using the <key> or <key>=<value> syntax.
399403
400404
Example usage:
@@ -414,7 +418,28 @@ Virtual Machine (JVM) shuts down. If set to 'true' and no value
414418
415419
Note, if the default event settings are modified, overhead may exceed 1%%.
416420
417-
""".formatted(exampleDirectory()).lines().toArray(String[]::new);
421+
""".formatted(jfcOptions(), exampleDirectory()).lines().toArray(String[]::new);
422+
}
423+
424+
private static String jfcOptions() {
425+
try {
426+
StringBuilder sb = new StringBuilder();
427+
for (SafePath s : SecuritySupport.getPredefinedJFCFiles()) {
428+
String name = JFC.nameFromPath(s.toPath());
429+
JFCModel model = JFCModel.create(s, l -> {});
430+
sb.append('\n');
431+
sb.append("Options for ").append(name).append(":\n");
432+
sb.append('\n');
433+
for (XmlInput input : model.getInputs()) {
434+
sb.append(" ").append(input.getOptionSyntax()).append('\n');
435+
sb.append('\n');
436+
}
437+
}
438+
return sb.toString();
439+
} catch (IOException | ParseException e) {
440+
Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Could not list .jfc options for JFR.start. " + e.getMessage());
441+
return "";
442+
}
418443
}
419444

420445
@Override

0 commit comments

Comments
 (0)
Please sign in to comment.