50
50
* To check up on the method, a debugger,
51
51
* upon getting new set for the EventSet,
52
52
* suspends VM with the method VirtualMachine.suspend(),
53
- * gets the List of geduggee 's threads calling VM.allThreads(),
53
+ * gets the List of debuggee 's threads calling VM.allThreads(),
54
54
* invokes the method EventSet.resume(), and
55
- * gets another List of geduggee 's threads.
55
+ * gets another List of debuggee 's threads.
56
56
* The debugger then compares values of
57
57
* each thread's suspendCount from first and second Lists.
58
58
*
63
63
* to be resulting in the event.
64
64
* - Upon getting new event, the debugger
65
65
* performs the check corresponding to the event.
66
+ * - The debugger informs the debuggee when it completes
67
+ * each test case, so it will wait before hitting
68
+ * communication breakpoints.
69
+ * This prevents the breakpoint SUSPEND_ALL policy
70
+ * disrupting the first test case check for
71
+ * SUSPEND_NONE, if the debuggee gets ahead of
72
+ * the debugger processing.
66
73
*/
67
74
68
75
public class resume008 extends TestDebuggerType1 {
@@ -124,7 +131,9 @@ protected void testRun() {
124
131
}
125
132
126
133
display ("......waiting for new ThreadStartEvent : " + i );
127
- EventSet eventSet = eventHandler .waitForRequestedEventSet (new EventRequest []{eventRequest }, waitTime , true );
134
+ EventSet eventSet = eventHandler
135
+ .waitForRequestedEventSet (new EventRequest []{eventRequest },
136
+ waitTime , true );
128
137
129
138
EventIterator eventIterator = eventSet .eventIterator ();
130
139
Event newEvent = eventIterator .nextEvent ();
@@ -134,7 +143,8 @@ protected void testRun() {
134
143
} else {
135
144
136
145
String property = (String ) newEvent .request ().getProperty ("number" );
137
- display (" got new ThreadStartEvent with propety 'number' == " + property );
146
+ display (" got new ThreadStartEvent with propety 'number' == "
147
+ + property );
138
148
139
149
display ("......checking up on EventSet.resume()" );
140
150
display ("......--> vm.suspend();" );
@@ -144,7 +154,8 @@ protected void testRun() {
144
154
145
155
Map <String , Integer > suspendsCounts1 = new HashMap <String , Integer >();
146
156
for (ThreadReference threadReference : vm .allThreads ()) {
147
- suspendsCounts1 .put (threadReference .name (), threadReference .suspendCount ());
157
+ suspendsCounts1 .put (threadReference .name (),
158
+ threadReference .suspendCount ());
148
159
}
149
160
display (suspendsCounts1 .toString ());
150
161
@@ -154,7 +165,8 @@ protected void testRun() {
154
165
display (" getting : Map<String, Integer> suspendsCounts2" );
155
166
Map <String , Integer > suspendsCounts2 = new HashMap <String , Integer >();
156
167
for (ThreadReference threadReference : vm .allThreads ()) {
157
- suspendsCounts2 .put (threadReference .name (), threadReference .suspendCount ());
168
+ suspendsCounts2 .put (threadReference .name (),
169
+ threadReference .suspendCount ());
158
170
}
159
171
display (suspendsCounts2 .toString ());
160
172
@@ -163,85 +175,90 @@ protected void testRun() {
163
175
164
176
switch (policy ) {
165
177
166
- case SUSPEND_NONE :
167
- display (" case SUSPEND_NONE" );
168
- for (String threadName : suspendsCounts1 .keySet ()) {
169
- display (" checking " + threadName );
170
- if (!suspendsCounts2 .containsKey (threadName )) {
171
- complain ("ERROR: couldn't get ThreadReference for " + threadName );
172
- testExitCode = TEST_FAILED ;
173
- break ;
174
- }
175
- int count1 = suspendsCounts1 .get (threadName );
176
- int count2 = suspendsCounts2 .get (threadName );
177
- if (count1 != count2 ) {
178
- complain ("ERROR: suspendCounts don't match for : " + threadName );
179
- complain ("before resuming : " + count1 );
180
- complain ("after resuming : " + count2 );
181
- testExitCode = TEST_FAILED ;
182
- break ;
183
- }
184
- }
185
- break ;
186
-
187
- case SUSPEND_THREAD :
188
- display (" case SUSPEND_THREAD" );
189
- for (String threadName : suspendsCounts1 .keySet ()) {
190
- display ("checking " + threadName );
191
- if (!suspendsCounts2 .containsKey (threadName )) {
192
- complain ("ERROR: couldn't get ThreadReference for " + threadName );
193
- testExitCode = TEST_FAILED ;
194
- break ;
195
- }
196
- int count1 = suspendsCounts1 .get (threadName );
197
- int count2 = suspendsCounts2 .get (threadName );
198
- String eventThreadName = ((ThreadStartEvent )newEvent ).thread ().name ();
199
- int expectedValue = count2 + (eventThreadName .equals (threadName ) ? 1 : 0 );
200
- if (count1 != expectedValue ) {
201
- complain ("ERROR: suspendCounts don't match for : " + threadName );
202
- complain ("before resuming : " + count1 );
203
- complain ("after resuming : " + count2 );
204
- testExitCode = TEST_FAILED ;
205
- break ;
206
- }
207
- }
208
- break ;
209
-
210
- case SUSPEND_ALL :
211
-
212
- display (" case SUSPEND_ALL" );
213
- for (String threadName : suspendsCounts1 .keySet ()) {
214
- display ("checking " + threadName );
215
-
216
- if (!newEvent .request ().equals (eventRequest ))
217
- break ;
218
- if (!suspendsCounts2 .containsKey (threadName )) {
219
- complain ("ERROR: couldn't get ThreadReference for " + threadName );
220
- testExitCode = TEST_FAILED ;
221
- break ;
222
- }
223
- int count1 = suspendsCounts1 .get (threadName );
224
- int count2 = suspendsCounts2 .get (threadName );
225
- if (count1 != count2 + 1 ) {
226
- complain ("ERROR: suspendCounts don't match for : " + threadName );
227
- complain ("before resuming : " + count1 );
228
- complain ("after resuming : " + count2 );
229
- testExitCode = TEST_FAILED ;
230
- break ;
231
- }
178
+ case SUSPEND_NONE :
179
+ display (" case SUSPEND_NONE" );
180
+ for (String threadName : suspendsCounts1 .keySet ()) {
181
+ display (" checking " + threadName );
182
+ if (!suspendsCounts2 .containsKey (threadName )) {
183
+ complain ("ERROR: couldn't get ThreadReference for "
184
+ + threadName );
185
+ testExitCode = TEST_FAILED ;
186
+ break ;
232
187
}
233
- break ;
234
-
235
- default : throw new Failure ("** default case 1 **" );
188
+ int count1 = suspendsCounts1 .get (threadName );
189
+ int count2 = suspendsCounts2 .get (threadName );
190
+ if (count1 != count2 ) {
191
+ complain ("ERROR: suspendCounts don't match for : "
192
+ + threadName );
193
+ complain ("before resuming : " + count1 );
194
+ complain ("after resuming : " + count2 );
195
+ testExitCode = TEST_FAILED ;
196
+ break ;
197
+ }
198
+ }
199
+ break ;
200
+
201
+ case SUSPEND_THREAD :
202
+ display (" case SUSPEND_THREAD" );
203
+ for (String threadName : suspendsCounts1 .keySet ()) {
204
+ display ("checking " + threadName );
205
+ if (!suspendsCounts2 .containsKey (threadName )) {
206
+ complain ("ERROR: couldn't get ThreadReference for "
207
+ + threadName );
208
+ testExitCode = TEST_FAILED ;
209
+ break ;
210
+ }
211
+ int count1 = suspendsCounts1 .get (threadName );
212
+ int count2 = suspendsCounts2 .get (threadName );
213
+ String eventThreadName = ((ThreadStartEvent )newEvent )
214
+ .thread ().name ();
215
+ int expectedValue = count2 +
216
+ (eventThreadName .equals (threadName ) ? 1 : 0 );
217
+ if (count1 != expectedValue ) {
218
+ complain ("ERROR: suspendCounts don't match for : "
219
+ + threadName );
220
+ complain ("before resuming : " + count1 );
221
+ complain ("after resuming : " + count2 );
222
+ testExitCode = TEST_FAILED ;
223
+ break ;
224
+ }
225
+ }
226
+ break ;
227
+
228
+ case SUSPEND_ALL :
229
+ display (" case SUSPEND_ALL" );
230
+ for (String threadName : suspendsCounts1 .keySet ()) {
231
+ display ("checking " + threadName );
232
+ if (!newEvent .request ().equals (eventRequest ))
233
+ break ;
234
+ if (!suspendsCounts2 .containsKey (threadName )) {
235
+ complain ("ERROR: couldn't get ThreadReference for "
236
+ + threadName );
237
+ testExitCode = TEST_FAILED ;
238
+ break ;
239
+ }
240
+ int count1 = suspendsCounts1 .get (threadName );
241
+ int count2 = suspendsCounts2 .get (threadName );
242
+ if (count1 != count2 + 1 ) {
243
+ complain ("ERROR: suspendCounts don't match for : "
244
+ + threadName );
245
+ complain ("before resuming : " + count1 );
246
+ complain ("after resuming : " + count2 );
247
+ testExitCode = TEST_FAILED ;
248
+ break ;
249
+ }
250
+ }
251
+ break ;
252
+ default : throw new Failure ("** default case 1 **" );
236
253
}
237
- }
254
+ informDebuggeeTestCase ( i );
238
255
256
+ }
239
257
display ("......--> vm.resume()" );
240
258
vm .resume ();
241
259
}
242
260
return ;
243
261
}
244
-
245
262
private ThreadStartRequest settingThreadStartRequest (int suspendPolicy ,
246
263
String property ) {
247
264
try {
@@ -254,5 +271,22 @@ private ThreadStartRequest settingThreadStartRequest(int suspendPolicy,
254
271
throw new Failure ("** FAILURE to set up ThreadStartRequest **" );
255
272
}
256
273
}
257
-
274
+ /**
275
+ * Inform debuggee which thread test the debugger has completed.
276
+ * Used for synchronization, so the debuggee does not move too quickly.
277
+ * @param testCase index of just completed test
278
+ */
279
+ void informDebuggeeTestCase (int testCase ) {
280
+ try {
281
+ ((ClassType )debuggeeClass )
282
+ .setValue (debuggeeClass .fieldByName ("testCase" ),
283
+ vm .mirrorOf (testCase ));
284
+ } catch (InvalidTypeException ite ) {
285
+ throw new Failure ("** FAILURE setting testCase **" );
286
+ } catch (ClassNotLoadedException cnle ) {
287
+ throw new Failure ("** FAILURE notifying debuggee **" );
288
+ } catch (VMDisconnectedException e ) {
289
+ throw new Failure ("** FAILURE debuggee connection **" );
290
+ }
291
+ }
258
292
}
1 commit comments
openjdk-notifier[bot] commentedon Sep 20, 2023
Review
Issues