…ther thread continued alone (#2221)
Fixes #2185
## What
After a thread other than the stopped one continued alone (`continued` with `allThreadsContinued: false`), Set Value refused in the thread that was still stopped. It said "The program has run since this value was shown: show it again to set it." `DAPClient.continued` ended the execution epoch of #2150 on every `continued` event, of any thread. So every value of the stop counted as out of date, and so did Jump to Source and Jump to Value Source on them.
The findings in #2185 show the design, checked against the debug adapters' sources:
- java-debug, debugpy and vscode-js-debug keep a stopped thread's references valid while another thread runs alone.
- GDB clears every reference on any resume. It's the only one that advertises `supportsSingleThreadExecutionRequests`.
## Change
- **`continued` with `allThreadsContinued: false`** no longer ends the execution epoch. The thread that continued is marked as having left its stop, as before, in the run states of #2181.
- **Frames carry their stop.** `DAPStackFrame` keeps the run-state version of its stop, which `DAPExecutionStack` passes, and its thread, from #2217.
- **The new `DAPClient.sendInExecutionEpoch(DAPStackFrame, …)`** sends a request only while both of these hold, checked in the same lock as before:
- the frame's epoch is current;
- the frame's thread hasn't left its stop (`DAPThreadRunStates.leftStopSince`).
The thread that reads the debug adapter's messages still never waits on that lock: the run states are an atomic swap.
- **Callers:** `DAPValueModifier` (Set Value), `DAPExpressionModifier` (Set Value on an Evaluate result) and `DAPLocations` (Jump to Source, Jump to Value Source) now pass their frame.
- **The epoch still ends for every thread** on:
- every Resume or step that LSP4IJ sends, including a `singleThread: true` one, which GDB needs;
- any `stopped` event, including `allThreadsStopped: true`, which adapters that renumber at every stop need;
- a `continued` event of all threads;
- Reset Frame.
- **Compatibility:** the existing `sendInExecutionEpoch(int, …)` overloads and the public `DAPStackFrame` constructors are unchanged.
- **Docs:** one sentence in the Set Value section of `docs/dap/UserGuide.md`.
Not in this PR:
- A `continue` response with `allThreadsContinued: false`, to a request sent without `singleThread`, still ends the epoch for all threads. IntelliJ resumes the session before Resume is sent, so no value of that stop is left to set. Undoing the run states set before the request fits with #2183's refused-resume handling.
- A value of a thread that exited while the session stays suspended now refuses as out of date. Before, `setVariable` was sent.
## Tests
New `DAPSetValueInAStoppedThreadSessionTest`, 5 session tests with an in-process debug adapter of two threads. Every wait is bounded and has a message.
- **The worker continues alone:** a local and an Evaluate result of `main` get `setVariable` and `setExpression` and show their new values. The worker's values refuse and send nothing.
- **A single-thread step:** Step Over with `singleThread: true` makes both threads' values refuse.
- **A stop of all threads:** the worker continues alone, then stops with `allThreadsStopped: true`. Both threads' earlier values refuse, and `main`'s local at the new stop can be set.
- **A continue of all threads:** both threads' values refuse.
- **Resume:** both threads' values refuse.
`DAPExecutionEpochTest` gets one unit test for the new `send`.
Red-green: without the change, the first test fails (`The local of 'main' is set`). The other four pass either way: they guard behaviour that already worked. With the change, all pass.
On main at 4e15453, the two classes pass headless on IC 2024.2, 2025.3 and IU 2026.3: 19 tests each. The `dap.*` tests pass on all three: 551 tests each, with 0 failures or skipped.
## Behaviour change
| Before | After |
|---|---|
| After another thread continues alone, Set Value, Jump to Source and Jump to Value Source on a value of the thread that's still stopped refuse: "The program has run since this value was shown" | They work in the stopped thread. Values of the thread that continued alone, or exited, still refuse. A single-thread step, any stop, and a continue or Resume of all threads still make every thread's values refuse |
Fixes #2178
What
"Terminate Thread" (#2153) was only in the context menu of a DAP session's Threads tab. VS Code also has it in its Call Stack view. IntelliJ's Frames view had no way to terminate the thread of the selected frame.
Change
XDebugger.Frames.Tree.Popup) now hasDAP.TerminateThreadtoo. There it sendsterminateThreadswith the thread of the selected frame, to the DAP session of that frame, when its DAP server supports the request (supportsTerminateThreadsRequest). It isn't shown for a frame of another debugger, for a DAP server without the request, or for a DAP frame that doesn't know its thread.DAPStackFrameknows its DAP thread: a new constructorDAPStackFrame(client, stackFrame, executionEpoch, threadId)andgetThreadId(). The two existing constructors leave it null, so the public API stays compatible.DAPExecutionStackpasses its thread to the frames it creates.XDebugSession.DATA_KEY, or else the project's current session, and uses its current stack frame.Tests
DAPTerminateThreadSessionTestgets 6 tests of the Frames view's menu. They update the action in the background, as the menu does, with the data the menu has there, and right-click as the Frames view does, withsetCurrentStackFrameon the selected frame. They check that:main, Terminate Thread onworker's frame sendsterminateThreadswithworker's id;startDebugging), the request goes to the child session and the root session gets none;Red-green:
DAPExecutionStackpassing the thread, the 2 tests that expect a request fail.After rebasing onto #2181:
DAPTerminateThreadSessionTestpasses headless on IC 2024.2, 2025.3 and IU 2026.3: 16 tests each.dap.*tests pass on all three: 500 each, 0 failures, 0 skipped.Behaviour change