C # assembly debugging launched by built-in mono runtime?

I am talking about a small game engine that uses C # to program games. So, I have a C ++ application that embeds mono executable time (I call it "launcher"). And I have a build written in C #, which is my library of game engine classes. The launcher launches the build as suggested in Embedding Mono .

And now the interesting part! The launcher implements false functions in C ++ that are mono-runtime as internal methods of my game engine classes. That's why my assembly of game engines is no different from a launcher, which implements a huge part of the engine in C ++.

Question: How do I debug a C # assembly? And more importantly, how should I debug the game I'm going to write in C # ???

As you understand, I cannot debug the assembly using the MonoDevelop Debugger, because it will not receive the internal C ++ implementations of some of its methods.

I need to launch Launcher. Then the launcher launches the C # build using the built-in mono execution. And then I need to connect something to the running assembly in order to enable debugging.

Or in any other way. Thanks!

+4
source share
2 answers

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

You can start the Mono soft debugger by passing parameters using the --debugger-agent command line --debugger-agent to the Mono runtime. This can be done from the deployment node by building a fake set of command line arguments and passing it to mono_jit_parse_options . For example, the Moonlight browser plugin uses debug agent values ​​from the MOON_SOFT_DEBUG environment variable, if installed.

Typically, debugger options are similar to

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

which will cause the application to try to connect to the debugger listening on this address and pause until the connection is established. Please note that the connection is established via TCP / IP, which means that remote debugging is very easy to configure, and even on the local computer you will use localhost. Additional options are described on the Mano man page.

Another piece you need is the debugger's GUI / controller, listening for a connection from your application, and handling stepping / rendering, etc. I would suggest using MonoDevelop. There is a library for the wired debugger protocol Mono.Debugger.Soft.dll, but it is rather low-level, and although Mono Tools for Visual Studio supports connecting to a soft debugger, it is not yet extensible, which allows you to debug Mono host embedding.

Using MonoDevelop to receive debugging connections from host embeddings currently requires the creation of addin, but it's pretty simple. Take a look at monodevelop-list is a good resource if you have additional questions.

+5
source

Use network debugging.

You can use Soft Debugger to debug Mono parts, and then use remote debugging for C ++ parts.

+1
source

All Articles