Skip to content

Instantly share code, notes, and snippets.

@mmasashi
Last active September 17, 2015 05:43
Show Gist options
  • Save mmasashi/0bb81f4e9269f7c5584d to your computer and use it in GitHub Desktop.
Save mmasashi/0bb81f4e9269f7c5584d to your computer and use it in GitHub Desktop.
Get sigdump with timestamp filename and extract memory section in sorted order by the variable name.
#!/bin/bash
pid=$(expr "$1" : '\([0-9][0-9]*\)')
if [ "$1" = "" ] || [ "$1" != "$pid" ]; then
echo "pid requires to be given"
exit 1
fi
kill -CONT $pid
sleep 1
DT_STR=$(date +"%Y%m%d_%H%M%S")
dump_fn="sigdump-${pid}.log.${DT_STR}"
mem_fn="memdump-${pid}.log.${DT_STR}"
mv "/tmp/sigdump-${pid}.log" "sigdump-${pid}.log.${DT_STR}"
line_num=$(cat $dump_fn| awk 'match($0, /All objects:/) {print NR}'|tail -n 1)
awk -v line_num=$line_num 'NR > line_num {print $2" "$1}' $dump_fn|sort > $mem_fn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment