test/hotspot/jtreg/vmTestbase/nsk/jdb/up/up002/up002.java
author iignatyev
Tue, 22 May 2018 10:08:04 -0700
changeset 50220 31361382634b
permissions -rw-r--r--
8199379: [TESTBUG] Open source vm testbase JDB tests Reviewed-by: mseledtsov, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50220
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     1
/*
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     4
 *
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     8
 *
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    14
 *
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    18
 *
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    21
 * questions.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    22
 */
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    23
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    24
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    25
/*
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    26
 * @test
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    27
 *
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    28
 * @summary converted from VM Testbase nsk/jdb/up/up002.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    29
 * VM Testbase keywords: [jpda, jdb]
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    30
 * VM Testbase readme:
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    31
 * DECSRIPTION
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    32
 *  This tests the jdb 'up' command. The test sets a breakpoint
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    33
 *  at 'func5' method in debugged 'nsk.jdb.up.up002a' class and then
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    34
 *  runs the debugee.  Once, an execution suspends at 'func5' method,
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    35
 *  the 'up' command is issued to the debugger several times.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    36
 *  The output is processed by counting the number of times
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    37
 *  each method name appears in the stack trace. The test passes
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    38
 *  if the obtained count matches the expected one.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    39
 * COMMENTS
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    40
 *  This test functionally equals to nsk/jdb/up/up001 test and
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    41
 *  replaces it.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    42
 *
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    43
 * @library /vmTestbase
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    44
 *          /test/lib
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    45
 * @run driver jdk.test.lib.FileInstaller . .
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    46
 * @build nsk.jdb.up.up002.up002
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    47
 *        nsk.jdb.up.up002.up002a
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    48
 * @run main/othervm PropertyResolvingWrapper nsk.jdb.up.up002.up002
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    49
 *      -arch=${os.family}-${os.simpleArch}
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    50
 *      -waittime=5
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    51
 *      -debugee.vmkind=java
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    52
 *      -transport.address=dynamic
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    53
 *      -jdb=${test.jdk}/bin/jdb
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    54
 *      -java.options="${test.vm.opts} ${test.java.opts}"
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    55
 *      -workdir=.
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    56
 *      -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    57
 */
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    58
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    59
package nsk.jdb.up.up002;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    60
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    61
import nsk.share.*;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    62
import nsk.share.jdb.*;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    63
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    64
import java.io.*;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    65
import java.util.*;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    66
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    67
public class up002 extends JdbTest {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    68
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    69
    public static void main (String argv[]) {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    70
        System.exit(run(argv, System.out) + JCK_STATUS_BASE);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    71
    }
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    72
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    73
    public static int run(String argv[], PrintStream out) {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    74
        debuggeeClass =  DEBUGGEE_CLASS;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    75
        firstBreak = FIRST_BREAK;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    76
        lastBreak = LAST_BREAK;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    77
        return new up002().runTest(argv, out);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    78
    }
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    79
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    80
    static final String PACKAGE_NAME     = "nsk.jdb.up.up002";
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    81
    static final String TEST_CLASS       = PACKAGE_NAME + ".up002";
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    82
    static final String DEBUGGEE_CLASS   = TEST_CLASS + "a";
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    83
    static final String FIRST_BREAK      = DEBUGGEE_CLASS + ".main";
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    84
    static final String LAST_BREAK       = DEBUGGEE_CLASS + ".lastBreak";
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    85
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    86
    static final String[][] FRAMES = new String[][] {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    87
        {"[1]", DEBUGGEE_CLASS + ".func5"},
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    88
        {"[2]", DEBUGGEE_CLASS + ".func4"},
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    89
        {"[3]", DEBUGGEE_CLASS + ".func3"},
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    90
        {"[4]", DEBUGGEE_CLASS + ".func2"},
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    91
        {"[5]", DEBUGGEE_CLASS + ".func1"},
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    92
        {"[6]", DEBUGGEE_CLASS + ".runIt"},
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    93
        {"[7]", DEBUGGEE_CLASS + ".main"}
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    94
                                                };
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    95
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    96
    protected void runCases() {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    97
        String[] reply;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    98
        Paragrep grep;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
    99
        int count;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   100
        Vector v;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   101
        String found;
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   102
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   103
        jdb.receiveReplyFor(JdbCommand.stop_in + DEBUGGEE_CLASS + ".func5");
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   104
        jdb.receiveReplyFor(JdbCommand.cont);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   105
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   106
        for (int i = 0; i < FRAMES.length; i++) {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   107
            jdb.receiveReplyFor(JdbCommand.where);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   108
            jdb.receiveReplyFor(JdbCommand.up);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   109
        }
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   110
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   111
        jdb.contToExit(1);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   112
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   113
        reply = jdb.getTotalReply();
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   114
        grep = new Paragrep(reply);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   115
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   116
        for (int i = 1; i < (FRAMES.length-1); i++) {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   117
            v = new Vector();
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   118
            v.add(FRAMES[i][0]);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   119
            v.add(FRAMES[i][1]);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   120
            count = grep.find(v);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   121
            if (count != (i+1)) {
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   122
                failure("Unexpected number of the stack frame: " + FRAMES[i][1] +
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   123
                    "\n\texpected value : " + (i+1) + ", got : " + count);
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   124
            }
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   125
        }
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   126
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   127
    }
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   128
31361382634b 8199379: [TESTBUG] Open source vm testbase JDB tests
iignatyev
parents:
diff changeset
   129
}