How to view C# stack trace when a breakpoint is hit in native C++ plugin (Unity)?
I'm debugging a Unity project with a native C++ plugin. I use CLion to hit breakpoints in the C++ code, but I want to see the C# (managed) stack trace that led to the native call.
In CLion, only the native stack is visible.
Is there a way to view the managed C# call stack at the moment the native breakpoint is hit — either in CLion or Rider?
Please sign in to leave a comment.
Hello,
Yes, it is supported in Rider. Please see the screenshot below.
Have a nice day!
Dmitry Kazantsev
Hello, does this mean I also need to put the C++ code into Rider? The C++ repo and C# repo are separate, and I use CLion for C++ since it’s better suited for C++ development. In this case, how can I view the C++ stack trace in Rider? Is there a way for C# to load both repos at the same time for debugging?
Hello Zhoujiazhiwork ,
Putting C++ code isn't necessary. But it can help with accessing C++ files.
For easy access to C++ sources, you can attach the native plugin directory to your Unity project via: right-click on the root node in explorer → Add → Existing Folder. You can put breakpoints in C++ files, so the debugger will stop at them:
Generally, when you see the debugger is in the line that invokes a native method, “Step Into” should navigate to the corresponding C++ file.
You might find this article helpful: SUPPORT-A-1957 How to use mix-mode debugger for Unity Mono process.
Have a nice day!
Dmitry Kazantsev
It looks promising, but in Rider, the ‘Add’ menu does not have an ‘Existing Folder’ option.
It is JetBrains Rider 2025.2.1.
It can't be done in the “File System” or “Unity” mode in the explorer. Switch to “Solution”, so that you should be able to add Existing Folder:
Dmitry Kazantsev
Does mixed-mode debugging only exist on Windows? I’m using macOS, and the native stack trace doesn’t show. I also cannot step into native code using “Step Into.”
Indeed, mixed-mode debug is currently only supported on Windows. Please vote for this feature request regarding MacOS support: RIDER-127358 Mono Mixed Mode. Support for MacOS