Skip to content

Commit 662acc4

Browse files
committed
Enabling VM Coredumps on Windows OS
- also handling failed SAAgent (loading multiple instances)
1 parent afd4d21 commit 662acc4

File tree

7 files changed

+78
-82
lines changed

7 files changed

+78
-82
lines changed

visualvm/coredump/manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ OpenIDE-Module: com.sun.tools.visualvm.coredump/0
55
OpenIDE-Module-Layer: com/sun/tools/visualvm/coredump/resources/layer.xml
66
OpenIDE-Module-Install: com/sun/tools/visualvm/coredump/Installer.class
77
OpenIDE-Module-Localizing-Bundle: com/sun/tools/visualvm/coredump/Bundle.properties
8-
OpenIDE-Module-Specification-Version: 1.0
8+
OpenIDE-Module-Specification-Version: 1.1
99

visualvm/coredump/src/com/sun/tools/visualvm/coredump/CoreDumpSupport.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.sun.tools.visualvm.coredump.impl.CoreDumpOverviewViewProvider;
3838
import com.sun.tools.visualvm.coredump.impl.CoreDumpProvider;
3939
import java.io.File;
40-
import org.openide.util.Utilities;
4140

4241
/**
4342
* Support for coredumps in VisualVM.
@@ -137,8 +136,6 @@ public static boolean storageDirectoryExists() {
137136

138137

139138
static void register() {
140-
if (Utilities.isWindows()) return;
141-
142139
DataSourceDescriptorFactory.getDefault().registerProvider(new CoreDumpDescriptorProvider());
143140
CoreDumpsContainer.sharedInstance();
144141
CoreDumpProvider.register();

visualvm/coredump/src/com/sun/tools/visualvm/coredump/CoreDumpsSorting.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.openide.awt.Mnemonics;
4141
import org.openide.util.NbBundle;
4242
import org.openide.util.NbPreferences;
43-
import org.openide.util.Utilities;
4443
import org.openide.util.actions.Presenter;
4544

4645
/**
@@ -92,15 +91,11 @@ protected void fireMenuSelected() {
9291
};
9392
Mnemonics.setLocalizedText(menu, NbBundle.getMessage(CoreDumpsSorting.class,
9493
"ACT_SortCoreDumps")); // NOI18N
95-
96-
if (Utilities.isWindows()) {
97-
menu.setEnabled(false);
98-
} else {
99-
menu.add(new SortAction(NbBundle.getMessage(CoreDumpsSorting.class,
100-
"ACT_TimeAdded"), BY_TIME_COMPARATOR, sorter)); // NOI18N
101-
menu.add(new SortAction(NbBundle.getMessage(CoreDumpsSorting.class,
102-
"ACT_DisplayName"), BY_NAME_COMPARATOR, sorter)); // NOI18N
103-
}
94+
95+
menu.add(new SortAction(NbBundle.getMessage(CoreDumpsSorting.class,
96+
"ACT_TimeAdded"), BY_TIME_COMPARATOR, sorter)); // NOI18N
97+
menu.add(new SortAction(NbBundle.getMessage(CoreDumpsSorting.class,
98+
"ACT_DisplayName"), BY_NAME_COMPARATOR, sorter)); // NOI18N
10499

105100
return menu;
106101
}

visualvm/coredump/src/com/sun/tools/visualvm/coredump/impl/AddVMCoredumpAction.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import javax.swing.ImageIcon;
3232
import org.openide.util.ImageUtilities;
3333
import org.openide.util.NbBundle;
34-
import org.openide.util.Utilities;
3534

3635

3736
/**
@@ -81,8 +80,7 @@ protected boolean isEnabled(CoreDumpsContainer contanier) {
8180
}
8281

8382
protected void initialize() {
84-
if (Utilities.isWindows()) setEnabled(false);
85-
else if (tracksSelection) super.initialize();
83+
if (tracksSelection) super.initialize();
8684
}
8785

8886

visualvm/coredump/src/com/sun/tools/visualvm/coredump/impl/Bundle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ LBL_System_properties=System properties
8888
Title_Unresolved_CoreDumps=Could Not Load Core Dump
8989

9090
MSG_Unresolved_CoreDumps=<html><b>These core dumps could not be found:</b><br>Do you want to load them on next VisualVM session?<br><br></html>
91+
92+
MSG_CoreDump_Failed=<b>Failed to read the VM coredump file.</b><br><br>Check the VisualVM logfile (Help | About | Logfile).

visualvm/coredump/src/com/sun/tools/visualvm/coredump/impl/CoreDumpOverviewView.java

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,25 @@ public CoreDumpOverviewView(CoreDump coreDump) {
5454

5555
protected DataViewComponent createComponent() {
5656
CoreDump coreDump = (CoreDump)getDataSource();
57-
DataViewComponent dvc = new DataViewComponent(
58-
new MasterViewSupport(coreDump).getMasterView(),
59-
new DataViewComponent.MasterViewConfiguration(false));
60-
6157
SaModel saAgent = SaModelFactory.getSAAgentFor(coreDump);
62-
Properties jvmProperties = saAgent.getSystemProperties();
63-
String jvmargs = saAgent.getJvmArgs();
6458

65-
dvc.configureDetailsView(new DataViewComponent.DetailsViewConfiguration(0.25, 0, -1, -1, -1, -1));
66-
67-
dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration(NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Saved_data"), true), DataViewComponent.TOP_LEFT); // NOI18N
68-
dvc.addDetailsView(new OverviewViewSupport.SnapshotsViewSupport(coreDump).getDetailsView(), DataViewComponent.TOP_LEFT);
59+
DataViewComponent dvc = new DataViewComponent(
60+
new MasterViewSupport(saAgent).getMasterView(),
61+
new DataViewComponent.MasterViewConfiguration(false));
6962

70-
dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration(NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Details"), true), DataViewComponent.TOP_RIGHT); // NOI18N
71-
dvc.addDetailsView(new OverviewViewSupport.JVMArgumentsViewSupport(jvmargs).getDetailsView(), DataViewComponent.TOP_RIGHT);
72-
dvc.addDetailsView(new OverviewViewSupport.SystemPropertiesViewSupport(jvmProperties).getDetailsView(), DataViewComponent.TOP_RIGHT);
63+
if (saAgent != null) {
64+
Properties jvmProperties = saAgent.getSystemProperties();
65+
String jvmargs = saAgent.getJvmArgs();
66+
67+
dvc.configureDetailsView(new DataViewComponent.DetailsViewConfiguration(0.25, 0, -1, -1, -1, -1));
68+
69+
dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration(NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Saved_data"), true), DataViewComponent.TOP_LEFT); // NOI18N
70+
dvc.addDetailsView(new OverviewViewSupport.SnapshotsViewSupport(coreDump).getDetailsView(), DataViewComponent.TOP_LEFT);
71+
72+
dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration(NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Details"), true), DataViewComponent.TOP_RIGHT); // NOI18N
73+
dvc.addDetailsView(new OverviewViewSupport.JVMArgumentsViewSupport(jvmargs).getDetailsView(), DataViewComponent.TOP_RIGHT);
74+
dvc.addDetailsView(new OverviewViewSupport.SystemPropertiesViewSupport(jvmProperties).getDetailsView(), DataViewComponent.TOP_RIGHT);
75+
}
7376

7477
return dvc;
7578
}
@@ -79,8 +82,8 @@ protected DataViewComponent createComponent() {
7982

8083
private static class MasterViewSupport extends JPanel {
8184

82-
public MasterViewSupport(CoreDump coreDump) {
83-
initComponents(coreDump);
85+
public MasterViewSupport(SaModel saAgent) {
86+
initComponents(saAgent);
8487
}
8588

8689

@@ -89,70 +92,73 @@ public DataViewComponent.MasterView getMasterView() {
8992
}
9093

9194

92-
private void initComponents(CoreDump coreDump) {
95+
private void initComponents(SaModel saAgent) {
9396
setLayout(new BorderLayout());
9497
setOpaque(false);
9598

96-
HTMLTextArea area = new HTMLTextArea("<nobr>" + getGeneralProperties(coreDump) + "</nobr>"); // NOI18N
99+
HTMLTextArea area = new HTMLTextArea("<nobr>" + getGeneralProperties(saAgent) + "</nobr>"); // NOI18N
97100
area.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8));
98101

99102
// TODO: implement listener for CoreDump.oomeHeapDumpEnabled
100103

101104
add(area, BorderLayout.CENTER);
102105
}
103106

104-
private String getGeneralProperties(CoreDump coreDump) {
105-
SaModel saAgent = SaModelFactory.getSAAgentFor(coreDump);
107+
private String getGeneralProperties(SaModel saAgent) {
106108
StringBuilder data = new StringBuilder();
107109

108-
// CoreDump information
109-
String commandLine = saAgent.getJavaCommand();
110-
111-
if (commandLine != null) {
112-
// Application information
113-
int firstSpace = commandLine.indexOf(' ');
114-
String mainClass;
115-
String mainArgs = null;
116-
if (firstSpace == -1) {
117-
mainClass = commandLine;
118-
} else {
119-
mainClass = commandLine.substring(0,firstSpace);
120-
mainArgs = commandLine.substring(firstSpace+1);
121-
}
122-
String mainClassLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Main_class"); // NOI18N
123-
String argsLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Arguments"); // NOI18N
124-
data.append("<b>"+mainClassLbl+":</b> " + mainClass + "<br>"); // NOI18N
125-
data.append("<b>"+argsLbl+":</b> " + (mainArgs == null ? NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_none") : mainArgs) + "<br>"); // NOI18N
126-
}
127-
128-
// JVM information
129-
String jvmFlags = saAgent.getJvmFlags();
130-
String jvmLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_JVM"); // NOI18N
131-
String jLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java"); // NOI18N
132-
String verLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java_Version"); // NOI18N
133-
String vendorLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java_Vendor"); // NOI18N
134-
String jhLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java_Home"); // NOI18N
135-
String flagsLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_JVM_Flags"); // NOI18N
136-
data.append("<br>"); // NOI18N
137-
data.append("<b>"+jvmLbl+":</b> " + saAgent.getVmName() + " (" + saAgent.getVmVersion() + ", " + saAgent.getVmInfo() + ")<br>"); // NOI18N
138-
Properties props = saAgent.getSystemProperties();
139-
if (props != null) {
140-
String javaVersion = props.getProperty("java.version"); // NOI18N
141-
String javaVendor = props.getProperty("java.vendor"); // NOI18N
142-
if (javaVersion != null || javaVendor != null) {
143-
data.append("<b>"+jLbl+":</b>");
144-
if (javaVersion != null) {
145-
data.append(" "+verLbl+" " + javaVersion); // NOI18N
110+
if (saAgent != null) {
111+
// CoreDump information
112+
String commandLine = saAgent.getJavaCommand();
113+
114+
if (commandLine != null) {
115+
// Application information
116+
int firstSpace = commandLine.indexOf(' ');
117+
String mainClass;
118+
String mainArgs = null;
119+
if (firstSpace == -1) {
120+
mainClass = commandLine;
121+
} else {
122+
mainClass = commandLine.substring(0,firstSpace);
123+
mainArgs = commandLine.substring(firstSpace+1);
146124
}
147-
if (javaVendor != null) {
148-
if (javaVersion != null) data.append(",");
149-
data.append(" "+vendorLbl+" " + javaVendor); // NOI18N
125+
String mainClassLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Main_class"); // NOI18N
126+
String argsLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Arguments"); // NOI18N
127+
data.append("<b>"+mainClassLbl+":</b> " + mainClass + "<br>"); // NOI18N
128+
data.append("<b>"+argsLbl+":</b> " + (mainArgs == null ? NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_none") : mainArgs) + "<br>"); // NOI18N
129+
}
130+
131+
// JVM information
132+
String jvmFlags = saAgent.getJvmFlags();
133+
String jvmLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_JVM"); // NOI18N
134+
String jLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java"); // NOI18N
135+
String verLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java_Version"); // NOI18N
136+
String vendorLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java_Vendor"); // NOI18N
137+
String jhLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_Java_Home"); // NOI18N
138+
String flagsLbl = NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_JVM_Flags"); // NOI18N
139+
data.append("<br>"); // NOI18N
140+
data.append("<b>"+jvmLbl+":</b> " + saAgent.getVmName() + " (" + saAgent.getVmVersion() + ", " + saAgent.getVmInfo() + ")<br>"); // NOI18N
141+
Properties props = saAgent.getSystemProperties();
142+
if (props != null) {
143+
String javaVersion = props.getProperty("java.version"); // NOI18N
144+
String javaVendor = props.getProperty("java.vendor"); // NOI18N
145+
if (javaVersion != null || javaVendor != null) {
146+
data.append("<b>"+jLbl+":</b>");
147+
if (javaVersion != null) {
148+
data.append(" "+verLbl+" " + javaVersion); // NOI18N
149+
}
150+
if (javaVendor != null) {
151+
if (javaVersion != null) data.append(",");
152+
data.append(" "+vendorLbl+" " + javaVendor); // NOI18N
153+
}
154+
data.append("<br>");
150155
}
151-
data.append("<br>");
152156
}
157+
data.append("<b>"+jhLbl+":</b> " + saAgent.getJavaHome() + "<br>"); // NOI18N
158+
data.append("<b>"+flagsLbl+":</b> " + (jvmFlags == null || jvmFlags.length() == 0 ? NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_none") : jvmFlags) + "<br><br>"); // NOI18N
159+
} else {
160+
data.append(NbBundle.getMessage(CoreDumpOverviewView.class, "MSG_CoreDump_Failed")); // NOI18N
153161
}
154-
data.append("<b>"+jhLbl+":</b> " + saAgent.getJavaHome() + "<br>"); // NOI18N
155-
data.append("<b>"+flagsLbl+":</b> " + (jvmFlags == null || jvmFlags.length() == 0 ? NbBundle.getMessage(CoreDumpOverviewView.class, "LBL_none") : jvmFlags) + "<br><br>"); // NOI18N
156162

157163
return data.toString();
158164

visualvm/coredump/src/com/sun/tools/visualvm/coredump/impl/CoreDumpProvider.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import org.openide.NotifyDescriptor;
5656
import org.openide.util.NbBundle;
5757
import org.openide.util.RequestProcessor;
58-
import org.openide.util.Utilities;
5958
import org.openide.windows.WindowManager;
6059

6160
/**
@@ -263,7 +262,6 @@ public void run() {
263262
}
264263

265264
public static void register() {
266-
if (Utilities.isWindows()) return;
267265
final CoreDumpProvider provider = new CoreDumpProvider();
268266
WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
269267
public void run() {

0 commit comments

Comments
 (0)