Debugging w / Embedded Mono, how to set breakpoints in C # code?

I am using Embedded Mono, works great. The main application is C ++ and I can load assemblies, create objects, call methods, etc.

Now I want to use MonoDevelop to connect to my program and then set breakpoints in managed (C #) code. After much research, I am passing the following to:

    static const char* options[] = {
          "--soft-breakpoints",
          "--debugger-agent=transport=dt_socket,address=127.0.0.1:10000"
        };

mono_jit_parse_options(sizeof(options)/sizeof(char*), (char**)options);
mono_debug_init(MONO_DEBUG_FORMAT_MONO);

      

After making the above calls, the application will connect to MonoDevelop.

On the MonoDevelop side, I install env. var MONODEVELOP_SDB_TEST=y

that lets you use "Run → Run With → Custom MonoSoft Debugger and it will connect to the application.

Here's the tricky part: in order to run Run -> Custom Command MonoSoft Debugger you had to open the project, to just do it I just opened the assembly (Debug built), then in the project options I added a custom command "Execute" and pointed to C ++. exe and checked the "Run external console" checkbox.

After clicking the Listen button in the MonoSoft Debugger dialog my application starts, I see messages in the application output about my assemblies, however, if I open the source file (C #) and try to set a breakpoint, turn the disabled color and never get hit. What I'm missing is I need to call some other mono_debug function to tell mono to debug my builds, is there some gdb path property to tell MonoDevelop where to look for sources?

+3


source to share


1 answer


When our application prints the stack traces (Environment.Stacktrace), do they have the source file and line information? If not, you should check that you have mdb symbol files next to the assemblies.

If your managed code was built with .NET compilers, you will have pdb files that Mono cannot load. Use the pdb2mdb tool to convert them to mdb files.



Also make sure the file paths in the stack trace match the paths to the actual source files on the host machine.

+2


source







All Articles