diff options
| author | Theofilos Augoustis <theofilos.augoustis@gmail.com> | 2025-11-12 15:03:53 +0000 |
|---|---|---|
| committer | Theofilos Augoustis <theofilos.augoustis@gmail.com> | 2025-11-12 15:03:53 +0000 |
| commit | 066cd6988fdd10f8056667e2c9908ad80693bd3c (patch) | |
| tree | f8742925291ea676364ac8e1c1e43e45fd8aca83 /src | |
| parent | c617d65faf754f113c3f7920260b67e701635772 (diff) | |
| download | focaccia-066cd6988fdd10f8056667e2c9908ad80693bd3c.tar.gz focaccia-066cd6988fdd10f8056667e2c9908ad80693bd3c.zip | |
Update QEMU tool to support run_until_any for GDB interface
Diffstat (limited to 'src')
| -rw-r--r-- | src/focaccia/tools/qemu/_qemu_tool.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/focaccia/tools/qemu/_qemu_tool.py b/src/focaccia/tools/qemu/_qemu_tool.py index 3aa6c73..6735d9e 100644 --- a/src/focaccia/tools/qemu/_qemu_tool.py +++ b/src/focaccia/tools/qemu/_qemu_tool.py @@ -225,11 +225,34 @@ class GDBServerStateIterator: gdb.execute(f'set $pc = {hex(new_pc)}') def run_until(self, addr: int) -> GDBProgramState: + """Continues emulator execution until specified address reached. + + :param addr: The address to stop at. + :returns: The emulator state at that point. + """ breakpoint = gdb.Breakpoint(f'*{addr:#x}') gdb.execute('continue') breakpoint.delete() return GDBProgramState(self._process, gdb.selected_frame(), self.arch) + def run_until_any(self, addresses: Iterable) -> GDBProgramState: + """Continues emulator execution until any of the specified addresses are reached. + + :param addresses: The addresses to stop at. + :returns: The emulator state at that point. + """ + breakpoints = [] + + for addr in addresses: + breakpoints.append(gdb.Breakpoint(f'*{addr:#x}')) + + gdb.execute('continue') + + for br in breakpoints: + br.delete() + + return GDBProgramState(self._process, gdb.selected_frame(), self.arch) + def exited(self) -> bool: return not self._process.is_valid() or len(self._process.threads()) == 0 |