Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/SerialExecutionDebuggee.java
41161 views
1
/*
2
* Copyright (c) 2006, 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
package nsk.share.jdi;
24
25
import java.io.IOException;
26
import java.io.StreamTokenizer;
27
import java.io.StringReader;
28
import nsk.share.Consts;
29
import sun.hotspot.WhiteBox;
30
31
/*
32
* This class is intended for execution several JDI tests in single VM and used together with nsk.share.jdi.SerialExecutionDebugger
33
*
34
* SerialExecutionDebuggee handles 2 commands:
35
* - COMMAND_EXECUTE_DEBUGGEE:<debuggee_class_name> :
36
* initialize 'currentDebuggee' with instance of class 'debuggee_class_name'(this class should
37
* be subclass of nsk.share.jpda.AbstractDebugeeTest) and execute it's method doTest()
38
*
39
* - COMMAND_CLEAR_DEBUGGEE
40
* set 'currentDebuggee' to null
41
*
42
* For more detailed description of serial test execution see SerialExecutionDebugger
43
*/
44
public class SerialExecutionDebuggee extends AbstractJDIDebuggee {
45
private final WhiteBox WB = WhiteBox.getWhiteBox();
46
47
public static void main(String args[]) {
48
new SerialExecutionDebuggee().doTest(args);
49
}
50
51
// command:<debuggee_class_name>[ debugee_parameters]
52
public static final String COMMAND_EXECUTE_DEBUGGEE = "COMMAND_EXECUTE_DEBUGGEE";
53
54
public static final String COMMAND_CLEAR_DEBUGGEE = "COMMAND_CLEAR_DEBUGGEE";
55
56
private AbstractJDIDebuggee currentDebuggee;
57
58
public boolean parseCommand(String command) {
59
if (super.parseCommand(command))
60
return true;
61
62
if (command.startsWith(COMMAND_EXECUTE_DEBUGGEE)) {
63
String debuggeeClassName = null;
64
65
try {
66
StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(command));
67
tokenizer.resetSyntax();
68
tokenizer.wordChars(Integer.MIN_VALUE, Integer.MAX_VALUE);
69
tokenizer.whitespaceChars(':', ':');
70
71
tokenizer.nextToken();
72
73
if (tokenizer.nextToken() != StreamTokenizer.TT_WORD) {
74
log.complain("Invalid command format: " + command);
75
System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
76
}
77
78
debuggeeClassName = tokenizer.sval;
79
} catch (IOException e) {
80
log.complain("Invalid command format: " + command);
81
System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
82
}
83
84
try {
85
// parse debuggee parameters
86
String[] debuggeeParameters = {};
87
88
int index = debuggeeClassName.indexOf(' ');
89
90
if (index > 0) {
91
debuggeeParameters = debuggeeClassName.substring(index).split(" ");
92
log.display("Debuggee parameters: " + debuggeeClassName.substring(index));
93
debuggeeClassName = debuggeeClassName.substring(0, index);
94
}
95
96
// create debuggee object
97
Class debuggeeClass = Class.forName(debuggeeClassName);
98
99
if (!AbstractJDIDebuggee.class.isAssignableFrom(debuggeeClass)) {
100
log.complain("Invalid debugee class: " + debuggeeClass);
101
System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
102
}
103
104
currentDebuggee = (AbstractJDIDebuggee) debuggeeClass.newInstance();
105
106
// pass to the current debuggee already created objects:
107
// argHandler, log, pipe
108
currentDebuggee.initDebuggee(argHandler, log, pipe, debuggeeParameters, false);
109
} catch (Exception e) {
110
log.complain("Unexpected exception during debuggee initialization: " + e);
111
e.printStackTrace(log.getOutStream());
112
System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
113
}
114
115
try {
116
// current debuggee performs test
117
currentDebuggee.doTest();
118
119
if (currentDebuggee.getSuccess()) {
120
log.display("Debuggee " + currentDebuggee + " finished successfully");
121
} else {
122
setSuccess(false);
123
log.complain("Debuggee " + currentDebuggee + "finished with errors");
124
}
125
126
return true;
127
} catch (Exception e) {
128
log.complain("Unexpected exception during debuggee execution: " + e);
129
e.printStackTrace(log.getOutStream());
130
System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
131
}
132
} else if (command.equals(COMMAND_CLEAR_DEBUGGEE)) {
133
currentDebuggee = null;
134
135
// The debuggee can intentionally create inflated monitors.
136
// With async deflation, this can pin a StateTestThread object
137
// until the next deflation cycle. This can confuse tests run
138
// by nsk/jdi/stress/serial/mixed002/TestDescription.java that
139
// expect only one StateTestThread object to exist in each
140
// of the debugger tests that mixed002 runs serially in the
141
// same VM.
142
WB.deflateIdleMonitors();
143
144
return true;
145
}
146
147
return false;
148
}
149
150
}
151
152