author | jgeorge |
Tue, 20 Mar 2018 11:24:32 +0530 | |
changeset 49463 | ccb003941743 |
child 50791 | b1e90a8a876c |
permissions | -rw-r--r-- |
49463
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
1 |
/* |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
4 |
* |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
8 |
* |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
13 |
* accompanied this code). |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
14 |
* |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
18 |
* |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
21 |
* questions. |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
22 |
*/ |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
23 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
24 |
import java.util.HashMap; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
25 |
import java.util.List; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
26 |
import java.util.ArrayList; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
27 |
import java.util.Map; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
28 |
import jdk.test.lib.apps.LingeredApp; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
29 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
30 |
/* |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
31 |
* @test |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
32 |
* @bug 8175312 |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
33 |
* @summary Test clhsdb 'g1regiondetails' and 'scanoops' commands for G1GC |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
34 |
* @library /test/lib |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
35 |
* @requires (vm.bits == "64" & os.maxMemory > 8g) |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
36 |
* @run main/othervm/timeout=2400 ClhsdbRegionDetailsScanOopsForG1 |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
37 |
*/ |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
38 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
39 |
public class ClhsdbRegionDetailsScanOopsForG1 { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
40 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
41 |
public static void main(String[] args) throws Exception { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
42 |
System.out.println("Starting ClhsdbRegionDetailsScanOopsForG1 test"); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
43 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
44 |
LingeredAppWithLargeStringArray theApp = null; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
45 |
try { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
46 |
ClhsdbLauncher test = new ClhsdbLauncher(); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
47 |
List<String> vmArgs = new ArrayList<String>(); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
48 |
vmArgs.add("-XX:+UseG1GC"); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
49 |
vmArgs.add("-Xmx8g"); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
50 |
vmArgs.add("-XX:G1HeapRegionSize=2m"); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
51 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
52 |
theApp = new LingeredAppWithLargeStringArray(); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
53 |
LingeredApp.startApp(vmArgs, theApp); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
54 |
System.out.println("Started LingeredAppWithLargeStringArray with pid " + theApp.getPid()); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
55 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
56 |
List<String> cmds = List.of("g1regiondetails"); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
57 |
Map<String, List<String>> expStrMap = new HashMap<>(); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
58 |
Map<String, List<String>> unExpStrMap = new HashMap<>(); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
59 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
60 |
// Test that the various types of regions are listed with the |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
61 |
// 'g1regiondetails' command |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
62 |
expStrMap.put("g1regiondetails", List.of( |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
63 |
"Region", |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
64 |
"Eden", |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
65 |
"Survivor", |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
66 |
"StartsHumongous", |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
67 |
"ContinuesHumongous", |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
68 |
"Free")); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
69 |
unExpStrMap.put("g1regiondetails", List.of("Unknown Region Type")); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
70 |
String regionDetailsOutput = test.run(theApp.getPid(), cmds, |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
71 |
expStrMap, unExpStrMap); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
72 |
if (regionDetailsOutput == null) { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
73 |
// Output could be null due to attach permission issues |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
74 |
// and if we are skipping this. |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
75 |
LingeredApp.stopApp(theApp); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
76 |
return; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
77 |
} |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
78 |
|
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
79 |
// Test the output of 'scanoops' -- get the start and end addresses |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
80 |
// from the StartsHumongous region. Ensure that it contains an |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
81 |
// array of Strings. |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
82 |
String[] snippets = regionDetailsOutput.split(":StartsHumongous"); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
83 |
snippets = snippets[0].split("Region: "); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
84 |
String[] words = snippets[snippets.length - 1].split(","); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
85 |
// words[0] and words[1] represent the start and end addresses |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
86 |
String cmd = "scanoops " + words[0] + " " + words[1]; |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
87 |
expStrMap = new HashMap<>(); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
88 |
expStrMap.put(cmd, List.of("[Ljava/lang/String")); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
89 |
test.run(theApp.getPid(), List.of(cmd), expStrMap, null); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
90 |
} catch (Exception ex) { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
91 |
throw new RuntimeException("Test ERROR " + ex, ex); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
92 |
} finally { |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
93 |
LingeredApp.stopApp(theApp); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
94 |
} |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
95 |
System.out.println("Test PASSED"); |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
96 |
} |
ccb003941743
8175312: SA: clhsdb: Provide an improved heap summary for 'universe' for G1GC
jgeorge
parents:
diff
changeset
|
97 |
} |