Skip to content

Commit

Permalink
8279662: serviceability/sa/ClhsdbScanOops.java can fail due to unexpe…
Browse files Browse the repository at this point in the history
…cted GC

Backport-of: fe0118f8040ce7e5e3d605942443e3a5d442fa92
  • Loading branch information
GoeLin committed Sep 22, 2022
1 parent 6e07afa commit b8f2a8d
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, 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
Expand Down Expand Up @@ -47,6 +47,7 @@
import java.util.ArrayList;
import jdk.test.lib.Utils;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.process.OutputAnalyzer;
import jtreg.SkippedException;

public class ClhsdbScanOops {
Expand All @@ -71,35 +72,54 @@ private static void testWithGcType(String gc) throws Exception {
Map<String, List<String>> expStrMap = new HashMap<>();
Map<String, List<String>> unExpStrMap = new HashMap<>();

String startAddress = null;
String endAddress = null;
String[] snippets = null;
String startAddress;
String endAddress;
String[] snippets;
String[] words;
String cmd;

// Run scanoops on the old gen
if (gc.contains("UseParallelGC")) {
snippets = universeOutput.split("PSOldGen \\[ ");
} else {
snippets = universeOutput.split("old \\[");
}
words = snippets[1].split(",");
// Get the addresses for Old gen
startAddress = words[0].replace("[", "");
endAddress = words[1];
cmd = "scanoops " + startAddress + " " + endAddress;
String output1 = test.run(theApp.getPid(), List.of(cmd), null, null);

// Run scanoops on the eden gen
if (gc.contains("UseParallelGC")) {
snippets = universeOutput.split("eden = ");
} else {
snippets = universeOutput.split("eden \\[");
}
String[] words = snippets[1].split(",");
// Get the addresses from Eden
words = snippets[1].split(",");
// Get the addresses for Eden gen
startAddress = words[0].replace("[", "");
endAddress = words[1];
String cmd = "scanoops " + startAddress + " " + endAddress;
cmds.add(cmd);

expStrMap.put(cmd, List.of
("java/lang/Object", "java/lang/Class", "java/lang/Thread",
"java/lang/String", "\\[B", "\\[I"));
cmd = "scanoops " + startAddress + " " + endAddress;
String output2 = test.run(theApp.getPid(), List.of(cmd), null, null);

// Look for expected types in the combined eden and old gens
OutputAnalyzer out = new OutputAnalyzer(output1 + output2);
List<String> expectStrs = List.of(
"java/lang/Object", "java/lang/Class", "java/lang/Thread",
"java/lang/String", "\\[B", "\\[I");
for (String expectStr : expectStrs) {
out.shouldMatch(expectStr);
}

// Test the 'type' option also
// scanoops <start addr> <end addr> java/lang/String
// Test the 'type' option also:
// scanoops <start addr> <end addr> java/lang/String
// Ensure that only the java/lang/String oops are printed.
cmd = cmd + " java/lang/String";
cmds.add(cmd);
expStrMap.put(cmd, List.of("java/lang/String"));
unExpStrMap.put(cmd, List.of("java/lang/Thread"));

test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
unExpStrMap.put(cmd, List.of("java/lang/Thread", "java/lang/Class", "java/lang/Object"));
test.run(theApp.getPid(), List.of(cmd), expStrMap, unExpStrMap);
} catch (SkippedException e) {
throw e;
} catch (Exception ex) {
Expand Down

1 comment on commit b8f2a8d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.