gcore: Obtain core dump of current running application

Core dump is always developer’s friends and can be admin user’s nightmare. Developer’s can always get some clue of what’s going wrong through the core files, given that the apps is compiled with -g.

In order to get core dump generated, we must enable the core through ulimit. Generate coredumps to help developer for debugging introduce you how to enable core dump as well as how to access the info through gdb.

Sometimes, the app may hangs there, reject to response. This is really headache for the programmers to debug without looking into its internal, investigate whats going wrong. You may choose to debug it directly through gdb . Or maybe you would like to generate the core file and send it to your development team. You can choose to abort it and collect the core file .

But what if abort is not the case? and you still want your apps to run, but wanna take a snapshot of current running apps into a core file?

Thanks to W.G. that leaves me a comment introducing gcore to us, that consider a godsend, and I think this command is really useful. Yes, a simple command that allow us to get core images of running processes.

Let say I am running an app call matrix (a simple ncurses sample app that emulates the words flow). I can obtain the process id by using pgrep and pass to gcore like this:

gcore `pgrep matrix`

The core file you obtain will be core.pid format like this:

core.6129

A tiny nice option gcore support you change your output core file’s name with -o

gcore -o matrix `pgrep matrix`

The line above will produce the core file as below:

matrix.6129

Freebsd provides a better gcore, it does allow you to temporary STOP the running process while gathering the core image, and resume it when done.

gcore -s `pgrep matrix`
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值