如何将 LLDB 附加到 C# .NET 进程并调试动态加载的 macOS 包?

How to attach LLDB to C# .NET process and debug dynamically loaded macOS bundle?

我已经开始为 Unity 和 Unreal 编写一个 C++ 中间件。现在,在 macOS 上,我想将 LLDB 附加到 Unity 沙箱项目的进程中,以便调试一些问题。我怎么能做这样的事?

我的中间件构建为 macOS 包,并通过 C# Unity 脚本动态加载。

public class MyMiddleware
{
  [DllImport("MyMiddleware")]
  public static extern int SomeFailingFunction();
}

public class SomeBehaviour: MonoBehaviour
{
  private void Start() {
    MyMiddleware.SomeFailingFunction();
  }
}

我在生成包时嵌入了调试信息。我想调试 SomeFailingFunction 的 C++ 实现。

看来我可以很好地将 LLDB 附加到 Unity 的主进程,只要它不干扰另一个调试器。就我而言,Unity 崩溃是因为我已经在使用 Visual Studio 的调试器。

另请注意,当您忘记停止 Visual Studio 的调试器、使用 LLDB 并且 Unity 崩溃时,您的场景在重新启动 Unity 时并不总是正确加载。我通过文件管理器和场景文件(在 Assets/Scenes 中)启动 Unity 来解决这个问题。

我还不知道有什么更干净/更方便的方法。最好是能够直接从 Visual Studio 的调试器中读取调试信息。