Skip to content

Attached debugger does not remove breakpoints before disconnecting #2368

Open
@OrBin

Description

@OrBin

What version of Go, VS Code & VS Code Go extension are you using?

Version Information

Go 1.18
VS Code 1.69.2
VS Code Go 0.35.1

Share the Go related settings you have added/edited

Default settings

Describe the bug

Using a remote debugging configuration with "attach" request (from launch.json), attaching the debugger, defining a breakpoint, then clicking "disconnect", the debugee continue running (as expected), but still has the breakpoints set, so that it stops in the breakpoints. This is a weird, unexpected behavior. GoLand, for example, sends ClearBreakpoint commands to dlv server for all registered breakpoints.
Instead, vscode-go just closes the connection without letting the process go back to the previous (=breakpointless) state.
For now, I worked around this with a script I added as a postDebugTask to open a socket to dlv server and clear all breakpoints. This is not a sustainable solution though.

Here is the relevant section in the code, AFAICT:

// For remote debugging, we want to leave the remote dlv server running,
// so instead of killing it via halt+detach, we just close the network connection.
// See https://www.github.com/go-delve/delve/issues/1587
if (this.isRemoteDebugging) {
log('Remote Debugging: close dlv connection.');
const rpcConnection = await this.connection;
// tslint:disable-next-line no-any
(rpcConnection as any)['conn']['end']();
return resolve();
}

Steps to reproduce the behavior:

  1. Add this configuration to launch.json:
{
    "name": "MyApp (attach)",
    "type": "go",
    "request": "attach",
    "debugAdapter": "dlv-dap",
    "mode": "remote",
    "substitutePath": [
        { "from": "${workspaceFolder}", "to": "/code" },
        { "from": "${env:GOROOT}", "to": "/usr/local/go"},
        { "from": "${env:GOPATH}", "to": "/root/go"},
    ],
    "host": "debugee_host",
    "port": <debugee_port>,
    "showLog": true,
    "trace": "log",
    "logOutput": "debugger,gdbwire,lldbout,debuglineerr,rpc,dap,fncall,minidump"
}
  1. Choose this configuration
  2. Click "Start Debugging (F5)"
  3. Add a breakpoint
  4. Make the app run the code with the breakpoint and see VS Code stopping in the breakpoint
  5. Continue
  6. Click "Disconnect"
  7. Make the app run the code with the breakpoint again and see that it stops even though VS Code is not even connected to dlv server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebugIssues related to the debugging functionality of the extension.NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions