Пример #1
0
def create_graph(force):
    run_cmd = cere_configure.cere_config["run_cmd"]
    build_cmd = cere_configure.cere_config["build_cmd"]
    logger.info('Start call graph creation')

    #Build again the application to be sure we give the right binary to pprof
    try:
        logger.debug(
            subprocess.check_output(
                "{0} MODE=\"original --instrument --instrument-app\" -B".
                format(build_cmd),
                stderr=subprocess.STDOUT,
                shell=True))
    except subprocess.CalledProcessError as err:
        logger.error(str(err))
        logger.error(err.output)
        return False

    binary = which(run_cmd)
    if not binary:
        logger.critical(
            "Cannot find the binary. Please provide binary name through cere configure --binary"
        )
        return False

    profile_file = "{0}/app.prof".format(var.CERE_PROFILE_PATH)
    if not os.path.isfile(profile_file):
        logger.critical("No profiling file. Please run cere profile")
        return False

    #regular expression to parse the gperf tool output
    regex_list = [
        r'(N.*)\s\[label\=\"(.*?)\\n([0-9]*)\s\((.*)\%\)\\rof\s(.*)\s\((.*)\%\)\\r',
        r'(N.*)\s\[label\=\"(.*)\\n([0-9]*)\s\((.*)\%\)\\r',
        r'(N.*)\s\-\>\s(N.*)\s\[label\=([0-9]*)\,',
        r'Legend\s\[.*Total samples:\s([0-9]*).*\]'
    ]

    cmd = subprocess.Popen("{0} -dot {1} {2}".format(conf.PPROF, binary,
                                                     profile_file),
                           shell=True,
                           stdout=subprocess.PIPE)

    digraph = nx.DiGraph()
    samples, digraph = parse_gPerfTool(digraph, cmd, regex_list)
    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)
    if not fix_self_coverage(digraph, samples):
        return False
    if not delete_useless_nodes(digraph):
        return False

    plot(digraph, "original")
    save_graph(digraph, "original")
    save_graph(digraph)

    logger.info('Call graph creation successefull')
    return True
Пример #2
0
def create_graph(force):
    run_cmd = cere_configure.cere_config["run_cmd"]
    build_cmd = cere_configure.cere_config["build_cmd"]
    logger.info("Start call graph creation")

    # Build again the application to be sure we give the right binary to pprof
    try:
        logger.debug(
            subprocess.check_output(
                '{0} MODE="original --instrument --instrument-app" -B'.format(build_cmd),
                stderr=subprocess.STDOUT,
                shell=True,
            )
        )
    except subprocess.CalledProcessError as err:
        logger.error(str(err))
        logger.error(err.output)
        return False

    binary = which(run_cmd)
    if not binary:
        logger.critical("Cannot find the binary. Please provide binary name through cere configure --binary")
        return False

    profile_file = "{0}/app.prof".format(var.CERE_PROFILE_PATH)
    if not os.path.isfile(profile_file):
        logger.critical("No profiling file. Please run cere profile")
        return False

    # regular expression to parse the gperf tool output
    regex_list = [
        r"(N.*)\s\[label\=\"(.*?)\\n([0-9]*)\s\((.*)\%\)\\rof\s(.*)\s\((.*)\%\)\\r",
        r"(N.*)\s\[label\=\"(.*)\\n([0-9]*)\s\((.*)\%\)\\r",
        r"(N.*)\s\-\>\s(N.*)\s\[label\=([0-9]*)\,",
        r"Legend\s\[.*Total samples:\s([0-9]*).*\]",
    ]

    cmd = subprocess.Popen(
        "{0} -dot {1} {2}".format(conf.PPROF, binary, profile_file), shell=True, stdout=subprocess.PIPE
    )

    digraph = nx.DiGraph()
    samples, digraph = parse_gPerfTool(digraph, cmd, regex_list)
    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)
    if not fix_self_coverage(digraph, samples):
        return False
    if not delete_useless_nodes(digraph):
        return False

    plot(digraph, "original")
    save_graph(digraph, "original")
    save_graph(digraph)

    logger.info("Call graph creation successefull")
    return True
Пример #3
0
    digraph.node[7]['_self_coverage'] = 9.
    digraph.node[7]['_coverage'] = 9.

    #add edges
    digraph.add_edge(1, 3, weight=30.)
    digraph.add_edge(1, 4, weight=20.)
    digraph.add_edge(2, 3, weight=35.)
    digraph.add_edge(3, 4, weight=1.)
    digraph.add_edge(4, 5, weight=1.)
    digraph.add_edge(5, 3, weight=1.)
    digraph.add_edge(5, 6, weight=4.)
    digraph.add_edge(5, 7, weight=4.)
    digraph.add_edge(3, 6, weight=22.)
    digraph.add_edge(4, 7, weight=5.)

    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)

    cycles = list(nx.simple_cycles(digraph))
    #If there is still a cycle we have a problem
    if len(cycles) != 0:
        print("Cycles are still present")
        plot(digraph, "final_fail")
        exit(1)
    if not fix_self_coverage(digraph, samples):
        print("Updating coverage failed")
        plot(digraph, "final_fail")
        exit(1)
    #If updating coverages failed to generate good coverage
    if digraph.node[3]["_self_coverage"] != 50 or digraph.node[3][
            "_coverage"] != 85:
Пример #4
0
    digraph.node[7]['_self_coverage'] = 9.
    digraph.node[7]['_coverage'] = 9.

    #add edges
    digraph.add_edge(1, 3, weight = 30.)
    digraph.add_edge(1, 4, weight = 20.)
    digraph.add_edge(2, 3, weight = 35.)
    digraph.add_edge(3, 4, weight = 1.)
    digraph.add_edge(4, 5, weight = 1.)
    digraph.add_edge(5, 3, weight = 1.)
    digraph.add_edge(5, 6, weight = 4.)
    digraph.add_edge(5, 7, weight = 4.)
    digraph.add_edge(3, 6, weight = 22.)
    digraph.add_edge(4, 7, weight = 5.)

    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)

    cycles = list(nx.simple_cycles(digraph))
    #If there is still a cycle we have a problem
    if len(cycles) != 0:
        print("Cycles are still present")
        plot(digraph, "final_fail")
        exit(1)
    if not fix_self_coverage(digraph, samples):
        print("Updating coverage failed")
        plot(digraph, "final_fail")
        exit(1)
    #If updating coverages failed to generate good coverage
    if digraph.node[3]["_self_coverage"] != 50 or digraph.node[3]["_coverage"] != 85:
        print("Error in removing cycle")