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