コード例 #1
0
ファイル: __init__.py プロジェクト: rommelsv/microprobe
    def save(self, name, bench=None):
        """Save a benchmark to disk.

        Save a synthesized benchmark to disk. If bench is not specified a
        benchmark is automatically synthesized using the :meth:`~.synthesize`
        method.

        :param name: Filename to save
        :type name: :class:`~.str`
        :param bench: Benchmark to save (Default value = None)
        :type bench: :class:`~.Benchmark`
        """
        if bench is None:
            bench = self.synthesize()

        starttime = time()
        program_str = self._wrap(bench)
        endtime = time()
        LOG.info(
            "Pass wrap: %s", (
                datetime.timedelta(
                    seconds=endtime - starttime
                )
            )
        )

        outputname = self._wrappers[0].outputname(name)
        fdx = open_generic_fd(outputname, 'wb')

        for elem in program_str:
            if isinstance(elem, six.string_types) and six.PY3:
                elem = elem.encode()
            fdx.write(elem)
        fdx.close()
コード例 #2
0
ファイル: mp_objdump2mpt.py プロジェクト: IBM/microprobe
def _main(arguments):
    """
    Program main, after processing the command line arguments

    :param arguments: Dictionary with command line arguments and values
    :type arguments: :class:`dict`
    """
    print_info("Arguments processed!")

    print_info("Importing target definition...")
    target = import_definition(arguments['target'])

    if "input_objdump_file" in arguments:
        print_info("Input file provided")
        file_fd = open_generic_fd(arguments["input_objdump_file"], 'r')
    else:
        print_info("No input file provided, reading from standard input... ")
        file_fd = sys.stdin

    dump_mpt(file_fd, target, arguments)