about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTheofilos Augoustis <theofilos.augoustis@gmail.com>2025-11-20 17:26:24 +0000
committerTheofilos Augoustis <theofilos.augoustis@gmail.com>2025-11-20 17:26:24 +0000
commitf38e1bda81d542d861a9bdfd074d529bd7b930a2 (patch)
tree489be873910a98f7f13d15eed76afc8648f18df4
parent0036438d2aae660d035770b41bcd996ce3e6738f (diff)
downloadfocaccia-f38e1bda81d542d861a9bdfd074d529bd7b930a2.tar.gz
focaccia-f38e1bda81d542d861a9bdfd074d529bd7b930a2.zip
Refactor stepping in QEMU validator
-rw-r--r--src/focaccia/qemu/_qemu_tool.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/focaccia/qemu/_qemu_tool.py b/src/focaccia/qemu/_qemu_tool.py
index 5dd76b5..4f897e7 100644
--- a/src/focaccia/qemu/_qemu_tool.py
+++ b/src/focaccia/qemu/_qemu_tool.py
@@ -304,14 +304,7 @@ class GDBServerStateIterator:
 
         if not state:
             # Step
-            pc = gdb.selected_frame().read_register('pc')
-            new_pc = pc
-            while pc == new_pc:  # Skip instruction chains from REP STOS etc.
-                self._step()
-                if self._is_exited():
-                    raise StopIteration
-                new_pc = gdb.selected_frame().read_register('pc')
-            state = self.current_state()
+            state = self._step()
 
         return state
 
@@ -351,7 +344,14 @@ class GDBServerStateIterator:
         gdb.execute(f'set $pc = {hex(new_pc)}')
 
     def _step(self):
-        gdb.execute('si', to_string=True)
+        pc = gdb.selected_frame().read_register('pc')
+        new_pc = pc
+        while pc == new_pc:  # Skip instruction chains from REP STOS etc.
+            gdb.execute('si', to_string=True)
+            if self._is_exited():
+                raise StopIteration
+            new_pc = gdb.selected_frame().read_register('pc')
+        return self.current_state()
 
     def current_tid(self) -> int:
         return gdb.selected_inferior().threads()[0].ptid[1]