Skip to content

[GR-64716] Fix extreme slowdown in debugger after resuming from a breakpoint. #11248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -502,5 +502,7 @@ public interface JDWPContext {

void steppingInProgress(Thread t, boolean value);

boolean isSteppingInProgress(Thread t);

void replaceController(DebuggerController newController);
}
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,22 @@ public boolean resume(Object thread) {

fine(() -> "Waking up thread: " + getThreadName(thread));
threadSuspension.removeHardSuspendedThread(thread);

Thread hostThread = context.asHostThread(thread);
if (!context.isSteppingInProgress(hostThread)) {
// We need to notify the Truffle debugger session that this thread is resumed.
// Otherwise, we risk losing an update to the stepping strategy, which causes a
// major slowdown due to frame materialization required for e.g. onReturn
// notifications.
fine(() -> "calling underlying resume method for guestThread: " + getThreadName(thread));

try {
debuggerSession.resume(hostThread);
} catch (IllegalStateException e) {
// debugger session is closed. Safe to ignore
}
}

lock.release();
lock.notifyAll();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public void setSteppingInProgress(boolean value) {
stepInProgress = value;
}

public boolean isSteppingInProgress() {
return stepInProgress;
}

public boolean disableSingleStepping(boolean forceDisable) {
if (forceDisable || stepInProgress) {
singleSteppingDisabledCounter++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ public void steppingInProgress(Thread t, boolean value) {
}
}

@Override
public boolean isSteppingInProgress(Thread t) {
Object previous = null;
try {
previous = controller.enterTruffleContext();
return context.getLanguage().getThreadLocalStateFor(t).isSteppingInProgress();
} finally {
controller.leaveTruffleContext(previous);
}
}

@Override
public Object[] getAllGuestThreads() {
StaticObject[] activeThreads = context.getActiveThreads();
Expand Down
Loading