Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/HiddenClass/events/DebuggeeBase.java
41161 views
/*1* Copyright (c) 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*/2223package nsk.jdi.HiddenClass.events;2425import nsk.share.Log;26import nsk.jdi.HiddenClass.events.DebuggerBase;27import nsk.share.jdi.ArgumentHandler;28import nsk.share.jpda.IOPipe;2930/* Debuggee base class. */31class DebuggeeBase {32private final IOPipe pipe;33private final Log log;3435protected void logMsg(String msg) { log.display(msg); }3637protected DebuggeeBase(ArgumentHandler argHandler) {38pipe = argHandler.createDebugeeIOPipe();39log = argHandler.createDebugeeLog();40}4142protected void syncWithDebugger() {43// Notify debugger that debuggee is ready.44logMsg("Debuggee: Sending command: " + DebuggerBase.COMMAND_READY);45pipe.println(DebuggerBase.COMMAND_READY);4647// Wait for COMMAND_RUN from debugger to continue execution.48logMsg("Debuggee: Waiting for command: " + DebuggerBase.COMMAND_RUN);49String command = pipe.readln();50if (command == null || !command.equals(DebuggerBase.COMMAND_RUN)) {51logMsg("FAIL: Debugee: unknown command: " + command);52throw new RuntimeException("Failed in sync with debugger. ");53}54}5556protected void quitSyncWithDebugger() {57// Notify debugger about debuggee completed status.58logMsg("Debuggee: Sending command: " + DebuggerBase.COMMAND_DONE);59pipe.println(DebuggerBase.COMMAND_DONE);6061// Wait for command QUIT from debugger to release started threads and exit.62logMsg("Debuggee: Waiting for command: " + DebuggerBase.COMMAND_QUIT);63String command = pipe.readln();64if (command == null || !command.equals(DebuggerBase.COMMAND_QUIT)) {65logMsg("FAIL: Debugee: unknown command: " + command);66throw new RuntimeException("Failed in sync with debugger. ");67}68}69}707172