Ejemplo n.º 1
0
def random_bug_finder(args):
    """Given a path to a sib file with canonical sil, attempt to find a perturbed
list of passes that the perf pipeline"""
    tools = bug_reducer_utils.SwiftTools(args.swift_build_dir)
    config = bug_reducer_utils.SILToolInvokerConfig(args)

    json_data = json.loads(
        subprocess.check_output(
            [tools.sil_passpipeline_dumper, '-Performance']))
    passes = sum((p[1:] for p in json_data), [])
    passes = ['-' + x[1] for x in passes]

    extra_args = []
    if args.extra_args is not None:
        extra_args.extend(args.extra_args)
    sil_opt_invoker = bug_reducer_utils.SILOptInvoker(config, tools,
                                                      args.input_file,
                                                      extra_args)

    # Make sure that the base case /does/ crash.
    max_count = args.max_count
    for count in range(max_count):
        print("Running round %i/%i" % (count, max_count))
        random.shuffle(passes)
        filename = sil_opt_invoker.get_suffixed_filename(str(count))
        result = sil_opt_invoker.invoke_with_passlist(passes, filename)
        if result == 0:
            print("*** Success with PassList: %s" % (' '.join(passes)))
            continue

        cmdline = sil_opt_invoker.cmdline_with_passlist(passes)
        print("*** Fail with PassList: %s" % (' '.join(passes)))
        print("*** Output File: %s" % filename)
        print("*** Reproducing commandline: %s" % ' '.join(cmdline))
        print("*** Trying to reduce pass list and function list")
        result = opt_bug_reducer.pass_bug_reducer(tools, config, passes,
                                                  sil_opt_invoker, True)
        if not result:
            sys.exit(-1)
Ejemplo n.º 2
0
def random_bug_finder(args):
    """Given a path to a sib file with canonical sil, attempt to find a perturbed
list of passes that the perf pipeline"""
    tools = swift_tools.SwiftTools(args.swift_build_dir)
    config = swift_tools.SILToolInvokerConfig(args)

    json_data = json.loads(subprocess.check_output(
        [tools.sil_passpipeline_dumper, '-Performance']))
    passes = sum((p[1:] for p in json_data), [])
    passes = ['-' + x[1] for x in passes]

    extra_args = []
    if args.extra_args is not None:
        extra_args.extend(args.extra_args)
    sil_opt_invoker = swift_tools.SILOptInvoker(config, tools,
                                                args.input_file,
                                                extra_args)

    # Make sure that the base case /does/ crash.
    max_count = args.max_count
    for count in range(max_count):
        print("Running round %i/%i" % (count, max_count))
        random.shuffle(passes)
        filename = sil_opt_invoker.get_suffixed_filename(str(count))
        result = sil_opt_invoker.invoke_with_passlist(passes, filename)
        if result['exit_code'] == 0:
            print("*** Success with PassList: %s" % (' '.join(passes)))
            continue

        cmdline = sil_opt_invoker.cmdline_with_passlist(passes)
        print("*** Fail with PassList: %s" % (' '.join(passes)))
        print("*** Output File: %s" % filename)
        print("*** Reproducing commandline: %s" % ' '.join(cmdline))
        print("*** Trying to reduce pass list and function list")
        result = opt_bug_reducer.pass_bug_reducer(tools, config, passes,
                                                  sil_opt_invoker, True)
        if not result:
            sys.exit(-1)