.net core debugger won't attach to self hosted runtime #72088
Unanswered
Dimension4
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Which managed debugger? VS code? Rider has its own debugger. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I have a mixed C# and C++ project. The C++ part hosts the core clr using a shared runtime (.net 6). I'm currently trying to debug my code in VS Code on macOS (since VS for Mac doesn't seem to be able to attach to native processes and the Rider debugger won't hit any breakpoints). My problem is that I the .net core debugger won't attach to the native process, even if the clr is already started and I'm waiting in .net code for a debugger to be attached.
I can debug the native part with LLDB and I can debug the .net part when I start the .net core debugger with the native executable. But whenever I try to attach to an already running instance of my exe the .net core debugger just won't attach.
I made a repro project (macOS only tho) here: https://github.com/Dimension4/DotnetAttachSelfHostedRepro. You need dotnet 6 and cmake with a somewhat recent C++ compiler to build the project. You can build the dotnet part with
dotnet build dotnet
and the cmake part using the cmake build task is VS Code (you probably need the CMake extension for this).launch.json contains 3 different configs:
If you manually launch the native exe (
build/NativeHost
), the program will loop forever in the debugger detection part ofClass1.cs
, even after attaching the debugger (using the second config from above).What am I doing wrong? Why isn't attaching working?
Update
It seems like I forgot to close the hostfxr handle in the repro project and after doing that I can attach just fine. However, the real code base still has the problem.
Update 2
Just tested the real code base on Windows and it works there just fine. It's only .net core on macOS that seems to cause problem (maybe the host application is a problem as well). The real code base is a plugin for an application that I have no control over, which runs as a native executable (no dotnet involved). Our plugin spins up the shared runtime. So either there are some debugging issues in .net 6 or something prevents the .net debugger from attaching in the host application. As I said, this happens only on macOS, Windows works fine.
Anyone any ideas what this could be or how I get more info out of the debugger?
Beta Was this translation helpful? Give feedback.
All reactions