golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.78k stars 726 forks source link

debug: delete legacy debug adapter #3096

Open hyangah opened 6 months ago

hyangah commented 6 months ago

It's been more than two years since we switched to dlv dap, and we halted any more dev/maintenance work for legacy debug adapter.

The legacy debug adapter is still being used as the default for "remote" debugging, but we also see an increased number of users switched to dlv-dap for remote debugging. (e.g. forked vscode-go for bazel, etc) Before the deletion, we are going to switch the default (https://github.com/golang/vscode-go/issues/2205) by warning potentially affected users and directing them to this issue.

(Update: 2024-04-04) Please see https://github.com/golang/vscode-go/issues/3096#issuecomment-2038160792

Known issues:

gopherbot commented 6 months ago

Change https://go.dev/cl/550917 mentions this issue: src/goDebugConfiguration: change remote/attach default to dlv-dap

acekingke commented 4 months ago

I Cannot make the breakpoint.

ramory-l commented 4 months ago

I Cannot make the breakpoint.

Same

VS CODE:

Version: 1.86.2 (Universal)
Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
Date: 2024-02-13T19:42:13.651Z
Electron: 27.2.3
ElectronBuildId: 26908389
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0

VS CODE launch config:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Go App",
      "type": "go",
      "request": "attach",
      "mode": "remote",
      "port": 2345,
      "host": "127.0.0.1",
      "showLog": true
    }
  ]
}

App runs in docker via: /bin/dlv --listen=:2345 --headless=true --log=true --accept-multiclient --api-version=2 exec /app;

gm0stache commented 4 months ago

i am trying to attach to a dlv instance running in a container. i am unable to create breakpoints.

vscode version/env:

Version: 1.86.2
Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
Date: 2024-02-13T19:42:12.210Z
Electron: 27.2.3
ElectronBuildId: 26908389
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0

vscode launch config:

  "launch": {
    "configurations": [
      {
        "name": "my-remote-service",
        "type": "go",
        "request": "attach",
        "mode": "remote",
        "remotePath": "/app",
        "port": 5555,
        "host": "127.0.0.1",
        "showLog": true,
        "logOutput": "rpc"
      }
    ],
  },

the dlv command executed on the server (aka. the debugging target):

dlv --listen=:5555 --headless=true --api-version=2 --accept-multiclient exec /server

any help is highly appreciated!

br gabriel

gm0stache commented 4 months ago

workaround for the meantime: just use the legacy debug adapter. do so by adding this config to your settings.json:

  "go.delveConfig": {
    "debugAdapter": "legacy"
  }

! be sure to track this issue and remove this config again!

qinggong8 commented 4 months ago

I added a new file settings.json under project/.vscode/settings.json with the above suggested content, restarted VSC, but still, I could not set break point (showing a circle but not in red). The BPs will display in red only when the debugger is not active.

Edit: Adding "debugAdapter": "legacy" to the launch.json seems to work.

gm0stache was right. Adding changes to settings.json works for all VSC instances, while adding to launch.json only works for that instance. The location of the VSC settings.json is at: C:\Users\myuserid\AppData\Roaming\Code\User\settings.json

........ "colorTabs.titleBackground": true, "colorTabs.ignoreCase": true, "go.alternateTools": { "dlv": "dlv"

},
"debug.allowBreakpointsEverywhere": true,
"go.delveConfig": {
    "debugAdapter": "legacy"
}

}

gmikhaile commented 4 months ago

same - can't make a breakpoint.

CariappaKGanapathi commented 4 months ago

I added a new file settings.json under project/.vscode/settings.json with the above suggested content, restarted VSC, but still, I could not set break point (showing a circle but not in red). The BPs will display in red only when the debugger is not active.

Edit: Adding "debugAdapter": "legacy" to the launch.json seems to work.

This worked for me as well. Thanks

bhaskarEEN commented 4 months ago

I added a new file settings.json under project/.vscode/settings.json with the above suggested content, restarted VSC, but still, I could not set break point (showing a circle but not in red). The BPs will display in red only when the debugger is not active.

Edit: Adding "debugAdapter": "legacy" to the launch.json seems to work.

This worked for me as well. Need to add this field inside the object under the configurations array

nrapport commented 3 months ago

I discovered that I couldn't make a breakpoint today either. I was under time pressure to resolve an issue and this caused a very frustrating delay.

fcheng58 commented 3 months ago

same problem for me. I couldn't add a breakpoint and it was fixed when adding "debugAdapter": "legacy".

andre-brizido commented 3 months ago

Same problem. Could not set breakpoints with dlv running in a remote Linux virtual machine and VS code running on windows. With the legacy adapter works.

uniemimu commented 3 months ago

Same. Using legacy debug adapter works for remote debugging. Whatever the new thing is, it doesn't work.

molixiaoge commented 3 months ago

Without "debugAdapter": "legacy" config,I cannot set any breakpoint .

KenelyOliveira commented 3 months ago

Same problem, and when I try to add "debugAdapter": "legacy" config, I get the following error:

Legacy debug adapter is deprecated. Please comment on issue 3096 if this impacts your workflows.

gm0stache commented 3 months ago

related issue: https://github.com/golang/vscode-go/issues/3096#issuecomment-1985839141

AmanitaVerna commented 3 months ago

I'm getting a "Legacy debug adapter is deprecated. Please comment on issue 3096 if this impacts your workflows." message when I debug locally.

The configuration I'm running has: "type": "go", "request": "launch", "mode": "debug",

sasklacz commented 3 months ago

I'm getting a "Legacy debug adapter is deprecated. Please comment on issue 3096 if this impacts your workflows." message when I debug locally.

The configuration I'm running has: "type": "go", "request": "launch", "mode": "debug",

Same here.

nrobert13 commented 3 months ago

I'm getting a "Legacy debug adapter is deprecated. Please comment on issue 3096 if this impacts your workflows." message when I debug locally.

The configuration I'm running has: "type": "go", "request": "launch", "mode": "debug",

same here

sasklacz commented 3 months ago

Also this partially helps, but I still can't add breakpoints in dependency libraries https://github.com/golang/vscode-go/issues/3175

bydanovm commented 3 months ago

I can't debug with new dvl-dlp adapter. I to add "debugAdapter": "legacy" config, it is help me

FurmanovD commented 3 months ago

And I've just fucked up a tech assessment because of this shit. I am soooooo frustrated...

paulbrittain commented 2 months ago

Like others here, I couldn't add a breakpoint without using the legacy adapter. The issue is that the file in which the breakpoint is being added can't be found.

Interestingly, this is the same problem I'm experiencing with Neovim's dap.

I'd love to know what the legacy adapter does that the new adapter doesn't do. It might help me to fix my neovim dap configuration. Then I can have the option of using VSCode or Neovim.

denis-manokhin commented 2 months ago

The same problem. Can't add breakpoint without legacy debug adapter. Sample debug config:

{
    "name": "service_name",
    "type": "go",
    "request": "attach",
    "mode": "remote",
    "remotePath": "",
    "port": 40000,
    "host": "127.0.0.1",
    "showLog": true,
    "trace": "log",
    "logOutput": "rpc"
}

And when I try to add breakpoint:

Screenshot 2024-04-04 at 11 39 15
suzmue commented 2 months ago

Thanks for all of the feedback! The legacy debug adapter attempts to match the files from the VS Code client to a list of files that are in the compiled binary (#45), whereas the dlv dap relies on manual configuration. It is clear from the comments on this issue and #3175 that dlv dap does need to have a solution for this problem beyond manual configuration.

We have decided to revert the change of the default back to legacy for remote attach in v0.41.3 and will address this breakpoint issue by adding automated path mapping to dlv dap, which will require changes in both delve and vscode-go.

The work on automated path mapping will be tracked in #3193.

gm0stache commented 2 months ago

thanks for addressing the issue! highly appreciate you work!

bluec0re commented 2 months ago

We're using the legacy adapter so that we can debug bazel (rules_go) managed binaries from within VS code (parts of the small wrapper to make it work: https://gist.github.com/bluec0re/af19ded857749fd2ec145f4e06f0e9b3).

91diego commented 2 months ago

Got this error

Expected to connect to externaldlv --headlessserver @ v1.7.3 or later via DAP. Older versions fail with "error layer=rpc rpc:invalid character 'C' looking for beginning of value" logged to the terminal.

hyangah commented 2 months ago

@91diego Can you check the versions of go and dlv used in your remote container? Is it possible to upgrade delve?