Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java
41152 views
/*1* Copyright (c) 2017, 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*/2223import java.util.HashMap;24import java.util.List;25import java.util.Map;2627import jdk.test.lib.apps.LingeredApp;28import jdk.test.lib.util.CoreUtils;29import jdk.test.lib.Platform;30import jtreg.SkippedException;3132/**33* @test34* @bug 819019835* @summary Test clhsdb pstack command on a live process36* @requires vm.hasSA37* @library /test/lib38* @run main/othervm ClhsdbPstack false39*/4041/**42* @test43* @bug 819019844* @summary Test clhsdb pstack command on a core file45* @requires vm.hasSA46* @library /test/lib47* @run main/othervm/timeout=480 ClhsdbPstack true48*/4950public class ClhsdbPstack {5152public static void main(String[] args) throws Exception {53boolean withCore = Boolean.parseBoolean(args[0]);54System.out.println("Starting ClhsdbPstack test: withCore==" + withCore);5556LingeredApp theApp = null;57String coreFileName = null;58try {59ClhsdbLauncher test = new ClhsdbLauncher();60theApp = new LingeredApp();61theApp.setForceCrash(withCore);62LingeredApp.startApp(theApp);63System.out.println("Started LingeredApp with pid " + theApp.getPid());6465if (withCore) {66String crashOutput = theApp.getOutput().getStdout();67coreFileName = CoreUtils.getCoreFileLocation(crashOutput, theApp.getPid());68}6970List<String> cmds = List.of("pstack -v");7172Map<String, List<String>> expStrMap = new HashMap<>();73if (!withCore && Platform.isOSX()) {74expStrMap.put("pstack -v", List.of(75"Not available for Mac OS X processes"));76} else {77expStrMap.put("pstack -v", List.of(78"No deadlocks found", "Common-Cleaner",79"Signal Dispatcher", "CompilerThread",80"Sweeper thread", "Service Thread",81"Reference Handler", "Finalizer", "main"));82}8384if (withCore) {85test.runOnCore(coreFileName, cmds, expStrMap, null);86} else {87test.run(theApp.getPid(), cmds, expStrMap, null);88}89} catch (SkippedException se) {90throw se;91} catch (Exception ex) {92throw new RuntimeException("Test ERROR " + ex, ex);93} finally {94if (!withCore) {95LingeredApp.stopApp(theApp);96}97}98System.out.println("Test PASSED");99}100}101102103