Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

debug: fix 'pause' command #2126

Merged
merged 7 commits into from
Jan 28, 2019
Merged

Conversation

xiphon
Copy link
Contributor

@xiphon xiphon commented Nov 14, 2018

Fixes #978

Addressed issues

  • Should maintain alive threads list and update it on 'ThreadsRequest'
  • Should update debugState and threads on 'PauseRequest'
  • Returning an empty array on threads request. VS Code expects that a process consists of at least one thread
  • Unhandled exception in handleReenterDebug in case of this.debugState.currentGoroutine is unitialized
  • Unhandled exception in threadsRequest when this.debugState is unitialized

@msftclas
Copy link

msftclas commented Nov 14, 2018

CLA assistant check
All CLA requirements met.

@xiphon xiphon force-pushed the fix-debug-pause branch 2 times, most recently from 5461e6b to 41e7373 Compare November 16, 2018 00:45
@xiphon xiphon changed the title debug: fix 'pause' command and stack frames data fetching debug: fix 'pause' command Nov 16, 2018
@ramya-rao-a
Copy link
Contributor

Thanks for the PR @xiphon! This is a very much needed feature along with your work in #2128.
Unfortunately, I am little tight on time, so it will take a while for me to look and test the changes. But I'll surely get to this in the next 2 weeks

@Nerzal
Copy link

Nerzal commented Jan 2, 2019

@ramya-rao-a did u have time to look at this ? :)

@OneOfOne
Copy link
Contributor

OneOfOne commented Jan 7, 2019

Any news about this?

@ramya-rao-a
Copy link
Contributor

@OneOfOne, @Nerzal,

Not yet, just back from vacation and catching up on notifications.
Have either of you gotten a chance to try out the changes in this PR?

@segevfiner, @brycekahle, @lggomez Would you mind taking a look at this PR, since all 3 of you have worked in various debugging features of this extension?

@OneOfOne
Copy link
Contributor

OneOfOne commented Jan 8, 2019

I rebased it on current master and I can confirm this fixes the pause command, however I hit #2133.

@jhendrixMSFT
Copy link
Member

@xiphon can you please rebase on top of master? Once that's done we can merge this change.

@xiphon
Copy link
Contributor Author

xiphon commented Jan 12, 2019

Rebased

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiphon Thanks again for the PR!

@jhendrixMSFT has reviewed and tried out the changes and they work as expected.

Can you update the description of this PR with details about why the pause feature was not working before and how this PR fixes it?

Since the changes in this PR are not trivial, it would help us in future maintenance to have a record of what changes went in and why.

I would like to mainly cover the below points:

  • We are now updating this.threads in the threadRequest and ensuring that it only has threads corresponding to current goroutines. What problem did this fix?
  • In handleReenterDebug, if the current state doesnt have a currentGoroutine, we add the first goroutine to it. What problem did this fix? Why dont we need to update the currentThread here as well?

@@ -751,15 +751,35 @@ class GoDebugSession extends LoggingDebugSession {
});
}

private updateThreads(goroutines: DebugGoroutine[]): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, what we are doing here is ensuring this.threads only has entries corresponding to existing goroutines.

We should either rename this to something that communicates the above or add a comment above the function for the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest updateThreads sounds good to me and is exactly what this routine is doing: it updates the threads list and sends the appropriate notifications to VS Code through Events interface.

Can't be more accurate than updateAndPropagateThreadsListToVsCode, though sounds redundant to me.

protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
if (this.continueRequestRunning) {
// Thread request to delve is syncronous and will block if a previous async continue request didn't return
response.body = { threads: [] };
response.body = { threads: [new Thread(1, 'Dummy')] };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give us some insight on why we have to create a dummy thread here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code expects that a process consists of at least one thread.
I guess it is something like "How would we stop/continue if there is no single thread?" or "How does the process exist if it doesn't have any alive threads?"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the spec.
"Even if a debug adapter does not support multiple threads, it must implement the threads request and return a single (dummy) thread."
So since we have no threads yet we must send a dummy thread.

@ramya-rao-a
Copy link
Contributor

@xiphon Can you answer the last 2 questions?

  • We are now updating this.threads in the threadRequest and ensuring that it only has threads corresponding to current goroutines. What problem did this fix?
  • In handleReenterDebug, if the current state doesnt have a currentGoroutine, we add the first goroutine to it. What problem did this fix? Why dont we need to update the currentThread here as well?

@xiphon
Copy link
Contributor Author

xiphon commented Jan 19, 2019

@ramya-rao-a

We are now updating this.threads in the threadRequest and ensuring that it only has threads corresponding to current goroutines. What problem did this fix?

Otherwise we will send to debugger a list containing non-existing/exited goroutines.

In handleReenterDebug, if the current state doesnt have a currentGoroutine, we add the first goroutine to it. What problem did this fix?

Unhandled exception in handleReenterDebug in case of unitialized currentGoroutine, currentGoroutine might be unitialized.

Why dont we need to update the currentThread here as well?

We always update currentThread before any handleReenterDebug call.

@ramya-rao-a
Copy link
Contributor

We always update currentThread before any handleReenterDebug call.

currentThread isnt being updated independently anywhere. It gets updated when they entire debug state is updated.

So now that we are specifically updating the goroutineId if the state doesnt have it, I was curious as to why we do that but not update the thread

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants