Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8279797: JFR: Show .jfc options in JFR.start help #7073

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java
Original file line number Diff line number Diff line change
@@ -42,10 +42,14 @@
import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
import jdk.jfr.internal.JVM;
import jdk.jfr.internal.LogLevel;
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
import jdk.jfr.internal.OldObjectSample;
import jdk.jfr.internal.PlatformRecording;
import jdk.jfr.internal.PrivateAccess;
import jdk.jfr.internal.SecuritySupport.SafePath;
import jdk.jfr.internal.SecuritySupport;
import jdk.jfr.internal.Type;
import jdk.jfr.internal.jfc.JFC;
import jdk.jfr.internal.jfc.model.JFCModel;
@@ -364,7 +368,7 @@ Virtual Machine (JVM) shuts down. If set to 'true' and no value
Turn on this flag only when you have an application that you
suspect has a memory leak. If the settings parameter is set to
'profile', then the information collected includes the stack
trace from where the potential leaking object wasallocated.
trace from where the potential leaking object was allocated.
(BOOLEAN, false)
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
take precedence. The whitespace character can be omitted for timespan values,
i.e. 20s. For more information about the settings syntax, see Javadoc of the
jdk.jfr package.
%s
Options must be specified using the <key> or <key>=<value> syntax.
Example usage:
@@ -414,7 +418,28 @@ Virtual Machine (JVM) shuts down. If set to 'true' and no value
Note, if the default event settings are modified, overhead may exceed 1%%.
""".formatted(exampleDirectory()).lines().toArray(String[]::new);
""".formatted(jfcOptions(), exampleDirectory()).lines().toArray(String[]::new);
}

private static String jfcOptions() {
try {
StringBuilder sb = new StringBuilder();
for (SafePath s : SecuritySupport.getPredefinedJFCFiles()) {
String name = JFC.nameFromPath(s.toPath());
JFCModel model = JFCModel.create(s, l -> {});
sb.append('\n');
sb.append("Options for ").append(name).append(":\n");
sb.append('\n');
for (XmlInput input : model.getInputs()) {
sb.append(" ").append(input.getOptionSyntax()).append('\n');
sb.append('\n');
}
}
return sb.toString();
} catch (IOException | ParseException e) {
Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Could not list .jfc options for JFR.start. " + e.getMessage());
return "";
}
}

@Override