debugger.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:VM32 作者: gagiel 项目源码 文件源码
def main(argc, argv):
    parser = argparse.ArgumentParser(description='VM32 Debuuger')
    parser.add_argument('-d', '--debug', action='store_true', dest='debug', help='Display debug information (DEBUG)')

    parser.add_argument('memoryImage', metavar='memory image', type=argparse.FileType('r'), help='Image to be loaded into the system memory')

    arguments = parser.parse_args(argv[1:])

    #enable logging
    if arguments.debug:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    cpu = CPU(arguments.memoryImage.read())

    #history stuff, if it fails don't worry and carry on
    try:
        historyPath = os.path.expanduser("~/.vm32history")

        import readline
        def save_history(historyPath=historyPath):
            readline.write_history_file(historyPath)

        if os.path.exists(historyPath):
            readline.read_history_file(historyPath)

        import atexit
        atexit.register(save_history)
    except Exception:
        print "GNU readline support not available"

    DebuggerShell(cpu).cmdloop()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号