Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java
41161 views
/*1* Copyright (c) 2001, 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.EventSet.resume;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829/**30* This class is used as debuggee application for the resume006 JDI test.31*/3233public class resume006a {3435//----------------------------------------------------- template section3637static final int PASSED = 0;38static final int FAILED = 2;39static final int PASS_BASE = 95;4041static ArgumentHandler argHandler;42static Log log;43static int testCase = -1;4445//-------------------------------------------------- log procedures4647private static void log1(String message) {48log.display("**> debuggee: " + message);49}5051private static void logErr(String message) {52log.complain("**> debuggee: " + message);53}5455//====================================================== test program5657static resume006aTestClass tcObject = new resume006aTestClass();5859//------------------------------------------------------ common section60static int instruction = 1;61static int end = 0;62// static int quit = 0;63// static int continue = 2;64static int maxInstr = 1; // 2;6566static int lineForComm = 2;6768private static void methodForCommunication() {69int i1 = instruction;70int i2 = i1;71int i3 = i2;72}73//---------------------------------------------------- main method7475public static void main (String argv[]) {7677argHandler = new ArgumentHandler(argv);78log = argHandler.createDebugeeLog();7980log1("debuggee started!");8182int exitCode = PASSED;838485label0:86for (int i = 0; ; i++) {8788if (instruction > maxInstr) {89logErr("ERROR: unexpected instruction: " + instruction);90exitCode = FAILED;91break ;92}9394log1("methodForCommunication(); : " + i);95methodForCommunication();9697switch (i) {9899//------------------------------------------------------ section tested100101case 0:102resume006aTestClass.method();103// Wait for debugger to complete the first test case104// before advancing to the next breakpoint105waitForTestCase(0);106break;107108case 1: resume006aTestClass.method();109break;110111case 2: resume006aTestClass.method();112113//------------------------------------------------- standard end section114115default:116instruction = end;117methodForCommunication();118break label0;119}120}121122log1("debuggee exits");123System.exit(exitCode + PASS_BASE);124}125// Synchronize with debugger progression.126static void waitForTestCase(int t) {127while (testCase < t) {128try {129Thread.sleep(100);130} catch (InterruptedException e) {131// ignored132}133}134}135}136137class resume006aTestClass {138139static int breakpointLine = 3;140static String awFieldName = "var1";141static String mwFieldName = "var2";142143static int var1 = 0;144static int var2 = 0;145static int var3 = 0;146147static void method () {148var1 = 1;149var3 = var1;150var2 = var3;151}152}153154155