1
1
/*
2
- * Copyright (c) 2017, 2019 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2017, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
36
36
import java .util .ArrayList ;
37
37
import jdk .test .lib .Utils ;
38
38
import jdk .test .lib .apps .LingeredApp ;
39
+ import jdk .test .lib .process .OutputAnalyzer ;
39
40
import jtreg .SkippedException ;
40
41
41
42
public class ClhsdbScanOops {
@@ -62,35 +63,54 @@ private static void testWithGcType(String gc) throws Exception {
62
63
Map <String , List <String >> expStrMap = new HashMap <>();
63
64
Map <String , List <String >> unExpStrMap = new HashMap <>();
64
65
65
- String startAddress = null ;
66
- String endAddress = null ;
67
- String [] snippets = null ;
66
+ String startAddress ;
67
+ String endAddress ;
68
+ String [] snippets ;
69
+ String [] words ;
70
+ String cmd ;
68
71
72
+ // Run scanoops on the old gen
73
+ if (gc .contains ("UseParallelGC" )) {
74
+ snippets = universeOutput .split ("PSOldGen \\ [ " );
75
+ } else {
76
+ snippets = universeOutput .split ("old \\ [" );
77
+ }
78
+ words = snippets [1 ].split ("," );
79
+ // Get the addresses for Old gen
80
+ startAddress = words [0 ].replace ("[" , "" );
81
+ endAddress = words [1 ];
82
+ cmd = "scanoops " + startAddress + " " + endAddress ;
83
+ String output1 = test .run (theApp .getPid (), List .of (cmd ), null , null );
84
+
85
+ // Run scanoops on the eden gen
69
86
if (gc .contains ("UseParallelGC" )) {
70
87
snippets = universeOutput .split ("eden = " );
71
88
} else {
72
89
snippets = universeOutput .split ("eden \\ [" );
73
90
}
74
- String [] words = snippets [1 ].split ("," );
75
- // Get the addresses from Eden
91
+ words = snippets [1 ].split ("," );
92
+ // Get the addresses for Eden gen
76
93
startAddress = words [0 ].replace ("[" , "" );
77
94
endAddress = words [1 ];
78
- String cmd = "scanoops " + startAddress + " " + endAddress ;
79
- cmds .add (cmd );
80
-
81
- expStrMap .put (cmd , List .of
82
- ("java/lang/Object" , "java/lang/Class" , "java/lang/Thread" ,
83
- "java/lang/String" , "\\ [B" , "\\ [I" ));
95
+ cmd = "scanoops " + startAddress + " " + endAddress ;
96
+ String output2 = test .run (theApp .getPid (), List .of (cmd ), null , null );
97
+
98
+ // Look for expected types in the combined eden and old gens
99
+ OutputAnalyzer out = new OutputAnalyzer (output1 + output2 );
100
+ List <String > expectStrs = List .of (
101
+ "java/lang/Object" , "java/lang/Class" , "java/lang/Thread" ,
102
+ "java/lang/String" , "\\ [B" , "\\ [I" );
103
+ for (String expectStr : expectStrs ) {
104
+ out .shouldMatch (expectStr );
105
+ }
84
106
85
- // Test the 'type' option also
86
- // scanoops <start addr> <end addr> java/lang/String
107
+ // Test the 'type' option also:
108
+ // scanoops <start addr> <end addr> java/lang/String
87
109
// Ensure that only the java/lang/String oops are printed.
88
110
cmd = cmd + " java/lang/String" ;
89
- cmds .add (cmd );
90
111
expStrMap .put (cmd , List .of ("java/lang/String" ));
91
- unExpStrMap .put (cmd , List .of ("java/lang/Thread" ));
92
-
93
- test .run (theApp .getPid (), cmds , expStrMap , unExpStrMap );
112
+ unExpStrMap .put (cmd , List .of ("java/lang/Thread" , "java/lang/Class" , "java/lang/Object" ));
113
+ test .run (theApp .getPid (), List .of (cmd ), expStrMap , unExpStrMap );
94
114
} catch (SkippedException e ) {
95
115
throw e ;
96
116
} catch (Exception ex ) {
0 commit comments