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

Relevant URLs:


<genBTC> In addition to strong C# development any experience you have with any of the following will be helpful….WPF, WCF, Sharepoint, Windows Forms, ASP.NET, Java, C++, Silverlight, T-SQL, SQL Server, SSIS, SSRS, SSAS, OLAP, MDX, ICE, MFC, WTL, ADO.NET, AJAX, Tibco EMS, REST, Swing, Cruise Control .NET, NAnt, NUnit, NDoc, FX Cop, Perforce, Visual SourceSafe, Infragistics, Syncfusion, FAST ESP, Design Patterns, Visual C++, Excel, VBA, DTS, Sybase, Oracle,
<genBTC> PL/SQL, STL, VB.NET, CSS, DHTML/HTML, JavaScript, ExtJS, JQuery, YUI, Dojo, UNIX/Linux, XML/XPath/XSLT, PHP, CMS, CRM, COM, Agile, IIS, SOAP, RUP, Flex, ActionScript, WebTrends, Google Analytics, Premium Solver, CPLEX, Regular Expressions, ActiveX, perl, ATL, ASP, and/or VB6.

Cross-Platform Development

The Experimental Stream Player is a portable console application I made for project testing and research. It plays Shoutcast / IceCast streaming Internet radio. Developed on Windows with C#, the same executable runs on both Windows under MS .NET 4.0 and on the Raspberry Pi under mono 3.8.0.

The Experimental Stream Player on the Raspberry Pi (ARM6)

The Experimental Stream Player on the Raspberry Pi (ARM6)

Being a long time friend of the fabulous BASS Audio Library and a fan of the Raspberry Pi, I’m very happy to see BASS supporting the Pi. El many mucho thankies grande go to Ian!

The Experimental Stream Player on Windows (x64)

The Experimental Stream Player on Windows (x64)

You can paste the source code into a console application (program.cs), get BASS (and perhaps the AAC plugin) and BASS.Net. Add a Reference to BASS.Net to your application and compile. Make sure the BASS library files (.dll /.so) are in your path.

If you don’t like to compile yourself, download the binaries archive instead. You will still need a mono installation, and the archive will likely contain an outdated exe… But it has all the necessary libs for Windows, Raspberry Pi and Mac there right away.

Note that the included Raspberry Pi libs are for ARM Linux, so they won’t work on your x86/x64 Linux machine. But you could download those libs from the BASS homepage nonetheless. I’d like to hear from you if you run this on Mac OSX, btw!

Furthermore, the supplied binaries are hardfp versions of BASS Audio Library for ARM Linux, so might not work on softfloat installs of Raspbian. If that’s the case, get the softfloat versions from the Link above.

Compiling Mono 3.8.0 on Windows

I want to cross-platform develop c# on Windows with Visual Studio, for the Raspberry Pi running mono. I’m using SQLite for it’s embeddedness and portable database files. Now, while mono has support for SQLite, my version 3.2.3 happens to have a documented bug with Mono.Data.Sqlite. So it can’t work with .NET 4.0 on Windows.

Doom and despair: The mono project does not have a newer installer for Windows. The available one installs the 3.2.3 instead of current 3.8.0. Attempting to use the Mono.Data.Sqlclient.dll from the Raspberry Pi on the Windows machine was no help either and gave me a BadImageFormatException.

Thus, I compileth mono on my Win7 box…

I’ve been mostly following the official guidance [1] from the mono project here, with some extra steps and additional information from outside sources:

  • mono 3.2.3 was already installed
  • downloaded / installed cygwin
  • obtained mono 3.8.0 source tarball and extracted to disk
  • replaced cygwin make.exe with the make.exe from mono 3.8.0 [2]
  • Added the mono 3.2.3 bin folder to the PATH variable
  • In cygwin, did export MONO_PATH=”/cygdrive/c/Program Files (x86)/Mono-3.2.3″ [3]
  • Gave my account NTFS permissions to the <mono_3.8.0_src>\runtime folder
  • Did a ./configure --host=i686-pc-mingw32
  • Followed by make, make install

This took forever, yet worked like a charm.

Some caveats apply, because my Windows machine is 64bit:
I can’t build my application to AnyCPU target [4], and I have to use the 64bit version of the sqlite3.dll – least everything grinds to a halt with more BadImageFormatException.

But yes, I can now code and compile test.exe in VS on Windows, scp the test.exe to the raspberry, and run it there with mono test.exe. Not bad.

C# console application (test.exe) running on Raspberry Pi

Relevant Documents:


OpenSSL Performance Comparison

willmore from #raspberrypi on freenode IRC has done interesting work, comparing Raspberry Pi openSSL performance against other systems; especially Arduino Galileo’s Quark Processor.

Concluding from willmore’s data, the Pi does especially well with AES ciphers: Running with stock performance options (no overclocking), AES performs nearly 7 times faster on the Raspberry Pi than on the Quark processor.

This makes the Pi an excellent and cost-effective choice for all kinds of secure, networked control and data acquisition tasks.