Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jpda/Debuggee.java
41161 views
/*1* Copyright (c) 2011, 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 vm.mlvm.share.jpda;2425import vm.mlvm.share.Env;26import vm.mlvm.share.MlvmTest;27import vm.share.options.Option;2829public abstract class Debuggee extends MlvmTest {3031@Option(name="debuggee.iterations", default_value="1", description="Iterations to run on debuggee")32public long _iterations = 1;3334@Option(name="debuggee.hangAt", default_value="", description="Hang up in specified point")35public String _hangAt = "";3637static {38setName("Debuggee");39}4041private boolean _isWarmingUp;4243public final boolean isWarmingUp() {44return _isWarmingUp;45}4647public final long getWarmupsCount() {48return _iterations;49}5051/**52* Used in static methods for getting access to Debuggee instance53*54* @return The current debuggee instance (there should be only one)55*/56public static Debuggee getDebuggeeInstance() {57return (Debuggee) MlvmTest.getInstance();58}5960@Override61public boolean run() throws Throwable {62startUp();63boolean result = false;64try {6566_isWarmingUp = true;67Env.traceNormal("Warming up (" + _iterations + " iterations)");68for (long w = _iterations - 1; w > 0; w--)69warmUp();70_isWarmingUp = false;7172Env.traceNormal("Starting main test");73result = runDebuggee();7475} finally {76tearDown();77}7879return result;80}8182protected void startUp() throws Throwable {83}8485protected void warmUp() throws Throwable {86}8788protected abstract boolean runDebuggee() throws Throwable;8990protected void tearDown() throws Throwable {91}9293public final void hangUpIfNeeded(String at) throws InterruptedException {94if (!_isWarmingUp && at.equals(_hangAt)) {95Env.traceNormal("Hanging at " + at);96hangupImpl();97} else {98if ( isWarmingUp() )99Env.traceDebug("Passing " + at);100else101Env.traceNormal("Passing " + at);102}103}104105protected void hangupImpl() throws InterruptedException {106for (;;)107Thread.sleep(60000);108}109}110111112