Skip to content

Commit

Permalink
8279797: JFR: Show .jfc options in JFR.start help
Browse files Browse the repository at this point in the history
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Jan 15, 2022
1 parent 9a18190 commit fef8f2d
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

1 comment on commit fef8f2d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.