Skip to content

Commit

Permalink
Keep the binding on during the whole DebugServerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Aug 17, 2024
1 parent 454804f commit 63d1560
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.oracle.truffle.api.debug.DebuggerTags;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrumentation.EventBinding;
import com.oracle.truffle.api.instrumentation.EventContext;
import com.oracle.truffle.api.instrumentation.ExecutionEventNode;
import com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory;
Expand Down Expand Up @@ -93,7 +92,7 @@ protected void onCreate(Env env) {
if (client != null) {
handler.setClient(client);
Instrumenter instrumenter = env.getInstrumenter();
var replAtMethod = new AtTheEndOfFirstMethod(handler, env, instrumenter);
var replAtMethod = new AtTheEndOfMethod(handler, env, instrumenter);
replAtMethod.activate(replAtMethodName);
} else {
env.getLogger(ReplDebuggerInstrument.class)
Expand Down Expand Up @@ -214,12 +213,14 @@ public void exit() {
*/
@Override
protected void onEnter(VirtualFrame frame) {
CallerInfo lastScope = Function.ArgumentsHelper.getCallerInfo(frame.getArguments());
Object lastReturn = EnsoContext.get(this).getNothing();
// Note [Safe Access to State in the Debugger Instrument]
monadicState = Function.ArgumentsHelper.getState(frame.getArguments());
nodeState = new ReplExecutionEventNodeState(lastReturn, lastScope);
startSessionImpl();
if (!atExit) {
CallerInfo lastScope = Function.ArgumentsHelper.getCallerInfo(frame.getArguments());
Object lastReturn = EnsoContext.get(this).getNothing();
// Note [Safe Access to State in the Debugger Instrument]
monadicState = Function.ArgumentsHelper.getState(frame.getArguments());
nodeState = new ReplExecutionEventNodeState(lastReturn, lastScope);
startSessionImpl();
}
}

@Override
Expand Down Expand Up @@ -303,13 +304,12 @@ CallerInfo getLastScope() {
}
}

private final class AtTheEndOfFirstMethod implements ExecutionEventNodeFactory {
private final class AtTheEndOfMethod implements ExecutionEventNodeFactory {
private final Instrumenter instr;
private final DebuggerMessageHandler handler;
private final TruffleInstrument.Env env;
private EventBinding<?> firstMethod;

AtTheEndOfFirstMethod(DebuggerMessageHandler h, TruffleInstrument.Env env, Instrumenter instr) {
AtTheEndOfMethod(DebuggerMessageHandler h, TruffleInstrument.Env env, Instrumenter instr) {
this.instr = instr;
this.handler = h;
this.env = env;
Expand All @@ -318,17 +318,13 @@ private final class AtTheEndOfFirstMethod implements ExecutionEventNodeFactory {
final void activate(String methodName) {
var b = SourceSectionFilter.newBuilder();
b.tagIs(StandardTags.RootBodyTag.class);
b.rootNameIs(
(n) -> {
return methodName.equals(n);
});
b.rootNameIs(methodName::equals);
var anyMethod = b.build();
this.firstMethod = instr.attachExecutionEventFactory(anyMethod, this);
instr.attachExecutionEventFactory(anyMethod, this);
}

@Override
public ExecutionEventNode create(EventContext ctx) {
firstMethod.dispose();
var log = env.getLogger(ReplExecutionEventNodeImpl.class);
return new ReplExecutionEventNodeImpl(true, ctx, handler, log);
}
Expand Down

0 comments on commit 63d1560

Please sign in to comment.