Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/untrace/untrace001/untrace001.java
40951 views
1
/*
2
* Copyright (c) 2002, 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
25
/*
26
* @test
27
*
28
* @summary converted from VM Testbase nsk/jdb/untrace/untrace001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test case for the 'untrace methods <thread id>' command.
33
* The debuggee program (untrace001a.java) creates an additional
34
* thread with name like "MyThread-1" and starts it. The jdb
35
* suspends the debuggee at a moment when the additional thread is
36
* waiting for notification for lock objects and then turns on method
37
* tracing for this thread by 'trace methods <thread id>' command.
38
* After expected notification the additional thread invokes checked
39
* debuggee's methods. Thus jdb output must have the trace messages of checked methods'
40
* entrance and exit.
41
* At second phase jdb suspends the debuggee and turns off tracing
42
* by checked command. After resuming the debuggee's additional
43
* thread invokes checked methods again. Tracing messages and debuggee's
44
* suspentions are not expected at this moment.
45
* The test passes if jdb output has one 'enter' messages and one 'exit'
46
* messages for every checked method.
47
* The test consists of two program:
48
* untrace001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
49
* untrace001a.java - the debugged application.
50
* COMMENTS
51
* Modified due to fix of the bug:
52
* 4785781 TTY: debuggee hangs in jdb 'untrace001' test in Mantis
53
*
54
* @library /vmTestbase
55
* /test/lib
56
* @build nsk.jdb.untrace.untrace001.untrace001a
57
* @run main/othervm
58
* nsk.jdb.untrace.untrace001.untrace001
59
* -arch=${os.family}-${os.simpleArch}
60
* -waittime=5
61
* -debugee.vmkind=java
62
* -transport.address=dynamic
63
* -jdb=${test.jdk}/bin/jdb
64
* -java.options="${test.vm.opts} ${test.java.opts}"
65
* -workdir=.
66
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
67
*/
68
69
package nsk.jdb.untrace.untrace001;
70
71
import nsk.share.*;
72
import nsk.share.jdb.*;
73
74
import java.io.*;
75
import java.util.*;
76
77
public class untrace001 extends JdbTest {
78
79
public static void main (String argv[]) {
80
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
81
}
82
83
public static int run(String argv[], PrintStream out) {
84
debuggeeClass = DEBUGGEE_CLASS;
85
firstBreak = FIRST_BREAK;
86
lastBreak = LAST_BREAK;
87
return new untrace001().runTest(argv, out);
88
}
89
90
static final String PACKAGE_NAME = "nsk.jdb.untrace.untrace001";
91
static final String TEST_CLASS = PACKAGE_NAME + ".untrace001";
92
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
93
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
94
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
95
static final String MYTHREAD = "MyThread";
96
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
97
98
static final String[] CHECKED_METHODS = {"func1", "func2", "func3"};
99
100
protected void runCases() {
101
String[] reply;
102
Paragrep grep;
103
int count;
104
Vector v;
105
String found;
106
String[] threads;
107
108
jdb.setBreakpointInMethod(LAST_BREAK);
109
reply = jdb.receiveReplyFor(JdbCommand.cont);
110
111
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
112
113
if (threads.length != 1) {
114
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
115
log.complain("Found: " + threads.length);
116
success = false;
117
}
118
119
for (int i = 0; i < threads.length; i++) {
120
reply = jdb.receiveReplyFor(JdbCommand.trace + "methods " + threads[i]);
121
}
122
123
// resumes debuggee suspended on method enter and exit until hit of the breakpoint
124
for (int i = 0; i < (CHECKED_METHODS.length*threads.length*2 + 1); i++) {
125
reply = jdb.receiveReplyFor(JdbCommand.cont);
126
}
127
128
for (int i = 0; i < threads.length; i++) {
129
reply = jdb.receiveReplyFor(JdbCommand.untrace + "methods " + threads[i]);
130
}
131
132
jdb.contToExit(CHECKED_METHODS.length*threads.length*2 + 2);
133
134
reply = jdb.getTotalReply();
135
if (!checkTrace(CHECKED_METHODS, reply)) {
136
success = false;
137
}
138
}
139
140
private boolean checkTrace (String[] checkedMethods, String[] reply) {
141
Paragrep grep;
142
String found;
143
int count;
144
Vector v = new Vector();
145
boolean result = true;
146
147
grep = new Paragrep(reply);
148
for (int i = 0; i < checkedMethods.length; i++) {
149
v.removeAllElements();
150
v.add(DEBUGGEE_THREAD + "." + checkedMethods[i]);
151
v.add("Method entered");
152
count = grep.find(v);
153
if (count != 1) {
154
log.complain("Count of method enter is incorrect for the method : " + DEBUGGEE_THREAD + "." + checkedMethods[i]);
155
log.complain("Should be 1 trace messages, found : " + count);
156
result= false;
157
}
158
159
v.removeAllElements();
160
v.add(DEBUGGEE_THREAD + "." + checkedMethods[i]);
161
v.add("Method exited");
162
count = grep.find(v);
163
if (count != 1) {
164
log.complain("Count of method exit is incorrect for the method : " + DEBUGGEE_THREAD + "." + checkedMethods[i]);
165
log.complain("Should be 1 trace messages, found : " + count);
166
result= false;
167
}
168
}
169
return result;
170
}
171
}
172
173