qemu = run_program(generator, initial_mem=mem,
bigendian=False, start_addr=initial_pc,
continuous_run=False)
- # TODO: SPRs. how??
+ # TODO: SPRs. how?? sigh, by cheating
+ if initial_sprs:
+ lr = initial_sprs.get('lr', None)
+ if lr is None:
+ lr = initial_sprs.get('LR', None)
+ if lr is not None:
+ qemu.set_lr(lr)
if initial_regs is not None:
for reg, val in enumerate(initial_regs):
qemu.set_gpr(reg, val)
self._rcache_trash('x 66')
self.gdb_eval('$cr=%d' % cr)
+ def set_lr(self, lr):
+ self._rcache_trash('x 67')
+ self.gdb_eval('$lr=%d' % lr)
+
def step(self):
self._rcache_trash()
return self.gdb.write('-exec-step-instruction')
self.qemu_popen.stdout.close()
self.qemu_popen.stdin.close()
+ def disasm(self, start, end):
+ res = self.gdb.write('-data-disassemble -s "%d" -e "%d" -- 0' % \
+ (start, end))
+ return res[0]['payload']['asm_insns']
+
def upload_mem(self, initial_mem, skip_zeros=False):
if isinstance(initial_mem, tuple):
addr, mem = initial_mem # assume 8-byte width
if continuous_run:
q.gdb_continue()
q.set_endian(bigendian)
-
+ d = q.disasm(start_addr, start_addr + program.size())
+ for line in d:
+ print ("qemu disasm", line)
return q