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()
评论列表
文章目录