author | mbaesken |
Thu, 28 Nov 2019 09:23:09 +0100 | |
changeset 59317 | 7089399d6ade |
parent 58384 | 9a3a700ca571 |
permissions | -rw-r--r-- |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
1 |
/* |
53635
247e5ca412f5
8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents:
52960
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
4 |
* |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
8 |
* |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
13 |
* accompanied this code). |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
14 |
* |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
18 |
* |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
21 |
* questions. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
22 |
*/ |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
23 |
|
50791
b1e90a8a876c
8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents:
50093
diff
changeset
|
24 |
/** |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
25 |
* @test |
52960
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
26 |
* @bug 8174994 8200613 |
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
27 |
* @summary Test the clhsdb commands 'printmdo', 'printall', 'jstack' on a CDS enabled corefile. |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
28 |
* @requires vm.cds |
50791
b1e90a8a876c
8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents:
50093
diff
changeset
|
29 |
* @requires vm.hasSA |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
30 |
* @requires os.family != "windows" |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
31 |
* @requires vm.flavor == "server" |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
32 |
* @library /test/lib |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
33 |
* @modules java.base/jdk.internal.misc |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
34 |
* @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSCore |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
35 |
*/ |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
36 |
|
58384 | 37 |
import java.io.File; |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
38 |
import java.io.IOException; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
39 |
import java.nio.file.Files; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
40 |
import java.nio.file.Path; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
41 |
import java.nio.file.Paths; |
58384 | 42 |
import java.util.ArrayList; |
43 |
import java.util.Arrays; |
|
44 |
import java.util.HashMap; |
|
45 |
import java.util.List; |
|
46 |
import java.util.Map; |
|
47 |
import java.util.Scanner; |
|
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
48 |
import java.util.regex.Matcher; |
58384 | 49 |
import java.util.regex.Pattern; |
50 |
||
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
51 |
import jdk.internal.misc.Unsafe; |
58384 | 52 |
|
53 |
import jdk.test.lib.Asserts; |
|
54 |
import jdk.test.lib.Platform; |
|
55 |
import jdk.test.lib.cds.CDSOptions; |
|
56 |
import jdk.test.lib.cds.CDSTestUtils; |
|
57 |
import jdk.test.lib.process.OutputAnalyzer; |
|
58 |
import jdk.test.lib.process.ProcessTools; |
|
59 |
import jdk.test.lib.SA.SATestUtils; |
|
60 |
||
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50791
diff
changeset
|
61 |
import jtreg.SkippedException; |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
62 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
63 |
class CrashApp { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
64 |
public static void main(String[] args) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
65 |
Unsafe.getUnsafe().putInt(0L, 0); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
66 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
67 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
68 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
69 |
public class ClhsdbCDSCore { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
70 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
71 |
private static final String TEST_CDS_CORE_FILE_NAME = "cds_core_file"; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
72 |
private static final String LOCATIONS_STRING = "location: "; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
73 |
private static final String RUN_SHELL_NO_LIMIT = "ulimit -c unlimited && "; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
74 |
private static final String SHARED_ARCHIVE_NAME = "ArchiveForClhsdbCDSCore.jsa"; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
75 |
private static final String CORE_PATTERN_FILE_NAME = "/proc/sys/kernel/core_pattern"; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
76 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
77 |
public static void main(String[] args) throws Exception { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
78 |
System.out.println("Starting ClhsdbCDSCore test"); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
79 |
cleanup(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
80 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
81 |
try { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
82 |
CDSOptions opts = (new CDSOptions()).setArchiveName(SHARED_ARCHIVE_NAME); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
83 |
CDSTestUtils.createArchiveAndCheck(opts); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
84 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
85 |
String[] jArgs = { |
51946
7bd8d6b011c9
8207745: serviceability/sa/TestJmapCore.java times out parsing a 4GB hprof file
sballal
parents:
51418
diff
changeset
|
86 |
"-Xmx512m", |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
87 |
"-XX:+UnlockDiagnosticVMOptions", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
88 |
"-XX:SharedArchiveFile=" + SHARED_ARCHIVE_NAME, |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
89 |
"-XX:+CreateCoredumpOnCrash", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
90 |
"-Xshare:auto", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
91 |
"-XX:+ProfileInterpreter", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
92 |
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
93 |
CrashApp.class.getName() |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
94 |
}; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
95 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
96 |
OutputAnalyzer crashOut; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
97 |
try { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
98 |
List<String> options = new ArrayList<>(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
99 |
options.addAll(Arrays.asList(jArgs)); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
100 |
crashOut = |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
101 |
ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix( |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
102 |
RUN_SHELL_NO_LIMIT, options.toArray(new String[0]))); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
103 |
} catch (Throwable t) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
104 |
throw new Error("Can't execute the java cds process.", t); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
105 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
106 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
107 |
System.out.println(crashOut.getOutput()); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
108 |
String crashOutputString = crashOut.getOutput(); |
58384 | 109 |
SATestUtils.unzipCores(new File(".")); |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
110 |
String coreFileLocation = getCoreFileLocation(crashOutputString); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
111 |
if (coreFileLocation == null) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
112 |
if (Platform.isOSX()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
113 |
File coresDir = new File("/cores"); |
59317
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
114 |
if (!coresDir.isDirectory()) { |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
115 |
throw new Error("cores is not a directory"); |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
116 |
} |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
117 |
// the /cores directory is usually not writable on macOS 10.15 |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
118 |
final String osVersion = System.getProperty("os.version"); |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
119 |
if (osVersion == null) { |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
120 |
throw new Error("Cannot query the 'os.version' property!"); |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
121 |
} |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
122 |
if (!coresDir.canWrite()) { |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
123 |
if (osVersion.startsWith("10.15")) { |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
124 |
throw new SkippedException("/cores is not writable"); |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
125 |
} else { |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
126 |
throw new Error("cores does not have write permissions"); |
7089399d6ade
8234625: hs test serviceability/sa/ClhsdbCDSCore.java fails on macOS 10.15
mbaesken
parents:
58384
diff
changeset
|
127 |
} |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
128 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
129 |
} else if (Platform.isLinux()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
130 |
// Check if a crash report tool is installed. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
131 |
File corePatternFile = new File(CORE_PATTERN_FILE_NAME); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
132 |
Scanner scanner = new Scanner(corePatternFile); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
133 |
while (scanner.hasNextLine()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
134 |
String line = scanner.nextLine(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
135 |
line = line.trim(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
136 |
System.out.println(line); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
137 |
if (line.startsWith("|")) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
138 |
System.out.println( |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
139 |
"\nThis system uses a crash report tool ($cat /proc/sys/kernel/core_pattern).\n" + |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
140 |
"Core files might not be generated. Please reset /proc/sys/kernel/core_pattern\n" + |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
141 |
"to enable core generation. Skipping this test."); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
142 |
cleanup(); |
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50791
diff
changeset
|
143 |
throw new SkippedException("This system uses a crash report tool"); |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
144 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
145 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
146 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
147 |
throw new Error("Couldn't find core file location in: '" + crashOutputString + "'"); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
148 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
149 |
try { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
150 |
Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size"); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
151 |
Files.move(Paths.get(coreFileLocation), Paths.get(TEST_CDS_CORE_FILE_NAME)); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
152 |
} catch (IOException ioe) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
153 |
throw new Error("Can't move core file: " + ioe, ioe); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
154 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
155 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
156 |
ClhsdbLauncher test = new ClhsdbLauncher(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
157 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
158 |
// Ensure that UseSharedSpaces is turned on. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
159 |
List<String> cmds = List.of("flags UseSharedSpaces"); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
160 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
161 |
String useSharedSpacesOutput = test.runOnCore(TEST_CDS_CORE_FILE_NAME, cmds, |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
162 |
null, null); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
163 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
164 |
if (useSharedSpacesOutput == null) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
165 |
// Output could be null due to attach permission issues. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
166 |
cleanup(); |
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50791
diff
changeset
|
167 |
throw new SkippedException("Could not determine the UseSharedSpaces value"); |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
168 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
169 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
170 |
if (!useSharedSpacesOutput.contains("true")) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
171 |
// CDS archive is not mapped. Skip the rest of the test. |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
172 |
cleanup(); |
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50791
diff
changeset
|
173 |
throw new SkippedException("The CDS archive is not mapped"); |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
174 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
175 |
|
52960
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
176 |
cmds = List.of("printmdo -a", "printall", "jstack -v"); |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
177 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
178 |
Map<String, List<String>> expStrMap = new HashMap<>(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
179 |
Map<String, List<String>> unExpStrMap = new HashMap<>(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
180 |
expStrMap.put("printmdo -a", List.of( |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
181 |
"CounterData", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
182 |
"BranchData")); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
183 |
unExpStrMap.put("printmdo -a", List.of( |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
184 |
"No suitable match for type of address")); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
185 |
expStrMap.put("printall", List.of( |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
186 |
"aload_0", |
50093
55153a374d18
8174995: SA: clhsdb 'where -a' throws Assertion Failure with illegal code 236 when CDS is used
jgeorge
parents:
49896
diff
changeset
|
187 |
"_nofast_aload_0", |
55153a374d18
8174995: SA: clhsdb 'where -a' throws Assertion Failure with illegal code 236 when CDS is used
jgeorge
parents:
49896
diff
changeset
|
188 |
"_nofast_getfield", |
55153a374d18
8174995: SA: clhsdb 'where -a' throws Assertion Failure with illegal code 236 when CDS is used
jgeorge
parents:
49896
diff
changeset
|
189 |
"_nofast_putfield", |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
190 |
"Constant Pool of", |
53635
247e5ca412f5
8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
jgeorge
parents:
52960
diff
changeset
|
191 |
"public static void main\\(java.lang.String\\[\\]\\)", |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
192 |
"Bytecode", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
193 |
"invokevirtual", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
194 |
"checkcast", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
195 |
"Exception Table", |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
196 |
"invokedynamic")); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
197 |
unExpStrMap.put("printall", List.of( |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
198 |
"sun.jvm.hotspot.types.WrongTypeException", |
50093
55153a374d18
8174995: SA: clhsdb 'where -a' throws Assertion Failure with illegal code 236 when CDS is used
jgeorge
parents:
49896
diff
changeset
|
199 |
"illegal code", |
55153a374d18
8174995: SA: clhsdb 'where -a' throws Assertion Failure with illegal code 236 when CDS is used
jgeorge
parents:
49896
diff
changeset
|
200 |
"Failure occurred at bci", |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
201 |
"No suitable match for type of address")); |
52960
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
202 |
expStrMap.put("jstack -v", List.of( |
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
203 |
"Common-Cleaner", |
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
204 |
"Method*")); |
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
205 |
unExpStrMap.put("jstack -v", List.of( |
a6182c464b31
8200613: SA: jstack throws UnmappedAddressException with a CDS core file
jgeorge
parents:
51946
diff
changeset
|
206 |
"sun.jvm.hotspot.debugger.UnmappedAddressException")); |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
207 |
test.runOnCore(TEST_CDS_CORE_FILE_NAME, cmds, expStrMap, unExpStrMap); |
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50791
diff
changeset
|
208 |
} catch (SkippedException e) { |
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50791
diff
changeset
|
209 |
throw e; |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
210 |
} catch (Exception ex) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
211 |
throw new RuntimeException("Test ERROR " + ex, ex); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
212 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
213 |
cleanup(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
214 |
System.out.println("Test PASSED"); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
215 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
216 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
217 |
// lets search for a few possible locations using process output and return existing location |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
218 |
private static String getCoreFileLocation(String crashOutputString) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
219 |
Asserts.assertTrue(crashOutputString.contains(LOCATIONS_STRING), |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
220 |
"Output doesn't contain the location of core file."); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
221 |
String stringWithLocation = Arrays.stream(crashOutputString.split("\\r?\\n")) |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
222 |
.filter(str -> str.contains(LOCATIONS_STRING)) |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
223 |
.findFirst() |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
224 |
.get(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
225 |
stringWithLocation = stringWithLocation.substring(stringWithLocation |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
226 |
.indexOf(LOCATIONS_STRING) + LOCATIONS_STRING.length()); |
51418
45d1f2ec5342
8207832: serviceability/sa/ClhsdbCDSCore.java failed with "Couldn't find core file location"
iklam
parents:
51287
diff
changeset
|
227 |
System.out.println("getCoreFileLocation found stringWithLocation = " + stringWithLocation); |
49896
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
228 |
String coreWithPid; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
229 |
if (stringWithLocation.contains("or ")) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
230 |
Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
231 |
if (!m.find()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
232 |
throw new Error("Couldn't find path to core inside location string"); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
233 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
234 |
coreWithPid = m.group(1); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
235 |
} else { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
236 |
coreWithPid = stringWithLocation.trim(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
237 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
238 |
if (new File(coreWithPid).exists()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
239 |
return coreWithPid; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
240 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
241 |
String justCore = Paths.get("core").toString(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
242 |
if (new File(justCore).exists()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
243 |
return justCore; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
244 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
245 |
Path coreWithPidPath = Paths.get(coreWithPid); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
246 |
String justFile = coreWithPidPath.getFileName().toString(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
247 |
if (new File(justFile).exists()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
248 |
return justFile; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
249 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
250 |
Path parent = coreWithPidPath.getParent(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
251 |
if (parent != null) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
252 |
String coreWithoutPid = parent.resolve("core").toString(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
253 |
if (new File(coreWithoutPid).exists()) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
254 |
return coreWithoutPid; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
255 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
256 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
257 |
return null; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
258 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
259 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
260 |
private static String[] getTestJavaCommandlineWithPrefix(String prefix, String... args) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
261 |
try { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
262 |
String cmd = ProcessTools.getCommandLine(ProcessTools.createJavaProcessBuilder(true, args)); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
263 |
return new String[]{"sh", "-c", prefix + cmd}; |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
264 |
} catch (Throwable t) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
265 |
throw new Error("Can't create process builder: " + t, t); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
266 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
267 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
268 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
269 |
private static void cleanup() { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
270 |
remove(TEST_CDS_CORE_FILE_NAME); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
271 |
remove(SHARED_ARCHIVE_NAME); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
272 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
273 |
|
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
274 |
private static void remove(String item) { |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
275 |
File toDelete = new File(item); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
276 |
toDelete.delete(); |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
277 |
} |
ec2dd30adbc1
8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents:
diff
changeset
|
278 |
} |