1#!/usr/bin/env python 2 3""" 4Script to Summarize statistics in the scan-build output. 5 6Statistics are enabled by passing '-internal-stats' option to scan-build 7(or '-analyzer-stats' to the analyzer). 8 9""" 10 11import string 12from operator import itemgetter 13import sys 14 15if __name__ == '__main__': 16 if len(sys.argv) < 2: 17 print >> sys.stderr, 'Usage: ', sys.argv[0],\ 18 'scan_build_output_file' 19 sys.exit(-1) 20 21 f = open(sys.argv[1], 'r') 22 Time = 0.0 23 TotalTime = 0.0 24 MaxTime = 0.0 25 Warnings = 0 26 Count = 0 27 FunctionsAnalyzed = 0 28 ReachableBlocks = 0 29 ReachedMaxSteps = 0 30 NumSteps = 0 31 NumInlinedCallSites = 0 32 NumBifurcatedCallSites = 0 33 MaxCFGSize = 0 34 Mode = 1 35 for line in f: 36 if ("Miscellaneous Ungrouped Timers" in line) : 37 Mode = 1 38 if (("Analyzer Total Time" in line) and (Mode == 1)) : 39 s = line.split() 40 Time = Time + float(s[6]) 41 Count = Count + 1 42 if (float(s[6]) > MaxTime) : 43 MaxTime = float(s[6]) 44 if ((("warning generated." in line) or ("warnings generated" in line)) and Mode == 1) : 45 s = line.split() 46 Warnings = Warnings + int(s[0]) 47 if (("The # of functions analysed (as top level)" in line) and (Mode == 1)) : 48 s = line.split() 49 FunctionsAnalyzed = FunctionsAnalyzed + int(s[0]) 50 if (("The % of reachable basic blocks" in line) and (Mode == 1)) : 51 s = line.split() 52 ReachableBlocks = ReachableBlocks + int(s[0]) 53 if (("The # of times we reached the max number of steps" in line) and (Mode == 1)) : 54 s = line.split() 55 ReachedMaxSteps = ReachedMaxSteps + int(s[0]) 56 if (("The maximum number of basic blocks in a function" in line) and (Mode == 1)) : 57 s = line.split() 58 if (MaxCFGSize < int(s[0])) : 59 MaxCFGSize = int(s[0]) 60 if (("The # of steps executed" in line) and (Mode == 1)) : 61 s = line.split() 62 NumSteps = NumSteps + int(s[0]) 63 if (("The # of times we inlined a call" in line) and (Mode == 1)) : 64 s = line.split() 65 NumInlinedCallSites = NumInlinedCallSites + int(s[0]) 66 if (("The # of times we split the path due to imprecise dynamic dispatch info" in line) and (Mode == 1)) : 67 s = line.split() 68 NumBifurcatedCallSites = NumBifurcatedCallSites + int(s[0]) 69 if ((") Total" in line) and (Mode == 1)) : 70 s = line.split() 71 TotalTime = TotalTime + float(s[6]) 72 73 print "TU Count %d" % (Count) 74 print "Time %f" % (Time) 75 print "Warnings %d" % (Warnings) 76 print "Functions Analyzed %d" % (FunctionsAnalyzed) 77 print "Reachable Blocks %d" % (ReachableBlocks) 78 print "Reached Max Steps %d" % (ReachedMaxSteps) 79 print "Number of Steps %d" % (NumSteps) 80 print "Number of Inlined calls %d (bifurcated %d)" % (NumInlinedCallSites, NumBifurcatedCallSites) 81 print "MaxTime %f" % (MaxTime) 82 print "TotalTime %f" % (TotalTime) 83 print "Max CFG Size %d" % (MaxCFGSize) 84