I've started writing a c++ middleware for Unity and Unreal. Now, on macOS, I want to attach LLDB to the process of a Unity sandbox project, in order to debug some issue. How can I do such a thing?
My middleware is built as a macOS bundle, and is dynamically loaded through a C# Unity script.
public class MyMiddleware
{
[DllImport("MyMiddleware")]
public static extern int SomeFailingFunction();
}
public class SomeBehaviour: MonoBehaviour
{
private void Start() {
MyMiddleware.SomeFailingFunction();
}
}
I've embedded debug informations while generating the bundle. I want to debug SomeFailingFunction
's C++ implementation.
It appears I can attach LLDB to Unity's main process fine, as long as it doesn't interfere with another debugger. In my case Unity crashed because I already was using Visual Studio's debugger.
Also note that when you forget to stop Visual Studio's debugger, use LLDB, and that Unity crashes, your scene doesn't always load correctly when restarting Unity. I work around that by starting Unity through the file manager, with the scene file (in Assets/Scenes).
I don't know of any cleaner / more convenient approach yet. The best would be to be able to directly read debug informations from Visual Studio's debugger.