调试嵌入式单声道运行时启动的 C# 程序集? [英] Debugging C# assembly launched by embedded mono runtime?

查看:19
本文介绍了调试嵌入式单声道运行时启动的 C# 程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我说的是使用 C# 进行游戏编程的小型游戏引擎.所以,我有一个嵌入单声道运行时的 C++ 应用程序(我称之为启动器").我有一个用 C# 编写的程序集,这是我的游戏引擎类库.启动器按照 Embedding Mono 中的建议启动程序集.

I am talking about a small game engine using C# for game programming. So, I have a C++ app embedding mono runtime (I call it 'launcher'). And I have an assembly written in C# which is my game engine class library. The launcher launches the assembly as it is suggested in Embedding Mono.

现在是有趣的部分!启动器在 C++ 中实现了作为我的游戏引擎类的内部方法公开给单声道运行时的杂项函数.这就是为什么如果没有使用 C++ 实现大部分引擎的启动器,我的游戏引擎组件就什么都不是.

And now the interesting part! The launcher implements in C++ miscelaneous functions which are exposed to the mono runtime as internal methods of my game engine classes. That is why my game engine assembly is nothing without the launcher which implements a huge part of the engine in C++.

问题:我应该如何调试我的 C# 程序集?更重要的是,我应该如何调试我要用 C# 编写的游戏???

The question: How am I supposed to debug my C# assembly? And what is more important, how am I supposed to debug a Game which I am going to write in C# ???

如您所知,我无法使用 MonoDevelop Debugger 调试程序集,因为它不会接收其某些方法的内部 C++ 实现.

As you understand I cannot debug the assembly using MonoDevelop Debugger because it won't receive internal C++ implementations of some of its methods.

我需要的是运行启动器.然后,启动器将使用嵌入式单声道运行时启动 C# 程序集.然后我需要一些东西来连接到已启动的程序集以允许其调试.

What I need is to run the Launcher. The launcher then will launch C# assembly using embedded mono runtime. And then I need something to connect to the launched assembly to allow its debugging.

或任何其他方式.谢谢!

Or any other way. Thank you!

推荐答案

我推荐使用 Mono Soft Debugger.从 Mono 2.6 开始,它就被包含在 Mono 运行时中,并且比旧的硬调试器更可靠,而且更便携.

I recommend using the Mono Soft Debugger. It's been included in the Mono runtime since Mono 2.6, and is more reliable than the old hard debugger, and also much more portable.

可以通过使用 --debugger-agent 命令行参数向 Mono 运行时传递选项来启动 Mono 软调试器.这可以从嵌入主机通过构造一组假的命令行参数并将其传递给 mono_jit_parse_options 来完成.例如,Moonlight 浏览器插件使用来自 MOON_SOFT_DEBUG 环境变量的调试器代理值(如果已设置).

The Mono soft debugger can be started by passing options using the --debugger-agent commandline argument to the Mono runtime. This can be done from an embedding host by constructing a fake set of commandline arguments and passing it to mono_jit_parse_options. For example, the Moonlight browser plugin uses the debugger agent values from MOON_SOFT_DEBUG environment variable if it is set.

通常调试器选项类似于

--debugger-agent="transport=dt_socket,address=$ADDRESS:$PORT"

这将导致应用尝试连接到侦听给定地址的调试器,并暂停直到建立连接.请注意,连接是通过 TCP/IP 建立的,这意味着远程调试非常容易设置,即使在本地计算机上您也可以使用 localhost.Mono 的手册页中记录了其他选项.

which will cause the app to try to connect to debugger listening on the given address, and pause until it establishes a connection. Note that the connection is established over TCP/IP, which means remote debugging is very easy to set up, and even on the local machine you would use localhost. Additional options are documented on Mono's man page.

您需要的另一部分是调试器 GUI/控制器,用于侦听来自您的应用程序的连接,并处理步进/可视化等.我建议使用 MonoDevelop.有一个用于调试器有线协议的库,称为 Mono.Debugger.Soft.dll,但它的级别相当低,尽管 Visual Studio 的 Mono 工具支持连接到软调试器,但它还不能以允许调试 Mono 的方式进行扩展嵌入主机.

The other piece you need is the debugger GUI/controller, to listen for the connection from your app, and handle stepping/visualizing, etc. I would suggest using MonoDevelop. There's a library for the debugger wire protocol called Mono.Debugger.Soft.dll, but it's fairly low-level, and although Mono Tools for Visual Studio supports connecting to the soft debugger, it's not yet extensible in a way that would allow debugging Mono embedding hosts.

目前使用 MonoDevelop 接受来自嵌入主机的调试器连接需要创建一个插件,但这相当简单.看看 Moonlight 调试器插件 举个例子.对于简单的用例,我建议您不要定义全新的项目类型,而只需创建一个处理现有 DotNetExecutionCommand 项目的调试处理程序,这样您就可以 run->run with...->your custom debugger.

Using MonoDevelop to accept debugger connections from embedding hosts currently requires creating an addin, but this is fairly straightforward. Take a look at the Moonlight debugger addin for an example. For simple use cases I would suggest that you don't define a whole new project type but just create a debug handler that handles existing DotNetExecutionCommand projects, so you can run->run with...->your custom debugger.

如果您有更多问题,monodevelop-list 邮件列表是一个很好的资源.

The monodevelop-list mailing list is a good resource if you have more questions.

这篇关于调试嵌入式单声道运行时启动的 C# 程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆