Skip to content

Commit 3e583dc

Browse files
committed
only send step completed event after we have bumped thread suspension count
1 parent 30fcbeb commit 3e583dc

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -615,16 +615,10 @@ private static void runJobs(List<Callable<Void>> jobs) {
615615

616616
private void suspendEventThread(CallFrame currentFrame, Object thread, SteppingInfo info, boolean forceSuspend) {
617617
fine(() -> "Suspending event thread: " + getThreadName(thread) + " with new suspension count: " + threadSuspension.getSuspensionCount(thread));
618-
619-
// if during stepping, send a step completed event back to the debugger
620-
if (info != null) {
621-
eventListener.stepCompleted(info, currentFrame);
622-
}
623-
624-
lockThread(thread, forceSuspend, true);
618+
lockThread(thread, forceSuspend, true, info, currentFrame);
625619
}
626620

627-
private void lockThread(Object thread, boolean forceSuspend, boolean isFirstCall) {
621+
private void lockThread(Object thread, boolean forceSuspend, boolean isFirstCall, SteppingInfo info, CallFrame currentFrame) {
628622
SimpleLock lock = getSuspendLock(thread);
629623
// in case a thread job is already posted on this thread
630624
checkThreadJobsAndRun(thread, forceSuspend);
@@ -636,6 +630,11 @@ private void lockThread(Object thread, boolean forceSuspend, boolean isFirstCall
636630
try {
637631
if (lock.isLocked() && isFirstCall) {
638632
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+
}
639638
}
640639
while (lock.isLocked()) {
641640
fine(() -> "lock.wait() for thread: " + getThreadName(thread));
@@ -688,7 +687,7 @@ private void checkThreadJobsAndRun(Object thread, boolean forceSuspend) {
688687
} else {
689688
job.runJob();
690689
}
691-
lockThread(thread, forceSuspend, false);
690+
lockThread(thread, forceSuspend, false, null, null);
692691
}
693692
}
694693

0 commit comments

Comments
 (0)