@@ -445,11 +445,11 @@ public void immediateSuspend(Object eventThread, byte suspendPolicy, Callable<Vo
445445 }
446446 }
447447 // immediately suspend the event thread
448- suspend (null , eventThread , SuspendStrategy .EVENT_THREAD , Collections .singletonList (callBack ), null , true );
448+ suspend (eventThread , SuspendStrategy .EVENT_THREAD , Collections .singletonList (callBack ), true );
449449 break ;
450450 case SuspendStrategy .EVENT_THREAD :
451451 // immediately suspend the event thread
452- suspend (null , eventThread , SuspendStrategy .EVENT_THREAD , Collections .singletonList (callBack ), null , true );
452+ suspend (eventThread , SuspendStrategy .EVENT_THREAD , Collections .singletonList (callBack ), true );
453453 break ;
454454 }
455455 }
@@ -485,7 +485,7 @@ public void disposeDebugger(boolean prepareReconnect) {
485485 // to a dead VM from a JDWP client point of view
486486 if (eventListener .vmDied ()) {
487487 // we're asked to suspend
488- suspend (null , context .asGuestThread (Thread .currentThread ()), SuspendStrategy .EVENT_THREAD , Collections .emptyList (), null , true );
488+ suspend (context .asGuestThread (Thread .currentThread ()), SuspendStrategy .EVENT_THREAD , Collections .emptyList (), true );
489489 }
490490 }
491491 // Creating a new thread, because the reset method
@@ -558,7 +558,7 @@ public void onLanguageContextInitialized(TruffleContext con, @SuppressWarnings("
558558 truffleContext = con ;
559559 }
560560
561- public void suspend (CallFrame currentFrame , Object thread , byte suspendPolicy , List <Callable <Void >> jobs , SteppingInfo steppingInfo , boolean forceSuspend ) {
561+ public void suspend (Object thread , byte suspendPolicy , List <Callable <Void >> jobs , boolean forceSuspend ) {
562562 fine (() -> "suspending from callback in thread: " + getThreadName (thread ));
563563
564564 // before sending any events to debugger, make sure to mark
@@ -575,8 +575,7 @@ public void suspend(CallFrame currentFrame, Object thread, byte suspendPolicy, L
575575 break ;
576576 case SuspendStrategy .EVENT_THREAD :
577577 fine (() -> "Suspend EVENT_THREAD" );
578- runJobs (jobs );
579- suspendEventThread (currentFrame , thread , steppingInfo , forceSuspend );
578+ suspendEventThread (thread , forceSuspend , jobs );
580579 break ;
581580 case SuspendStrategy .ALL :
582581 fine (() -> "Suspend ALL" );
@@ -591,14 +590,10 @@ public void run() {
591590 DebuggerController .this .suspend (activeThread );
592591 }
593592 }
594- // send any breakpoint events here, since now all threads that are
595- // expected to be suspended
596- // have increased suspension count
597- runJobs (jobs );
598593 }
599594 });
600595 suspendThread .start ();
601- suspendEventThread (currentFrame , thread , steppingInfo , forceSuspend );
596+ suspendEventThread (thread , forceSuspend , jobs );
602597 break ;
603598 }
604599 }
@@ -613,12 +608,12 @@ private static void runJobs(List<Callable<Void>> jobs) {
613608 }
614609 }
615610
616- private void suspendEventThread (CallFrame currentFrame , Object thread , SteppingInfo info , boolean forceSuspend ) {
611+ private void suspendEventThread (Object thread , boolean forceSuspend , List < Callable < Void >> jobs ) {
617612 fine (() -> "Suspending event thread: " + getThreadName (thread ) + " with new suspension count: " + threadSuspension .getSuspensionCount (thread ));
618- lockThread (thread , forceSuspend , true , info , currentFrame );
613+ lockThread (thread , forceSuspend , true , jobs );
619614 }
620615
621- private void lockThread (Object thread , boolean forceSuspend , boolean isFirstCall , SteppingInfo info , CallFrame currentFrame ) {
616+ private void lockThread (Object thread , boolean forceSuspend , boolean isFirstCall , List < Callable < Void >> jobs ) {
622617 SimpleLock lock = getSuspendLock (thread );
623618 // in case a thread job is already posted on this thread
624619 checkThreadJobsAndRun (thread , forceSuspend );
@@ -630,11 +625,7 @@ private void lockThread(Object thread, boolean forceSuspend, boolean isFirstCall
630625 try {
631626 if (lock .isLocked () && isFirstCall ) {
632627 threadSuspension .suspendThread (thread );
633- // if during stepping, send a step completed event back to the debugger
634- if (info != null ) {
635- assert currentFrame != null ;
636- eventListener .stepCompleted (info , currentFrame );
637- }
628+ runJobs (jobs );
638629 }
639630 while (lock .isLocked ()) {
640631 fine (() -> "lock.wait() for thread: " + getThreadName (thread ));
@@ -687,7 +678,7 @@ private void checkThreadJobsAndRun(Object thread, boolean forceSuspend) {
687678 } else {
688679 job .runJob ();
689680 }
690- lockThread (thread , forceSuspend , false , null , null );
681+ lockThread (thread , forceSuspend , false , Collections . emptyList () );
691682 }
692683 }
693684
@@ -953,9 +944,18 @@ public Void call() {
953944 }
954945 });
955946 }
947+ if (steppingInfo != null ) {
948+ jobs .add (new Callable <>() {
949+ @ Override
950+ public Void call () {
951+ eventListener .stepCompleted (steppingInfo , callFrames [0 ]);
952+ return null ;
953+ }
954+ });
955+ }
956956
957957 // now, suspend the current thread until resumed by e.g. a debugger command
958- suspend (callFrames [ 0 ], currentThread , suspendPolicy , jobs , steppingInfo , hit || steppingInfo != null );
958+ suspend (currentThread , suspendPolicy , jobs , hit || steppingInfo != null );
959959 }
960960
961961 private boolean matchLocation (Pattern [] patterns , CallFrame callFrame ) {
0 commit comments