Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/where/where004/where004.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/where/where004.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* A test case for the 'where' command. The test sets a breakpoint32* at func5() in debugged `where004a` class and then runs debugee.33* Once, execution comes to a halt at func5(), the 'where' command34* is issued to the debugger. The test passes if items printed in35* stack trace are equal to expected ones.36* COMMENTS37* This test functionally equals to nsk/jdb/where/where001 test38* and replaces it.39*40* @library /vmTestbase41* /test/lib42* @build nsk.jdb.where.where004.where004a43* @run main/othervm44* nsk.jdb.where.where004.where00445* -arch=${os.family}-${os.simpleArch}46* -waittime=547* -debugee.vmkind=java48* -transport.address=dynamic49* -jdb=${test.jdk}/bin/jdb50* -java.options="${test.vm.opts} ${test.java.opts}"51* -workdir=.52* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"53*/5455package nsk.jdb.where.where004;5657import nsk.share.*;58import nsk.share.jdb.*;5960import java.io.*;61import java.util.*;6263public class where004 extends JdbTest {6465public static void main (String argv[]) {66System.exit(run(argv, System.out) + JCK_STATUS_BASE);67}6869public static int run(String argv[], PrintStream out) {70debuggeeClass = DEBUGGEE_CLASS;71firstBreak = FIRST_BREAK;72lastBreak = LAST_BREAK;73return new where004().runTest(argv, out);74}7576static final String PACKAGE_NAME = "nsk.jdb.where.where004";77static final String TEST_CLASS = PACKAGE_NAME + ".where004";78static final String DEBUGGEE_CLASS = TEST_CLASS + "a";79static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";80static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";8182static final String[][] FRAMES = new String[][] {83{DEBUGGEE_CLASS + ".func5", "71"},84{DEBUGGEE_CLASS + ".func4", "67"},85{DEBUGGEE_CLASS + ".func3", "63"},86{DEBUGGEE_CLASS + ".func2", "59"},87{DEBUGGEE_CLASS + ".func1", "55"},88{DEBUGGEE_CLASS + ".runIt", "48"},89{DEBUGGEE_CLASS + ".main", "39"}90};91protected void runCases() {92String[] reply;93Paragrep grep;94int count;95Vector v;96String found;9798jdb.receiveReplyFor(JdbCommand.stop_in + DEBUGGEE_CLASS + ".func5");99jdb.receiveReplyFor(JdbCommand.cont);100101reply = jdb.receiveReplyFor(JdbCommand.where);102grep = new Paragrep(reply);103104for (int i = 0; i < FRAMES.length; i++) {105v = new Vector();106v.add(FRAMES[i][0]);107v.add(FRAMES[i][1]);108count = grep.find(v);109if (count != 1) {110failure("Unexpected number or location of the stack frame: " + FRAMES[i][0] +111"\n\texpected value : 1, got one: " + count);112}113}114115jdb.contToExit(1);116}117}118119120