Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java
41161 views
/*1* Copyright (c) 2002, 2018, 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*/2223package nsk.jdi.EventRequestManager.createStepRequest;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829// THIS TEST IS LINE NUMBER SENSITIVE3031/**32* The debugged application of the test.33*/34public class crstepreq003a {3536//----------------------------------------------------- immutable common fields3738static final int PASSED = 0;39static final int FAILED = 2;40static final int PASS_BASE = 95;41static final int quit = -1;4243static int instruction = 1;44static int lineForComm = 2;45static int exitCode = PASSED;4647private static ArgumentHandler argHandler;48private static Log log;49private static IOPipe pipe;5051//------------------------------------------------------ mutable common fields5253//------------------------------------------------------ test specific fields5455static Object waitnotifyObj = new Object();5657//------------------------------------------------------ mutable common method5859public static void main (String argv[]) {6061argHandler = new ArgumentHandler(argv);62log = new Log(System.out, argHandler);63pipe = argHandler.createDebugeeIOPipe(log);6465display("debuggee started!");6667label0:68for (int testCase = 0; instruction != quit; testCase++) {6970switch (testCase) {71//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test case section72case 0:7374Thread thread0 = new Thread0crstepreq003a("thread0");75threadStart(thread0);76threadJoin (thread0, "0");77break;7879case 1:8081Thread thread1 = new Thread0crstepreq003a("thread1");82threadStart(thread1);83threadJoin (thread1, "1");84break;8586case 2:8788Thread thread2 = new Thread0crstepreq003a("thread2");89threadStart(thread2);90threadJoin (thread2, "2");9192//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end of section9394default:95instruction = quit;96break;97}9899// display("call methodForCommunication() #0");100// methodForCommunication();101if (instruction == quit)102break;103}104105display("debuggee exits");106System.exit(PASSED + PASS_BASE);107}108109//--------------------------------------------------------- test specific methodss110111static void threadJoin (Thread t, String number) {112try {113t.join();114} catch ( InterruptedException e ) {115exitCode = FAILED;116complain("Case #" + number + ": caught unexpected InterruptedException while waiting for thread finish" );117}118}119120static int threadStart (Thread t) {121synchronized (waitnotifyObj) {122t.start();123try {124waitnotifyObj.wait();125} catch (InterruptedException e) {126exitCode = FAILED;127complain("Caught unexpected InterruptedException while waiting for thread start" );128return FAILED;129}130}131return PASSED;132}133134static void breakInThread() {135Object dummy = new Object();136synchronized(dummy) { // crstepreq003.lineForBreakInThread137int i = 1; // This is line of step event's location for STEP_OVER and STEP_INTO -- crstepreq003.checkedLines[0-1]138}139}140141//---------------------------------------------------------- immutable common methods142143static void display(String msg) {144log.display("debuggee > " + msg);145}146147static void complain(String msg) {148log.complain("debuggee FAILURE > " + msg);149}150151private static void methodForCommunication() {152int i = instruction;153int curInstruction = i;154}155}156157//--------------------------------------------------------- test specific classes158159/**160* This thread will be suspended on breakpoint. No locks are used.161*/162class Thread0crstepreq003a extends Thread {163public Thread0crstepreq003a (String name) {164super(name);165}166167public void run() {168crstepreq003a.display("enter thread " + getName());169170synchronized(crstepreq003a.waitnotifyObj) {171crstepreq003a.waitnotifyObj.notifyAll();172}173174crstepreq003a.display("call breakInThread()");175crstepreq003a.breakInThread();176177crstepreq003a.display("exit thread " + getName()); // This is line of step event's location for STEP_OUT -- crstepreq003.checkedLines[2]178}179}180181182