Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/up/up002/up002.java
40951 views
/*1* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324/*25* @test26*27* @summary converted from VM Testbase nsk/jdb/up/up002.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* This tests the jdb 'up' command. The test sets a breakpoint32* at 'func5' method in debugged 'nsk.jdb.up.up002a' class and then33* runs the debugee. Once, an execution suspends at 'func5' method,34* the 'up' command is issued to the debugger several times.35* The output is processed by counting the number of times36* each method name appears in the stack trace. The test passes37* if the obtained count matches the expected one.38* COMMENTS39* This test functionally equals to nsk/jdb/up/up001 test and40* replaces it.41*42* @library /vmTestbase43* /test/lib44* @build nsk.jdb.up.up002.up002a45* @run main/othervm46* nsk.jdb.up.up002.up00247* -arch=${os.family}-${os.simpleArch}48* -waittime=549* -debugee.vmkind=java50* -transport.address=dynamic51* -jdb=${test.jdk}/bin/jdb52* -java.options="${test.vm.opts} ${test.java.opts}"53* -workdir=.54* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"55*/5657package nsk.jdb.up.up002;5859import nsk.share.*;60import nsk.share.jdb.*;6162import java.io.*;63import java.util.*;6465public class up002 extends JdbTest {6667public static void main (String argv[]) {68System.exit(run(argv, System.out) + JCK_STATUS_BASE);69}7071public static int run(String argv[], PrintStream out) {72debuggeeClass = DEBUGGEE_CLASS;73firstBreak = FIRST_BREAK;74lastBreak = LAST_BREAK;75return new up002().runTest(argv, out);76}7778static final String PACKAGE_NAME = "nsk.jdb.up.up002";79static final String TEST_CLASS = PACKAGE_NAME + ".up002";80static final String DEBUGGEE_CLASS = TEST_CLASS + "a";81static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";82static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";8384static final String[][] FRAMES = new String[][] {85{"[1]", DEBUGGEE_CLASS + ".func5"},86{"[2]", DEBUGGEE_CLASS + ".func4"},87{"[3]", DEBUGGEE_CLASS + ".func3"},88{"[4]", DEBUGGEE_CLASS + ".func2"},89{"[5]", DEBUGGEE_CLASS + ".func1"},90{"[6]", DEBUGGEE_CLASS + ".runIt"},91{"[7]", DEBUGGEE_CLASS + ".main"}92};9394protected void runCases() {95String[] reply;96Paragrep grep;97int count;98Vector v;99String found;100101jdb.receiveReplyFor(JdbCommand.stop_in + DEBUGGEE_CLASS + ".func5");102jdb.receiveReplyFor(JdbCommand.cont);103104for (int i = 0; i < FRAMES.length; i++) {105jdb.receiveReplyFor(JdbCommand.where);106jdb.receiveReplyFor(JdbCommand.up);107}108109jdb.contToExit(1);110111reply = jdb.getTotalReply();112grep = new Paragrep(reply);113114for (int i = 1; i < (FRAMES.length-1); i++) {115v = new Vector();116v.add(FRAMES[i][0]);117v.add(FRAMES[i][1]);118count = grep.find(v);119if (count != (i+1)) {120failure("Unexpected number of the stack frame: " + FRAMES[i][1] +121"\n\texpected value : " + (i+1) + ", got : " + count);122}123}124125}126127}128129130