I'm writing a tool for core dump analysis and one thing I'd like to print is an estimate of how much virtual memory the process was using at the time of the dump. These core dumps could be due to crashes or could be manually taken using gcore (e.g. for sizing). Essentially, I'd like to print the equivalent of the PS VSZ column.
I've looked into readelf and gdb and have focused on the latter. For example, I've got a simple program that just hangs and I see in PS:
$ ps auxwww | grep a.out
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 16644 0.0 0.0 4108 472 pts/5 S+ 13:51 0:00 ./a.out
I take a core using gcore, at which point it's using 4,206,592 bytes VSZ. Then I wrote a quick script that parses info target
output and sums the address ranges and I get 1,814,528 bytes. I also tried info proc mappings
but that seems to only work if the process is running.
Any ideas?