Created
April 15, 2014 13:50
-
-
Save hiboma/10734390 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # here is an original code: | |
| # http://serverfault.com/questions/173999/dump-a-linux-processs-memory-to-file | |
| # | |
| function extract_memory_region() | |
| { | |
| pid=$1 | |
| grep rw-p /proc/${pid}/maps | sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p' | |
| } | |
| function gdb_dump_memory() | |
| { | |
| pid=$1 | |
| start=$2 | |
| end=$3 | |
| gdb --batch --pid ${pid} -ex "dump memory ${pid}-$start-$stop.dump 0x$start 0x$stop" | |
| } | |
| pid=$1 | |
| if [ "$pid" = "" ]; then | |
| echo "[usage] $0 <pid>" | |
| exit 1 | |
| fi | |
| extract_memory_region $pid | while read start stop | |
| do | |
| gdb_dump_memory $pid $start $end | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment