Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/wherei/wherei001/wherei001.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/wherei/wherei001.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* A positive test case for the 'wherei <thread id>' command.32* The test checks if jdb correctly reports stack trace for33* every checked thread id.34* COMMENTS35*36* @library /vmTestbase37* /test/lib38* @build nsk.jdb.wherei.wherei001.wherei001a39* @run main/othervm40* nsk.jdb.wherei.wherei001.wherei00141* -arch=${os.family}-${os.simpleArch}42* -waittime=543* -debugee.vmkind=java44* -transport.address=dynamic45* -jdb=${test.jdk}/bin/jdb46* -java.options="${test.vm.opts} ${test.java.opts}"47* -workdir=.48* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"49*/5051package nsk.jdb.wherei.wherei001;5253import nsk.share.*;54import nsk.share.jdb.*;5556import java.io.*;57import java.util.*;5859public class wherei001 extends JdbTest {6061public static void main (String argv[]) {62System.exit(run(argv, System.out) + JCK_STATUS_BASE);63}6465public static int run(String argv[], PrintStream out) {66debuggeeClass = DEBUGGEE_CLASS;67firstBreak = FIRST_BREAK;68lastBreak = LAST_BREAK;69return new wherei001().runTest(argv, out);70}7172static final String PACKAGE_NAME = "nsk.jdb.wherei.wherei001";73static final String TEST_CLASS = PACKAGE_NAME + ".wherei001";74static final String DEBUGGEE_CLASS = TEST_CLASS + "a";75static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";76static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";77static final String DEBUGGEE_THREAD = PACKAGE_NAME + ".MyThread";7879protected void runCases() {80String[] reply;81Paragrep grep;82int count;83Vector v;84String found;85String[] threads;8687jdb.setBreakpointInMethod(LAST_BREAK);88reply = jdb.receiveReplyFor(JdbCommand.cont);8990threads = jdb.getThreadIds(DEBUGGEE_THREAD);9192if (threads.length != 5) {93log.complain("jdb should report 5 instance of " + DEBUGGEE_THREAD);94log.complain("Found: " + threads.length);95success = false;96}9798for (int i = 0; i < threads.length; i++) {99if (!checkStack(threads[i])) {100success = false;101}102}103104jdb.contToExit(1);105}106107private boolean checkStack (String threadId) {108Paragrep grep;109String[] reply;110String found;111int count;112Vector v;113boolean result = true;114String[] func = { "func5", "func4", "func3", "func2", "func1", "run" };115116reply = jdb.receiveReplyFor(JdbCommand.wherei + threadId);117118grep = new Paragrep(reply);119for (int i = 0; i < func.length; i++) {120count = grep.find(DEBUGGEE_THREAD + "." + func[i]);121if (count != 1) {122log.complain("Contents of stack trace is incorrect for thread " + threadId);123log.complain("Searched for: " + DEBUGGEE_THREAD + "." + func[i]);124log.complain("Count : " + count);125result= false;126}127}128return result;129}130}131132133