def run_ropgadget_on_pair(bench_name, prog_before, prog_after, opts, \ logfile, outfd, errfd): outfd.seek(0, 0) errfd.seek(0, 0) res_before, res_after = None, None args = [get_ropgadget(), '--binary', prog_before] + opts returncode, _, _, _ = cmd.run_limited_cmd(args, outfd, errfd, bench_name) # ROPgadget returns 1 if success if returncode <> 1: cmd.warning("something failed while running \"" + ' '.join(args) + "\"") else: res_before = read_ropgadget_output(logfile) outfd.seek(0, 0) errfd.seek(0, 0) args = [get_ropgadget(), '--binary', prog_after] + opts returncode, _, _, _ = cmd.run_limited_cmd(args, outfd, errfd, bench_name) # ROPgadget returns 1 if success if returncode <> 1: cmd.warning("something failed while running \"" + ' '.join(args) + "\"") else: res_after = read_ropgadget_output(logfile) return (res_before, res_after)
def run_occam(dirname, execname, workdir, cpu, mem, slash_opts=[]): #benchmark_name = os.path.basename(os.path.normpath(dirname)) benchmark_name = execname outfile = benchmark_name + ".occam.out" errfile = benchmark_name + ".occam.err" outfd = open(os.path.join(workdir, outfile), "w") errfd = open(os.path.join(workdir, errfile), "w") res_before, res_after = None, None #1. Generate bitcode: run `make` returncode, _, _, _ = cmd.run_limited_cmd(['make'], outfd, errfd, benchmark_name, dirname) if returncode <> 0: cmd.warning("something failed while running \"make\"" + benchmark_name + "\n" + \ "Read logs " + outfile + " and " + errfile) else: #2. Run slash (OCCAM) on it: `build.sh opts` slash_args = ['./build.sh'] slash_args.extend(slash_opts) print "Running slash with options " + str(slash_args) returncode,_,_,_ = \ cmd.run_limited_cmd(slash_args, outfd, errfd, benchmark_name, dirname, cpu, mem) if returncode <> 0: cmd.warning("something failed while running \"" + ' '.join(slash_args) + \ "\"" + benchmark_name + "\n" + \ "Read logs " + outfile + " and " + errfile) outfd.close() errfd.close() if returncode == 0: #All OCCAM output is redirected to error logfile = os.path.join(workdir, errfile) (res_before, res_after) = read_occam_output(logfile) return (benchmark_name, res_before, res_after)
def run_occam(dirname, execname, workdir, cpu, mem): #benchmark_name = os.path.basename(os.path.normpath(dirname)) benchmark_name = execname outfile = benchmark_name + ".occam.out" errfile = benchmark_name + ".occam.err" outfd = open(os.path.join(workdir, outfile), "w") errfd = open(os.path.join(workdir, errfile), "w") res_before, res_after = None, None #Generate bitcode returncode,_,_,_ = cmd.run_limited_cmd(['make'], outfd, errfd, benchmark_name, dirname) if returncode <> 0: cmd.warning("something failed while running \"make\"" + benchmark_name + "\n" + \ "Read logs " + outfile + " and " + errfile) else: #Run slash (OCCAM) on it returncode,_,_,_ = cmd.run_limited_cmd(['make','slash'], outfd, errfd, benchmark_name, dirname, cpu, mem) if returncode <> 0: cmd.warning("something failed while running \"make slash\"" + benchmark_name + "\n" + \ "Read logs " + outfile + " and " + errfile) outfd.close() errfd.close() if returncode == 0: #All OCCAM output is redirected to error logfile = os.path.join(workdir, errfile) (res_before, res_after) = read_occam_output(logfile) return (benchmark_name, res_before, res_after)
def run_ropgadget_on_pair(bench_name, prog_before, prog_after, opts, \ logfile, outfd, errfd): outfd.seek(0,0) errfd.seek(0,0) res_before, res_after = None, None args = [get_ropgadget(), '--binary', prog_before] + opts returncode,_,_,_ = cmd.run_limited_cmd(args, outfd, errfd, bench_name) # ROPgadget returns 1 if success if returncode <> 1: cmd.warning("something failed while running \"" + ' '.join(args) + "\"") else: res_before = read_ropgadget_output(logfile) outfd.seek(0,0) errfd.seek(0,0) args = [get_ropgadget(), '--binary', prog_after] + opts returncode,_,_,_ = cmd.run_limited_cmd(args, outfd, errfd, bench_name) # ROPgadget returns 1 if success if returncode <> 1: cmd.warning("something failed while running \"" + ' '.join(args) + "\"") else: res_after = read_ropgadget_output(logfile) return (res_before, res_after)