Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java
41149 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 pmap command on a live process36* @requires vm.hasSA37* @library /test/lib38* @run main/othervm ClhsdbPmap false39*/4041/**42* @test43* @bug 819019844* @summary Test clhsdb pmap command on a core file45* @requires vm.hasSA46* @library /test/lib47* @run main/othervm/timeout=480 ClhsdbPmap true48*/4950public class ClhsdbPmap {5152public static void main(String[] args) throws Exception {53boolean withCore = Boolean.parseBoolean(args[0]);54System.out.println("Starting ClhsdbPmap 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("pmap");7172Map<String, List<String>> expStrMap = new HashMap<>();73if (!withCore && Platform.isOSX()) {74expStrMap.put("pmap", List.of("Not available for Mac OS X processes"));75} else {76expStrMap.put("pmap", List.of("jvm", "java", "jli", "jimage"));77}7879if (withCore) {80test.runOnCore(coreFileName, cmds, expStrMap, null);81} else {82test.run(theApp.getPid(), cmds, expStrMap, null);83}84} catch (SkippedException se) {85throw se;86} catch (Exception ex) {87throw new RuntimeException("Test ERROR " + ex, ex);88} finally {89if (!withCore) {90LingeredApp.stopApp(theApp);91}92}93System.out.println("Test PASSED");94}95}969798