microsoft / vscode-mono-debug

A simple VS Code debug adapter for mono
Other
159 stars 173 forks source link

Remote debugging #27

Closed 1iveowl closed 2 years ago

1iveowl commented 7 years ago

I'm trying to debug remotely with VS Code running on a PC and the code running on a Raspberry Pi.

I got it to work, but in a strange way.

I'm using VS Code 10.11.1 and on the Raspberry Pi I have mono v4.8.1 installed

The RPI has ip-addr: 192.168.0.7.

Here is what I do:

1) On the rpi: mcs -debug program.cs 2) On the rpi run: mono --debug --debugger-agent=transport=dt_socket,server=y,address=192.168.7:55555 program.exe and the debugging session spins up. 3) On the PC: Press F5

When I press F5 I get the error "Unable to open 'program.cs': File not found (\home\pi\share\Test\program.cs)." and the option to "Create the file" or "Cancel".

If I choose cancel, the debug session on the rpi will finalize, but the break point I've set for the debugger will no be hit.

However, if I choose "Create the file" a new empty file will be created in c:\home\pi\share\Test\program.cs on the PC. If I copy in the content of my original program.cs file and save it, the debugging will run, and I will hit the break point as expected.

So, it "works", but is there a way to config this more smoothly? I.e. where the local file c:\home\pi\share\Test\program.cs does not need to be created? I guess that I could just mirror the file structure between the two devices, but that seems "too easy".

Also, is there a way for automatically running step 1) and 2) above on the RPI, every time I press F5?

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "mono",
            "request": "launch",
            "program": "${workspaceRoot}/program.exe",
            "args": [],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": "",
            "runtimeExecutable": null,
            "env": {},
            "externalConsole": false
        },
        {
            "name": "Attach",
            "type": "mono",
            "request": "attach",
            "address": "192.168.0.7",
            "port": 55555
        }
    ]
}

Code:

using System;

namespace Test
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            System.Console.WriteLine("Hello World!");
        }
    }
}
galvesribeiro commented 6 years ago

Almost one year later... Do we have any news on that matter?

VysotskiVadim commented 6 years ago

@1iveowl, I believe it happens because you've compiled program.exe at Raspberry pi, so the compiler put at mdb file path to source code at Raspberry Pi. As a solution I could recommend you compile your program at PC, then transfer it to Raspberry like here, and then run and debug it like you did.