1998-05-24 00:35:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# This script parses the output of a gcc bootstrap when using warning
|
|
|
|
# flags and determines various statistics.
|
|
|
|
#
|
|
|
|
# By Kaveh Ghazi (ghazi@caip.rutgers.edu) 12/13/97.
|
|
|
|
|
1998-10-05 13:27:05 +02:00
|
|
|
# This function does one of three things. It either passes through
|
|
|
|
# all warning data, or passes through gcc toplevel warnings, or passes
|
|
|
|
# through a particular subdirectory set of warnings.
|
|
|
|
subdirectoryFilter()
|
|
|
|
{
|
|
|
|
if test "$filter" = '' ; then
|
|
|
|
# Pass through all lines.
|
|
|
|
cat $1
|
|
|
|
else
|
|
|
|
if test "$filter" = nosub ; then
|
|
|
|
# Omit all subdirectories.
|
|
|
|
$AWK 'BEGIN{t=1} ; /^cd [a-z]*; make/{if(t==1)t=0} ; /Leaving directory/{if(t==0)t=1} ; {if(t==1)print}' $1
|
|
|
|
else
|
|
|
|
# Pass through only subdir $filter.
|
|
|
|
$AWK "/^cd $filter"'; make/{if(t==0)t=1} ; /Leaving directory/{if(t==1)t=0} ; {if(t==1)print}' $1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
1998-06-01 02:26:36 +02:00
|
|
|
# This function displays all warnings from stageN of the bootstrap.
|
|
|
|
stageNwarns()
|
1998-05-24 00:35:33 +02:00
|
|
|
{
|
1998-06-01 02:26:36 +02:00
|
|
|
stageNminus1=`expr $stageN - 1`
|
1998-05-24 00:35:33 +02:00
|
|
|
# Some awks choke on long lines so grep them out.
|
|
|
|
grep -v libf2c.a $1 | \
|
1998-06-01 02:26:36 +02:00
|
|
|
$AWK "/ warning: /{if(t==1)print} ; /stage$stageNminus1/{if(t==0)t=1} ; /stage$stageN/{if(t==1)t=0}"
|
1998-05-24 00:35:33 +02:00
|
|
|
}
|
|
|
|
|
1998-10-05 13:27:05 +02:00
|
|
|
usage="usage: `basename $0` [-s stage] [-nosub|-ch|-cp|-f|-java] [file(s)]"
|
1998-06-01 02:26:36 +02:00
|
|
|
stageN=3
|
|
|
|
|
1998-05-24 00:35:33 +02:00
|
|
|
# Find a good awk.
|
|
|
|
if test -z "$AWK" ; then
|
|
|
|
for AWK in gawk nawk awk ; do
|
|
|
|
if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
1998-06-01 02:26:36 +02:00
|
|
|
while test -n "$1" ; do
|
|
|
|
case "$1" in
|
|
|
|
-s) if test -z "$2"; then echo $usage; exit 1; fi; stageN="$2"; shift 2 ;;
|
|
|
|
-s*) stageN="`expr $1 : '-s\(.*\)'`" ; shift ;;
|
1998-10-05 13:27:05 +02:00
|
|
|
-nosub|-ch|-cp|-f|-java) filter="`expr $1 : '-\(.*\)'`" ; shift ;;
|
1998-06-01 02:26:36 +02:00
|
|
|
-*) echo $usage ; exit 1 ;;
|
|
|
|
*) break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
1998-10-05 13:27:05 +02:00
|
|
|
# Check for a valid value of $stageN.
|
|
|
|
case "$stageN" in
|
|
|
|
[1-9]) ;;
|
|
|
|
*) echo "Stage <$stageN> must be in the range [1..9]." ; exit 1 ;;
|
|
|
|
esac
|
1998-06-01 02:26:36 +02:00
|
|
|
|
1998-05-24 00:35:33 +02:00
|
|
|
for file in "$@" ; do
|
|
|
|
|
1998-10-05 13:27:05 +02:00
|
|
|
if test "$filter" = '' ; then
|
|
|
|
echo "Counting all warnings,"
|
|
|
|
else
|
|
|
|
if test "$filter" = nosub ; then
|
|
|
|
echo "Counting non-subdirectory warnings,"
|
|
|
|
else
|
|
|
|
echo "Counting warnings in the gcc/$filter subdirectory,"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
count=`subdirectoryFilter $file | stageNwarns | wc -l`
|
|
|
|
echo there are $count warnings in stage$stageN of this bootstrap.
|
1998-05-24 00:35:33 +02:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo Number of warnings per file:
|
1998-10-05 13:27:05 +02:00
|
|
|
subdirectoryFilter $file | stageNwarns | $AWK -F: '{print$1}' | \
|
|
|
|
sort | uniq -c | sort -nr
|
1998-05-24 00:35:33 +02:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo Number of warning types:
|
1998-10-05 13:27:05 +02:00
|
|
|
subdirectoryFilter $file | stageNwarns | sed 's/.*warning: //;
|
1998-05-24 00:35:33 +02:00
|
|
|
s/`\(int\)'"'"'/"\1"/g;
|
1998-10-05 13:27:05 +02:00
|
|
|
s/`\(long\)'"'"'/"\1"/g;
|
1998-05-24 00:35:33 +02:00
|
|
|
s/`\(char\)'"'"'/"\1"/g;
|
|
|
|
s/`\(inline\)'"'"'/"\1"/g;
|
|
|
|
s/`\(else\)'"'"'/"\1"/g;
|
|
|
|
s/`\(return\)'"'"'/"\1"/g;
|
|
|
|
s/`\(static\)'"'"'/"\1"/g;
|
|
|
|
s/`\(extern\)'"'"'/"\1"/g;
|
1998-10-05 13:27:05 +02:00
|
|
|
s/`\(const\)'"'"'/"\1"/g;
|
1998-05-24 00:35:33 +02:00
|
|
|
s/`\(longjmp\)'"'"' or `\(vfork\)'"'"'/"\1" or "\2"/g;
|
|
|
|
s/`'"[^']*'/"'`???'"'/g;"'
|
1998-10-05 13:27:05 +02:00
|
|
|
s/.*format, .* arg (arg [0-9][0-9]*)/??? format, ??? arg (arg ???)/;
|
|
|
|
s/\([( ]\)arg [0-9][0-9]*\([) ]\)/\1arg ???\2/;
|
1998-05-24 00:35:33 +02:00
|
|
|
s/"\([^"]*\)"/`\1'"'"'/g' | \
|
|
|
|
sort | uniq -c | sort -nr
|
|
|
|
|
|
|
|
done
|