Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/HiddenClass/events/DebuggeeBase.java
41161 views
1
/*
2
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package nsk.jdi.HiddenClass.events;
25
26
import nsk.share.Log;
27
import nsk.jdi.HiddenClass.events.DebuggerBase;
28
import nsk.share.jdi.ArgumentHandler;
29
import nsk.share.jpda.IOPipe;
30
31
/* Debuggee base class. */
32
class DebuggeeBase {
33
private final IOPipe pipe;
34
private final Log log;
35
36
protected void logMsg(String msg) { log.display(msg); }
37
38
protected DebuggeeBase(ArgumentHandler argHandler) {
39
pipe = argHandler.createDebugeeIOPipe();
40
log = argHandler.createDebugeeLog();
41
}
42
43
protected void syncWithDebugger() {
44
// Notify debugger that debuggee is ready.
45
logMsg("Debuggee: Sending command: " + DebuggerBase.COMMAND_READY);
46
pipe.println(DebuggerBase.COMMAND_READY);
47
48
// Wait for COMMAND_RUN from debugger to continue execution.
49
logMsg("Debuggee: Waiting for command: " + DebuggerBase.COMMAND_RUN);
50
String command = pipe.readln();
51
if (command == null || !command.equals(DebuggerBase.COMMAND_RUN)) {
52
logMsg("FAIL: Debugee: unknown command: " + command);
53
throw new RuntimeException("Failed in sync with debugger. ");
54
}
55
}
56
57
protected void quitSyncWithDebugger() {
58
// Notify debugger about debuggee completed status.
59
logMsg("Debuggee: Sending command: " + DebuggerBase.COMMAND_DONE);
60
pipe.println(DebuggerBase.COMMAND_DONE);
61
62
// Wait for command QUIT from debugger to release started threads and exit.
63
logMsg("Debuggee: Waiting for command: " + DebuggerBase.COMMAND_QUIT);
64
String command = pipe.readln();
65
if (command == null || !command.equals(DebuggerBase.COMMAND_QUIT)) {
66
logMsg("FAIL: Debugee: unknown command: " + command);
67
throw new RuntimeException("Failed in sync with debugger. ");
68
}
69
}
70
}
71
72