8248882: SA PMap and PStack support on OSX works with core files. Enable them
Reviewed-by: sspitsyn, amenkov
This commit is contained in:
parent
ab729d7075
commit
816a7060ba
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot
test/hotspot/jtreg/serviceability/sa
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -195,7 +195,7 @@ public class CLHSDB {
|
||||
private void attachDebugger(final String executablePath, final String corePath) {
|
||||
// Try to open this core file
|
||||
try {
|
||||
System.err.println("Opening core file, please wait...");
|
||||
System.out.println("Opening core file, please wait...");
|
||||
|
||||
// FIXME: display exec'd debugger's output messages during this
|
||||
// lengthy call
|
||||
|
@ -54,15 +54,17 @@ public class PMap extends Tool {
|
||||
}
|
||||
|
||||
public void run(PrintStream out, Debugger dbg) {
|
||||
if (PlatformInfo.getOS().equals("darwin")) {
|
||||
out.println("Not available on Mac OS X");
|
||||
return;
|
||||
}
|
||||
|
||||
CDebugger cdbg = dbg.getCDebugger();
|
||||
if (cdbg != null) {
|
||||
List<LoadObject> l = cdbg.getLoadObjectList();
|
||||
for (Iterator<LoadObject> itr = l.iterator() ; itr.hasNext();) {
|
||||
Iterator<LoadObject> itr = l.iterator();
|
||||
if (!itr.hasNext() && PlatformInfo.getOS().equals("darwin")) {
|
||||
// If the list is empty, we assume we attached to a process, and on OSX we can only
|
||||
// get LoadObjects for a core file.
|
||||
out.println("Not available for Mac OS X processes");
|
||||
return;
|
||||
}
|
||||
while (itr.hasNext()) {
|
||||
LoadObject lo = itr.next();
|
||||
out.print(lo.getBase() + "\t");
|
||||
out.print(lo.getSize()/1024 + "K\t");
|
||||
|
@ -59,11 +59,6 @@ public class PStack extends Tool {
|
||||
}
|
||||
|
||||
public void run(PrintStream out, Debugger dbg) {
|
||||
if (PlatformInfo.getOS().equals("darwin")) {
|
||||
out.println("Not available on Mac OS X");
|
||||
return;
|
||||
}
|
||||
|
||||
CDebugger cdbg = dbg.getCDebugger();
|
||||
if (cdbg != null) {
|
||||
ConcurrentLocksPrinter concLocksPrinter = null;
|
||||
@ -80,6 +75,12 @@ public class PStack extends Tool {
|
||||
}
|
||||
|
||||
List<ThreadProxy> l = cdbg.getThreadList();
|
||||
if (l.isEmpty() && PlatformInfo.getOS().equals("darwin")) {
|
||||
// If the list is empty, we assume we attached to a process, and on OSX we can only
|
||||
// get the native thread list for core files.
|
||||
out.println("Not available for Mac OS X processes");
|
||||
return;
|
||||
}
|
||||
final boolean cdbgCanDemangle = cdbg.canDemangle();
|
||||
for (Iterator<ThreadProxy> itr = l.iterator() ; itr.hasNext();) {
|
||||
ThreadProxy th = itr.next();
|
||||
|
@ -26,47 +26,70 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.test.lib.apps.LingeredApp;
|
||||
import jdk.test.lib.util.CoreUtils;
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8190198
|
||||
* @summary Test clhsdb pmap command
|
||||
* @summary Test clhsdb pmap command on a live process
|
||||
* @requires vm.hasSA
|
||||
* @library /test/lib
|
||||
* @run main/othervm ClhsdbPmap
|
||||
* @run main/othervm ClhsdbPmap false
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8190198
|
||||
* @summary Test clhsdb pmap command on a core file
|
||||
* @requires vm.hasSA
|
||||
* @library /test/lib
|
||||
* @run main/othervm ClhsdbPmap true
|
||||
*/
|
||||
|
||||
public class ClhsdbPmap {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Starting ClhsdbPmap test");
|
||||
boolean withCore = Boolean.parseBoolean(args[0]);
|
||||
System.out.println("Starting ClhsdbPmap test: withCore==" + withCore);
|
||||
|
||||
LingeredApp theApp = null;
|
||||
String coreFileName = null;
|
||||
try {
|
||||
ClhsdbLauncher test = new ClhsdbLauncher();
|
||||
theApp = LingeredApp.startApp();
|
||||
theApp = new LingeredApp();
|
||||
theApp.setForceCrash(withCore);
|
||||
LingeredApp.startApp(theApp);
|
||||
System.out.println("Started LingeredApp with pid " + theApp.getPid());
|
||||
|
||||
if (withCore) {
|
||||
String crashOutput = theApp.getOutput().getStdout();
|
||||
coreFileName = CoreUtils.getCoreFileLocation(crashOutput);
|
||||
}
|
||||
|
||||
List<String> cmds = List.of("pmap");
|
||||
|
||||
Map<String, List<String>> expStrMap = new HashMap<>();
|
||||
if (Platform.isOSX()) {
|
||||
expStrMap.put("pmap",
|
||||
List.of("Not available on Mac OS X"));
|
||||
if (!withCore && Platform.isOSX()) {
|
||||
expStrMap.put("pmap", List.of("Not available for Mac OS X processes"));
|
||||
} else {
|
||||
expStrMap.put("pmap",
|
||||
List.of("jvm", "java", "net", "nio", "jimage"));
|
||||
expStrMap.put("pmap", List.of("jvm", "java", "jli", "jimage"));
|
||||
}
|
||||
|
||||
test.run(theApp.getPid(), cmds, expStrMap, null);
|
||||
if (withCore) {
|
||||
test.runOnCore(coreFileName, cmds, expStrMap, null);
|
||||
} else {
|
||||
test.run(theApp.getPid(), cmds, expStrMap, null);
|
||||
}
|
||||
} catch (SkippedException se) {
|
||||
throw se;
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Test ERROR " + ex, ex);
|
||||
} finally {
|
||||
LingeredApp.stopApp(theApp);
|
||||
if (!withCore) {
|
||||
LingeredApp.stopApp(theApp);
|
||||
}
|
||||
}
|
||||
System.out.println("Test PASSED");
|
||||
}
|
||||
|
@ -26,35 +26,54 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.test.lib.apps.LingeredApp;
|
||||
import jdk.test.lib.util.CoreUtils;
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8190198
|
||||
* @summary Test clhsdb pstack command
|
||||
* @summary Test clhsdb pstack command on a live process
|
||||
* @requires vm.hasSA
|
||||
* @library /test/lib
|
||||
* @run main/othervm ClhsdbPstack
|
||||
* @run main/othervm ClhsdbPstack false
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8190198
|
||||
* @summary Test clhsdb pstack command on a core file
|
||||
* @requires vm.hasSA
|
||||
* @library /test/lib
|
||||
* @run main/othervm ClhsdbPstack true
|
||||
*/
|
||||
|
||||
public class ClhsdbPstack {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Starting ClhsdbPstack test");
|
||||
boolean withCore = Boolean.parseBoolean(args[0]);
|
||||
System.out.println("Starting ClhsdbPstack test: withCore==" + withCore);
|
||||
|
||||
LingeredApp theApp = null;
|
||||
String coreFileName = null;
|
||||
try {
|
||||
ClhsdbLauncher test = new ClhsdbLauncher();
|
||||
theApp = LingeredApp.startApp();
|
||||
theApp = new LingeredApp();
|
||||
theApp.setForceCrash(withCore);
|
||||
LingeredApp.startApp(theApp);
|
||||
System.out.println("Started LingeredApp with pid " + theApp.getPid());
|
||||
|
||||
if (withCore) {
|
||||
String crashOutput = theApp.getOutput().getStdout();
|
||||
coreFileName = CoreUtils.getCoreFileLocation(crashOutput);
|
||||
}
|
||||
|
||||
List<String> cmds = List.of("pstack -v");
|
||||
|
||||
Map<String, List<String>> expStrMap = new HashMap<>();
|
||||
if (Platform.isOSX()) {
|
||||
if (!withCore && Platform.isOSX()) {
|
||||
expStrMap.put("pstack -v", List.of(
|
||||
"Not available on Mac OS X"));
|
||||
"Not available for Mac OS X processes"));
|
||||
} else {
|
||||
expStrMap.put("pstack -v", List.of(
|
||||
"No deadlocks found", "Common-Cleaner",
|
||||
@ -63,13 +82,19 @@ public class ClhsdbPstack {
|
||||
"Reference Handler", "Finalizer", "main"));
|
||||
}
|
||||
|
||||
test.run(theApp.getPid(), cmds, expStrMap, null);
|
||||
if (withCore) {
|
||||
test.runOnCore(coreFileName, cmds, expStrMap, null);
|
||||
} else {
|
||||
test.run(theApp.getPid(), cmds, expStrMap, null);
|
||||
}
|
||||
} catch (SkippedException se) {
|
||||
throw se;
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Test ERROR " + ex, ex);
|
||||
} finally {
|
||||
LingeredApp.stopApp(theApp);
|
||||
if (!withCore) {
|
||||
LingeredApp.stopApp(theApp);
|
||||
}
|
||||
}
|
||||
System.out.println("Test PASSED");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user