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
+12 -1
View File
@@ -352,7 +352,9 @@ def excerpt(near=None, after=20, tail=40):
def cpu_snapshot(times=3, apart=1.0):
"""Where the CPUs are (Captain Bob, 2026-11-19: "Diagnose on CI"): QEMU's monitor asked for
the registers `times` times, `apart` seconds apart, and the lines that name the program
counter printed -- so a failed check's log shows where the kernel is, and whether it moves.
counter printed, with the code at it (`x /8wx` at that address, which names the function offline: the image is
loaded where the firmware puts it) -- so a failed check's log shows where the kernel is, and
whether it moves.
A monitor that does not answer is said, and the run goes on."""
for k in range(times):
try:
@@ -363,6 +365,15 @@ def cpu_snapshot(times=3, apart=1.0):
return
pcs = [l.strip() for l in said.splitlines() if re.search(r"\b(PC|RIP|EIP|pc)\s*[=:]?\s*[0-9a-fA-F]", l)]
print(f" --- the CPUs, {k + 1} of {times}: " + (" | ".join(pcs) if pcs else said.strip()[:200]), flush=True)
m = re.search(r"\b(?:PC|RIP|EIP|pc)\s*[=:]?\s*([0-9a-fA-F]+)", said)
if not m:
continue
try: # the code there: unique enough to name the function offline
c = qcmd("human-monitor-command", **{"command-line": f"x /8wx 0x{m.group(1)}"})
code = c.get("return", "") if isinstance(c, dict) else str(c)
print(f" the code at the PC: {' '.join(code.split())[:200]}", flush=True)
except Exception as e:
print(f" the code at the PC: the monitor did not answer ({e})", flush=True)
if k + 1 < times:
time.sleep(apart)