Skip to content

Commit c8f40b1

Browse files
committed
JFRSnapshotSupport.takeJfrDump() can optionally stop JFR recording
1 parent 0c09215 commit c8f40b1

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

visualvm/jfr/src/org/graalvm/visualvm/jfr/JFRSnapshotSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ static void register() {
126126
jfrDumpProvider.initialize();
127127
}
128128

129-
public static void takeJfrDump(Application application, boolean openView) {
130-
jfrDumpProvider.createJfrDump(application, openView);
129+
public static void takeJfrDump(Application application, boolean openView, boolean stopJfr) {
130+
jfrDumpProvider.createJfrDump(application, openView, stopJfr);
131131
}
132132

133133
public static void takeRemoteJfrDump(Application application, String dumpFile, boolean customizeDumpFile) {

visualvm/jfr/src/org/graalvm/visualvm/jfr/impl/JFRDumpAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected void actionPerformed(Set<DataSource> dataSources, ActionEvent actionEv
7474
boolean tagged = (actionEvent.getModifiers() & Toolkit.
7575
getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
7676
if (application.isLocalApplication()) {
77-
JFRSnapshotSupport.takeJfrDump(application, !tagged);
77+
JFRSnapshotSupport.takeJfrDump(application, !tagged, false);
7878
} else {
7979
JFRSnapshotSupport.takeRemoteJfrDump(application, null, !tagged);
8080
}

visualvm/jfr/src/org/graalvm/visualvm/jfr/impl/JFRRecordingProvider.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void remoteJfrStopRecording(Application application) {
137137
jfrStopRecording(application);
138138
}
139139

140-
public void createJfrDump(final Application application, final boolean openView) {
140+
public void createJfrDump(final Application application, final boolean openView, final boolean stopJfr) {
141141
VisualVM.getInstance().runTask(new Runnable() {
142142
public void run() {
143143
Jvm jvm = JvmFactory.getJVMFor(application);
@@ -168,6 +168,13 @@ public void run() {
168168
if (openView) {
169169
DataSourceWindowManager.sharedInstance().openDataSource(jfrDump);
170170
}
171+
if (stopJfr) {
172+
jvm.stopJfrRecording();
173+
Set<DataSource> ds = ActionUtils.getSelectedDataSources();
174+
JFRDumpAction.instance().updateState(ds);
175+
JFRStartAction.instance().updateState(ds);
176+
JFRStopAction.instance().updateState(ds);
177+
}
171178
} else {
172179
notifyJfrDumpFailed(application);
173180
}

0 commit comments

Comments
 (0)