From: Luke Kenneth Casson Leighton Date: Thu, 27 May 2021 17:25:50 +0000 (+0100) Subject: add disassembly dump and set_lr to qemu X-Git-Tag: xlen-bcd~525 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=79200317ae241c037e8ebe0ed2753ee4ec7c6d8d;p=openpower-isa.git add disassembly dump and set_lr to qemu --- diff --git a/src/openpower/decoder/isa/pypowersim.py b/src/openpower/decoder/isa/pypowersim.py index b32815dd..50d6024e 100644 --- a/src/openpower/decoder/isa/pypowersim.py +++ b/src/openpower/decoder/isa/pypowersim.py @@ -134,7 +134,13 @@ def run_tst(args, generator, qemu, 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) diff --git a/src/openpower/simulator/qemu.py b/src/openpower/simulator/qemu.py index b775c26c..28042d0b 100644 --- a/src/openpower/simulator/qemu.py +++ b/src/openpower/simulator/qemu.py @@ -168,6 +168,10 @@ class QemuController: 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') @@ -186,6 +190,11 @@ class QemuController: 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 @@ -247,7 +256,9 @@ def run_program(program, initial_mem=None, extra_break_addr=None, 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