dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 673 forks source link

Can't attach arm vscode debugger to x64 docker container #7575

Open sudsy opened 1 month ago

sudsy commented 1 month ago

Issue Description

I running an ARM MAC and am having trouble attaching to a container that is built for x64.

Steps to Reproduce

Use VsCode run and debug to Attach to a Docker .net core container that has been built using platform linux/amd64.

The exact same container debugs properly when it is built for ARM

This problem only occurs on local docker (docker desktop or orbstack) - When I use a remote x64 host it works as expected.

Expected Behavior

This container should bring up the debugger in the same way that it does if it is built fro ARM

Actual Behavior

The debugger never connects nor does it timeout

Logs

Starting: "docker" exec -i gen3-pvl_grpc-1 /remote_debugger/vsdbg --interpreter=vscode

C# log

Post the output from Output-->C# here

C# LSP Trace Logs

Post the output from Output-->C# LSP Trace Logs here. Requires `dotnet.server.trace` to be set to `Trace`

Environment information

VSCode version: 1.93.1 C# Extension: 2.45.25 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 8.0.201 Commit: 4c2d78f037 Workload version: 8.0.200-manifests.3097af8b Runtime Environment: OS Name: Mac OS X OS Version: 14.6 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/8.0.201/ .NET workloads installed: There are no installed workloads to display. Host: Version: 8.0.2 Architecture: arm64 Commit: 1381d5ebd2 .NET SDKs installed: 6.0.411 [/usr/local/share/dotnet/sdk] 6.0.417 [/usr/local/share/dotnet/sdk] 7.0.305 [/usr/local/share/dotnet/sdk] 8.0.201 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.19 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.25 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.19 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.25 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |astro-vscode|astro-build|2.14.2|astro-build.astro-vscode-2.14.2-darwin-arm64| |atlascode|atlassian|3.0.10|atlassian.atlascode-3.0.10| |code-spell-checker|streetsidesoftware|3.0.1|streetsidesoftware.code-spell-checker-3.0.1| |code-spell-checker-british-english|streetsidesoftware|1.4.11|streetsidesoftware.code-spell-checker-british-english-1.4.11| |copilot|GitHub|1.229.0|github.copilot-1.229.0| |csdevkit|ms-dotnettools|1.10.18|ms-dotnettools.csdevkit-1.10.18-darwin-arm64| |csharp|ms-dotnettools|2.45.25|ms-dotnettools.csharp-2.45.25-darwin-arm64| |EditorConfig|EditorConfig|0.16.4|editorconfig.editorconfig-0.16.4| |figma-vscode-extension|figma|0.3.5|figma.figma-vscode-extension-0.3.5| |git-graph|mhutchie|1.30.0|mhutchie.git-graph-1.30.0| |hexeditor|ms-vscode|1.10.0|ms-vscode.hexeditor-1.10.0| |playwright|ms-playwright|1.1.7|ms-playwright.playwright-1.1.7| |prettier-vscode|esbenp|11.0.0|esbenp.prettier-vscode-11.0.0| |remote-containers|ms-vscode-remote|0.384.0|ms-vscode-remote.remote-containers-0.384.0| |remote-explorer|ms-vscode|0.4.3|ms-vscode.remote-explorer-0.4.3| |remote-ssh|ms-vscode-remote|0.114.3|ms-vscode-remote.remote-ssh-0.114.3| |remote-ssh-edit|ms-vscode-remote|0.86.0|ms-vscode-remote.remote-ssh-edit-0.86.0| |resourcemonitor|mutantdino|1.0.7|mutantdino.resourcemonitor-1.0.7| |rest-client|humao|0.25.1|humao.rest-client-0.25.1| |vscode-docker|ms-azuretools|1.29.2|ms-azuretools.vscode-docker-1.29.2| |vscode-dotnet-runtime|ms-dotnettools|2.1.5|ms-dotnettools.vscode-dotnet-runtime-2.1.5| |vscode-eslint|dbaeumer|3.0.10|dbaeumer.vscode-eslint-3.0.10| |vscode-mdx|unifiedjs|1.8.10|unifiedjs.vscode-mdx-1.8.10| |vscode-tailwindcss|bradlc|0.12.10|bradlc.vscode-tailwindcss-0.12.10| |vscode-thunder-client|rangav|2.25.4|rangav.vscode-thunder-client-2.25.4| |vscode-yaml|redhat|1.15.0|redhat.vscode-yaml-1.15.0|;
WardenGnaw commented 1 month ago

Can you run file on /remote_debugger/vsdbg in the docker container?

sudsy commented 1 month ago

Results on broken image

/remote_debugger/vsdbg: POSIX shell script, ASCII text executable

Results on working image

/remote_debugger/vsdbg: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=2c44bdde133c446ec3a2f87bae75e5901926ce6e, with debug_info, not stripped

WardenGnaw commented 1 month ago

/remote_debugger/vsdbg: POSIX shell script, ASCII text executable sounds like this might just be the getvsdbgsh script.

Did you run curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /remote_debugger/vsdbg

See more information at https://github.com/dotnet/vscode-csharp/wiki/Attaching-to-remote-processes#installing-vsdbg-on-the-server

sudsy commented 1 month ago

OK, if I let vscode install the debugger itself when I am prompted I get:

/remote_debugger/vsdbg: POSIX shell script, ASCII text executable

I have tried running the following command as part of my docker build or as a seperate shell command that I run manually after the container has started.

curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /remote_debugger

In both of those cases I get:

/remote_debugger/vsdbg: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped

Sadly even with the correct executable it's timing out trying to connect to the debugger.