def construct_invocation_map(triples_file): triples = read_str_from(triples_file) to_map = {} from_map = {} for triple in triples: active = triple[0] passive = triple[1] count = triple[2] if active in to_map: if passive in to_map[active]: to_map[active][passive] += count else: to_map[active][passive] = count else: to_map[active] = {} to_map[active][passive] = count if passive in from_map: if active in from_map[passive]: from_map[passive][active] += count else: from_map[passive][active] = count else: from_map[passive] = {} from_map[passive][active] = count return from_map, to_map
def src_to_html(targets, go, commit_hash, install_line_numbers=False): filehash = {} if install_line_numbers: f2ts = {} l4ms = read_str_from(go + "_getty_alll4m_" + commit_hash + "_.ex") for target in targets: tp, lv = _target_to_path(target) real_path = go + "_getty_allcode_" + commit_hash + "_/" + tp if real_path not in filehash: filehash[real_path] = lv if install_line_numbers: if real_path not in f2ts: f2ts[real_path] = set() f2ts[real_path].add(target) for jp in filehash: try: print "preprocessing: " + jp with open(jp, "r") as javaf: allsrc = javaf.read() if install_line_numbers: print " -- installing anchors ..." allsrc = _install_anchors_for(allsrc, f2ts[jp], l4ms) print " -- syntax highlighting ..." lvs = filehash[jp] newsrchtml = \ src_html_header.format( "../" * (lvs + 1), config.version_time) + \ allsrc + src_html_footer.format("../" * lvs) with open(jp + ".html", 'w') as wf: wf.write(newsrchtml) except: pass
def get_expansion_set(go): expansion = set([]) try: files = os.from_sys_call( " ".join(["ls", go, "|", "grep", config.expansion_tmp_files])).strip().split("\n") for fl in files: fl = fl.strip() ep = set([]) try: ep = ep | set(ex.read_str_from(go + fl)) except: pass expansion = expansion | ep return expansion except: return expansion
def visit(villa_path, pwd, proj_dir, go, prev_hash, post_hash, pkg_prefix="-"): print("\n****************************************************************"); print(" Getty Villa: Semantiful Differential Analyzer "); print("****************************************************************\n"); print "current working directory: " + pwd + "\n" diff_out = go + "text.diff" os.sys_call("git diff {0} {1} > {2}".format(prev_hash, post_hash, diff_out)) ''' 1-st pass: checkout prev_commit as detached head, and get all sets and etc, in simple (bare) mode (-s) remember to clear after this pass ''' bin_path, src_rel_path, test_src_rel_path = checkout_build(proj_dir, prev_hash) run_villa = "java -jar {0} -s {1} {2} {3} {4} {5} {6} -o {7}".format( villa_path, diff_out, bin_path, test_src_rel_path, pkg_prefix, prev_hash, post_hash, go) run_villa_l4ms = "java -jar {0} -l {1} {2} {3} -o {4}".format( villa_path, src_rel_path, test_src_rel_path, prev_hash, go) print "\n\nstart to run Villa ... \n\n" + run_villa + "\n and \n" + run_villa_l4ms chdir(proj_dir) os.sys_call(run_villa) os.sys_call(run_villa_l4ms) chdir(pwd) old_changed_methods = ex.read_str_from(go + "_getty_chgmtd_src_old_{0}_.ex".format(prev_hash)) old_all_methods = ex.read_str_from(go + "_getty_allmtd_src_{0}_.ex".format(prev_hash)) old_l2m = ex.read_str_from(go + "_getty_fl2m_{0}_.ex".format(prev_hash)) old_m2l = ex.read_str_from(go + "_getty_fm2l_{0}_.ex".format(prev_hash)) old_changed_tests = ex.read_str_from(go + "_getty_chgmtd_test_old_{0}_.ex".format(prev_hash)) # # DEBUG ONLY # print old_changed_methods # print len(old_all_methods) # print old_l2m # print old_m2l # print old_changed_tests git.clear_temp_checkout(prev_hash) ''' 2-nd pass: checkout post_commit as detached head, and get all sets and etc, in complex mode (-c) remember to clear after this pass ''' bin_path, src_rel_path, test_src_rel_path = checkout_build(proj_dir, post_hash) run_villa = "java -jar {0} -c {1} {2} {3} {4} {5} {6} -o {7}".format( villa_path, diff_out, bin_path, test_src_rel_path, pkg_prefix, prev_hash, post_hash, go) run_villa_l4ms = "java -jar {0} -l {1} {2} {3} -o {4}".format( villa_path, src_rel_path, test_src_rel_path, post_hash, go) print "\n\nstart to run Villa ... \n\n" + run_villa + "\n and \n" + run_villa_l4ms chdir(proj_dir) os.sys_call(run_villa) os.sys_call(run_villa_l4ms) chdir(pwd) new_changed_methods = ex.read_str_from(go + "_getty_chgmtd_src_new_{0}_.ex".format(post_hash)) new_improved_changed_methods = ex.read_str_from(go + "_getty_chgmtd_src_{0}_{1}_.ex".format(prev_hash, post_hash)) new_removed_changed_methods = ex.read_str_from(go + "_getty_chgmtd_src_gone_{0}_{1}_.ex".format(prev_hash, post_hash)) # TODO or FIXME # new_all_ccc_related = ex.read_str_from(go + "_getty_cccmtd_{0}_.ex".format(post_hash)) # not needed for now # new_all_cccs = ex.read_str_from(go + "_getty_ccc_{0}_.ex".format(post_hash)) # not needed for now new_all_methods = ex.read_str_from(go + "_getty_allmtd_src_{0}_.ex".format(post_hash)) new_l2m = ex.read_str_from(go + "_getty_fl2m_{0}_.ex".format(post_hash)) new_m2l = ex.read_str_from(go + "_getty_fm2l_{0}_.ex".format(post_hash)) new_inner_dataflow_methods = ex.read_str_from(go + "_getty_dfinner_{0}_.ex".format(post_hash)) new_outer_dataflow_methods = ex.read_str_from(go + "_getty_dfouter_{0}_.ex".format(post_hash)) new_changed_tests = ex.read_str_from(go + "_getty_chgmtd_test_new_{0}_.ex".format(post_hash)) # # DEBUG ONLY # print new_changed_methods # print new_improved_changed_methods # print new_removed_changed_methods # print new_all_ccc_related # print new_all_cccs # print len(new_all_methods) # print new_l2m # print new_m2l # print new_inner_dataflow_methods # print new_outer_dataflow_methods # print new_changed_tests git.clear_temp_checkout(post_hash) ''' 3-rd pass: checkout prev_commit as detached head, and get all sets and etc, in recovery mode (-r) remember to clear after this pass ''' bin_path, src_rel_path, test_src_rel_path = checkout_build(proj_dir, prev_hash) run_villa = "java -jar {0} -r {1} {2} {3} {4} {5} {6} -o {7}".format( villa_path, diff_out, bin_path, test_src_rel_path, pkg_prefix, prev_hash, post_hash, go) print "\n\nstart to run Villa ... \n\n" + run_villa chdir(proj_dir) os.sys_call(run_villa) chdir(pwd) old_improved_changed_methods = ex.read_str_from(go + "_getty_chgmtd_src_{1}_{0}_.ex".format(prev_hash, post_hash)) old_added_changed_methods = ex.read_str_from(go + "_getty_chgmtd_src_gain_{0}_{1}_.ex".format(prev_hash, post_hash)) # TODO or FIXME # old_all_ccc_related = ex.read_str_from(go + "_getty_cccmtd_{0}_.ex".format(prev_hash)) # not needed for now # old_all_cccs = ex.read_str_from(go + "_getty_ccc_{0}_.ex".format(prev_hash)) # not needed for now old_inner_dataflow_methods = ex.read_str_from(go + "_getty_dfinner_{0}_.ex".format(prev_hash)) old_outer_dataflow_methods = ex.read_str_from(go + "_getty_dfouter_{0}_.ex".format(prev_hash)) # # DEBUG ONLY # print old_changed_methods # print old_improved_changed_methods # print old_added_changed_methods # print old_all_ccc_related # print old_all_cccs # print len(old_all_methods) # print old_inner_dataflow_methods # print old_outer_dataflow_methods git.clear_temp_checkout(prev_hash) print 'Villa analysis is completed.' return old_changed_methods, old_improved_changed_methods, old_added_changed_methods, \ old_all_methods, \ old_inner_dataflow_methods, old_outer_dataflow_methods, \ old_l2m, old_m2l, \ new_changed_methods, new_improved_changed_methods, new_removed_changed_methods, \ new_all_methods, \ new_inner_dataflow_methods, new_outer_dataflow_methods, \ new_l2m, new_m2l, \ old_changed_tests, new_changed_tests
def visit(villa_path, pwd, proj_dir, go, prev_hash, post_hash, pkg_prefix="-"): print("\n****************************************************************") print(" Getty Villa: Semantiful Differential Analyzer ") print("****************************************************************\n") print "current working directory: " + pwd + "\n" diff_out = go + "text.diff" os.sys_call(" ".join( ["git diff", str(config.git_diff_extra_ops), "{0} {1} > {2}"]).format(prev_hash, post_hash, diff_out)) ''' 1-st pass: checkout prev_commit as detached head, and get all sets and etc, in simple (bare) mode (-s) remember to clear after this pass ''' bin_path, src_rel_path, test_src_rel_path = checkout_build(prev_hash) run_villa = "java -jar {0} -s {1} {2} {3} {4} {5} {6} -o {7}".format( villa_path, diff_out, bin_path, test_src_rel_path, pkg_prefix, prev_hash, post_hash, go) run_villa_l4ms = "java -jar {0} -l {1} {2} {3} -o {4}".format( villa_path, src_rel_path, test_src_rel_path, prev_hash, go) print "\n\nstart to run Villa ... \n\n" + run_villa + "\n and \n" + run_villa_l4ms chdir(proj_dir) os.sys_call(run_villa) os.sys_call(run_villa_l4ms) chdir(pwd) old_changed_methods = ex.read_str_from( go + "_getty_chgmtd_src_old_{0}_.ex".format(prev_hash)) old_all_methods = ex.read_str_from( go + "_getty_allmtd_src_{0}_.ex".format(prev_hash)) old_l2m = ex.read_str_from(go + "_getty_fl2m_{0}_.ex".format(prev_hash)) old_m2l = ex.read_str_from(go + "_getty_fm2l_{0}_.ex".format(prev_hash)) old_changed_tests = ex.read_str_from( go + "_getty_chgmtd_test_old_{0}_.ex".format(prev_hash)) git.clear_temp_checkout(prev_hash) ''' 2-nd pass: checkout post_commit as detached head, and get all sets and etc, in complex mode (-c) remember to clear after this pass ''' bin_path, src_rel_path, test_src_rel_path = checkout_build(post_hash) run_villa = "java -jar {0} -c {1} {2} {3} {4} {5} {6} -o {7}".format( villa_path, diff_out, bin_path, test_src_rel_path, pkg_prefix, prev_hash, post_hash, go) run_villa_l4ms = "java -jar {0} -l {1} {2} {3} -o {4}".format( villa_path, src_rel_path, test_src_rel_path, post_hash, go) print "\n\nstart to run Villa ... \n\n" + run_villa + "\n and \n" + run_villa_l4ms chdir(proj_dir) os.sys_call(run_villa) os.sys_call(run_villa_l4ms) chdir(pwd) new_changed_methods = ex.read_str_from( go + "_getty_chgmtd_src_new_{0}_.ex".format(post_hash)) new_improved_changed_methods = ex.read_str_from( go + "_getty_chgmtd_src_{0}_{1}_.ex".format(prev_hash, post_hash)) new_removed_changed_methods = ex.read_str_from( go + "_getty_chgmtd_src_gone_{0}_{1}_.ex".format(prev_hash, post_hash)) # TODO or FIXME # new_all_ccc_related = ex.read_str_from(go + "_getty_cccmtd_{0}_.ex".format(post_hash)) # not needed for now # new_all_cccs = ex.read_str_from(go + "_getty_ccc_{0}_.ex".format(post_hash)) # not needed for now new_all_methods = ex.read_str_from( go + "_getty_allmtd_src_{0}_.ex".format(post_hash)) new_l2m = ex.read_str_from(go + "_getty_fl2m_{0}_.ex".format(post_hash)) new_m2l = ex.read_str_from(go + "_getty_fm2l_{0}_.ex".format(post_hash)) new_changed_tests = ex.read_str_from( go + "_getty_chgmtd_test_new_{0}_.ex".format(post_hash)) git.clear_temp_checkout(post_hash) ''' 3-rd pass: checkout prev_commit as detached head, and get all sets and etc, in recovery mode (-r) remember to clear after this pass ''' bin_path, src_rel_path, test_src_rel_path = checkout_build(prev_hash) run_villa = "java -jar {0} -r {1} {2} {3} {4} {5} {6} -o {7}".format( villa_path, diff_out, bin_path, test_src_rel_path, pkg_prefix, prev_hash, post_hash, go) print "\n\nstart to run Villa ... \n\n" + run_villa chdir(proj_dir) os.sys_call(run_villa) chdir(pwd) old_improved_changed_methods = ex.read_str_from( go + "_getty_chgmtd_src_{1}_{0}_.ex".format(prev_hash, post_hash)) old_added_changed_methods = ex.read_str_from( go + "_getty_chgmtd_src_gain_{0}_{1}_.ex".format(prev_hash, post_hash)) # TODO or FIXME # old_all_ccc_related = ex.read_str_from(go + "_getty_cccmtd_{0}_.ex".format(prev_hash)) # not needed for now # old_all_cccs = ex.read_str_from(go + "_getty_ccc_{0}_.ex".format(prev_hash)) # not needed for now git.clear_temp_checkout(prev_hash) print 'Villa analysis is completed.' return old_changed_methods, old_improved_changed_methods, old_added_changed_methods, \ old_all_methods, old_l2m, old_m2l, \ new_changed_methods, new_improved_changed_methods, new_removed_changed_methods, \ new_all_methods, new_l2m, new_m2l, \ old_changed_tests, new_changed_tests