I have a .NET application that I have ported to .NET Core. I am testing it on Ubuntu 14.04.
I am trying to figure out how to get a .dmp file or the Linux equivalent
you want a core dump, this is built into the OS.
first ulimit -Sc unlimited
as the user you want to run the process as so allow creating a core file of any size.
Then kill -4 <pid>
This should generate the core dump. It should probably be in the directory where the process was run from.
If you can't login as the user the application runs as, you will need to put this into limits.conf.
I can get core dump by Using Environment.FailFast("core dump")
in my C# code. Maybe you need to set core dump size and location with ulimit -c unlimited
and echo coredump > /proc/sys/kernel/core_pattern
first.
[xxx/tmp]$ ls core*
core.dotnet.10470
The generation of linux coredumps is defined by what's in /proc/sys/kernel/core_pattern
. If certain signals (e.g. SIGSEGV
or SIGQUIT
) cause a process to terminate, an image of the process's memory is basically written into that file. If it starts with a pipe-symbol |
, it can be streamed into an application which does dump analysis. It's documented here: http://man7.org/linux/man-pages/man5/core.5.html
If you configure it like that:
echo coredump > /proc/sys/kernel/core_pattern
it will write a file named coredump
into the current directory.
If you configure it like that:
echo "/tmp/cores/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern
It will create a file like /tmp/cores/core.bash.8539.drehbahn-mbp.1236975953
(see https://sigquit.wordpress.com/2009/03/13/the-core-pattern/)
As others suggested, also set ulimit -S -c unlimited
to allow coredumps of any size.
Here is a blog-post which shows how to create and analyze .NET Core coredumps under linux: http://blogs.microsoft.co.il/sasha/2017/02/26/analyzing-a-net-core-core-dump-on-linux/
Good news!: Now you can install a tool to get the dump automatically.
First you run dotnet tool install -g dotnet-dump
then you can dotnet-dump [-h|--help] [--version] <command>
For more info and examples see: https://docs.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-dump