Skip to content

Conversation

@jbdoderlein
Copy link
Contributor

Add restart frame support to the DAP.

Demo :

restartframe.mp4

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

❌ Patch coverage is 49.29577% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 46%. Comparing base (091726a) to head (e6ed8cc).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...g/rascalmpl/interpreter/result/RascalFunction.java 69% 21 Missing and 9 partials ⚠️
src/org/rascalmpl/dap/RascalDebugAdapter.java 0% 13 Missing ⚠️
src/org/rascalmpl/debug/DebugHandler.java 0% 10 Missing ⚠️
src/org/rascalmpl/dap/RascalDebugEventTrigger.java 0% 7 Missing ⚠️
src/org/rascalmpl/interpreter/Evaluator.java 20% 3 Missing and 1 partial ⚠️
...eter/control_exceptions/RestartFrameException.java 0% 4 Missing ⚠️
...scalmpl/debug/AbstractInterpreterEventTrigger.java 0% 2 Missing ⚠️
src/org/rascalmpl/debug/DebugMessageFactory.java 0% 1 Missing ⚠️
src/org/rascalmpl/debug/IDebugMessage.java 0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              main   #2582   +/-   ##
=======================================
- Coverage       46%     46%   -1%     
- Complexity    6661    6665    +4     
=======================================
  Files          794     795    +1     
  Lines        65746   65800   +54     
  Branches      9852    9859    +7     
=======================================
+ Hits         30634   30641    +7     
- Misses       32746   32795   +49     
+ Partials      2366    2364    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@DavyLandman DavyLandman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly fine, I have one place where I want to ask @jurgenvinju to take a look once he's back.

Comment on lines 365 to 382
// Handle frame restart at this level
// Restore environment state and retry execution
// Continue the while loop to retry the call
if(ctx instanceof Evaluator) {
Evaluator evaluator = (Evaluator) ctx;
var stackTrace = evaluator.getCurrentStack();
if(stackTrace.size() == 1){ // should not happen because this is the REPL frame
throw new ImplementationError("Cannot restart frame of the REPL");
}
if (rfe.getTargetFrameId() == stackTrace.size() -1) { // the frame to restart
restartFrame = true;
continue; // restart the frame by continuing the while loop
}
else { // not the frame to restart, rethrow to let upper frames handle it
throw rfe;
}
}
throw new ImplementationError("Frame restart is only supported in Evaluator contexts");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is something for @jurgenvinju to review.

@jbdoderlein
Copy link
Contributor Author

With the exception breakpoint PR merged, I adapted the code so that it's now possible to restart a frame when hitting a breakpoint exception :

restartonexception.mp4

@DavyLandman
Copy link
Member

@jurgenvinju can you do a final review?

}

@Override
public Result<IValue> call(Type[] actualStaticTypes, IValue[] actuals, Map<String, IValue> keyArgValues) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wrap of the whole function body in a while is a bit extreme, the args & types shouldn't change, so is there no way to make the while loop much closer to the actual body eval of this function?

@jbdoderlein
Copy link
Contributor Author

@jurgenvinju suggested moving the while loop inside the runBody function. I thought this would work (and it would have reduced code inside the while loop) but in fact this is not the case.
The main problem is that the environment cleaning code is inside the call method, in the finally block. This code is essential because without it, we have variable redefinition errors.
Two solution :

  • add environment cleaning code in the restart frame handling. This would cause code duplication (and a lot of comments because the callee environment are handled inside the call function, and we would need to change them inside runBody function)
  • keep the loop in call

Another side effect is that moving code inside runBody make it impossible to restart frame on exception breakpoint (this is not a main feature, but it's useful).

@jurgenvinju
Copy link
Member

@jbdoderlein thanks for explaining. Then let's go with your original solution.

@DavyLandman DavyLandman merged commit c03d8bb into usethesource:main Feb 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants