Add ability to run GoDebugStart with --accept-multiclient
I'm having several problems using the built in :GoDebug methods in vim-go. It is likely related to the large project I am working on, but for instance, on random lines my gRPC server will crash upon a :GoDebugNext call. This doesn't happen when I use dlv directly.
Anyways, the main reason I use :GoDebug is for the nice UI within vim. I was hoping to be able to start GoDebugStart with --accept-multiclient as the dlv flag under the hood. That way, I can control the dlv commands directly, and see the changes appear on the vim screen. The problem is, I can't figure out a way to add that flag to the dlv command that gets run with GoDebugStart.
Is there a built-in way to do this already? Could it be added as an option?
Thank you.
The problem is, I can't figure out a way to add that flag to the dlv command that gets run with GoDebugStart.
If you want to try this, you'd add --accept-multiclient to the list at https://github.com/fatih/vim-go/blob/master/autoload/go/debug.vim#L638-L642.
Is there a built-in way to do this already?
No
Could it be added as an option?
Vim-go doesn't currently support this, but it could. I'm happy to review a PR.
It is likely related to the large project I am working on, but for instance, on random lines my gRPC server will crash upon a :GoDebugNext call. This doesn't happen when I use dlv directly.
That's odd. What are the symptoms of the crash?
Those line refs don't seem to point to the meaningful place. Looking it I would say it would be here https://github.com/fatih/vim-go/blob/master/autoload/go/debug.vim#L743 (~ 100 lines below).
Would this option be set always or opt in for example with g:go_dlv_flags ?
The position of the relevant line has changed since my previous comments, but you found its new position.
I'd prefer to not allow arbitrary flags. For this, we'd probably want a specific option: g:go_debug_multiclient.
Can I give it a go or is this something you'd prefer doing yourself?
I'd be happy to review a PR. Keep in mind that the client currently kills the process being debugged when it exits. That will need to be made conditional on whether the client is a multiclient or not.
Ok, so far here's what I found:
Starting the dlv server to accept multi clients is straitforward, just add --accept-multiclient and thats it. Then on a new terminal use dlv connect <addr> and we're good.
However when we enter commands on the terminal client, the vim-go client doesn't get notified that a command was actually executed.
As a simple example consider:
1 | func main() {
2 | * fmt.Println("Hello")
3 | x := 2
4 | y := x + 1
5 | * fmt.Printf("x + y = %d\n", x + y)
6 | }
If we have breakpoints on *, the process will halt on line 2. If in the terminal dlv we run next the process moves onto line 3, but nothing is actually shown on vim-go's interface. If we then switch to vim and run :GoDebugNext we get visual feedback on vim-go's interface and we get placed in line 4.
I suspect the dlv server doesn't broadcast the commands from 1 client to the remaining clients, or that the vim-go's client isn't listening for updates (assuming these are supported). I don't know enough about the API delve exposes and how it handles multiclient (yet). Or maybe is something simpler like refreshing the debugger UI?
@bhcleek what's your take on this? Am I missing something obvious?
I'd have to look more closely to know for sure.
There's a logging window that shows all the interaction with the debugger; it should reveal whether dlv is sending any info to the vim-go client.