Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/step/step002/step002.java
40955 views
/*1* Copyright (c) 2003, 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/step/step002.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* The test for the 'step' command.32* The test checks the following cases:33* - step inside current method,34* - step into called method,35* - step up to calling method.36* The test works as follows. The jdb sets breakpoint at the line37* where new value is assigned to local variable. The jdb issues38* 'step' command. Then the test checks whether a step is done by39* requesting a value of local variable using 'eval' command.40* The next two cases are checked with a pair of 'step' and41* 'where' commands. The test checks a stack trace after step42* using 'where' command.43* The test consists of two program:44* step002.java - test driver, i.e. launches jdb and debuggee,45* writes commands to jdb, reads the jdb output,46* step002a.java - the debugged application.47* COMMENTS48* This test replaces the nsk/jdb/step/step002 one.49*50* @library /vmTestbase51* /test/lib52* @build nsk.jdb.step.step002.step00253*54* @comment make sure step002a is compiled w/ full debug info55* @clean nsk.jdb.step.step002.step002a56* @compile -g:lines,source,vars step002a.java57*58* @run main/othervm59* nsk.jdb.step.step002.step00260* -arch=${os.family}-${os.simpleArch}61* -waittime=562* -debugee.vmkind=java63* -transport.address=dynamic64* -jdb=${test.jdk}/bin/jdb65* -java.options="${test.vm.opts} ${test.java.opts}"66* -workdir=.67* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"68*/6970package nsk.jdb.step.step002;7172import nsk.share.*;73import nsk.share.jdb.*;7475import java.io.*;76import java.util.*;7778public class step002 extends JdbTest {7980public static void main (String argv[]) {81System.exit(run(argv, System.out) + JCK_STATUS_BASE);82}8384public static int run(String argv[], PrintStream out) {85debuggeeClass = DEBUGGEE_CLASS;86firstBreak = FIRST_BREAK;87lastBreak = LAST_BREAK;88return new step002().runTest(argv, out);89}9091static final String PACKAGE_NAME = "nsk.jdb.step.step002";92static final String TEST_CLASS = PACKAGE_NAME + ".step002";93static final String DEBUGGEE_CLASS = TEST_CLASS + "a";94static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";95static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";96static final int BREAKPOINT_LINE = 50;9798protected void runCases() {99String[] reply;100Paragrep grep;101int count;102Vector v;103String found;104String[] threads;105106reply = jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE);107reply = jdb.receiveReplyFor(JdbCommand.cont);108109// case #1 : step inside frame;110reply = jdb.receiveReplyFor(JdbCommand.step);111reply = jdb.receiveReplyFor(JdbCommand.eval + "intVar");112grep = new Paragrep(reply);113if (grep.find("1234") == 0) {114failure("CASE #1 FAILED: Wrong location after step inside current method");115}116117// case #1 : step into called frame;118reply = jdb.receiveReplyFor(JdbCommand.step);119reply = jdb.receiveReplyFor(JdbCommand.where);120grep = new Paragrep(reply);121if (grep.find("foo") == 0) {122failure("CASE #2 FAILED: Wrong location after step into called method");123}124125// case #1 : step out to calling frame;126reply = jdb.receiveReplyFor(JdbCommand.step);127reply = jdb.receiveReplyFor(JdbCommand.where);128grep = new Paragrep(reply);129if (grep.find("foo") > 0) {130failure("CASE #2 FAILED: Wrong location after step up to calling method");131}132if (grep.find("runIt") == 0) {133failure("CASE #2 FAILED: Wrong location after step up to calling method");134}135136jdb.contToExit(1);137}138}139140141