When removing a function from the function set and adding it to deferred, we
[llvm.git] / utils / CompareDebugInfo.py
blob2cd647e43a8599b5555ac2745ab7f8b608a42fde
1 #!/usr/bin/python
3 import os
4 import sys
6 DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".dbg.out"
7 OPT_DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".dbg.opt.out"
8 LOG_FILE="Output/" + sys.argv[1] + ".log"
9 NATIVE_DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".native.dbg.out"
10 NATIVE_OPT_DBG_OUTPUT_FILE="Output/" + sys.argv[1] + ".native.dbg.opt.out"
11 NATIVE_LOG_FILE="Output/" + sys.argv[1] + ".native.log"
12 REPORT_FILE="Output/" + sys.argv[1] + ".dbg.report.html"
14 class BreakPoint:
15 def __init__(self, bp_name):
16 self.name = bp_name
17 self.values = {}
18 self.missing_args = []
19 self.matching_args = []
20 self.notmatching_args = []
21 self.missing_bp = False
23 def setMissing(self):
24 self.missing_bp = True
26 def getArgCount(self):
27 return len(self.values)
29 def getMissingArgCount(self):
30 if self.missing_bp == True:
31 return len(self.values)
32 return len(self.missing_args)
34 def getMatchingArgCount(self):
35 if self.missing_bp == True:
36 return 0
37 return len(self.matching_args)
39 def getNotMatchingArgCount(self):
40 if self.missing_bp == True:
41 return 0
42 return len(self.notmatching_args)
44 def recordArgument(self, arg_name, value):
45 self.values[arg_name] = value
47 def __repr__(self):
48 print self.name
49 items = self.values.items()
50 for i in range(len(items)):
51 print items[i][0]," = ",items[i][1]
52 return ''
54 def compare_args(self, other, file):
55 myitems = self.values.items()
56 otheritems = other.values.items()
57 match = False
58 for i in range(len(myitems)):
59 if i >= len(otheritems):
60 match = True
61 self.missing_args.append(myitems[i][0])
62 elif cmp(myitems[i][1], otheritems[i][1]):
63 match = True
64 self.notmatching_args.append(myitems[i][0])
65 else:
66 self.matching_args.append(myitems[i][0])
68 self.print_list(self.matching_args, " Matching arguments ", file)
69 self.print_list(self.notmatching_args, " Not Matching arguments ", file)
70 self.print_list(self.missing_args, " Missing arguments ", file)
71 return match
73 def print_list(self, items, txt, pfile):
74 if len(items) == 0:
75 return
76 pfile.write(self.name)
77 pfile.write(txt)
78 for e in items:
79 pfile.write(e)
80 pfile.write(' ')
81 pfile.write('\n')
83 def read_input(filename, dict):
84 f = open(filename, "r")
85 lines = f.readlines()
86 for l in range(len(lines)):
87 c = lines[l].split()
88 if c[0] == "#Breakpoint":
89 bp = dict.get(c[2])
90 if bp is None:
91 bp = BreakPoint(c[1])
92 dict[c[2]] = bp
93 if c[0] == "#Argument":
94 bp = dict.get(c[2])
95 if bp is None:
96 bp = BreakPoint(c[1])
97 dict[c[2]] = bp
98 bp.recordArgument(c[3], c[4])
99 return
101 f1_breakpoints = {}
102 read_input(DBG_OUTPUT_FILE, f1_breakpoints)
103 f1_items = f1_breakpoints.items()
105 f2_breakpoints = {}
106 read_input(OPT_DBG_OUTPUT_FILE, f2_breakpoints)
107 f2_items = f2_breakpoints.items()
109 f = open(LOG_FILE, "w")
110 f.write("Log output\n")
111 for f2bp in range(len(f2_items)):
112 id = f2_items[f2bp][0]
113 bp = f2_items[f2bp][1]
114 bp1 = f1_breakpoints.get(id)
115 if bp1 is None:
116 bp.setMissing()
117 else:
118 bp1.compare_args(bp,f)
119 f.close()
121 nf1_breakpoints = {}
122 read_input(NATIVE_DBG_OUTPUT_FILE, nf1_breakpoints)
123 nf1_items = nf1_breakpoints.items()
125 nf2_breakpoints = {}
126 read_input(NATIVE_OPT_DBG_OUTPUT_FILE, nf2_breakpoints)
127 nf2_items = nf2_breakpoints.items()
129 nfl = open(NATIVE_LOG_FILE, "w")
130 for nf2bp in range(len(nf2_items)):
131 id = nf2_items[nf2bp][0]
132 bp = nf2_items[nf2bp][1]
133 bp1 = nf1_breakpoints.get(id)
134 if bp1 is None:
135 bp.setMissing()
136 else:
137 bp1.compare_args(bp,nfl)
138 nfl.close()
140 f1_arg_count = 0
141 f1_matching_arg_count = 0
142 f1_notmatching_arg_count = 0
143 f1_missing_arg_count = 0
144 for idx in range(len(f1_items)):
145 bp = f1_items[idx][1]
146 f1_arg_count = f1_arg_count + bp.getArgCount()
147 f1_matching_arg_count = f1_matching_arg_count + bp.getMatchingArgCount()
148 f1_notmatching_arg_count = f1_notmatching_arg_count + bp.getNotMatchingArgCount()
149 f1_missing_arg_count = f1_missing_arg_count + bp.getMissingArgCount()
151 nf1_arg_count = 0
152 nf1_matching_arg_count = 0
153 nf1_notmatching_arg_count = 0
154 nf1_missing_arg_count = 0
155 for idx in range(len(nf1_items)):
156 bp = nf1_items[idx][1]
157 nf1_arg_count = nf1_arg_count + bp.getArgCount()
158 nf1_matching_arg_count = nf1_matching_arg_count + bp.getMatchingArgCount()
159 nf1_notmatching_arg_count = nf1_notmatching_arg_count + bp.getNotMatchingArgCount()
160 nf1_missing_arg_count = nf1_missing_arg_count + bp.getMissingArgCount()
162 rf = open(REPORT_FILE, "w")
163 rf.write("<tr><td>")
164 rf.write(str(sys.argv[1]))
165 rf.write("</td><td>|</td><td>")
166 rf.write(str(nf1_arg_count))
167 rf.write("</td><td><b>")
168 rf.write(str(nf1_matching_arg_count))
169 rf.write("</b></td><td>")
170 rf.write(str(nf1_notmatching_arg_count))
171 rf.write("</td><td>")
172 rf.write(str(nf1_missing_arg_count))
173 rf.write("</td><td>|</td><td>")
174 rf.write(str(f1_arg_count))
175 rf.write("</td><td><b>")
176 rf.write(str(f1_matching_arg_count))
177 rf.write("</b></td><td>")
178 rf.write(str(f1_notmatching_arg_count))
179 rf.write("</td><td>")
180 rf.write(str(f1_missing_arg_count))
181 rf.write("\n")
182 rf.close()