qemu_session.py: the CPU snapshot also dumps the code at each PC

Eight words at the PC, by its address, name the function offline. The
image loads where the firmware puts it, and the boot does not print
that address. aarch64's monitor has no $pc, so the address is taken
from the register line; checked on a real, paused QEMU.

Test first: the snapshot test, 6 checks; the new one failed before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-19 02:32:21 +00:00
parent b6c87b3045
commit 13fae6df30
4 changed files with 30 additions and 1 deletions
+4
View File
@@ -24,6 +24,8 @@ report("qemu_session.py has cpu_snapshot()", any(f.name == "cpu_snapshot" for f
calls = []
def qcmd(cmd, **args):
calls.append((cmd, args))
if args.get("command-line", "").startswith("x "):
return {"return": "00000000400812a4: 0xd503201f 0x94000123 0xf9400000 0xd65f03c0\n"}
return {"return": "X0=0000000000000001\nPC=00000000400812a4 X30=0000000040081000 SP=0000000040300000\n"}
import re
g = {"qcmd": qcmd, "re": re, "time": type("T", (), {"sleep": staticmethod(lambda s: None)}), "ok": True,
@@ -40,6 +42,8 @@ said = out.getvalue()
regs = [c for c in calls if c[0] == "human-monitor-command" and c[1].get("command-line") == "info registers"]
report("a failed check asks the monitor for the registers three times", len(regs) == 3)
report(" and prints where the CPU is, each time", said.count("PC=00000000400812a4") == 3)
code = [c for c in calls if c[0] == "human-monitor-command" and c[1].get("command-line", "") == "x /8wx 0x00000000400812a4"]
report(" and the code at the PC each time, by its address (the monitor has no $pc on aarch64)", len(code) == 3 and said.count("0xd503201f") == 3)
calls.clear(); out = io.StringIO()
with contextlib.redirect_stdout(out):
if "check" in g: g["check"]("a check that passes", True)