Repository navigation
fix: a stop while suspended lists each thread once, and only the threads of the session that stopped - #2124
Conversation
…ads of the session that stopped Fixes redhat-developer#2118 A stopped event while the debug session was suspended added every thread to the session's suspend context again, so the Frames view listed each thread once more at each such stop. In a tree of sessions ('startDebugging'), that context could be another session's: the frames, steps and resumes of the new stop then went to that session's connection. Each stop now gets a new suspend context of the client that stopped, with the threads it has just read. IntelliJ takes each positionReached as a new stop anyway: it selects the context's active stack and its top frame, and the Frames view clears its thread list.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2124 +/- ##
==========================================
+ Coverage 50.48% 50.57% +0.08%
==========================================
Files 816 816
Lines 33871 33897 +26
Branches 5287 5289 +2
==========================================
+ Hits 17101 17142 +41
+ Misses 14114 14106 -8
+ Partials 2656 2649 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
…h continued before it was shown doesn't suspend it DAPContinuedEventSessionTest (new) attaches a debug session to a DAP server in the test process. Its program has the threads 'main' and 'worker', and the server stops only the thread it names. Once 'main' has stopped: - 'continued' of all threads resumes the session, and the next stop's suspend context has one execution stack per thread (redhat-developer#2124 already gives each stop a context of its own: the duplicate threads redhat-developer#2106 feared don't happen); - 'continued' of 'main' alone ('allThreadsContinued: false') resumes it; - 'continued' of 'worker' alone leaves it suspended at 'main', and asks for the threads again; - with the session running, the server sends 'stopped' and 'continued' back to back, and answers 'threads' only once both are written, so the client reads 'continued' before it can suspend the session. A session listener records each stop the session is suspended at: the stop which continued is never one of them, and the next stop is shown. Without the check of DAPContinuedEvents, the last test fails: the session is suspended at the stop which continued, then at the next one. Refs redhat-developer#2106
…h continued before it was shown doesn't suspend it DAPContinuedEventSessionTest (new) attaches a debug session to a DAP server in the test process. Its program has the threads 'main' and 'worker', and the server stops only the thread it names. Once 'main' has stopped: - 'continued' of all threads resumes the session, and the next stop's suspend context has one execution stack per thread (#2124 already gives each stop a context of its own: the duplicate threads #2106 feared don't happen); - 'continued' of 'main' alone ('allThreadsContinued: false') resumes it; - 'continued' of 'worker' alone leaves it suspended at 'main', and asks for the threads again; - with the session running, the server sends 'stopped' and 'continued' back to back, and answers 'threads' only once both are written, so the client reads 'continued' before it can suspend the session. A session listener records each stop the session is suspended at: the stop which continued is never one of them, and the next stop is shown. Without the check of DAPContinuedEvents, the last test fails: the session is suspended at the stop which continued, then at the next one. Refs #2106
Fixes #2118
What
When the debug adapter sent
stoppedwhile the session was suspended, the Frames view listed each thread again, and each later stop added them once more.Cause
DAPClient.getSuspendContextreused the session'sDAPSuspendContextwhen the session was suspended, and calledaddToExecutionStackfor every thread, which always appends.threads, so the reuse only duplicates.startDebuggingstarts share one debug session, so the reused context could belong to another session's client. The new stop's stacks and frames then took that client: their requests, and Resume and the steps, went to the other session's connection.Change
DAPSuspendContextof the client that stopped (createSuspendContext, private). The threads are read again at each stop anyway.DAPSuspendContextand all public signatures are unchanged.Why a new context, not replacing stacks by thread id:
positionReachedas a new stop. On 2024.2, 2025.3 and 2026.3,XDebugSessionImpltakes the context's active stack and its top frame as current, and on a paused event the Frames view clears its thread list and reads it again. So keeping the old context kept no selection.setCurrentStackFrame(expectedSuspendContext, …)). One context object for two stops defeats that check.continued. With a context per stop, the context's client is the one whose stop is shown.Behaviour changes
Test
DAPSecondStopWhileSuspendedSessionTest(new) attaches a debug session to a DAP server in the test process. The program has the threadsmainandworker, and the server stops only the thread that hits a breakpoint (allThreadsStopped: false):mainstops, and while the session is suspended,workerstops;worker's frame;mainandworkeronce each, both throughcomputeExecutionStacks, as the Frames view reads it, and throughgetExecutionStacks().On
mainit fails:expected:<[main, worker]> but was:<[main, worker, main, worker]>.maindaptests with the fix