@@ -117,6 +117,7 @@ private static void log3(String message) {
117
117
static int waitTime ;
118
118
119
119
static VirtualMachine vm = null ;
120
+ static Debugee debuggee = null ;
120
121
static EventRequestManager eventRManager = null ;
121
122
static EventQueue eventQueue = null ;
122
123
static EventSet eventSet = null ;
@@ -137,8 +138,6 @@ private static void log3(String message) {
137
138
138
139
private int runThis (String argv [], PrintStream out ) {
139
140
140
- Debugee debuggee ;
141
-
142
141
argsHandler = new ArgumentHandler (argv );
143
142
logHandler = new Log (out , argsHandler );
144
143
Binder binder = new Binder (argsHandler , logHandler );
@@ -336,13 +335,23 @@ private int runThis (String argv[], PrintStream out) {
336
335
break label1 ;
337
336
log2 (" thread2 is at breakpoint" );
338
337
339
-
340
338
log2 ("......checking up that thread2.resume() resumes thread2 suspended with VirtualMachine.suspend()" );
341
339
342
340
log2 (" enabling breakpRequest3" );
343
341
breakpRequest3 .enable ();
342
+
343
+ // don't do vm.suspend() until mainThread is waiting
344
+ line = pipe .readln ();
345
+ if (line .equals ("waiting" )) {
346
+ log2 (" : returned string is 'waiting'" );
347
+ } else {
348
+ log3 ("ERROR: returned string is not 'waiting': " + line );
349
+ expresult = returnCode4 ;
350
+ break label1 ;
351
+ }
344
352
log2 (" suspending the thread2 with vm.suspend()" );
345
353
vm .suspend ();
354
+
346
355
log2 (" first resuming the thread2 with eventSet.resume()" );
347
356
eventSet .resume ();
348
357
log2 (" checking up thread's state" );
@@ -361,13 +370,17 @@ private int runThis (String argv[], PrintStream out) {
361
370
break label1 ;
362
371
log2 (" thread2 is at breakpoint" );
363
372
364
-
365
- log2 (" resuming the thread2" );
373
+ log2 (" resuming the thread2" );
366
374
thread2 .resume ();
367
375
376
+ log2 (" undo the vm.suspend() with vm.resume()" );
377
+ vm .resume ();
378
+ }
379
+ // These are only needed if we break out of the loop due to an error
380
+ if (expresult != returnCode0 ) {
381
+ vm .resume ();
382
+ vm .resume (); // for case error when both VirtualMachine and the thread2 were suspended
368
383
}
369
- vm .resume ();
370
- vm .resume (); // for case error when both VirtualMachine and the thread2 were suspended
371
384
372
385
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373
386
log2 (" the end of testing" );
@@ -487,7 +500,8 @@ private int breakpoint () {
487
500
try {
488
501
eventSet = eventQueue .remove (waitTime *60000 );
489
502
if (eventSet == null ) {
490
- log3 ("ERROR: timeout for waiting for a BreakpintEvent" );
503
+ log3 ("ERROR: timeout for waiting for a BreakpointEvent" );
504
+ debuggee .printThreadsInfo (vm );
491
505
returnCode = returnCode3 ;
492
506
break labelBP ;
493
507
}
0 commit comments