本文整理汇总了Python中memory.Memory.tofile方法的典型用法代码示例。如果您正苦于以下问题:Python Memory.tofile方法的具体用法?Python Memory.tofile怎么用?Python Memory.tofile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类memory.Memory
的用法示例。
在下文中一共展示了Memory.tofile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Machine
# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import tofile [as 别名]
#.........这里部分代码省略.........
del self.breakpoints[int(rest, 16)]
del self.breakpoint_conditions[int(rest, 16)]
except:
pass
elif cmd == 'breakpoints':
self.display('List of breakpoints currently set:')
for b in self.breakpoints.keys():
self.display('\t%x' % b)
elif cmd == 'track':
self.tracked_registers.add(int(rest))
elif cmd == 'untrack':
self.tracked_registers.discard(int(rest))
elif cmd == 'reset':
self.reset()
break
elif cmd == 'print':
try:
self.display(eval(rest, globals(), self.__dict__))
except:
self.display("Error while evaluating expression")
elif cmd == 'exec':
try:
exec rest in globals(), self.__dict__
except:
self.display("Error while evaluating statements")
elif cmd == 'hex':
self.hex_input_mode = True
self.display('Program input will now be treated as hexadecimal.')
elif cmd == 'text':
self.hex_input_mode = False
self.display('Program input will now be treated as text.')
elif cmd == 'dump':
with open(rest, 'wb') as f:
self.mem.tofile(f)
elif cmd == 'mem':
self.display_mem(int(rest, 16))
print ''
elif cmd == 's':
if rest != '':
self.step_count = int(rest)
else:
self.step_count = 1
break
elif cmd == 'insncount':
self.display(self.insn_count)
elif cmd == 'c':
break
elif cmd == 'f':
self.break_at_finish = 0
break
elif cmd == 'tbreak':
self.breakpoints[int(rest, 16)] = 1
elif cmd == 'bt':
self.print_backtrace()
elif cmd == 'trace':
self.trace = Tracer(rest).trace
elif cmd == 'disas':
addr = int(rest, 16)
lines = disassembler.disassemble(addr, self.mem,
addr + 10)
for line in lines:
print "%x: %s" % line
else:
self.display('Unrecognized command')
def print_backtrace(self):