Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/where/where005/where005.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/where005.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* A test case for the 'where' command. The debugged 'where005a'32* application throws a null pointer exception in 'func6()' method.33* The test passes if the 'where' command produces the correct34* stack trace.35* COMMENTS36* This test functionally equals to nsk/jdb/where/where002 test37* and replaces it.38* Modified due to fix of the bug:39* 4818762 TEST_BUG: two jdb test incorrectly check debuggee exit code40*41* @library /vmTestbase42* /test/lib43* @build nsk.jdb.where.where005.where005a44* @run main/othervm45* nsk.jdb.where.where005.where00546* -arch=${os.family}-${os.simpleArch}47* -waittime=548* -debugee.vmkind=java49* -transport.address=dynamic50* -jdb=${test.jdk}/bin/jdb51* -java.options="${test.vm.opts} ${test.java.opts}"52* -workdir=.53* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"54*/5556package nsk.jdb.where.where005;5758import nsk.share.*;59import nsk.share.jdb.*;6061import java.io.*;62import java.util.*;6364public class where005 extends JdbTest {6566public static void main (String argv[]) {67System.exit(run(argv, System.out) + JCK_STATUS_BASE);68}6970public static int run(String argv[], PrintStream out) {71debuggeeClass = DEBUGGEE_CLASS;72firstBreak = FIRST_BREAK;73lastBreak = LAST_BREAK;74return new where005(true).runTest(argv, out);75}7677public where005 (boolean debuggeeShouldFail) {78super(debuggeeShouldFail);79}8081static final String PACKAGE_NAME = "nsk.jdb.where.where005";82static final String TEST_CLASS = PACKAGE_NAME + ".where005";83static final String DEBUGGEE_CLASS = TEST_CLASS + "a";84static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";85static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";8687static final String[][] FRAMES = new String[][] {88{DEBUGGEE_CLASS + ".func6", "76"},89{DEBUGGEE_CLASS + ".func5", "71"},90{DEBUGGEE_CLASS + ".func4", "67"},91{DEBUGGEE_CLASS + ".func3", "63"},92{DEBUGGEE_CLASS + ".func2", "59"},93{DEBUGGEE_CLASS + ".func1", "55"},94{DEBUGGEE_CLASS + ".runIt", "48"},95{DEBUGGEE_CLASS + ".main", "39"}96};97protected void runCases() {98String[] reply;99Paragrep grep;100int count;101Vector v;102String found;103104reply = jdb.receiveReplyFor(JdbCommand.cont);105grep = new Paragrep(reply);106107if (grep.find("NullPointerException") == 0) {108failure("Expected NullPointerException is not thrown");109} else {110reply = jdb.receiveReplyFor(JdbCommand.where);111grep = new Paragrep(reply);112113for (int i = 0; i < FRAMES.length; i++) {114v = new Vector();115v.add(FRAMES[i][0]);116v.add(FRAMES[i][1]);117count = grep.find(v);118if (count != 1) {119failure("Unexpected number or location of the stack frame: " + FRAMES[i][0] +120"\n\texpected value : 1, got one: " + count);121}122}123}124jdb.sendCommand(JdbCommand.quit);125}126}127128129