Skip to content

Commit

Permalink
8279662: serviceability/sa/ClhsdbScanOops.java can fail do to unexpec…
Browse files Browse the repository at this point in the history
…ted GC

Reviewed-by: sspitsyn, kevinw
  • Loading branch information
plummercj committed Feb 2, 2022
1 parent e3d5c9e commit fe0118f
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java
Original file line number Diff line number Diff line change
@@ -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

3 comments on commit fe0118f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on fe0118f Sep 19, 2022

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on fe0118f Sep 19, 2022

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-fe0118f8 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit fe0118f8 from the openjdk/jdk repository.

The commit being backported was authored by Chris Plummer on 2 Feb 2022 and was reviewed by Serguei Spitsyn and Kevin Walls.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-fe0118f8:GoeLin-backport-fe0118f8
$ git checkout GoeLin-backport-fe0118f8
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-fe0118f8

Please sign in to comment.