def main(): """ Program main """ args = sys.argv[1:] cmdline = microprobe.utils.cmdline.CLI("MicroprobeTest (mpt) to C tool", mpt_options=True, default_config_file="mp_mpt2c.cfg", force_required=['target']) groupname = "MPT to C arguments" cmdline.add_group(groupname, "Command arguments related to MPT to C tool") cmdline.add_option("c-output-file", "O", None, "C output file name", group=groupname, opt_type=new_file_ext(".c"), required=True) groupname = "Fixing options" cmdline.add_group(groupname, "Command arguments related to fixing options") cmdline.add_flag("fix-indirect-branches", None, "Fix branches without known target", groupname) cmdline.add_flag( "fix-branch-next", None, "Force target of branches to be the next " "sequential instruction", groupname) cmdline.add_flag( "fix-memory-references", None, "Ensure that registers used by instructions accessing " "storage are initialized to valid locations", groupname) cmdline.add_flag( "fix-memory-registers", None, "Fix non-storage instructions touching registers used for" " storage address computations (implies " "--fix-memory-referenes flag)", groupname) cmdline.add_flag("endless", None, "Wrap the code generated within an endless loop", groupname) print_info("Processing input arguments...") cmdline.main(args, _main)
def main(): """ Program main """ args = sys.argv[1:] cmdline = microprobe.utils.cmdline.CLI( "MicroprobeTest (mpt) to TRACE tool", mpt_options=True, default_config_file="mp_mpt2trace.cfg", force_required=['target'] ) groupname = "MPT to trace arguments" cmdline.add_group( groupname, "Command arguments related to MPT to trace tool") cmdline.add_option( "trace-output-file", "O", None, "C output file name", group=groupname, opt_type=new_file_ext([".qt", ".qt.gz", ".qt.bz2"]), required=True ) groupname = "Trace generation options" cmdline.add_group(groupname, "Command arguments related to trace generation options") cmdline.add_option( "default-memory-access-pattern", None, None, "Memory access pattern for memory references that are not modeled by" "Microprobe or not modeled using 'MP' decorator in MPT file. " "Format: comma separated list of addresses or address ranges. If a " "file path is provided, the file is readed to gather the list of " "addresses. The format of the file should be one address or range " "per line. Address range format is : <start>-<end>-<strid>. E.g. " "0x100-0x200-0x010 will generate 0x100,0x110,0x120...0x1F0,0x200 " "pattern.", group=groupname, opt_type=file_with(csv_with_ranges(0, 0xFFFFFFFFFFFFFFFF)), ) cmdline.add_option( "default-branch-pattern", None, None, "Branch pattern for branches that are not modeled by" "Microprobe or not modeled using 'BP' decorator in MPT file. " "Format: string with T or N, for taken and not taken branches, " " respectively. If a file path is provided, the file is readed to " "gather the branch pattern. The format of the file should be one " "string providing the branch pattern (T and N characters).", group=groupname, opt_type=file_with(string_with_chars('TN')), ) cmdline.add_option( "default-branch-indirect-target-pattern", None, None, "Branch target pattern for branches that are not modeled by" "Microprobe or not modeled using 'BT' decorator in MPT file. " "Format: comma separated list of target addresses. If a file " "path is provided, the file is readed to gather the list of addresses." " The format of the file should be one address per line.", group=groupname, opt_type=file_with(csv_with_integer), ) cmdline.add_option( "max-trace-size", None, _DEFAULT_MAX_INS, "Maximum trace size in intructions. Default: %d" % _DEFAULT_MAX_INS, group=groupname, opt_type=int_type(0, 999999999999), ) cmdline.add_flag( "show-trace", None, "Show trace while being generated", group=groupname, ) cmdline.add_flag( "safe-bin", None, "Ignore unrecognized binary codifications (do not" "fail). Useful when MPTs are generated by dumping directly code " "pages, which contain padding zeros and other non-code stuff)", groupname ) print_info("Processing input arguments...") cmdline.main(args, _main)
def main(): """Program main.""" args = sys.argv[1:] cmdline = microprobe.utils.cmdline.CLI( "MicroprobeTest (mpt) to ELF tool", mpt_options=True, default_config_file="mp_mpt2elf.cfg", force_required=['target'], ) group_name = "MPT to ELF arguments" cmdline.add_group( group_name, "Command arguments related to MPT to ELF tool", ) cmdline.add_option( "elf-output-file", "O", None, "ELF output file name", group=group_name, opt_type=new_file_ext(".s"), required=True, ) cmdline.add_option( "compiler", None, None, "Path to the compiler", group=group_name, ) cmdline.add_option( "compiler-flags", None, "", "Compiler flags to use, if compiler is provided", group=group_name, ) group_name = "Fixing options" cmdline.add_group( group_name, "Command arguments related to fixing options", ) cmdline.add_flag( "fix-indirect-branches", None, "Fix branches without known target", group_name, ) cmdline.add_flag( "fix-branch-next", None, "Force target of branches to be the next " "sequential instruction", group_name, ) cmdline.add_flag( "fix-memory-references", None, "Ensure that registers used by instructions accessing " "storage are initialized to valid locations", group_name, ) cmdline.add_flag( "fix-memory-registers", None, "Fix non-storage instructions touching registers used for" " storage address computations (implies " "--fix-memory-references flag)", group_name, ) cmdline.add_flag( "fix-flatten-code", None, "All code is flatten using consecutive addresses", group_name, ) cmdline.add_flag( "safe-bin", None, "Ignore unrecognized binary codifications (do not" "fail). Useful when MPTs are generated by dumping " "directly code " "pages, which contain padding zeros and other " "non-code stuff)", group_name, ) cmdline.add_flag( "raw-bin", None, "Process all instruction entries together. They " "all shoud be binary entries. Implies --safe-bin " "flag. Useful when MPTs are generated by dumping " "directly code " "pages, which contain padding zeros and other " "non-code stuff)", group_name, ) cmdline.add_flag( "fix-long-jump", None, "Sometimes the generated code is unable compile due a long jump " "displacement required to jump to the start insturction.", group_name, ) cmdline.add_option( "fix-start-address", "S", None, "Sometimes the user requires the main start point to be on specific " "address to avoid compilation issues or comply with the execution " "environment requirements. This flag forces the main entry point of " "execution to be at the specified address. It is up to the user to " "define a proper entry point that does not clash with existing code.", group=group_name, opt_type=int_type(0, 2**64) ) group_name = "Wrapping options" cmdline.add_group( group_name, "Command arguments related to wrapping options", ) cmdline.add_flag( "no-wrap-test", None, "By default the code is wrapped like it was " "a function call, use this flag to disable the " "wrapping", group_name, ) cmdline.add_flag( "wrap-endless", None, "Use this flag to wrap the code in an endless " "loop assuming it is a function. " "If needed (--reset option), additional " "instructions are added to reset the " "the initial state between loop iterations. ", group_name, ) cmdline.add_option( "wrap-endless-threshold", None, 1, "Maximum percentage of instructions allowed in the reset code if " "--wrap-endless and --reset is used. I.e. if 10 is set, the tool will " "fail if the reset code required is more than 10%% of the actual " "code of the test case." " Default is 1%%.", group=group_name, opt_type=float_type(0, 1000), required=False, ) cmdline.add_flag( "reset", None, "Use this flag to enable the generation of reset " "code if wrap-endless is enabled.", group_name, ) print_info("Processing input arguments...") cmdline.main(args, _main)
def main(): """ Program main """ args = sys.argv[1:] cmdline = microprobe.utils.cmdline.CLI( "MicroprobeTest (mpt) to test tool", mpt_options=True, default_config_file="mp_mpt2test.cfg", force_required=['target']) groupname = "MPT to test arguments" cmdline.add_group(groupname, "Command arguments related to MPT to test tool") cmdline.add_option("c-output-file", "O", None, "C output file name", group=groupname, opt_type=new_file_ext(".c"), required=True) groupname = "Fixing options" cmdline.add_group(groupname, "Command arguments related to fixing options") cmdline.add_flag("fix-indirect-branches", None, "Fix branches without known target", groupname) cmdline.add_flag( "fix-branch-next", None, "Force target of branches to be the next " "sequential instruction", groupname) cmdline.add_flag( "fix-memory-references", None, "Ensure that registers used by instructions accessing " "storage are initialized to valid locations", groupname) cmdline.add_flag( "fix-memory-registers", None, "Fix non-storage instructions touching registers used for" " storage address computations (implies " "--fix-memory-referenes flag)", groupname) cmdline.add_flag( "safe-bin", None, "Ignore unrecognized binary codifications (do not" "fail). Useful when MPTs are generated by dumping " "directly code " "pages, which contain padding zeros and other " "non-code stuff)", groupname, ) cmdline.add_flag( "raw-bin", None, "Process all instruction entries together. They " "all shoud be binary entries. Implies --safe-bin " "flag. Useful when MPTs are generated by dumping " "directly code " "pages, which contain padding zeros and other " "non-code stuff)", groupname, ) cmdline.add_flag("endless", None, "Wrap the code generated within an endless loop", groupname) print_info("Processing input arguments...") cmdline.main(args, _main)
def main(): """Program main.""" args = sys.argv[1:] cmdline = microprobe.utils.cmdline.CLI( "MicroprobeTest (mpt) to BIN tool", mpt_options=True, avp_options=False, default_config_file="mp_mpt2bin.cfg", force_required=['target'], ) group_name = "MPT to BIN arguments" cmdline.add_group( group_name, "Command arguments related to MPT to BIN tool", ) cmdline.add_option( "bin-output-file", "O", None, "BIN output file name", group=group_name, opt_type=new_file_ext(".bin"), required=True, ) cmdline.add_flag( "big-endian", None, "Test case in big endian (default is little " "endian)", group_name, ) group_name = "Fixing options" cmdline.add_group( group_name, "Command arguments related to fixing options", ) cmdline.add_flag( "fix-indirect-branches", None, "Fix branches without known target", group_name, ) cmdline.add_flag( "fix-branch-next", None, "Force target of branches to be the next " "sequential instruction", group_name, ) cmdline.add_flag( "fix-memory-references", None, "Ensure that registers used by instructions accessing " "storage are initialized to valid locations", group_name, ) cmdline.add_flag( "fix-memory-registers", None, "Fix non-storage instructions touching registers used for" " storage address computations (implies " "--fix-memory-references flag)", group_name, ) cmdline.add_flag( "fix-flatten-code", None, "All code is flatten using consecutive addresses", group_name, ) cmdline.add_flag( "safe-bin", None, "Ignore unrecognized binary codifications (do not" "fail). Useful when MPTs are generated by dumping " "directly code " "pages, which contain padding zeros and other " "non-code stuff)", group_name, ) group_name = "Wrapping options" cmdline.add_group( group_name, "Command arguments related to wrapping options", ) cmdline.add_flag( "no-wrap-test", None, "By default the code is wrapped like it was " "a function call, use this flag to disable the " "wrapping", group_name, ) cmdline.add_flag( "wrap-endless", None, "Use this flag to wrap the code in an endless " "loop assuming it is a function. " "If needed, additional instructions are " "added to reset the " "the initial state between loop iterations. ", group_name, ) cmdline.add_option( "wrap-endless-threshold", None, 1, "Maximum percentage of instructions allowed in the reset code if " "--wrap-endless loop is used. I.e. if 10 is set, the tool will " "fail if the reset code required is more than 10%% of the actual " "code of the test case." " Default is 1%%.", group=group_name, opt_type=float_type(0, 1000), required=False, ) cmdline.add_flag( "endless", None, "Use this flag to wrap the code in an endless " "loop.", group_name, ) print_info("Processing input arguments...") cmdline.main(args, _main)