Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/dump/dump002/dump002.java
40951 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/dump/dump002.28* VM Testbase keywords: [quick, jpda, jdb]29* VM Testbase readme:30* DESCRIPTION31* This is a test for the 'dump' command.32* The test works as follows. Upon the debuggee is suspended33* on breakpoint, jdb issues 'dump' command for an object34* of debugged class and for element in array fields.35* The test passes if all checked fields with their values36* are listed.37* The test consists of two parts:38* dump002.java - test driver, i.e. launches jdb and debuggee,39* writes commands to jdb, reads the jdb output,40* dump002a.java - the debugged application.41* COMMENTS42* The test replaces the nsk/jdb/dump/dump001 one.43* Test fixed according to test bug:44* 5045859 TEST_BUG: some JDB tests do not recognize JDB prompt45*46* @library /vmTestbase47* /test/lib48* @build nsk.jdb.dump.dump002.dump002a49* @run main/othervm50* nsk.jdb.dump.dump002.dump00251* -arch=${os.family}-${os.simpleArch}52* -waittime=553* -debugee.vmkind=java54* -transport.address=dynamic55* -jdb=${test.jdk}/bin/jdb56* -java.options="${test.vm.opts} ${test.java.opts}"57* -workdir=.58* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"59*/6061package nsk.jdb.dump.dump002;6263import nsk.share.*;64import nsk.share.jdb.*;6566import java.io.*;67import java.util.*;6869public class dump002 extends JdbTest {7071public static void main (String argv[]) {72System.exit(run(argv, System.out) + JCK_STATUS_BASE);73}7475public static int run(String argv[], PrintStream out) {76debuggeeClass = DEBUGGEE_CLASS;77firstBreak = FIRST_BREAK;78lastBreak = LAST_BREAK;79compoundPromptIdent = COMPOUND_PROMPT_IDENT;80return new dump002().runTest(argv, out);81}8283static final String PACKAGE_NAME = "nsk.jdb.dump.dump002";84static final String TEST_CLASS = PACKAGE_NAME + ".dump002";85static final String DEBUGGEE_CLASS = TEST_CLASS + "a";86static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";87static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";88static final String COMPOUND_PROMPT_IDENT = "main";8990static final String[] CHECKED_FIELDS = {91"_dump002a",92"iStatic",93"iPrivate",94"iProtect",95"iPublic",96"iFinal",97"iTransient",98"iVolatile",99"iArray",100"sStatic",101"sPrivate",102"sProtected",103"sPublic",104"sFinal",105"sTransient",106"sVolatile",107"sArray",108"fBoolean",109"fByte",110"fChar",111"fDouble",112"fFloat",113"fInt",114"fLong",115"fShort"116};117118protected void runCases() {119String[] reply;120Paragrep grep;121int count;122Vector v = new Vector();123String found;124125jdb.setBreakpointInMethod(LAST_BREAK);126reply = jdb.receiveReplyFor(JdbCommand.cont);127128reply = jdb.receiveReplyFor(JdbCommand.dump + DEBUGGEE_CLASS + "._dump002a");129grep = new Paragrep(reply);130for (int i = 0; i < CHECKED_FIELDS.length; i++) {131v.setSize(0);132v.add(CHECKED_FIELDS[i]);133v.add("null");134if (grep.find(v) > 0) {135failure("The field is not dumped : " + CHECKED_FIELDS[i]);136}137}138139String checkedField = DEBUGGEE_CLASS + ".iArray[0]";140reply = jdb.receiveReplyFor(JdbCommand.dump + checkedField);141checkField(reply, checkedField);142143checkedField = DEBUGGEE_CLASS + ".sArray[0]";144reply = jdb.receiveReplyFor(JdbCommand.dump + checkedField);145checkField(reply, checkedField);146147jdb.contToExit(1);148}149150void checkField (String[] reply, String fieldName) {151Paragrep grep;152Vector v = new Vector();153154grep = new Paragrep(reply);155v.setSize(0);156v.add(fieldName);157v.add("null");158if (grep.find(v) > 0) {159failure("The field is not dumped : " + fieldName);160}161}162}163164165