test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java
author sspitsyn
Tue, 26 Jun 2018 13:50:59 -0700
changeset 50802 fa380b3b2b7d
parent 50791 b1e90a8a876c
child 53596 bb40a5303c84
permissions -rw-r--r--
8205721: Problem list serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java Summary: Add the test to the ProblemList.txt Reviewed-by: 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
/*
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48181
diff changeset
     2
 * Copyright (c) 2017, 2018, 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;
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    28
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48181
diff changeset
    29
/**
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    30
 * @test
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    31
 * @bug 8191538
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    32
 * @summary Test clhsdb 'vmstructsdump' command
50791
b1e90a8a876c 8205419: [testbug] TestJmapCore failing without SA: introduce @requires vm.hasSAandCanAttach
goetz
parents: 48181
diff changeset
    33
 * @requires vm.hasSA
48181
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    34
 * @library /test/lib
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    35
 * @run main/othervm ClhsdbVmStructsDump
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    36
 */
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
public class ClhsdbVmStructsDump {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    39
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    40
    public static void main(String[] args) throws Exception {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    41
        System.out.println("Starting ClhsdbVmStructsDump test");
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    42
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    43
        LingeredApp theApp = null;
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    44
        try {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    45
            ClhsdbLauncher test = new ClhsdbLauncher();
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    46
            theApp = LingeredApp.startApp();
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    47
            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
    48
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    49
            List<String> cmds = List.of("vmstructsdump");
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    50
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    51
            Map<String, List<String>> expStrMap = new HashMap<>();
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    52
            expStrMap.put("vmstructsdump", List.of(
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    53
                "field ConstantPool _pool_holder InstanceKlass*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    54
                "field InstanceKlass _methods Array<Method*>*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    55
                "field InstanceKlass _constants ConstantPool*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    56
                "field Klass _name Symbol*",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    57
                "type ClassLoaderData* null",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    58
                "type DictionaryEntry KlassHashtableEntry",
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    59
                "field JavaThread _next JavaThread*",
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);
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    66
        } catch (Exception ex) {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    67
            throw new RuntimeException("Test ERROR " + ex, ex);
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    68
        } finally {
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    69
            LingeredApp.stopApp(theApp);
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    70
        }
61a14b5cb1c6 8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol
jgeorge
parents:
diff changeset
    71
        System.out.println("Test PASSED");
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
}