diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-10-31 08:30:53 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-10-31 08:30:53 +0000 |
commit | dc446b46b44cf724cfae685ba2e61ce60b9c8173 (patch) | |
tree | aa82eb6a7b851658dd48e17bac5e07380d435374 /contrib/warn_summary | |
parent | c7bdb2f6c42d8715067785e4b695d3b2903e42ad (diff) | |
download | gcc-dc446b46b44cf724cfae685ba2e61ce60b9c8173.tar.gz |
* warn_summary (longLineFilter): New shell function to encapsulate
this functionality. It is off by default, only active if -llf
flag is specified.
(subdirectoryFilter): Fix bug in filtering which made some
subdirectory warnings erroneously appear in the toplevel set.
(stageNfilter): Renamed from `stageNwarns'. Updated to collect
warnings from stage1 as well as stage0, which means warnings from
outside the bootstrap directory. Eg, the libraries, etc.
(warningFilter): New shell function to encapsulate this
functionality.
(keywordFilter): New shell function to encapsulate this
functionality.
Store data in a temp file rather than calculating it 3x. Arrange
to remove it on exit and signals.
Add -pass/-wpass flags to do "pass through" (i.e. manual
inspection) of bootstrap output from a particular stageN as well
as language subdirs.
Add better comments/documentation.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23473 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'contrib/warn_summary')
-rwxr-xr-x | contrib/warn_summary | 158 |
1 files changed, 124 insertions, 34 deletions
diff --git a/contrib/warn_summary b/contrib/warn_summary index 2ce64034bdf..21dfe99fa77 100755 --- a/contrib/warn_summary +++ b/contrib/warn_summary @@ -1,39 +1,129 @@ #!/bin/sh +# # This script parses the output of a gcc bootstrap when using warning # flags and determines various statistics. +# +# usage: warn_summary [-llf] [-s stage] [-nosub|-ch|-cp|-f|-java] +# [-pass|-wpass] [file(s)] +# +# -llf +# Filter out long lines from the bootstap output before any other +# action. This is useful for systems with broken awks/greps which choke +# on long lines. It is not done by default as it sometimes slows things +# down. +# +# -s number +# Take warnings from stage "Number". Stage 0 means show warnings from +# before and after the gcc bootstrap directory. E.g. libraries, etc. +# This presupposes using "gcc -W*" for the stage1 compiler. +# +# -nosub +# Only show warnings from the gcc top level directory. +# -ch|-cp|-f|-java +# Only show warnings from the specified language subdirectory. +# These flags assume the output contains "Entering/Leaving" messages from +# gnu make. They override each other so only the last one takes effect. +# +# -pass +# Pass through the bootstrap output after filtering stage and subdir +# (useful for manual inspection.) This is all lines, not just warnings. +# -wpass +# Pass through only warnings from the bootstrap output after filtering +# stage and subdir. # # By Kaveh Ghazi (ghazi@caip.rutgers.edu) 12/13/97. + +# Some awks choke on long lines, sed seems to do a better job. +# Truncate lines > 255 characters. RE '.\{255,\}' doesn't seem to work. :-( +# Only do this if -llf was specified, because it can really slow things down. +longLineFilter() +{ + if test -z "$llf" ; then + cat $1 + else + sed 's/^\(...............................................................................................................................................................................................................................................................\).*/\1/' $1 + fi +} + # 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 + longLineFilter $1 | ( + if test -z "$filter" ; then # Pass through all lines. - cat $1 + cat 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 + $AWK 'BEGIN{t=1} ; /Entering directory.*\/gcc\/[a-z]/{t--} ; /Leaving directory.*\/gcc\/[a-z]/{t++} ; {if(t==1)print}' 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 + $AWK "BEGIN {t=-1} ; /^cd $filter; make/{t=0} ; /Entering directory .*\/gcc\/$filter/{t++} ; /Leaving directory .*\/gcc\/$filter/{t--} ; {if(t==1)print}" fi - fi + fi ) } -# This function displays all warnings from stageN of the bootstrap. -stageNwarns() +# This function displays all lines from stageN of the bootstrap. If +# stage==0, then show lines prior to stage1 and lines from after the last +# stage. I.e. utilities, libraries, etc. +stageNfilter() { - stageNminus1=`expr $stageN - 1` -# Some awks choke on long lines so grep them out. - grep -v libf2c.a $1 | \ - $AWK "/ warning: /{if(t==1)print} ; /stage$stageNminus1/{if(t==0)t=1} ; /stage$stageN/{if(t==1)t=0}" + if test "$stageN" -lt 1 ; then + # stage "0" means check everything *but* gcc. + $AWK "BEGIN{t=1} ; /^Bootstrapping the compiler/{t=0} ; /^Building runtime libraries/{t=1} ; {if(t==1)print}" + else + if test "$stageN" -eq 1 ; then + $AWK "/^Bootstrapping the compiler|^Building the C and C\+\+ compiler/{t=1} ; /stage$stageN/{t=0} ; {if(t==1)print}" + else + stageNminus1=`expr $stageN - 1` + $AWK "/stage$stageNminus1/{t=1} ; /stage$stageN/{t=0} ; {if(t==1)print}" + fi + fi +} + +# This function displays lines containing warnings. +warningFilter() +{ + grep ' warning: ' $1 } -usage="usage: `basename $0` [-s stage] [-nosub|-ch|-cp|-f|-java] [file(s)]" +# This function replaces `xxx' with `???', where xxx is usually some +# variable or function name. This allows similar warnings to be +# counted together when summarizing. However it avoids replacing +# certain C keywords which are known appear in various messages. + +keywordFilter() { + sed 's/.*warning: //; + s/`\(int\)'"'"'/"\1"/g; + s/`\(long\)'"'"'/"\1"/g; + s/`\(char\)'"'"'/"\1"/g; + s/`\(inline\)'"'"'/"\1"/g; + s/`\(else\)'"'"'/"\1"/g; + s/`\(return\)'"'"'/"\1"/g; + s/`\(static\)'"'"'/"\1"/g; + s/`\(extern\)'"'"'/"\1"/g; + s/`\(const\)'"'"'/"\1"/g; + s/`\(noreturn\)'"'"'/"\1"/g; + s/`\(longjmp\)'"'"' or `\(vfork\)'"'"'/"\1" or "\2"/g; + s/`'"[^']*'/"'`???'"'/g;"' + s/.*format, .* arg (arg [0-9][0-9]*)/??? format, ??? arg (arg ???)/; + s/\([( ]\)arg [0-9][0-9]*\([) ]\)/\1arg ???\2/; + s/"\([^"]*\)"/`\1'"'"'/g' +} + + +# Start the main section. + +usage="usage: `basename $0` [-llf] [-s stage] [-nosub|-ch|-cp|-f|-java] [-pass|-wpass] [file(s)]" stageN=3 +tmpfile=/tmp/tmp-warn.$$ + +# Remove $tmpfile on exit and various signals. +trap "rm -f $tmpfile" 0 +trap "rm -f $tmpfile ; exit 1" 1 2 3 5 9 13 15 # Find a good awk. if test -z "$AWK" ; then @@ -46,11 +136,15 @@ if test -z "$AWK" ; then done fi +# Parse command line arguments. while test -n "$1" ; do case "$1" in + -llf) llf=1 ; shift ;; -s) if test -z "$2"; then echo $usage; exit 1; fi; stageN="$2"; shift 2 ;; -s*) stageN="`expr $1 : '-s\(.*\)'`" ; shift ;; -nosub|-ch|-cp|-f|-java) filter="`expr $1 : '-\(.*\)'`" ; shift ;; + -pass) pass=1 ; shift ;; + -wpass) pass=w ; shift ;; -*) echo $usage ; exit 1 ;; *) break ;; esac @@ -58,13 +152,25 @@ done # Check for a valid value of $stageN. case "$stageN" in - [1-9]) ;; - *) echo "Stage <$stageN> must be in the range [1..9]." ; exit 1 ;; + [0-9]) ;; + *) echo "Stage <$stageN> must be in the range [0..9]." ; exit 1 ;; esac for file in "$@" ; do - if test "$filter" = '' ; then + subdirectoryFilter $file | stageNfilter > $tmpfile + + # (Just) show me the warnings. + if test "$pass" != '' ; then + if test "$pass" = w ; then + warningFilter $tmpfile + else + cat $tmpfile + fi + continue + fi + + if test -z "$filter" ; then echo "Counting all warnings," else if test "$filter" = nosub ; then @@ -73,31 +179,15 @@ for file in "$@" ; do echo "Counting warnings in the gcc/$filter subdirectory," fi fi - count=`subdirectoryFilter $file | stageNwarns | wc -l` + count=`warningFilter $tmpfile | wc -l` echo there are $count warnings in stage$stageN of this bootstrap. echo echo Number of warnings per file: - subdirectoryFilter $file | stageNwarns | $AWK -F: '{print$1}' | \ - sort | uniq -c | sort -nr + warningFilter $tmpfile | $AWK -F: '{print$1}' | sort | uniq -c | sort -nr echo echo Number of warning types: - subdirectoryFilter $file | stageNwarns | sed 's/.*warning: //; - s/`\(int\)'"'"'/"\1"/g; - s/`\(long\)'"'"'/"\1"/g; - s/`\(char\)'"'"'/"\1"/g; - s/`\(inline\)'"'"'/"\1"/g; - s/`\(else\)'"'"'/"\1"/g; - s/`\(return\)'"'"'/"\1"/g; - s/`\(static\)'"'"'/"\1"/g; - s/`\(extern\)'"'"'/"\1"/g; - s/`\(const\)'"'"'/"\1"/g; - s/`\(longjmp\)'"'"' or `\(vfork\)'"'"'/"\1" or "\2"/g; - s/`'"[^']*'/"'`???'"'/g;"' - s/.*format, .* arg (arg [0-9][0-9]*)/??? format, ??? arg (arg ???)/; - s/\([( ]\)arg [0-9][0-9]*\([) ]\)/\1arg ???\2/; - s/"\([^"]*\)"/`\1'"'"'/g' | \ - sort | uniq -c | sort -nr + warningFilter $tmpfile | keywordFilter | sort | uniq -c | sort -nr done |