1
1
/*
2
- * Copyright (c) 2017, 2020 , 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
47
47
import java .util .ArrayList ;
48
48
import jdk .test .lib .Utils ;
49
49
import jdk .test .lib .apps .LingeredApp ;
50
+ import jdk .test .lib .process .OutputAnalyzer ;
50
51
import jtreg .SkippedException ;
51
52
52
53
public class ClhsdbScanOops {
@@ -71,35 +72,54 @@ private static void testWithGcType(String gc) throws Exception {
71
72
Map <String , List <String >> expStrMap = new HashMap <>();
72
73
Map <String , List <String >> unExpStrMap = new HashMap <>();
73
74
74
- String startAddress = null ;
75
- String endAddress = null ;
76
- String [] snippets = null ;
75
+ String startAddress ;
76
+ String endAddress ;
77
+ String [] snippets ;
78
+ String [] words ;
79
+ String cmd ;
77
80
81
+ // Run scanoops on the old gen
82
+ if (gc .contains ("UseParallelGC" )) {
83
+ snippets = universeOutput .split ("PSOldGen \\ [ " );
84
+ } else {
85
+ snippets = universeOutput .split ("old \\ [" );
86
+ }
87
+ words = snippets [1 ].split ("," );
88
+ // Get the addresses for Old gen
89
+ startAddress = words [0 ].replace ("[" , "" );
90
+ endAddress = words [1 ];
91
+ cmd = "scanoops " + startAddress + " " + endAddress ;
92
+ String output1 = test .run (theApp .getPid (), List .of (cmd ), null , null );
93
+
94
+ // Run scanoops on the eden gen
78
95
if (gc .contains ("UseParallelGC" )) {
79
96
snippets = universeOutput .split ("eden = " );
80
97
} else {
81
98
snippets = universeOutput .split ("eden \\ [" );
82
99
}
83
- String [] words = snippets [1 ].split ("," );
84
- // Get the addresses from Eden
100
+ words = snippets [1 ].split ("," );
101
+ // Get the addresses for Eden gen
85
102
startAddress = words [0 ].replace ("[" , "" );
86
103
endAddress = words [1 ];
87
- String cmd = "scanoops " + startAddress + " " + endAddress ;
88
- cmds .add (cmd );
89
-
90
- expStrMap .put (cmd , List .of
91
- ("java/lang/Object" , "java/lang/Class" , "java/lang/Thread" ,
92
- "java/lang/String" , "\\ [B" , "\\ [I" ));
104
+ cmd = "scanoops " + startAddress + " " + endAddress ;
105
+ String output2 = test .run (theApp .getPid (), List .of (cmd ), null , null );
106
+
107
+ // Look for expected types in the combined eden and old gens
108
+ OutputAnalyzer out = new OutputAnalyzer (output1 + output2 );
109
+ List <String > expectStrs = List .of (
110
+ "java/lang/Object" , "java/lang/Class" , "java/lang/Thread" ,
111
+ "java/lang/String" , "\\ [B" , "\\ [I" );
112
+ for (String expectStr : expectStrs ) {
113
+ out .shouldMatch (expectStr );
114
+ }
93
115
94
- // Test the 'type' option also
95
- // scanoops <start addr> <end addr> java/lang/String
116
+ // Test the 'type' option also:
117
+ // scanoops <start addr> <end addr> java/lang/String
96
118
// Ensure that only the java/lang/String oops are printed.
97
119
cmd = cmd + " java/lang/String" ;
98
- cmds .add (cmd );
99
120
expStrMap .put (cmd , List .of ("java/lang/String" ));
100
- unExpStrMap .put (cmd , List .of ("java/lang/Thread" ));
101
-
102
- test .run (theApp .getPid (), cmds , expStrMap , unExpStrMap );
121
+ unExpStrMap .put (cmd , List .of ("java/lang/Thread" , "java/lang/Class" , "java/lang/Object" ));
122
+ test .run (theApp .getPid (), List .of (cmd ), expStrMap , unExpStrMap );
103
123
} catch (SkippedException e ) {
104
124
throw e ;
105
125
} catch (Exception ex ) {
0 commit comments