Repository navigation
Closed
Description
What happens
When the adapter sends stopped while the session is already suspended, LSP4IJ adds every thread to the current suspend context again:
- the Frames view then lists each thread twice;
- each later stop adds them once more;
- the older copies keep the frames they were built with.
Reproduced on IntelliJ IDEA Community 2024.2 and 2025.3, with a test whose adapter stops main and then worker:
The threads which the Frames view lists expected:<[main, worker]> but was:<[main, worker, main, worker]>
When it happens
- The adapter stops only the thread that hit a breakpoint (
allThreadsStopped: false), and a second thread stops while the first stop is shown. - The program resumes without LSP4IJ knowing, then stops again. An example is GDB after
continuetyped in the Debug console. LSP4IJ doesn't handle thecontinuedevent yet (DAP: support the Continued event #2106), so the session is still suspended at the next stop.
Steps
- Debug a program with two threads,
mainandworker, with an adapter that stops only the thread that hits a breakpoint. mainstops at a breakpoint.- While the session is suspended,
workerstops at a breakpoint. - Open the thread list of the Frames view.
Expected
Each thread is listed once, and the session shows the stop in worker.
Cause
On main (35eb012):
DAPClient.stoppedreads the threads and the stopped thread's frames, then callssuspend(DAPClient.java:569-588).getSuspendContextreuses the session'sDAPSuspendContextwhen the session is suspended, and callsaddToExecutionStackfor every thread (DAPClient.java:753-761).DAPSuspendContext.addToExecutionStackalways appends a newDAPExecutionStack(DAPSuspendContext.java:36-43), so the stacks of the earlier stop stay.- The Frames view gets all of
getExecutionStacks()throughXSuspendContext.computeExecutionStacks.
Suggested fix
- Create a new
DAPSuspendContextfor each stop ingetSuspendContext. The threads are read again on every stop anyway (getThreads(true)). - If the old context must be kept,
addToExecutionStackshould replace the stack of a thread that is already there, keyed by the thread id.
Activity
fix: a stop while suspended lists each thread once, and only the thre…