#!/bin/sh # Verify correct program usage if [ $# != 1 ]; then echo "Syntax:"; echo " $0 "; echo "where is setup, webify, or cleanup."; exit; fi # The program we want to mess with for running the gnome-session filename=/opt/gnome2/bin/gnome-session # A little awk program to extract valgrind statistics... awk_prog=$(echo \' \ 'BEGIN {errors=0;' \ 'definitely_size=0; definitely_number=0;' \ 'possibly_size=0; possibly_number=0;' \ 'still_size=0; still_number=0}' \ '/ERROR SUMMARY/ {errors+=$7}' \ '/LEAK SUMMARY/ {' \ 'getline; definitely_size+=$4; definitely_number+=$7;' \ 'getline; possibly_size+=$4; possibly_number+=$7;' \ 'getline; still_size+=$4; still_number+=$7' \ '}' \ 'END {print ' \ '"" errors ""' \ '"" definitely_size " (" definitely_number ")"' \ '"" possibly_size " (" possibly_number ")"' \ '"" still_size " (" still_number ")"' \ '""}' \ \') setup() { mv $filename $filename.orig mkdir -p /tmp/valgrind echo "#!/bin/sh" > $filename # Other options to consider: # --show-reachable=yes echo "~/bin/valgrind --logfile=/tmp/valgrind/log" \ "--trace-children=yes --tool=memcheck --num-callers=48" \ "--leak-check=yes --leak-resolution=high " \ "gnome-session.orig \$*" >> $filename chmod 0755 $filename } cleanup() { rm -rf /tmp/valgrind mv $filename.orig $filename } webify() { if [ -e new-logs ]; then echo "new-logs already exists! Aborting..." exit fi mkdir -p new-logs stat_file=new-logs/valgrind-statistics.html # Create the beginning of the valgrind-statistics.html file echo "" \ "`date +%F` Valgrind statistics" \ "" \ > $stat_file echo "

Valgrind statistics from `date +%F` run

" >> $stat_file echo "" \ "" \ "" \ "" \ "" \ "" \ "" >> $stat_file for file in `ls /tmp/valgrind/*`; do # We only care about valgrinded programs from /opt/gnome2 process=`cat $file | head -n 7 | tail -n 1 | sed -e "s/==[0-9]*==[ ]*//"` if (`which -a $process | grep /opt/gnome2 > /dev/null`); then # Determine the new filename to use instead of log.pidxxxxxx basename=`echo $process | sed -e s#.*/##` i=0; while [ -f new-logs/$basename.$i.log.txt ]; do let i=i+1; done # Save the new file cp -a $file new-logs/$basename.$i.log.txt # Save some statistics too echo -n " " >> $stat_file command="cat $file | awk $awk_prog"; echo $(eval $command) >> $stat_file fi done # Create the beginning of the valgrind-statistics.html file echo "" >> $stat_file chmod a+r new-logs/* rsync -e /usr/local/bin/ssh -az --progress new-logs/ \ www.gnome.org:public_html/valgrind/`date +%F` } if [ $1 == "setup" ]; then setup; elif [ $1 == "cleanup" ]; then cleanup; elif [ $1 == "webify" ]; then webify; fi
ProcessErrorsDefinitely LostPossibly LostStill Reachable
" >> $stat_file if (( $i > 0 )); then echo -n "$basename#$i" >> $stat_file else echo -n "$basename" >> $stat_file fi echo -n "