#! /usr/bin/env python3
import sys
Copyright By PowCoder代写 加微信 powcoder
from sys import argv
from pathlib import Path
from delta_debugger import run_target
from delta_debugger.delta import delta_debug
def exist_check(file):
if not Path(file).exists():
print(f”{file} not found”, sys.stderr)
def main() -> int:
if len(argv) < 3:
print(f"usage: {argv[0]} [target] [crashing input file]")
target, input_file = argv[1], argv[2]
if not Path(target).exists():
print(f"{target} not found", sys.stderr)
if not Path(input_file).exists():
print(f"{input_file} not found", sys.stderr)
with open(input_file, "rb") as fp:
input = fp.read()
if not run_target(target=target, input=input):
"Sanity check failed: the program does not crash with the initial input",
file=sys.stderr,
delta_debugging_result = delta_debug(target=target, input=input)
f"Original Input Size: {len(input)}",
f"Minimized Input Size: {len(delta_debugging_result)}",
with open(f"{input_file}.delta", "wb") as fp:
fp.write(delta_debugging_result)
if __name__ == "__main__":
usage: delta-debug [target] [crashing input file]
sys.exit(main(*sys.argv[1:]))
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com