Skip to content

Support debugging programs with multiple goroutines #2338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aarzilli opened this issue Jun 4, 2019 · 2 comments
Closed

Support debugging programs with multiple goroutines #2338

aarzilli opened this issue Jun 4, 2019 · 2 comments

Comments

@aarzilli
Copy link

aarzilli commented Jun 4, 2019

Goroutines are something of a major feature of Go. Over 8% of the language keywords are dedicated specifically to this feature and it has been used as a selling point for the language throughout its history.
It is unfortunate that vim-go debugger has some serious shortcomings when it comes to debugging programs that use more than one goroutine:

  1. There is no way to see which goroutines are running or switch between them
  2. If multiple goroutines simultaneously hit a breakpoint only one will be shown and the others will be silently ignored
  3. If during the execution of GoDebugNext or GoDebugStep a goroutine, other than the goroutine where GoDebugNext/GoDebugStep is executed, hits a breakpoint the debugger will silently switch to the new goroutine and any subsequent attempt at using GoDebugNext/GoDebugStep will fail with a "next while nexting" error.

Configuration (MUST fill this out):

vim-go version:

1.20

@xbsura
Copy link

xbsura commented Aug 26, 2019

Hi:

I have the same request, and I have finished it

But I dont know whether this repo is still developing, so maybe I will do a pull request, and then, I will fork a repo

@xbsura
Copy link

xbsura commented Aug 27, 2019

I have made a pr for this, and for your questions, I will try to answer it:

  1. vim-go does not have this command, in my pr, I add a command: GoDebugGoroutines to show all goroutines running(but maybe a lot)

2 & 3 , it seems different, but the have the same reason, a little difficult to expain because my poor english...

In golang dlv(which vim-go use this to debug), breakpoint will stop all goroutines running, but there is no limit that one goroutine run at the same time, for dlv, when you type next, it stopped and tell you it stopped when It runs to "next line", but sometimes(most of times), the next line is not in your current goroutine, for vim-go, it must know this behavior and try to deal with it, vim-go must wait for "next" stops at the current debug goroutine and then stop, but vim-go not do this, so as what you see, when multi goroutine running, "next" will jump to random gorouting and stopped, then the next failed

In my pr, I fixed this problem, when you debug in one goroutine, the "next" command will always skip to the same goroutine the next line, And I add a command: GoDebugGoRoutine + Id, to switch goroutines, after switch goroutine, the "next" command will run in new goroutine

Wish you like it

bhcleek added a commit that referenced this issue Sep 17, 2019
@bhcleek bhcleek closed this as completed Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants