如何在Linux上转储.NET Core应用程序 [英] How to Dump a .NET Core Application on Linux
问题描述
我有一个已移植到.NET Core的.NET应用程序.我正在Ubuntu 14.04上对其进行测试.
我试图弄清楚程序崩溃时如何获取.dmp文件或Linux等效文件.我打电话给Environment.FailFast
,但据我所知,它不会像Windows那样生成.dmp文件.根据这种情况 Environment.FailFast
应该正在创建转储,但如果找不到,则<. /p>
此外,我尝试使用gcore
手动创建转储.这可以工作,但是生成转储需要很长时间(我的应用程序不是那么大),并且当我将gdb指向我的应用程序dll时,我无法识别出它,因此我无法在gdb中获得正确的调用堆栈
在Linux上转储.NET Core应用程序的最佳方法是什么?
谢谢!
Linux coredumps的生成由/proc/sys/kernel/core_pattern
中的内容定义.如果某些信号(例如SIGSEGV或SIGQUIT)导致进程终止,则基本上将进程内存的映像写入该文件中.如果它以竖线符号|
开头,则可以将其流式传输到进行转储分析的应用程序中.它记录在这里: http://man7.org/linux/man- pages/man5/core.5.html
如果您这样配置它:
echo coredump > /proc/sys/kernel/core_pattern
它将名为coredump
的文件写入当前目录.
如果您这样配置它:
echo "/tmp/cores/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern
它将创建一个类似于/tmp/cores/core.bash.8539.drehbahn-mbp.1236975953
的文件(请参见 https://sigquit.wordpress.com/2009/03/13/the-core-pattern/)
正如其他人建议的那样,还设置ulimit -S -c unlimited
以允许任何大小的核心转储.
这里是一篇博客文章,显示了如何在Linux下创建和分析.NET Core核心转储: http://blogs.microsoft.co.il/sasha/2017/02/26/analyzing-a-net-core-核心转储Linux/
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 when the program crashes. I call Environment.FailFast
but as far as I can tell this doesn't generate a .dmp file like it does on Windows. Acording to this case Environment.FailFast
should be creating a dump but if it is I can't find it.
In addition I have tried manually creating a dump using gcore
. This works however it takes a long time to generate the dump (my application isn't that big) and I am unable to get the correct callstacks in gdb after the fact as when I point gdb to my application dll it doesn't recognize it.
What it he best way to get a dump of a .NET Core application on Linux?
Thanks!
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/
这篇关于如何在Linux上转储.NET Core应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!