@@ -117,6 +117,7 @@ private static void log3(String message) {
117117 static int waitTime ;
118118
119119 static VirtualMachine vm = null ;
120+ static Debugee debuggee = null ;
120121 static EventRequestManager eventRManager = null ;
121122 static EventQueue eventQueue = null ;
122123 static EventSet eventSet = null ;
@@ -137,8 +138,6 @@ private static void log3(String message) {
137138
138139 private int runThis (String argv [], PrintStream out ) {
139140
140- Debugee debuggee ;
141-
142141 argsHandler = new ArgumentHandler (argv );
143142 logHandler = new Log (out , argsHandler );
144143 Binder binder = new Binder (argsHandler , logHandler );
@@ -336,13 +335,23 @@ private int runThis (String argv[], PrintStream out) {
336335 break label1 ;
337336 log2 (" thread2 is at breakpoint" );
338337
339-
340338 log2 ("......checking up that thread2.resume() resumes thread2 suspended with VirtualMachine.suspend()" );
341339
342340 log2 (" enabling breakpRequest3" );
343341 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+ }
344352 log2 (" suspending the thread2 with vm.suspend()" );
345353 vm .suspend ();
354+
346355 log2 (" first resuming the thread2 with eventSet.resume()" );
347356 eventSet .resume ();
348357 log2 (" checking up thread's state" );
@@ -361,13 +370,17 @@ private int runThis (String argv[], PrintStream out) {
361370 break label1 ;
362371 log2 (" thread2 is at breakpoint" );
363372
364-
365- log2 (" resuming the thread2" );
373+ log2 (" resuming the thread2" );
366374 thread2 .resume ();
367375
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
368383 }
369- vm .resume ();
370- vm .resume (); // for case error when both VirtualMachine and the thread2 were suspended
371384
372385 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373386 log2 (" the end of testing" );
@@ -487,7 +500,8 @@ private int breakpoint () {
487500 try {
488501 eventSet = eventQueue .remove (waitTime *60000 );
489502 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 );
491505 returnCode = returnCode3 ;
492506 break labelBP ;
493507 }
0 commit comments