muhammadsammy / free-vscode-csharp

Free/Libre fork of the official C# extension for vscode
https://open-vsx.org/extension/muhammad-sammy/csharp
Other
110 stars 10 forks source link

Remote attach to netcoredbg process from open-vscode #33

Closed C-SELLERS closed 2 years ago

C-SELLERS commented 2 years ago

Issue Description

Heyo,

I am working on a project that requires a remote debug connection from one container running open vscode to another container running a dotnet 5 program. I'm attempting to use muhammadsammy/free-omnisharp-vscode & samsung/netcoredbg, since microsoft C# extension is proprietary and won't work with open vs code 😒.

I have tried quite a few different ways of attempting to do this, but have hit quite a few roadblocks. If anyone has some advice on this kind of setup please let me know. I am going to post this in both free-omnisharp-vscode & netcoredbg repos.

Here are my latest attempts

Attempt 1

connect.sh ssh -o "StrictHostKeyChecking no" test@172.19.0.2 '/QuantConnect/netcoredbg --interpreter=vscode --log --engineLogging=/Log/log.txt --attach 91' (Variations of this, with/without PID, with/without logging)

Output

No PID Included: Operating system """ not supported

Tweaking this a bit to do try logging I also see Operating system "{Content Length: 56}" not supported πŸ˜•

So it making the connection and starting netcoredbg but the debugger is having issues.

PID Included: {"seq":1,"body":{},"event":"initialized","type":"event"}stderr: Error: 0x80070057 Failed to attach to 91

Attempt 2

Output

So this is interesting, because I see two different behaviors

  1. Running locally (Official C# Extension); connects, launches program, debugger attaches, breaks on exception. πŸ€”

Not really important though because its not my use case. The exception is probably because I am using official C# with netcoredbg ❌

  1. Running in Open VS Code

Operating system """ not supported 😒

Ideas

I noticed netcoredbg has a --server flag that would allow launching the process and then debugging through a port instead of requiring SSH, has anybody used this and had it work? I see in a VSCode configuration I can add "debugServer", but its just the port. πŸ€”

Even trying this locally with an exposed port did not work as I would've hoped.

Environment information

VSCode version: 1.62.3 C# Extension: 1.23.16

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.402 Commit: e9d3381880 Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.402/ Host (useful for support): Version: 5.0.11 Commit: f431858f8b .NET SDKs installed: 5.0.402 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 5.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |csharp|muhammad-sammy|1.23.16| |jupyter|ms-toolsai|2021.8.12| |python|ms-python|2021.11.1422169775|;
C-SELLERS commented 2 years ago

I figured out this guy

Operating system """ not supported

I was using a bash script as my pipetransport to set up the connection to netcoredbg on the remote machine, but the way the debugger extension would attempt to use my pipetransport, is to send commands to read the processes on the remote. Because my pipetransport was not really an open line to the remote machine it would break attempting to read the OS and then the processes. Failing out.

Getting past this I am still facing other issues.

  1. If I provide a process name, it doesn't resolve the process ID automatically like the official omnisharp. For now I can work around this, but it wouldn't be too crazy to resolve the PID using a similar process as it does now to read the processes from the remote machine.

  2. I am hitting a new bug after getting connected and selecting the process. It correctly attaches and sets breakpoints, but fails on a command "configurationDone". Digging into this guy.

(C) {"command":"configurationDone","type":"request","seq":6}
<- (R) {"seq":8,"command":"configurationDone","message":"Failed command 'configurationDone' : 0x80070057","request_seq":6,"success":false,"type":"response","adapterElapsedTime":2063}
C-SELLERS commented 2 years ago

Just wanted to update how I ended up working around this problem.

I decided to run netcoredbg in server mode on the remote machine. From there I made a custom extension that connects to the debugger using VSCodes built in vscode.DebugAdapterServer.

I did have to register a debugger in my custom extension to make it a smooth process, but definitely something that could be done in this extension rather easily.

gautaz commented 1 month ago

Hello,

Sorry I'm being late for the party...

I have the exact same needs as @C-SELLERS and I was wondering if this extension had evolved in the meantime to fulfill these needs.

@muhammadsammy I saw the proof of concept that @C-SELLERS provided 3 years ago, is this something that will be part of or is already part of free-vscode-csharp?