Skip to content

Commit

Permalink
[GR-52556] Fix issue when stepping and resuming only the current thread.
Browse files Browse the repository at this point in the history
PullRequest: graal/17296
  • Loading branch information
javeleon committed Mar 21, 2024
2 parents cd50dd2 + b5f1470 commit fcf1a80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,33 +362,23 @@ public Object[] getVisibleGuestThreads() {
return visibleThreads.toArray(new Object[visibleThreads.size()]);
}

public void resumeAll(boolean sessionClosed) {
Object eventThread = null;

// The order of which to resume threads is not specified, however when RESUME_ALL command is
// sent while performing a stepping request, some debuggers (IntelliJ is a known case) will
// expect all other threads but the current stepping thread to be resumed first.
void forceResumeAll() {
for (Object thread : getVisibleGuestThreads()) {
boolean resumed = false;
SimpleLock suspendLock = getSuspendLock(thread);
synchronized (suspendLock) {
while (!resumed) {
if (isStepping(thread)) {
eventThread = thread;
break;
} else {
resumed = resume(thread, sessionClosed);
}
resumed = resume(thread, true);
}
}
}
if (eventThread != null) {
boolean resumed = false;
SimpleLock suspendLock = getSuspendLock(eventThread);
}

public void resumeAll() {
for (Object thread : getVisibleGuestThreads()) {
SimpleLock suspendLock = getSuspendLock(thread);
synchronized (suspendLock) {
while (!resumed) {
resumed = resume(eventThread, sessionClosed);
}
resume(thread, false);
}
}
}
Expand Down Expand Up @@ -475,10 +465,6 @@ private String getThreadName(Object thread) {
return getContext().getThreadName(thread);
}

private boolean isStepping(Object thread) {
return commandRequestIds.get(thread) != null;
}

public void disposeDebugger(boolean prepareReconnect) {
if (!prepareReconnect) {
// OK, we're closing down the context which is equivalent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static CommandResult createReply(Packet packet, DebuggerController controller) {
controller.fine(() -> "Resume all packet");

PacketStream reply = new PacketStream().replyPacket().id(packet.id);
controller.resumeAll(false);
controller.resumeAll();
return new CommandResult(reply);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void reset(boolean prepareForReconnect) {
controller.endSession();

// resume all threads
controller.resumeAll(true);
controller.forceResumeAll();

if (prepareForReconnect) {
// replace the controller instance
Expand Down

0 comments on commit fcf1a80

Please sign in to comment.