March 24th, 2008 mysurface Posted in Uncategorized | Hits: 66952 | 5 Comments »
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:
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:
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`