Debugging mono applications with gdb

Debugging a C# app that:

  • Uses native libraries
  • Segfaults on Linux w/ mono
  • Runs fine on Windows

Given that a native C app using the same calls to the native lib will not Segfault, you can:

  • set MONO_LOG_LEVEL=debug
  • set MONO_LOG_MASK=dll
  • Create a .gdbinit file as per [1].
  • Use the –args switch to tell gdb to run mono with your exe
  • Once in gdb, use “r” to run mono with your exe.
  • Use “bt” to get a backtrace
  • Use “info sharedlibrary <libname>” on your native library

If you have debug symbols, you can:

  • Use “info registers” and
  • “info frame” to get stack frame information

You can also do:

mono –trace=all <executable>

An example is at http://pastebin.com/Kza9kemJ

Relevant URLs:
[1] http://www.mono-project.com/docs/debug+profile/debug/#debugging-with-gdb

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s