#!/home/gbs35/jc/bin/perl # #NAME # FindDbg - find and summarize debug calls. # #SYNOPSIS # FindDbg file... # #DESCRIPTION # This program runs thru its input, and produces a summary of the debug # stuff that is found. The idea is to report on how the V package has been # used in the source files names. It looks for things like: # :2 bc preprocessor lines/ # D5() debug output. # Read() debug versions of library routines. # Fenter/Fexit/FReturn # Func function header flag. # "V.h" debug header file. # Vlvl debug level flag. # #AUTHOR # John Chambers for (<>) { if (/^:([0-9])/) { # bc preprocessor lines. ++ $bc{$1}; s/^:[0-9]//; # Strip off the :n for further analysys. } if (/\b([A-Z][A-Za-z0-9_]*)\(/) { # Capitalized function name. if ($1 eq 'Fenter') { ++ $DBGF{$1}; } elsif ($1 eq 'D') { ++ $DF{"D"}; } elsif ($1 eq 'H') { ++ $DF{"H"}; } elsif ($1 eq 'P') { ++ $DF{"P"}; } elsif ($1 eq 'S') { ++ $DF{"S"}; } elsif ($1 eq 'V') { ++ $DF{"V"}; } elsif ($1 eq 'ChkFlvlM') { ++ $DBGF{$1}; } elsif ($1 eq 'MyName') { ++ $DBGF{$1}; } elsif ($1 eq 'Caller') { ++ $DBGF{$1}; } elsif ($1 eq 'DBGinit') { ++ $DF{$1}; } elsif ($1 eq 'D_init') { ++ $DF{$1}; } elsif ($1 eq 'A_init') { ++ $DF{$1}; } elsif ($1 eq 'V_init') { ++ $DF{$1}; } elsif ($1 eq 'Fpush') { ++ $DBGF{$1}; } elsif ($1 eq 'Freturn') { ++ $DBGF{$1}; } elsif ($1 eq 'FReturn') { ++ $DBGF{$1}; } elsif ($1 eq 'Return') { ++ $DBGF{$1}; } elsif ($1 eq 'FVoid') { ++ $DBGF{$1}; } elsif ("$1" =~ m/^([DHSPV])([0-9])$/) { ++ $DF{"$1$2"}; } elsif ("$1" =~ m/^([DHSPV])([0-9])([a-zA-Z0-9])$/) { ++ $DF{"$1$2$3"}; } else { ++ $Func{$1}; } } if (/\b([a-z][A-Za-z0-9_]*)\(/) { # Lower-case function name. if ($1 eq 'Vinit') { ++ $DF{$1}; } elsif ($1 eq 'Vopt') { ++ $DF{$1}; } } if (/\bFctname\b/) { ++ $DBGF{"ChkFlvl"}; } if (/\bChkFlvl\b/) { ++ $DBGF{"ChkFlvl"}; } if (/\bFpop\b/) { ++ $DBGF{"Fpop"}; } if (/\bFexit\b/) { ++ $DBGF{"Fexit"}; } if (/\bFExit\b/) { ++ $DBGF{"FExit"}; } if (/^#\s*include\s+"V.h"/) { ++ $DBGH{"V.h"}; } if (/^#\s*include\s+"verbose.h"/) { ++ $DBGH{"verbose.h"}; } if (/^#\s*include\s+"audit.h"/) { ++ $DBGH{"audit.h"}; } } if (%bc) { print "-- Conditional (bc) lines:\n"; for $key (sort keys(%bc)) { printf "%5d :%s\n",$bc{$key},$key; } } if (%DBGH) { print "-- Debug header files:\n"; for $key (sort keys(%DBGH)) { printf "%5d %s\n",$DBGH{$key},$key; } } if ($V_h) { printf "%5d #include \"%s\"\n",$V_h,"V.h"; } if ($Fenter) { printf "%5d %s\n",$Fenter,"Fenter"; } if ($Fexit) { printf "%5d %s\n",$Fexit,"Fexit"; } if ($FExit) { printf "%5d %s\n",$FExit,"FExit"; } if ($Freturn) { printf "%5d %s\n",$Freturn,"Freturn"; } if ($FReturn) { printf "%5d %s\n",$FReturn,"FReturn"; } if ($Return) { printf "%5d %s\n",$Return,"Return"; } if ($FVoid) { printf "%5d %s\n",$FVoid,"FVoid"; } if (%DBGF) { print "-- Function debug macros:\n"; for $key (sort keys(%DBGF)) { printf "%5d %s\n",$DBGF{$key},$key; } } if (%DF) { print "-- Debug output:\n"; for $key (sort keys(%DF)) { printf "%5d %s()\n",$DF{$key},$key; } } if (%Func) { print "-- Possible debug function wrappers:\n"; for $key (sort keys(%Func)) { printf "%5d %s()\n",$Func{$key},$key; } }