vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

debug: delete legacy debug adapter

Open hyangah opened this issue 1 year ago • 30 comments

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:

  • [ ] https://github.com/golang/vscode-go/issues/3175 This happens when file paths in local and remote machines differ. A workaround is to configure the substitutePath setting, as described in this comment. We are currently working on automated path mapping. https://github.com/golang/vscode-go/issues/3193

hyangah avatar Dec 18 '23 20:12 hyangah

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

gopherbot avatar Dec 18 '23 20:12 gopherbot

I Cannot make the breakpoint.

acekingke avatar Feb 19 '24 09:02 acekingke

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;

ramory-l avatar Feb 19 '24 09:02 ramory-l

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 avatar Feb 19 '24 13:02 gm0stache

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!

gm0stache avatar Feb 19 '24 13:02 gm0stache

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"
}

}

qinggong8 avatar Feb 19 '24 16:02 qinggong8

same - can't make a breakpoint.

wer14 avatar Feb 20 '24 04:02 wer14

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

CariappaKGanapathi avatar Feb 20 '24 07:02 CariappaKGanapathi

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

bhaskarEEN avatar Feb 20 '24 14:02 bhaskarEEN

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.

nrapport avatar Feb 28 '24 01:02 nrapport

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

fcheng58 avatar Feb 28 '24 05:02 fcheng58

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.

andre-brizido avatar Mar 06 '24 13:03 andre-brizido

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

uniemimu avatar Mar 06 '24 17:03 uniemimu

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

molixiaoge avatar Mar 08 '24 07:03 molixiaoge

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.

KenelyOliveira avatar Mar 08 '24 14:03 KenelyOliveira

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

gm0stache avatar Mar 12 '24 11:03 gm0stache

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",

AmanitaVerna avatar Mar 21 '24 14:03 AmanitaVerna

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 avatar Mar 22 '24 14:03 sasklacz

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 avatar Mar 22 '24 15:03 nrobert13

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

sasklacz avatar Mar 22 '24 15:03 sasklacz

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

bydanovm avatar Mar 22 '24 22:03 bydanovm

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

FurmanovD avatar Mar 27 '24 14:03 FurmanovD

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.

paulbrittain avatar Mar 29 '24 20:03 paulbrittain

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

denis-manokhin avatar Apr 04 '24 06:04 denis-manokhin

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.

suzmue avatar Apr 04 '24 20:04 suzmue

thanks for addressing the issue! highly appreciate you work!

gm0stache avatar Apr 05 '24 04:04 gm0stache

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).

bluec0re avatar Apr 05 '24 09:04 bluec0re

Got this error

Expected to connect to external dlv --headless server @ 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.

91diego avatar Apr 19 '24 08:04 91diego

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

hyangah avatar Apr 19 '24 12:04 hyangah