Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java
41149 views
/*1* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 817499426* @summary Test the clhsdb commands 'jstack', 'printall', 'where' with CDS enabled27* @requires vm.hasSA & vm.cds28* @library /test/lib29* @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSJstackPrintAll30*/3132import java.util.List;33import java.util.Arrays;34import java.util.Map;35import java.util.HashMap;36import jdk.test.lib.cds.CDSTestUtils;37import jdk.test.lib.cds.CDSOptions;38import jdk.test.lib.apps.LingeredApp;39import jtreg.SkippedException;4041public class ClhsdbCDSJstackPrintAll {4243public static void main(String[] args) throws Exception {44System.out.println("Starting ClhsdbCDSJstackPrintAll test");45String sharedArchiveName = "ArchiveForClhsdbJstackPrintAll.jsa";46LingeredApp theApp = null;4748try {49CDSOptions opts = (new CDSOptions()).setArchiveName(sharedArchiveName);50CDSTestUtils.createArchiveAndCheck(opts);5152ClhsdbLauncher test = new ClhsdbLauncher();53theApp = LingeredApp.startApp(54"-XX:+UnlockDiagnosticVMOptions",55"-XX:SharedArchiveFile=" + sharedArchiveName,56"-Xshare:auto");57System.out.println("Started LingeredApp with pid " + theApp.getPid());5859// Ensure that UseSharedSpaces is turned on.60List<String> cmds = List.of("flags UseSharedSpaces");6162String useSharedSpacesOutput = test.run(theApp.getPid(), cmds,63null, null);6465if (useSharedSpacesOutput == null) {66LingeredApp.stopApp(theApp);67// Attach permission issues.68throw new SkippedException("Could not determine the UseSharedSpaces value");69}7071if (useSharedSpacesOutput.contains("UseSharedSpaces = false")) {72// CDS archive is not mapped. Skip the rest of the test.73LingeredApp.stopApp(theApp);74throw new SkippedException("The CDS archive is not mapped");75}7677cmds = List.of("jstack -v", "printall", "where -a");7879Map<String, List<String>> expStrMap = new HashMap<>();80Map<String, List<String>> unExpStrMap = new HashMap<>();81expStrMap.put("jstack -v", List.of(82"No deadlocks found",83"Common-Cleaner",84"Signal Dispatcher",85"Method*",86"LingeredApp.steadyState"));87unExpStrMap.put("jstack -v", List.of(88"sun.jvm.hotspot.types.WrongTypeException",89"No suitable match for type of address"));90expStrMap.put("printall", List.of(91"aload_0",92"_nofast_aload_0",93"_nofast_getfield",94"_nofast_putfield",95"Constant Pool of",96"public static void main\\(java.lang.String\\[\\]\\)",97"Bytecode",98"invokevirtual",99"checkcast",100"Exception Table",101"invokedynamic"));102unExpStrMap.put("printall", List.of(103"No suitable match for type of address",104"illegal code",105"Failure occurred at bci"));106expStrMap.put("where -a", List.of(107"Java Stack Trace for SteadyStateThread",108"private static void steadyState"));109unExpStrMap.put("where -a", List.of(110"illegal code",111"Failure occurred at bci"));112test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);113} catch (SkippedException e) {114throw e;115} catch (Exception ex) {116throw new RuntimeException("Test ERROR " + ex, ex);117} finally {118LingeredApp.stopApp(theApp);119}120System.out.println("Test PASSED");121}122}123124125