Merge pull request #49 from puremourning/go

Go support using vscode-go
This commit is contained in:
mergify[bot] 2019-07-31 18:22:32 +00:00 • committed by GitHub
commit f8fc1719e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 24 deletions

View file

@ -86,6 +86,7 @@ on a best-efforts basis:
- Java (see caveats)
- C# (c-sharp) using dotnet core
- Go (requires separate installation of [Delve][])
## Languages known not to work
@ -158,6 +159,7 @@ The debug adapters themselves have certain runtime dependencies:
| Bourne Shell | Experimental | `--all` or `--enable-bash` | vscode-bash-debug | Bash v?? |
| C# (dotnet core) | Experimental | `--force-enable-csharp` | netcoredbg | DotNet core |
| C# (mono) | Experimental | `--force-enable-csharp` | vscode-mono-debug | Mono |
| Go | Experimental | `--enable-go` | vscode-go | Go, [Delve][] |
For other languages, you'll need some other way to install the gadget.
@ -579,6 +581,30 @@ Requires `install_gadget.py --force-enable-c-sharp`.
}
```
* Go
Requires:
* `install_gadget.py --enable-go`
* [Delve][delve-install] installed, e.g. `go get -u github.com/go-delve/delve/cmd/dlv`
* Delve to be in your PATH, or specify the `dlvToolPath` launch option
```json
{
"configurations": {
"run": {
"adapter": "vscode-go",
"configuration": {
"request": "launch",
"program": "${fileDirname}",
"mode": "debug",
"dlvToolPath": "$HOME/go/bin/dlv"
}
}
}
}
```
Also the mock debugger, but that isn't actually useful.
## Partially supported
@ -610,3 +636,5 @@ Copyright © 2018 Ben Jackson
[gitter]: https://gitter.im/vimspector/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link
[java-debug-server]: https://github.com/Microsoft/java-debug
[website]: https://puremourning.github.io/vimspector-web/
[delve]: https://github.com/go-delve/delve
[delve-install]: https://github.com/go-delve/delve/tree/master/Documentation/installation

View file

@ -43,8 +43,8 @@ GADGETS = {
'vscode-cpptools': {
'language': 'c',
'download': {
'url': ( 'https://github.com/Microsoft/vscode-cpptools/releases/download/'
'${version}/${file_name}' ),
'url': 'https://github.com/Microsoft/vscode-cpptools/releases/download/'
'${version}/${file_name}',
},
'do': lambda name, root: InstallCppTools( name, root ),
'all': {
@ -80,8 +80,8 @@ GADGETS = {
'vscode-python': {
'language': 'python',
'download': {
'url': ( 'https://github.com/Microsoft/vscode-python/releases/download/'
'${version}/${file_name}' ),
'url': 'https://github.com/Microsoft/vscode-python/releases/download/'
'${version}/${file_name}',
},
'all': {
'version': '2019.5.17059',
@ -111,8 +111,8 @@ GADGETS = {
'language': 'csharp',
'enabled': False,
'download': {
'url': ( 'https://github.com/Samsung/netcoredbg/releases/download/latest/'
'${file_name}' ),
'url': 'https://github.com/Samsung/netcoredbg/releases/download/latest/'
'${file_name}',
'format': 'tar',
},
'all': {
@ -175,15 +175,37 @@ GADGETS = {
'vscode-bash-debug': {
'language': 'bash',
'download': {
'url': ( 'https://github.com/rogalmic/vscode-bash-debug/releases/'
'download/${version}/${file_name}' ),
'url': 'https://github.com/rogalmic/vscode-bash-debug/releases/'
'download/${version}/${file_name}',
},
'all': {
'file_name': 'bash-debug-0.3.5.vsix',
'version': 'v0.3.5',
'checksum': '',
}
}
},
'vscode-go': {
'language': 'go',
'download': {
'url': 'https://github.com/microsoft/vscode-go/releases/download/'
'${version}/${file_name}'
},
'all': {
'version': '0.11.4',
'file_name': 'Go-0.11.4.vsix',
'checksum':
'ff7d7b944da5448974cb3a0086f4a2fd48e2086742d9c013d6964283d416027e'
},
'adapters': {
'vscode-go': {
'name': 'delve',
'command': [
'node',
'${gadgetDir}/vscode-go/out/src/debugAdapter/goDebug.js'
],
},
},
},
}

View file

@ -187,12 +187,23 @@ class ProjectBreakpoints( object ):
self._breakpoints_handler = handler
def SendBreakpoints( self ):
def SendBreakpoints( self, doneHandler = None ):
assert self._breakpoints_handler is not None
# Clear any existing breakpoints prior to sending new ones
self._breakpoints_handler.ClearBreakpoints()
awaiting = 0
def response_handler( source, msg ):
if msg:
self._breakpoints_handler.AddBreakpoints( source, msg )
nonlocal awaiting
awaiting = awaiting - 1
if awaiting == 0 and doneHandler:
doneHandler()
for file_name, line_breakpoints in self._line_breakpoints.items():
breakpoints = []
for bp in line_breakpoints:
@ -211,8 +222,9 @@ class ProjectBreakpoints( object ):
'path': file_name,
}
awaiting = awaiting + 1
self._connection.DoRequest(
lambda msg: self._breakpoints_handler.AddBreakpoints( source, msg ),
lambda msg: response_handler( source, msg ),
{
'command': 'setBreakpoints',
'arguments': {
@ -224,8 +236,9 @@ class ProjectBreakpoints( object ):
)
if self._server_capabilities.get( 'supportsFunctionBreakpoints' ):
awaiting = awaiting + 1
self._connection.DoRequest(
lambda msg: self._breakpoints_handler.AddBreakpoints( None, msg ),
lambda msg: response_handler( None, msg ),
{
'command': 'setFunctionBreakpoints',
'arguments': {
@ -241,14 +254,18 @@ class ProjectBreakpoints( object ):
self._SetUpExceptionBreakpoints()
if self._exceptionBreakpoints:
awaiting = awaiting + 1
self._connection.DoRequest(
None, # There is nothing on the response to this
lambda msg: response_handler( None, None ),
{
'command': 'setExceptionBreakpoints',
'arguments': self._exceptionBreakpoints
}
)
if awaiting == 0 and doneHandler:
doneHandler()
def _SetUpExceptionBreakpoints( self ):
exceptionBreakpointFilters = self._server_capabilities.get(

View file

@ -683,18 +683,19 @@ class DebugSession( object ):
def OnEvent_initialized( self, message ):
self._codeView.ClearBreakpoints()
self._breakpoints.SendBreakpoints()
def onBreakpointsDone():
if self._server_capabilities.get( 'supportsConfigurationDoneRequest' ):
self._connection.DoRequest(
lambda msg: self._OnInitializeComplete(),
{
'command': 'configurationDone',
}
)
else:
self._OnInitializeComplete()
if self._server_capabilities.get( 'supportsConfigurationDoneRequest' ):
self._connection.DoRequest(
lambda msg: self._OnInitializeComplete(),
{
'command': 'configurationDone',
}
)
else:
self._OnInitializeComplete()
self._codeView.ClearBreakpoints()
self._breakpoints.SendBreakpoints( onBreakpointsDone )
def OnEvent_thread( self, message ):
self._stackTraceView.OnThreadEvent( message[ 'body' ] )

View file

@ -0,0 +1 @@
hello_world

View file

@ -0,0 +1,14 @@
{
"configurations": {
"run": {
"adapter": "vscode-go",
"configuration": {
"request": "launch",
"program": "${workspaceRoot}/hello-world.go",
"mode": "debug",
"dlvToolPath": "$HOME/go/bin/dlv",
"trace": true
}
}
}
}

View file

@ -0,0 +1,6 @@
package main
import "fmt"
func main() {
var v = "test"
fmt.Println("hello world: " + v)
}