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

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

问题描述

我正在谈论一个使用C#进行游戏编程的小游戏引擎。
所以,我有一个C ++应用程序嵌入单声道运行时(我称之为'启动器')。我有一个C#编写的程序集,它是我的游戏引擎类库。启动器将按照嵌入单声道中的建议启动程序集。



现在有趣的部分!
启动器以C ++隐藏的功能实现,这些功能暴露于单稳态运行时,作为游戏引擎类的内部方法。这就是为什么我的游戏引擎程序集是没有启动器,在C ++中实现引擎的大部分。



问题:我应该如何调试我的C#程序集?更重要的是,我应该如何调试一个我将在C#中编写的游戏。



据了解,我无法使用MonoDevelop调试程序集调试器,因为它不会收到一些方法的内部C ++实现。



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



或任何其他方式。谢谢!

解决方案

我建议使用Mono Soft Debugger。它已经包含在Mono 2.6以来的Mono运行时间,比旧的硬调试器更可靠,而且更便于携带。



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



通常,调试器选项类似于

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

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



您需要的另一件是调试器GUI /控制器,用于监听应用程序的连接,并处理步进/可视化等等。我建议使用MonoDevelop。有一个名为Mono.Debugger.Soft.dll的调试器线路协议库,但它是相当低级别的,虽然Visual Studio的Mono Tools支持连接到软调试器,但是它还没有扩展,这将允许调试Mono嵌入主机。



使用MonoDevelop接受来自嵌入式主机的调试器连接,目前需要创建一个插件,但这是相当简单的。看看月光调试器插件为例。对于简单的用例,我建议您不要定义一个全新的项目类型,而只需创建一个处理现有DotNetExecutionCommand项目的调试处理程序,因此您可以运行...运行... - >您的自定义调试器。



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


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.

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++.

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# ???

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

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!

解决方案

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.

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.

Typically debugger options are something like

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

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.

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.

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.

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

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

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