From d26ae0a7d583da5034cd6271f953b6253119ceae Mon Sep 17 00:00:00 2001 From: Theofilos Augoustis Date: Tue, 26 Dec 2023 21:03:01 +0100 Subject: Verify QEMU by converting logs to internal data format Co-authored-by: Theofilos Augoustis Co-authored-by: Nicola Crivellin --- tools/invoke_qemu_tool.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tools/invoke_qemu_tool.py (limited to 'tools/invoke_qemu_tool.py') diff --git a/tools/invoke_qemu_tool.py b/tools/invoke_qemu_tool.py new file mode 100644 index 0000000..152c208 --- /dev/null +++ b/tools/invoke_qemu_tool.py @@ -0,0 +1,78 @@ +""" +This mechanism exists to retrieve per-instruction program snapshots from QEMU, +specifically including memory dumps. This is surprisingly nontrivial (we don't +have a log option like `-d memory`), and the mechanism we have implemented to +achieve this is accordingly complicated. + +In short: We use QEMU's feature to interact with the emulation via a GDB server +interface together with parsing QEMU's logs to record register and memory state +at single-instruction intervals. + +We need QEMU's log in addition to the GDB server because QEMU's GDB server does +not support querying memory mapping information. We need this information to +know from where we need to read memory, so we parse memory mappings from the +log (option `-d page`). + +We need two scripts (this one and the primary `qemu_tool.py`) because we can't +pass arguments to scripts executed via `gdb -x