How Can I Create A Dump File of a Running Process in Linux?
Well the way to create a dump file is:
gcore - Generate a core file for a running process
SYNOPSIS gcore [-o filename] pid
pmap <PID>
or
strace -f -o xxx -p <PID>
might be the tools you are looking for.
pmap shows you an overview about the memory usage of the provided process. strace tracks down every action a process takes. With -f you tell strace to also consider watching over child processes and -o xxx tells strace to write the output to a file. You can also start a new process by using strace, e.g. with
strace cat /etc/passwd
If you are interested in specific information only, such as what files were opened, you can start strace accordingly:
strace -f -o xxx -e trace=open -p <PID>
Try this:
cat /proc/<pid>/smaps > mem.txt
This link might also help you.
Meanwhile ProcDump from the Sysinternals suite has also been made available under the very liberal MIT license from the respective GitHub page.
Usage: procdump [OPTIONS...] TARGET
OPTIONS
-C CPU threshold at which to create a dump of the process from 0 to 100 * nCPU
-c CPU threshold below which to create a dump of the process from 0 to 100 * nCPU
-M Memory commit threshold in MB at which to create a dump
-m Trigger when memory commit drops below specified MB value.
-n Number of dumps to write before exiting
-s Consecutive seconds before dump is written (default is 10)
TARGET must be exactly one of these:
-p pid of the process
So as you can deduce from the command line arguments, it's easy to take "snapshots" of a process you know misbehaves by taking up undue amounts of resources to be later analyzed with gdb
or so.
This ProcDump for Linux is, however, not feature-complete in comparison with its Windows cousin.