Skip to content

Remote Debugging On Linux Arm

Gregg Miskelly edited this page Nov 30, 2017 · 22 revisions

This is a beta release feature

The extension supports remote debugging netcoreapp 2.1 on linux-arm. Debugging does not support netcoreapp 2.0. The extension has been tested against Raspbian 8 and 9. Please let us know if you run into issues with other distributions.

If you run into any problems, please file an issue and note in the text that this is related to linux-arm.

Choose one of the following deployment methods:

  • Framework Dependent Deployment: Compile the application locally. Deploy the binary to linux-arm. Requires the .NET Core Runtime to be installed on linux-arm.

  • Self Contained Deployment: Compile and publish the application locally. Deploy the standalone application to linux-arm.

Prerequisites

Install .NET Core SDK v2.2.0 preview locally (IDE computer)

  • Install a daily build of dotnet SDK 2.2.0 beta locally.
  • Ensure that .NET Command Line Tools v2.2 or higher is installed
    • Run dotnet --info to verify.

      Example:

       $ dotnet --info
      .NET Command Line Tools (2.2.0-preview1-007582)
      
      Product Information:
      Version:            2.2.0-preview1-007582
      ...

Install the debugger for linux-arm (target computer)

  • Install the native dependencies of .NET Core. On Raspbian, the only thing missing is libunwind8.
  • Run the following command on linux-arm (installs to ~/vsdbg):
curl -sSL https://aka.ms/getvsdbgshbeta | bash /dev/stdin -r linux-arm -v latest -l ~/vsdbg

Framework-Dependent Deployment

Framework-dependent deployments are when the application is deployed without a copy of .NET Core itself, so the application depends on the shared .NET Core Framework being installed. See docs.microsoft.com for more information.

Install prerequisites

  • General prerequisites

  • On the target computer, install a linux-arm daily build of .NET Core Runtime v2.1 preview.

    Example (installs to ~/dotnet):

    mkdir ~/dotnet & curl -sSL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/master/dotnet-runtime-latest-linux-arm.tar.gz | 
    tar xvzf /dev/stdin -C ~/dotnet
    

Create a new console project

On the IDE computer:

  • Run dotnet new console -n MyConsoleApp. This will create a new netcoreapp v2.1 console application called MyConsoleApp.
    • The restoring of the NuGet packages may fail with an error. To download the NuGet packages that match the daily build, you can choose either option below:
      • Create a nuget.config file with the following block:
      <configuration>
      	  <packageSources>
      	    <add key="dotnet-myget" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
      	  </packageSources>
      </configuration> 
      • Run dotnet restore --source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json.

Build and Deploy

On the IDE computer:

  • In your application's root folder, run dotnet build
  • Copy all the files under bin/Debug/netcoreapp2.1/ to your linux-arm device.
    • To test run your application, on linux-arm, run the entrypoint MyConsoleApp.dll with dotnet.
      $ ~/dotnet/dotnet MyConsoleApp.dll

Remotely debug your application

Reference the sample launch.json below.

  • The "program" field is set to the dotnet executable and the first "args" item is the application .dll relative to the current working directory ("cwd") on linux-arm.
  • Update the fields under "pipeArgs" to include the IP address of the linux-arm device and the ssh keyfile.
  • The "debuggerPath" points to the location where you installed the debugger to on linux-arm.

Sample launch.json

    {
        "name": ".NET Core Remote Launch - Framework Dependent (console)",
        "type": "coreclr",
        "request": "launch",
        "program": "~/dotnet/dotnet",
        "args": [
            "./MyConsoleApp.dll"
        ],
        "cwd": "~/MyConsoleApp",
        "stopAtEntry": false,
        "console": "internalConsole",
        "pipeTransport": {
            "pipeCwd": "${workspaceRoot}",
            "pipeProgram": "/usr/bin/ssh",
            "pipeArgs": [
                "-T", "-i", "mysshkeyfile",
                "pi@10.10.10.10"
            ],
            "debuggerPath": "~/vsdbg/vsdbg"
            }
    }

Self-Contained Deployment

Self-contained deployments are when all of an applications' dependencies are carried with the deployment. So the only thing that must be installed on the target computer is the native dependencies of .NET Core. See docs.microsoft.com for more information.

Install prerequisites

Create a new console project

On the IDE computer:

  • Run dotnet new console -n MyConsoleApp. This will create a new netcoreapp v2.1 console application called MyConsoleApp.
    • The NuGet package restoral may fail to get the necessary packages. To download the NuGet packages that match the daily build, you can choose either option below:
      • Create a nuget.config file with the following block:
      <configuration>
      	  <packageSources>
      	    <add key="dotnet-myget" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
      	  </packageSources>
      </configuration> 
      • Run dotnet restore --source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json.

Build and Deploy

On the IDE computer:

  • Run dotnet publish -r linux-arm
  • Copy all the files under bin/Debug/netcoreapp2.1/linux-arm/publish/ to linux-arm.
  • Test your application by running the standalone executable MyConsoleApp.
    $ ./MyConsoleApp

Remotely debug your standalone application executable

Reference the sample launch.json below.

  • The "program" field is the standalone executable relative to the current working directory ("cwd") on linux-arm.
  • Update the fields under "pipeArgs" to include the IP address of the linux-arm device and the ssh keyfile.
  • The "debuggerPath" points to the location where you installed the debugger to on linux-arm.

Sample launch.json

    {
        "name": ".NET Core Remote Launch - Standalone Application (console)",
        "type": "coreclr",
        "request": "launch",
        "program": "MyConsoleApp",
        "args": [],
        "cwd": "~/MyConsoleApp",
        "stopAtEntry": false,
        "console": "internalConsole",
        "pipeTransport": {
            "pipeCwd": "${workspaceRoot}",
            "pipeProgram": "/usr/bin/ssh",
            "pipeArgs": [
                "-T", "-i", "mysshkeyfile",
                "pi@10.10.10.10"
            ],
            "debuggerPath": "~/vsdbg/vsdbg"
            }
    }
Clone this wiki locally