gcore - dumping memory
So I recently ran into a situation where I needed to figure out what a process was doing on my FreeBSD box when it spun out of control. My plan of attack was to force a core dump, but I wanted to let the process continue to run.
That’s when I came across the unix gcore command:
http://www.freebsd.org/cgi/man.cgi?query=gcore&sektion=1
This handy guy did the trick. Don’t forget to use the “-s” parameter to temporarily suspended the process to create a consistent stacktrace during the dump.
After that I was off to the races with gdb. At first gdb wasn’t showing anything in the backtrace, but I was quick to recall that perhaps the issue was in another thread and pulled up the list of threads using info threads. Selecting the correct thread (thread <number>) revealed what the culript I was after was up to. Gotcha!