DSPThread: cannot be suspended if program is terminated #1033
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have started to experiment with replacing our custom debuggers in the Eclipse Epsilon project with LSP4E-based debuggers, and we've noticed one odd issue when we stop at a breakpoint and then resume and let the program stop. This pull request proposes a workaround for the issue for the time being - the deeper issue seems to be how to handle the case where a
continue
request resumes all threads.Scenario
In one of our test programs, we have a main thread T1 start, then another thread T2 starts and stops at a breakpoint. In the Epsilon debug adapter, we stop all threads when we hit a breakpoint, so our
stopped
event provides both the specific thread that hit the breakpoint, and also callssetAllThreadsStopped(true)
. Our program stops as expected, like this:I press F8 to continue (which continues all threads: we indicate this in our response to the
continue
request by callingsetAllThreadsContinued(true)
), and hit the next breakpoint as usual:I press F8 once more, and the program finishes successfully, but I'm left with this odd state:
From what I gathered by debugging, it looks like resuming the thread did not clear the
isSuspended
flag from the other thread, despite the response from the debug adapter that all threads had been continued. I saw that we got to this part of DSPThread just fine, and the resume event was fired:However, I did not notice the
continued()
method being called for the other thread, despite this response. We send outthread
start and exit events, so if those events are processed in time before theterminated
event then the threads are removed by the time the program exits, but it's not always the case.Workaround
I propose changing the
isSuspended()
method inDSPThread
so it won't returntrue
if the program is terminated. This fixes the issues around showing terminated threads in a program as paused or as available to be resumed. This small change results in the desired output: