1 #!/usr/bin/env python 2 #===- lib/fuzzer/scripts/merge_data_flow.py ------------------------------===# 3 # 4 # The LLVM Compiler Infrastructure 5 # 6 # This file is distributed under the University of Illinois Open Source 7 # License. See LICENSE.TXT for details. 8 # 9 #===------------------------------------------------------------------------===# 10 # Merge several data flow traces into one. 11 # Usage: 12 # merge_data_flow.py trace1 trace2 ... > result 13 #===------------------------------------------------------------------------===# 14 import sys 15 import fileinput 16 from array import array 17 18 def Merge(a, b): 19 res = array('b') 20 for i in range(0, len(a)): 21 res.append(ord('1' if a[i] == '1' or b[i] == '1' else '0')) 22 return res.tostring() 23 24 def main(argv): 25 D = {} 26 for line in fileinput.input(): 27 [F,BV] = line.strip().split(' ') 28 if F in D: 29 D[F] = Merge(D[F], BV) 30 else: 31 D[F] = BV; 32 for F in D.keys(): 33 print("%s %s" % (F, D[F])) 34 35 if __name__ == '__main__': 36 main(sys.argv) 37