Skip to content
Permalink
Browse files
8279662: serviceability/sa/ClhsdbScanOops.java can fail do to unexpec…
…ted GC

Reviewed-by: sspitsyn, kevinw
  • Loading branch information
plummercj committed Feb 2, 2022
1 parent e3d5c9e commit fe0118f8040ce7e5e3d605942443e3a5d442fa92
Showing 1 changed file with 38 additions and 18 deletions.
@@ -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
@@ -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 {
@@ -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) {

1 comment on commit fe0118f

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on fe0118f Feb 2, 2022

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.