Skip to content

Commit

Permalink
[DAP] Only need to add completion listener to main module
Browse files Browse the repository at this point in the history
The language-specific debuggers are the ones responsible for copying over execution
listeners when we cross language boundaries. This avoids one risk related to concurrent
modifications and accesses of the execution listeners.
  • Loading branch information
agarciadom committed Sep 2, 2024
1 parent 57639fd commit f1f5981
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,6 @@ protected ThreadState attachTo(IEolModule module) {
module.getContext().getExecutorFactory().setExecutionController(thread.debugger);
}

// Attach the completion listener to this module, if we haven't done so yet
boolean hasListener = false;
for (IExecutionListener l : module.getContext().getExecutorFactory().getExecutionListeners()) {
if (l == completionListener) {
hasListener = true;
break;
}
}
if (!hasListener) {
module.getContext().getExecutorFactory().addExecutionListener(completionListener);
}

// Attach to the module's output and error streams
final PrintStream outStream = createStream(module.getContext(), OutputEventArgumentsCategory.STDOUT);
module.getContext().setOutputStream(outStream);
Expand Down Expand Up @@ -397,6 +385,7 @@ public void connect(IDebugProtocolClient client) {
throw new IllegalStateException("connect(): the module has not been set up yet");
}
attachTo(mainModule);
mainModule.getContext().getExecutorFactory().addExecutionListener(completionListener);

this.client = client;
client.initialized();
Expand Down

0 comments on commit f1f5981

Please sign in to comment.