The Debug Adapter code runs in a separate Nodejs process spawned by Visual Studio Code when you debug Go code.
Please see The Debug Adapter Protocol to understand how the Debug Adapter acts as an intermediary between VS Code and the debugger which in case of Go is delve
Clone this repo and then run npm install
git clone https://github.com/Microsoft/vscode-go cd vscode-go npm install
This is the option you would take if you want to understand or change the way the Go debug adapter interacts with delve.
This lets you debug the code in the goDebug.ts
file which powers the debug adapter which runs in a different Nodejs process than the rest of the extension. Therefore, you won't be able to debug the code powering the rest of the extension.
vscode-go
folder in VS Code. Choose the Launch as server
debug configuraion from the drop down in the debug viewlet. Add a breakpoint in the desired localtion in the vscode-go/src/debugAdapter/goDebug.ts
file"debugServer": 4711
in the root of the configuration. Start debugging your Go application and the breakpoint in the goDebug.ts
file in the other VS Code instance will be hit.This is the option you would take if you have changes both in the goDebug.ts
file (which powers the debug adapter) as well any of the other files in this project. This setup involves three instances of Visual Studio Code:
vscode-go
folder in one instance. Choose the Launch Extension
debug target and hit F5. This will launch a second instance of Visual Studio Code."debugServer": 4711
in the root of the configuration.vscode-go/src/debugAdapter
folder. In this instance hit F5 to launch the debug adapter in server mode under the debugger.In some edge cases (like veryfing workbench behavior and state before executing debug adapter apicalls) debugging VS Code itself can be helpful. Once you ensure that you can build and run Visual Studio Code from source successfully, follow the below steps:
$HOME/.vscode-oss-dev/extensions/ms-vscode.go
(the location may vary by OS)vscode
folder in Visual Studio Code. Launch the VS Code debug instance (OSS - Code) by choosing the Launch VS Code
debug configuraion from the drop down in the debug viewlet. Add a breakpoint in the desired localtion.vscode-go
folder. Choose the Launch as server
debug configuration from the drop down in the debug viewlet. Add a breakpoint in the desired localtion in the vscode-go/src/debugAdapter/goDebug.ts
file"debugServer": 4711
in the root of the configuration. Start debugging your Go application and the breakpoint in the goDebug.ts
file in the other VS Code instance will be hit, along with the breakpoints set up in the vscode files