Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/next/next001/next001.java
40955 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/next/next001.
29
* VM Testbase keywords: [jpda, jdb]
30
* VM Testbase readme:
31
* DECSRIPTION
32
* A positive test for the 'next' command.
33
* The debuggee program (next001a.java) creates two additional
34
* threads of MyThread type and starts them. The jdb sets up breakpoint
35
* inside the method 'func2' which is invoked in these addional threads.
36
* When breakpoint is hitted the checked command is called at the line
37
* in which debuggee's method ('func3') is invoked. After this,
38
* the stack trace of the current method is checked by 'where' command.
39
* The test passes if only calling method ('func2') presents in stack
40
* trace, but not the called method ('func3').
41
* The test consists of two program:
42
* next001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
43
* next001a.java - the debugged application.
44
* COMMENTS
45
*
46
* @library /vmTestbase
47
* /test/lib
48
* @build nsk.jdb.next.next001.next001a
49
* @run main/othervm
50
* nsk.jdb.next.next001.next001
51
* -arch=${os.family}-${os.simpleArch}
52
* -waittime=5
53
* -debugee.vmkind=java
54
* -transport.address=dynamic
55
* -jdb=${test.jdk}/bin/jdb
56
* -java.options="${test.vm.opts} ${test.java.opts}"
57
* -workdir=.
58
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
59
*/
60
61
package nsk.jdb.next.next001;
62
63
import nsk.share.*;
64
import nsk.share.jdb.*;
65
66
import java.io.*;
67
import java.util.*;
68
69
public class next001 extends JdbTest {
70
71
public static void main (String argv[]) {
72
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
73
}
74
75
public static int run(String argv[], PrintStream out) {
76
debuggeeClass = DEBUGGEE_CLASS;
77
firstBreak = FIRST_BREAK;
78
lastBreak = LAST_BREAK;
79
return new next001().runTest(argv, out);
80
}
81
82
static final String PACKAGE_NAME = "nsk.jdb.next.next001";
83
static final String TEST_CLASS = PACKAGE_NAME + ".next001";
84
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
85
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
86
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
87
static final String MYTHREAD = "MyThread";
88
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
89
90
static final String[] checkedMethods = {"func1", "func2", "func3"};
91
92
protected void runCases() {
93
String[] reply;
94
Paragrep grep;
95
int count;
96
Vector v;
97
String found;
98
String[] threads;
99
100
jdb.setBreakpointInMethod(LAST_BREAK);
101
102
int breakCount = 0;
103
int nextCount = 0;
104
for (int i = 0; i < next001a.numThreads; i++) {
105
reply = jdb.receiveReplyFor(JdbCommand.cont);
106
if (jdb.isAtBreakpoint(reply, LAST_BREAK)) {
107
breakCount++;
108
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak;
109
110
reply = jdb.receiveReplyFor(JdbCommand.next);
111
if (!checkNext()) {
112
success = false;
113
} else {
114
nextCount++;
115
}
116
}
117
}
118
119
jdb.contToExit(1);
120
121
if (nextCount != next001a.numThreads) {
122
log.complain("Wrong number of 'next' events: " + nextCount);
123
log.complain("Must be equal to : " + next001a.numThreads);
124
success = false;
125
}
126
}
127
128
129
private boolean checkNext () {
130
Paragrep grep;
131
String found;
132
int count;
133
boolean result = true;
134
String[] reply;
135
136
reply = jdb.receiveReplyFor(JdbCommand.where);
137
138
grep = new Paragrep(reply);
139
count = grep.find(DEBUGGEE_THREAD + "." + checkedMethods[2]);
140
if (count > 0) {
141
log.complain("Debuggee is suspended in wrong method after 'next' command: " + DEBUGGEE_THREAD + "." + checkedMethods[2]);
142
result= false;
143
}
144
145
count = grep.find(DEBUGGEE_THREAD + "." + checkedMethods[1]);
146
if (count != 1) {
147
log.complain("Checked method does not exist in thread stack trace: " + DEBUGGEE_THREAD + "." + checkedMethods[1]);
148
result= false;
149
}
150
151
return result;
152
}
153
}
154
155