Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate Core Dump for Mono C# Application

I am currently working on a c# linux application being run under mono. Although, I believe I've handled any possible exceptions that might be thrown within my program, but should I have missed any, I was wondering if there is a way that when the C# application crashes it creates a core dump file so I can see the exception and go through it to try and determine what caused the problem like GDB does for C programs.

I'm using OpenSuse 12.1 for my application.

Thanks for any help you can provide.

like image 875
Boardy Avatar asked Aug 20 '12 21:08

Boardy


1 Answers

Sounds like you want a SuperAssert for Mono. I could only find this Mono mail thread. They discuss the possible conversion of the Managed Debugger to Mono. Unfortunately the Microsoft EULA appears to have prevented them from porting this one. Therefore it looks like you'll need to use the Operating System directly. Here is the official guide on how you capture a core dump

The following steps should be taken to prepare for capturing a core dump:

-Disable the limit for the maximum size of a core dump file
-Configure a fixed location for storing core dumps
-Disable AppArmor
-Enable core dumps for setuid and setgid processes

The quick step guide for this is as follows:

Run

ulimit -c unlimited

Run

install -m 1777 -d /var/local/dumps

Run

echo "/var/local/dumps/core.%e.%p"> /proc/sys/kernel/core_pattern

Run

rcapparmor stop

Run

sysctl -w kernel.suid_dumpable=2

(Re)start problematic processes.

Also take a look at this thread: Core dump in Linux - if you think the app might crash, maybe you could setup a technical support helper script/exe to perform all the above actions and launch the Mono application. This would make it easy for end user to reproduce the problem and send you the dump to diagnose the problem.

like image 143
Jeremy Thompson Avatar answered Sep 29 '22 19:09

Jeremy Thompson