Skip to content

Mixed C#/Swig/C++ debugging in vscode #34958

@m17kea

Description

@m17kea

Initially filed on microsoft/vscode-cpptools#5292.

  • OS and Version: OSX Remote SSH Connection to Amazon Linux 2 (RHEL7 equivalent)
  • VS Code Version: 1.44.0
  • C/C++ Extension Version: 0.27.0
  • Swig 4.0.1
  • GCC Version: 9.2
  • GDB Version: 8.3
  • Other extensions you installed (and if the issue persists after disabling them): C#, CMake, CMake Tools, Test Explorer UI, .Net Core Test Explorer

SDK installed via:

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm 
sudo yum install -y dotnet-sdk-2.2

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.2.402
 Commit:    c7f2f96116

Runtime Environment:
 OS Name:     amzn
 OS Version:  2
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/2.2.402/

Host (useful for support):
  Version: 2.2.8
  Commit:  b9aa1abc51

.NET Core SDKs installed:
  2.2.402 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

I am trying to implement mixed-mode debugging in vscode.

To Reproduce
I am running a test with the following command:
VSTEST_HOST_DEBUG=1 && dotnet vstest testdll.dll --Tests:classname.testname --Parallel --logger:trx;LogFileName=output.trx

This spins up three dotnet processes of which i attach to the third with:

{
    name: '.NET Core Attach',
    type: 'coreclr',
    request: 'attach',
    processId: "${command:pickProcess}", 
    env: {
             "LD_LIBRARY_PATH": "/media/psf/Home/Documents/dev.nosync/Derivitec/symbols-2.2.8;/home/linuxbrew/.linuxbrew/lib/gcc/9/;/media/psf/Home/Documents/dev.nosync/Derivitec/src/build/Debug/Derivitec/;/media/psf/Home/Documents/dev.nosync/Derivitec/src/build/Debug/Derivitec.Wrap/;$LD_LIBRARY_PATH",
            "LD_DEBUG":"all",
            "LD_DEBUG_OUTPUT":"/tmp/testrunner.log"
    }
}

I successfully reach a break point in C# before the C++ I'm interested in.

I attach again with:

{
     "name": "(gdb) Attach",
    "type": "cppdbg",
    "request": "attach",
    "program": "/usr/share/dotnet/dotnet",
    "processId": "${command:pickProcess}",
    "additionalSOLibSearchPath": "${workspaceFolder}/symbols-2.2.8;/home/linuxbrew/.linuxbrew/lib/gcc/9/;${workspaceFolder}/src/build/Debug/Derivitec/;${workspaceFolder}/src/build/Debug/Derivitec.Wrap/",
    "MIMode": "gdb",
    "miDebuggerPath": "/home/linuxbrew/.linuxbrew/bin/gdb",
    "setupCommands": [
         {
             "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true,
         }
    ],
    "logging": { 
         "trace": true, 
         "traceResponse": true,
         "engineLogging": true   
    }
}

The gdb debugger attaches successfully and my cpp breakpoints become active in the Breakpoints window. I then press play on the C# debugger. In the call stack the gdb debugger the pauses on an exception as follows:

Screenshot 2020-04-13 at 17 29 22

After continuing the debugger a couple of times it crashes the dotnet process running the test.

I tried adding the libcoreclr source using dotnet-symbol --recurse-subdirectories /usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.8/libcoreclr.so -o symbols-2.2.8 and referencing it in both additionalSOLibSearchPath properties but it does not seem to load it.

GDB logs attached:

gdb.log

Any insights would be greatly appreciated.

Many thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions