2
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
27
* @summary Test the clhsdb 'jdis' command
30
* @run main/othervm ClhsdbJdis
33
import java.util.HashMap;
36
import java.util.ArrayList;
38
import jdk.test.lib.apps.LingeredApp;
39
import jtreg.SkippedException;
41
public class ClhsdbJdis {
43
public static void main(String[] args) throws Exception {
44
LingeredApp theApp = null;
45
System.out.println("Starting the ClhsdbJdis test");
48
ClhsdbLauncher test = new ClhsdbLauncher();
49
theApp = LingeredApp.startApp();
50
System.out.println("Started LingeredApp with pid " + theApp.getPid());
52
// Run 'jstack -v' command to get the Method Address
53
List<String> cmds = List.of("jstack -v");
54
String output = test.run(theApp.getPid(), cmds, null, null);
56
// Test the 'jdis' command passing in the address obtained from
57
// the 'jstack -v' command
58
cmds = new ArrayList<String>();
61
String[] parts = output.split("LingeredApp.steadyState");
62
String[] tokens = parts[1].split(" ");
63
for (String token : tokens) {
64
if (token.contains("Method")) {
65
String[] address = token.split("=");
66
// address[1] represents the address of the Method
67
cmdStr = "jdis " + address[1];
73
Map<String, List<String>> expStrMap = new HashMap<>();
74
expStrMap.put(cmdStr, List.of(
75
"private static void steadyState\\(java\\.lang\\.Object\\)",
77
"public class jdk.test.lib.apps.LingeredApp @",
78
"public class jdk\\.test\\.lib\\.apps\\.LingeredApp @",
82
"start bci end bci handler bci catch type",
83
"Constant Pool of \\[public class jdk\\.test\\.lib\\.apps\\.LingeredApp @"));
85
test.run(theApp.getPid(), cmds, expStrMap, null);
86
} catch (SkippedException e) {
88
} catch (Exception ex) {
89
throw new RuntimeException("Test ERROR " + ex, ex);
91
LingeredApp.stopApp(theApp);
93
System.out.println("Test PASSED");