From d57d639908a19c3dfcc31829eb7996cf3bfc8b4e Mon Sep 17 00:00:00 2001 From: Theofilos Augoustis Date: Wed, 5 Nov 2025 14:23:48 +0000 Subject: Integrate QEMU plugin directly into Focaccia --- src/focaccia/tools/_qemu_tool.py | 20 ++---- src/focaccia/tools/validate_qemu.py | 124 ++++++++++++++++++++------------ src/focaccia/tools/validation_server.py | 66 ++++++++--------- 3 files changed, 112 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/src/focaccia/tools/_qemu_tool.py b/src/focaccia/tools/_qemu_tool.py index 706a9fe..631c79b 100644 --- a/src/focaccia/tools/_qemu_tool.py +++ b/src/focaccia/tools/_qemu_tool.py @@ -106,11 +106,11 @@ class GDBProgramState(ReadableProgramState): raise MemoryAccessError(addr, size, str(err)) class GDBServerStateIterator: - def __init__(self, address: str, port: int): + def __init__(self, remote: str): gdb.execute('set pagination 0') gdb.execute('set sysroot') gdb.execute('set python print-stack full') # enable complete Python tracebacks - gdb.execute(f'target remote {address}:{port}') + gdb.execute(f'target remote {remote}') self._process = gdb.selected_inferior() self._first_next = True @@ -291,22 +291,12 @@ def collect_conc_trace(gdb: GDBServerStateIterator, \ return states, matched_transforms def main(): - prog = make_argparser() - prog.add_argument('hostname', - help='The hostname at which to find the GDB server.') - prog.add_argument('port', - type=int, - help='The port at which to find the GDB server.') - - args = prog.parse_args() - - gdbserver_addr = 'localhost' - gdbserver_port = args.port + args = make_argparser().parse_args() try: - gdb_server = GDBServerStateIterator(gdbserver_addr, gdbserver_port) + gdb_server = GDBServerStateIterator(args.remote) except: - raise Exception(f'Unable to perform basic GDB setup') + raise Exception('Unable to perform basic GDB setup') try: if args.executable is None: diff --git a/src/focaccia/tools/validate_qemu.py b/src/focaccia/tools/validate_qemu.py index 2b7e65c..edef9ae 100755 --- a/src/focaccia/tools/validate_qemu.py +++ b/src/focaccia/tools/validate_qemu.py @@ -6,6 +6,8 @@ Spawn GDB, connect to QEMU's GDB server, and read test states from that. We need two scripts (this one and the primary `qemu_tool.py`) because we can't pass arguments to scripts executed via `gdb -x