author | goetz |
Fri, 20 Jul 2018 09:46:57 +0200 | |
changeset 51214 | 67736b4846a0 |
parent 50791 | b1e90a8a876c |
child 51287 | 7b1ddbafa134 |
permissions | -rw-r--r-- |
48381
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
1 |
/* |
50791
b1e90a8a876c
8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents:
48381
diff
changeset
|
2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
48381
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
4 |
* |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
8 |
* |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
13 |
* accompanied this code). |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
14 |
* |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
18 |
* |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
21 |
* questions. |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
22 |
*/ |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
23 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
24 |
import java.util.HashMap; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
25 |
import java.util.List; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
26 |
import java.util.Map; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
27 |
import java.util.ArrayList; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
28 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
29 |
import jdk.test.lib.apps.LingeredApp; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
30 |
|
50791
b1e90a8a876c
8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents:
48381
diff
changeset
|
31 |
/** |
48381
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
32 |
* @test |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
33 |
* @bug 8193124 |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
34 |
* @summary Test the clhsdb 'jdis' command |
50791
b1e90a8a876c
8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents:
48381
diff
changeset
|
35 |
* @requires vm.hasSA |
48381
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
36 |
* @library /test/lib |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
37 |
* @run main/othervm ClhsdbJdis |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
38 |
*/ |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
39 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
40 |
public class ClhsdbJdis { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
41 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
42 |
public static void main(String[] args) throws Exception { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
43 |
LingeredApp theApp = null; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
44 |
System.out.println("Starting the ClhsdbJdis test"); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
45 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
46 |
try { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
47 |
ClhsdbLauncher test = new ClhsdbLauncher(); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
48 |
theApp = LingeredApp.startApp(); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
49 |
System.out.println("Started LingeredApp with pid " + theApp.getPid()); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
50 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
51 |
// Run 'jstack -v' command to get the Method Address |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
52 |
List<String> cmds = List.of("jstack -v"); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
53 |
String output = test.run(theApp.getPid(), cmds, null, null); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
54 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
55 |
// Test the 'jdis' command passing in the address obtained from |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
56 |
// the 'jstack -v' command |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
57 |
cmds = new ArrayList<String>(); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
58 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
59 |
// Output could be null if the test was skipped due to |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
60 |
// attach permission issues. |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
61 |
if (output != null) { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
62 |
String cmdStr = null; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
63 |
String[] parts = output.split("LingeredApp.main"); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
64 |
String[] tokens = parts[1].split(" "); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
65 |
for (String token : tokens) { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
66 |
if (token.contains("Method")) { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
67 |
String[] address = token.split("="); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
68 |
// address[1] represents the address of the Method |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
69 |
cmdStr = "jdis " + address[1]; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
70 |
cmds.add(cmdStr); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
71 |
break; |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
72 |
} |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
73 |
} |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
74 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
75 |
Map<String, List<String>> expStrMap = new HashMap<>(); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
76 |
expStrMap.put(cmdStr, List.of( |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
77 |
"public static void main(java.lang.String[])", |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
78 |
"Holder Class", |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
79 |
"public class jdk.test.lib.apps.LingeredApp @", |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
80 |
"Bytecode", |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
81 |
"line bci bytecode", |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
82 |
"Exception Table", |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
83 |
"start bci end bci handler bci catch type", |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
84 |
"Constant Pool of [public class jdk.test.lib.apps.LingeredApp @")); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
85 |
|
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
86 |
test.run(theApp.getPid(), cmds, expStrMap, null); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
87 |
} |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
88 |
} catch (Exception ex) { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
89 |
throw new RuntimeException("Test ERROR " + ex, ex); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
90 |
} finally { |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
91 |
LingeredApp.stopApp(theApp); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
92 |
} |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
93 |
System.out.println("Test PASSED"); |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
94 |
} |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
95 |
} |
8b434af2703d
8193124: SA: Testcases for clhsdb jdis and findpc commands
sballal
parents:
diff
changeset
|
96 |