test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java
author rehn
Tue, 21 May 2019 10:34:57 +0200
changeset 54955 46409371a691
parent 53596 bb40a5303c84
permissions -rw-r--r--
8223306: Remove threads linked list (use ThreadsList's array in SA) Reviewed-by: coleenp, dholmes, dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     1
/*
53596
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     4
 *
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     7
 * published by the Free Software Foundation.
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     8
 *
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    13
 * accompanied this code).
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    14
 *
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    18
 *
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    21
 * questions.
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    22
 */
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    23
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    24
import java.util.HashMap;
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    25
import java.util.List;
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    26
import java.util.Map;
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    27
import jdk.test.lib.apps.LingeredApp;
53596
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
    28
import jtreg.SkippedException;
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    29
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48181
diff changeset
    30
/**
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    31
 * @test
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    32
 * @bug 8191538
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    33
 * @summary Test clhsdb 'vmstructsdump' command
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48181
diff changeset
    34
 * @requires vm.hasSA
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    35
 * @library /test/lib
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    36
 * @run main/othervm ClhsdbVmStructsDump
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    37
 */
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    38
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    39
public class ClhsdbVmStructsDump {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    40
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    41
    public static void main(String[] args) throws Exception {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    42
        System.out.println("Starting ClhsdbVmStructsDump test");
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    43
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    44
        LingeredApp theApp = null;
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    45
        try {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    46
            ClhsdbLauncher test = new ClhsdbLauncher();
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    47
            theApp = LingeredApp.startApp();
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    48
            System.out.println("Started LingeredApp with pid " + theApp.getPid());
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    49
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    50
            List<String> cmds = List.of("vmstructsdump");
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    51
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    52
            Map<String, List<String>> expStrMap = new HashMap<>();
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    53
            expStrMap.put("vmstructsdump", List.of(
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    54
                "field ConstantPool _pool_holder InstanceKlass*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    55
                "field InstanceKlass _methods Array<Method*>*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    56
                "field InstanceKlass _constants ConstantPool*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    57
                "field Klass _name Symbol*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    58
                "type ClassLoaderData* null",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    59
                "type DictionaryEntry KlassHashtableEntry",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    60
                "field JavaThread _osthread OSThread*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    61
                "type TenuredGeneration CardGeneration",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    62
                "field JVMState _bci",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    63
                "type Universe null",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    64
                "type ConstantPoolCache MetaspaceObj"));
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    65
            test.run(theApp.getPid(), cmds, expStrMap, null);
53596
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
    66
        } catch (SkippedException se) {
bb40a5303c84 8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
jgeorge
parents: 50791
diff changeset
    67
            throw se;
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    68
        } catch (Exception ex) {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    69
            throw new RuntimeException("Test ERROR " + ex, ex);
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    70
        } finally {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    71
            LingeredApp.stopApp(theApp);
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    72
        }
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    73
        System.out.println("Test PASSED");
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    74
    }
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    75
}